From e2567577acefc794c8663e14c16964d6d125ba21 Mon Sep 17 00:00:00 2001 From: Amit Genish Date: Sun, 31 Jul 2022 21:42:19 +0300 Subject: [PATCH] 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'] +});