What we currently use, for the most part, is the awesome tsup. The only exception for this is the @react-email/tailwind package which currently uses vite due to a few issues with tsup and tailwindcss’s bundling. If you want to build a package you can just run:

package/* (ex: package/render)
pnpm build

This will literally run tsup with a few settings we have for it. Generally they are just
src/index.ts --format esm,cjs --dts --external react which generates both an ESM and CJS versions of the package and the type definitions that were exported from src/index.ts, which is the entry point. --external react here ensures that react is not bundled in which can cause many issues.

Why build before publishing?

Currently, we do building for most of the packages. This is important for a few key reasons that improve the usability of each package:

  1. All the exported types can be imported from the same place the JavaScript is imported
  2. We have proper CommonJS and ES Modules support
  3. Code that isn’t exported is not published nor downloaded