Skip to content

Commit

Permalink
react: Export as pure ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed Feb 25, 2024
1 parent e8417b2 commit 36973ff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
11 changes: 2 additions & 9 deletions react/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
{
"name": "@giscus/react",
"version": "2.4.0",
"main": "dist/index.js",
"module": "dist/wrapper.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/wrapper.mjs"
}
},
"type": "module",
"exports": "./dist/index.js",
"files": [
"dist"
],
Expand Down
2 changes: 1 addition & 1 deletion react/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"node"
],
"include": [
"vite.config.ts"
"vite.config.mts"
]
}
17 changes: 2 additions & 15 deletions react/vite.config.ts → react/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,13 @@ import typescript from '@rollup/plugin-typescript';

const resolvePath = (str: string) => resolve(__dirname, str);

function wrapper() {
return {
name: 'wrapper',
generateBundle() {
this.emitFile({
type: 'asset',
fileName: 'wrapper.mjs',
source: `import module from './index.js';\n\nexport default module;`,
});
},
};
}

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), wrapper()],
plugins: [react()],
build: {
lib: {
entry: resolvePath('src/lib/index.ts'),
formats: ['cjs'],
formats: ['es'],
fileName: 'index',
},
rollupOptions: {
Expand Down

0 comments on commit 36973ff

Please sign in to comment.