import { defineConfig } from 'tsup'; export default defineConfig({ /* One entry per component folder — this is what produces the per-component subpath exports. `scripts/gen-exports.mjs` derives package.json#exports from the same folder layout, so the two stay in sync automatically. */ entry: [ 'src/index.ts', 'src/lib/index.ts', 'src/hooks/index.ts', 'src/icons/index.ts', 'src/components/*/index.ts', ], outDir: 'dist', format: ['esm', 'cjs'], target: 'es2022', dts: true, tsconfig: 'tsconfig.build.json', clean: true, treeshake: true, /* ESM code-splitting pulls shared internals (cn, variant presets, Radix re-exports) into shared chunks instead of copying them into every component. CJS cannot split, so it duplicates — that is expected. */ splitting: true, /* React must come from the consuming app, never from the kit. */ external: ['react', 'react-dom', 'react/jsx-runtime'], /* No sourcemaps: `scripts/add-use-client.mjs` prepends a line to the entry files after the fact, which would leave every mapping off by one. Shipping no map is more honest than shipping a wrong one, and keeps the tarball small. */ sourcemap: false, });