Skip to content

Commit

Permalink
Merge pull request #33 from amitgk1/bugfix/package-type-module
Browse files Browse the repository at this point in the history
Bugfix - cesium is not a function
  • Loading branch information
nshen authored Aug 6, 2022
2 parents 14fb272 + c8b4629 commit 213610a
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>cesium-vite</title>
<script type="module" src="/src/index.js"></script>
<script type="module" src="/src/index.ts"></script>
</head>

<body>
Expand Down
5 changes: 3 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:.."
}
}
File renamed without changes.
1 change: 1 addition & 0 deletions demo/vite.config.js → demo/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from 'vite';
import cesium from 'vite-plugin-cesium';

export default defineConfig({
plugins: [cesium()]
});
23 changes: 17 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
16 changes: 7 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/';
Expand Down Expand Up @@ -118,5 +118,3 @@ function vitePluginCesium(options: VitePluginCesiumOptions = {}): Plugin {
}
};
}

export default vitePluginCesium;
10 changes: 8 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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
}
}
10 changes: 10 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -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
});

0 comments on commit 213610a

Please sign in to comment.