Subpath exports for individual components (react-email/components/*) #3529
mattwigham
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Goals
marked/prismjs/tailwindcssfrom the consolidated dist.@react-email/*packages with a first-class narrow-import path that still lives under thereact-emailumbrella.Background
We render a few React Email components client-side inside a live email editor (built on
@react-email/editor). Migrating from the now-deprecated individual@react-email/*packages toreact-emailv6 adds +190 KB gzip (+33%) to our editor chunk — measured on a Vite/rolldown build.Tree-shaking can’t recover it: the consolidated
dist/index.mjshas top-level imports ofprismjs/marked/tailwindcssplus a top-levelPrism$1.languages.markup = {...}side effect, so evenimport { Body } from "react-email"keeps all three heavy deps. PatchingsideEffects: falsewould drop the Prism registration too, so that’s not safe.Current alternatives aren't great: keep the deprecated packages (forever install warnings), alias
react-email/components/*to the shippedsrc/(reaches into private internals), or eat the +190 KB. None of these is something to recommend.@react-email/editoritself is the canonical example of a consumer that ships these components to the browser, so this is an important use case for you all as well.Proposal
Add subpath exports so consumers can do:
Ideally with per-component dist entries + types, so each is fully tree-shakeable on its own. Happy to put up a PR if there’s interest in the direction.
All reactions