Skip to content

Add tsdown for cjs and esm builds#421

Draft
abhithesys wants to merge 1 commit intomainfrom
abhishek/cjs-builds
Draft

Add tsdown for cjs and esm builds#421
abhithesys wants to merge 1 commit intomainfrom
abhishek/cjs-builds

Conversation

@abhithesys
Copy link
Copy Markdown
Contributor

What

Migrate all packages to dual ESM/CJS builds using tsdown, and add CJS entry points for react-ui. This eliminates the need for transpilePackages in Next.js and build.transpile in Nuxt, fixing the friction reported in #360 where consumers had to manually configure their bundlers to use OpenUI packages.

fixes point 3 in #360

Changes

  • Migrated lang-core, react-lang, react-headless, react-email, and openui-cli builds from tsc to tsdown with dual ESM (.mjs) + CJS (.cjs) output and co-located type declarations (.d.mts, .d.cts)
  • Added CJS bundles for react-ui (via tsdown) alongside its existing tsc-based ESM build for the . and ./genui-lib entry points
  • Updated package.json exports maps across all packages with proper import/require conditional exports
  • Added react-headless exports field and "type": "module" (was previously CJS-only with no exports map)
  • Added typecheck, check:publint, and check:attw scripts to each package
  • Installed tsdown, publint, and @arethetypeswrong/cli as root devDependencies
  • Removed transpilePackages from all Next.js example/docs configs and build.transpile from the Nuxt example config
  • Updated root and package-level ESLint configs to ignore *.config.ts files

Test Plan

  • Verified locally
    • Built all packages with pnpm build and confirmed dual-format output files exist
    • Ran publint and attw checks against built packages
    • Ran existing unit tests (vitest run) for lang-core, react-lang, react-headless
    • Verified Next.js examples resolve packages correctly without transpilePackages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant