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
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..2381e20 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()]
});
diff --git a/package.json b/package.json
index 38a08f6..32c2001 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": "tsup --watch",
+ "build": "tsup",
+ "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",
+ "tsup": "^6.2.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/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;
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/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
+});