diff --git a/esbuild.config.ts b/esbuild.config.ts index 9481e29..6ae929c 100644 --- a/esbuild.config.ts +++ b/esbuild.config.ts @@ -3,38 +3,18 @@ import esbuild from 'esbuild'; execSync('tsc -p tsconfig.build.json', { stdio: 'inherit' }); -const commonConfig = { +await esbuild.build({ entryPoints: ['src/index.tsx'], bundle: true, sourcemap: true, minify: true, target: ['es2020'], - - // Keep imports like "Chakra.Menu" - treeShaking: true, - - // Don't let esbuild split files — Chakra compound components break + format: 'esm', + outfile: 'dist/index.js', + packages: 'external' as const, splitting: false, - - // Important for Chakra v3 (which uses modern ESM + emotion) + treeShaking: true, 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'], }); diff --git a/package.json b/package.json index b7cc637..f6f8f1f 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,7 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, "types": "dist/index.d.ts", @@ -47,10 +46,6 @@ { "path": "dist/index.js", "limit": "300 kB" - }, - { - "path": "dist/index.cjs", - "limit": "400 kB" } ], "devDependencies": {