Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions esbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,38 @@ import esbuild from 'esbuild';

execSync('tsc -p tsconfig.build.json', { stdio: 'inherit' });

await esbuild.build({
const commonConfig = {
entryPoints: ['src/index.tsx'],
bundle: true,
sourcemap: true,
minify: true,
target: ['es2020'],
format: 'esm',
outfile: 'dist/index.js',
packages: 'external' as const,
splitting: false,

// Keep imports like "Chakra.Menu"
treeShaking: true,

// Don't let esbuild split files — Chakra compound components break
splitting: false,

// Important for Chakra v3 (which uses modern ESM + emotion)
supported: {
'import-meta': true,
},
};

// ESM build - externalize all packages for tree-shaking in bundlers
await esbuild.build({
...commonConfig,
outfile: 'dist/index.js',
format: 'esm',
packages: 'external' as const,
});

// CJS build - bundle dependencies to avoid ESM/CJS interop issues
// Only externalize React (peer dependency)
await esbuild.build({
...commonConfig,
outfile: 'dist/index.cjs',
format: 'cjs',
external: ['react', 'react-dom', 'react/jsx-runtime'],
});
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -46,6 +47,10 @@
{
"path": "dist/index.js",
"limit": "300 kB"
},
{
"path": "dist/index.cjs",
"limit": "400 kB"
}
],
"devDependencies": {
Expand Down