render: Prettier is bundled even when `pretty` is never used
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- react, typescript, vite
- Domain
- build-system, performance
Research direction
Start by tracing how render() handles the pretty option and how the package exports render and pretty; the issue names no source files or tests. Compare the proposed core entry point with removing the option in a major release, then check how each affects bundler output for the Vite SSR reproduction. Done means callers that never use pretty can avoid Prettier in their bundle while pretty formatting remains available.
Written by the indexing model from the issue text.
Description
Versions
react-email 6.11.8, @react-email/render 2.2.0, prettier 3.9.10
Problem
render() only uses Prettier when options.pretty is set, but because that branch reaches import("prettier/standalone"), bundlers have to include Prettier for every caller of render. The option is only known at runtime, so the import can't be tree-shaken.
In a Vite SSR build for Cloudflare Workers that never sets pretty, the Worker bundle gets two extra chunks:
| Chunk | Raw | Gzip |
|---|---|---|
prettier/standalone |
103 KB | 30 KB |
prettier/plugins/html |
197 KB | 55 KB |
| Total | 299 KB | 85 KB |
The code never runs, but it still counts toward the Worker's upload size.
Relation to #3608
#3608 asked to drop Prettier as a dependency, and I'm not asking for that. It's fine as a dependency, and these numbers match the 83 KB gzipped mentioned there. Using a bundler was the suggested fix, but the bundler is what can't remove it here.
To reproduce
import { render } from 'react-email';
export const getHtml = (body: React.ReactElement) => render(body);
Build this for SSR with Vite and look for standalone-*.js and html-*.js in the output.
Suggested fix
pretty is already a separate export and the package has "sideEffects": false, so the if (options?.pretty) branch in render is the only thing keeping Prettier in the graph. Either of these would let bundlers drop it:
- Add an entry point whose
renderhas noprettyoption, such as@react-email/render/core. This is non-breaking. - Deprecate the option in favour of
pretty(await render(element)), and remove it in the next major version.
- Dominant language
- TypeScript
- Stars
- 20k
- Forks
- 1.1k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 80
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from resend/react-email
-
Heading: margin shortcut props (m, mt, mx, ...) produce invalid CSS for values with units such as "1.5rem" or "10px"Possibly taken @officialasishkumar claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
resend/react-email#3924 ·
Maintainers usually reply within 1 day
-
email export: `--outDir` outside the project fails for `<Tailwind>` templates with "Cannot find module 'css-tree/dist/csstree.esm'" (since 6.8.0)Possibly taken @theluckystrike claimed this 4 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 76/100
resend/react-email#3912 ·
Maintainers usually reply within 1 day
-
Dependency DashboardOpendependencies
Difficulty 5/5 Over a week Newbie friendliness 15/100
resend/react-email#746 ·
Maintainers usually reply within 1 day
All issues in resend/react-email
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
code-yeongyu/senpi#7139 ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
lingdojo/kana-dojo#34395 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
bug status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
mastra-ai/mastra#31093 · 1 comment ·
Maintainers usually reply within 1 day
-
area:web p2 product:business triage:active type:bug
Difficulty 1/5 Under an hour Newbie friendliness 89/100
cuadrao-ai/argus#2328 ·
Maintainers usually reply within 1 day
-
bug frontend good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
nikhilb2/simple_invoicing#907 ·