Skip to content

Commit 81d6b94

Browse files
jontascchanxzy
authored andcommitted
fix(esm): bundle ESM/CJS builds to avoid Node ESM resolution issues in SSR
1 parent d5bb8e0 commit 81d6b94

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

esbuild.mjs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
import * as esbuild from 'esbuild';
2-
import { glob } from 'glob';
3-
4-
const files = glob.sync('src/**/*.{ts,tsx}', {
5-
ignore: ['src/examples/**', 'src/**/__tests__/**', 'src/**/*.spec.{ts,tsx}'],
6-
});
72

83
// Exports ESM
94
esbuild.build({
10-
entryPoints: files,
11-
outdir: 'dist/esm',
12-
bundle: false,
5+
entryPoints: ['src/index.ts'],
6+
outfile: 'dist/esm/index.js',
7+
bundle: true,
138
sourcemap: true,
14-
splitting: true,
15-
platform: 'browser',
9+
platform: 'neutral',
1610
format: 'esm',
1711
target: ['esnext'],
1812
minify: true,
13+
external: ['react'],
1914
});
2015

21-
// Exports CJS
2216
esbuild.build({
23-
entryPoints: files,
24-
outdir: 'dist/cjs',
25-
bundle: false,
17+
entryPoints: ['src/index.ts'],
18+
outfile: 'dist/cjs/index.js',
19+
bundle: true,
2620
sourcemap: true,
27-
platform: 'browser',
21+
platform: 'neutral',
2822
format: 'cjs',
2923
target: ['esnext'],
3024
minify: true,
31-
});
25+
external: ['react'],
26+
});

0 commit comments

Comments
 (0)