Skip to content

Commit

Permalink
build es modules with .mjs extention
Browse files Browse the repository at this point in the history
get rid of `SyntaxError: Cannot use import statement outside a module`
  • Loading branch information
strickczq committed Sep 13, 2022
1 parent d166068 commit 0552848
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
8 changes: 4 additions & 4 deletions react/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@giscus/react",
"version": "2.2.0",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs.js",
"import": "./dist/index.es.js"
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
}
},
"files": [
Expand Down
5 changes: 4 additions & 1 deletion react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export default defineConfig({
lib: {
entry: resolve(__dirname, 'src/lib/index.ts'),
formats: ['cjs', 'es'],
fileName: (format) => `index.${format}.js`,
fileName: (format) => ({
cjs: 'index.cjs',
es: 'index.mjs',
}[format]),
},
rollupOptions: {
external: ['react', 'react-dom', 'react/jsx-runtime'],
Expand Down
8 changes: 4 additions & 4 deletions vue/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@giscus/vue",
"version": "2.2.0",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs.js",
"import": "./dist/index.es.js"
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
}
},
"files": [
Expand Down
5 changes: 4 additions & 1 deletion vue/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export default defineConfig({
lib: {
entry: resolvePath('src/lib/index.ts'),
formats: ['cjs', 'es'],
fileName: (format) => `index.${format}.js`,
fileName: (format) => ({
cjs: 'index.cjs',
es: 'index.mjs',
}[format]),
},
rollupOptions: {
external: ['vue'],
Expand Down
6 changes: 3 additions & 3 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"name": "giscus",
"version": "1.2.0",
"type": "module",
"main": "dist/giscus.js",
"module": "dist/giscus.js",
"main": "dist/giscus.mjs",
"module": "dist/giscus.mjs",
"exports": {
".": {
"types": "./types/giscus.d.ts",
"import": "./dist/giscus.js"
"import": "./dist/giscus.mjs"
}
},
"types": "types/giscus.d.ts",
Expand Down
1 change: 1 addition & 0 deletions web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default defineConfig({
lib: {
entry: 'src/giscus.ts',
formats: ['es'],
fileName: `giscus.mjs`,
},
rollupOptions: {
external: /^lit/,
Expand Down

0 comments on commit 0552848

Please sign in to comment.