Add tsdown for cjs and esm builds - #421
Merged
Merged
Conversation
1 task
- Fix module/types root fields and export paths to reference tsdown's
.mjs/.d.mts outputs instead of tsc's .js/.d.ts (which were bare
re-exports, not the bundled artifacts)
- Remove manual build:dcts copy step; tsdown now generates .d.cts for
main and genui-lib directly via per-format outDir configs
- Add ESM build configs for main index and genui-lib so tsdown produces
.mjs + .d.mts alongside the existing CJS outputs
- Add check:attw and prepublishOnly to react-ui; add prepublishOnly to
lang-core, react-lang, react-email, react-headless so publint/attw
run before every publish
- Fix Theme re-export in src/index.ts to use inline `type` modifier,
resolving rolldown MISSING_EXPORT warning
abhithesys
marked this pull request as ready for review
April 8, 2026 21:30
ritvik-thesys
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Migrate all publishable packages to dual ESM/CJS builds using
tsdown, eliminating the need fortranspilePackagesin Next.js andbuild.transpilein Nuxt. This fixes the friction reported in #360 where consumers had to manually configure their bundlers to use OpenUI packages.fixes point 3 in #360.
fixes: #436
Changes
Build system
lang-core,react-lang,react-headless, andreact-emailbuilds fromtsctotsdownwith dual ESM (.mjs) + CJS (.cjs) output and bundled type declarations (.d.mts,.d.cts)react-ui(viatsdown) for the.and./genui-libentry points, alongside the existingtsc-based ESM build for per-component sub-pathstsdowngenerates bundled.d.mts/.d.ctsdeclarations (no bare relative imports), making types resolve correctly in all TypeScriptmoduleResolutionmodesPackage exports
exportsmaps across all packages with properimport/requireconditional exports, each pointing to the correct.mjs/.cjsJS and.d.mts/.d.ctstype filesexportsfield and"type": "module"toreact-headless(previously had no exports map)main,module, andtypesfields to reference the correct tsdown-generated artifacts./tailwindexport fromreact-ui(unused)zodfromdependenciestopeerDependenciesacross all packages that use itPublish guards
check:publintandcheck:attwscripts to all packagesprepublishOnlyto all packages runningcheck:publint && check:attwbefore every publish, preventing accidental publishing of a broken buildlang-coreto the GitHub Actions publish workflow (was missing)Quality fixes
Themere-export inreact-ui/src/index.tsto usetypemodifier, resolving a rolldownMISSING_EXPORTbuild warningshareThread.scssimport fromShareThreadModal.tsx(already forwarded viaopenUIChat.scss)transpilePackagesfrom all Next.js example and docs configsVersions
All packages receive a minor version bump:
@openuidev/react-ui0.10.20.11.0@openuidev/lang-core0.1.20.2.0@openuidev/react-lang0.1.50.2.0@openuidev/react-headless0.7.110.8.0@openuidev/react-email0.1.30.2.0Test Plan
pnpm buildand confirmed dual-format output files exist (.mjs,.cjs,.d.mts,.d.cts)pnpm check:publint— no errors on all packages (cosmetic repository URL suggestion only onreact-ui)pnpm check:attw— all green (node10, node16 CJS, node16 ESM, bundler) on all packagesButton,Theme, andopenuiLibraryfrom the built.d.mtsdeclarations withstrictmode — no errorsrequire()onlang-core,react-headless, andreact-ui/Button— exports load correctlyworkspace:^, confirmedButton,Callout,ThemeProvider, andopenuiLibraryrender correctly in the browser andpnpm buildsucceedsopenui-chat,shadcn-chat,vercel-ai-chat) build successfully withouttranspilePackages