From e2567577acefc794c8663e14c16964d6d125ba21 Mon Sep 17 00:00:00 2001 From: Amit Genish Date: Sun, 31 Jul 2022 21:42:19 +0300 Subject: [PATCH 1/6] added tsdv to support es modules imports --- package.json | 23 +++++++++++++++++------ tsconfig.json | 10 ++++++++-- tsdv.config.ts | 6 ++++++ 3 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 tsdv.config.ts diff --git a/package.json b/package.json index 38a08f6..102c8ec 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,23 @@ "name": "vite-plugin-cesium", "version": "1.2.19", "description": "Cesium library plugin for Vite", - "main": "dist/index.js", - "types": "dist/index.d.ts", + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", "files": [ "dist" ], + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.js" + } + }, "scripts": { - "build": "tsc", - "dev": "tsc -w" + "dev": "tsdv watch", + "build": "tsdv build", + "prepare": "npm run build" }, "keywords": [ "vite", @@ -36,10 +45,12 @@ "@types/node": "^14.14.31", "@types/serve-static": "^1.13.9", "prettier": "^2.2.1", + "tsdv": "^0.6.1", "typescript": "^4.2.2", - "vite": "^2.7.1" + "vite": "^3.0.4" }, "peerDependencies": { - "cesium": "^1.88.0" + "cesium": "^1.88.0", + "vite": ">=2.7.1" } } diff --git a/tsconfig.json b/tsconfig.json index 9e479cf..0639959 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,17 @@ { - "extends": "@tsconfig/node12/tsconfig.json", "include": [ "src" ], "compilerOptions": { "outDir": "dist", "declaration": true, + "target": "ES2017", + "module": "commonjs", "removeComments": false, - }, + "strict": true, + "moduleResolution": "node", + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true + } } \ No newline at end of file diff --git a/tsdv.config.ts b/tsdv.config.ts new file mode 100644 index 0000000..af257a9 --- /dev/null +++ b/tsdv.config.ts @@ -0,0 +1,6 @@ +import { defineConfig } from 'tsdv'; + +export default defineConfig({ + target: 'node12', + formats: ['es', 'cjs'] +}); From 0da8e3b9e45deaa93afc846e336fdf47c5f0dedc Mon Sep 17 00:00:00 2001 From: Amit Genish Date: Sun, 31 Jul 2022 21:42:47 +0300 Subject: [PATCH 2/6] moved default export to function line --- src/index.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index ee02558..468bc67 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,15 +11,15 @@ interface VitePluginCesiumOptions { rebuildCesium?: boolean; devMinifyCesium?: boolean; cesiumBuildRootPath?: string; - cesiumBuildPath?: string + cesiumBuildPath?: string; } -function vitePluginCesium(options: VitePluginCesiumOptions = {}): Plugin { - const { - rebuildCesium = false, - devMinifyCesium = false, - cesiumBuildRootPath = 'node_modules/cesium/Build', - cesiumBuildPath = 'node_modules/cesium/Build/Cesium/' +export default function vitePluginCesium(options: VitePluginCesiumOptions = {}): Plugin { + const { + rebuildCesium = false, + devMinifyCesium = false, + cesiumBuildRootPath = 'node_modules/cesium/Build', + cesiumBuildPath = 'node_modules/cesium/Build/Cesium/' } = options; let CESIUM_BASE_URL = 'cesium/'; @@ -118,5 +118,3 @@ function vitePluginCesium(options: VitePluginCesiumOptions = {}): Plugin { } }; } - -export default vitePluginCesium; From 85eb1595d079f98bc079a4e98e1a1e139f1b3dbe Mon Sep 17 00:00:00 2001 From: Amit Genish Date: Sun, 31 Jul 2022 21:43:52 +0300 Subject: [PATCH 3/6] change demo project to TS & vite@3 --- demo/index.html | 2 +- demo/package.json | 5 +++-- demo/src/{index.js => index.ts} | 0 demo/{vite.config.js => vite.config.ts} | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) rename demo/src/{index.js => index.ts} (100%) rename demo/{vite.config.js => vite.config.ts} (99%) diff --git a/demo/index.html b/demo/index.html index 3aac827..bef254d 100644 --- a/demo/index.html +++ b/demo/index.html @@ -5,7 +5,7 @@ cesium-vite - + diff --git a/demo/package.json b/demo/package.json index dbcada9..36ac4f1 100644 --- a/demo/package.json +++ b/demo/package.json @@ -2,14 +2,15 @@ "name": "cesium-demo", "version": "1.0.0", "license": "MIT", + "type": "module", "scripts": { "dev": "vite", "build": "vite build", "serve": "vite build && vite preview" }, "devDependencies": { - "cesium": "^1.91.0", - "vite": "^2.9.1", + "cesium": "^1.95.0", + "vite": "^3.0.4", "vite-plugin-cesium": "link:.." } } diff --git a/demo/src/index.js b/demo/src/index.ts similarity index 100% rename from demo/src/index.js rename to demo/src/index.ts diff --git a/demo/vite.config.js b/demo/vite.config.ts similarity index 99% rename from demo/vite.config.js rename to demo/vite.config.ts index 3a93255..258b4d7 100644 --- a/demo/vite.config.js +++ b/demo/vite.config.ts @@ -1,5 +1,6 @@ import { defineConfig } from 'vite'; import cesium from 'vite-plugin-cesium'; + export default defineConfig({ plugins: [cesium()] }); From 85fcda36dff19e064af4333462fc02949e27ef7d Mon Sep 17 00:00:00 2001 From: nshen121 Date: Sat, 6 Aug 2022 17:10:37 +0800 Subject: [PATCH 4/6] replace tsdv with tsup --- package.json | 6 +++--- tsdv.config.ts | 6 ------ tsup.config.ts | 10 ++++++++++ 3 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 tsdv.config.ts create mode 100644 tsup.config.ts diff --git a/package.json b/package.json index 102c8ec..32c2001 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ } }, "scripts": { - "dev": "tsdv watch", - "build": "tsdv build", + "dev": "tsup --watch", + "build": "tsup", "prepare": "npm run build" }, "keywords": [ @@ -45,7 +45,7 @@ "@types/node": "^14.14.31", "@types/serve-static": "^1.13.9", "prettier": "^2.2.1", - "tsdv": "^0.6.1", + "tsup": "^6.2.1", "typescript": "^4.2.2", "vite": "^3.0.4" }, diff --git a/tsdv.config.ts b/tsdv.config.ts deleted file mode 100644 index af257a9..0000000 --- a/tsdv.config.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { defineConfig } from 'tsdv'; - -export default defineConfig({ - target: 'node12', - formats: ['es', 'cjs'] -}); diff --git a/tsup.config.ts b/tsup.config.ts new file mode 100644 index 0000000..0455782 --- /dev/null +++ b/tsup.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'tsup'; + +export default defineConfig({ + entry: ['src/index.ts'], + format: ['esm', 'cjs'], + splitting: false, + clean: true, + dts: true, + minify: false +}); From 5871d8c8c40ea7e971eecedae38ca6011c00d2d7 Mon Sep 17 00:00:00 2001 From: nshen121 Date: Sat, 6 Aug 2022 17:23:08 +0800 Subject: [PATCH 5/6] remove node12 in ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 700add9..48694d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node_version: ['12', '14', '16'] + node_version: ['14', '16'] include: - os: macos-latest node_version: 16 From c8b46297eb8402464b54512e0b1555cebe8fc0bc Mon Sep 17 00:00:00 2001 From: nshen121 Date: Sat, 6 Aug 2022 17:52:45 +0800 Subject: [PATCH 6/6] do not use cesium 1.96.0 --- demo/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/package.json b/demo/package.json index 36ac4f1..2381e20 100644 --- a/demo/package.json +++ b/demo/package.json @@ -9,7 +9,7 @@ "serve": "vite build && vite preview" }, "devDependencies": { - "cesium": "^1.95.0", + "cesium": "1.95.0", "vite": "^3.0.4", "vite-plugin-cesium": "link:.." }