Skip to content

chore(docs): note tsup + emitDecoratorMetadata gotcha for render#3470

Open
mvanhorn wants to merge 1 commit intoresend:canaryfrom
mvanhorn:fix/3177-tsup-decorator-gotcha
Open

chore(docs): note tsup + emitDecoratorMetadata gotcha for render#3470
mvanhorn wants to merge 1 commit intoresend:canaryfrom
mvanhorn:fix/3177-tsup-decorator-gotcha

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented May 5, 2026

Summary

Document the tsup + emitDecoratorMetadata build gotcha on the Render utility page so backend users hitting ReferenceError: React is not defined in production bundles have somewhere to land.

Why this matters

Issue #3177 reports the failure mode and explicitly frames it as "worth a docs mention since it affects an unrelated tsconfig flag." The chain is:

  • emitDecoratorMetadata: true makes tsup route .tsx through SWC instead of esbuild (egoist/tsup#792)
  • SWC defaults to the classic JSX runtime, so the output emits React.createElement calls
  • Combined with the recommended external: ["react"], the bundle references React without importing it

This affects any TS project that needs runtime decorator metadata (NestJS, type-graphql, TypeORM).

Changes

A new section at the end of apps/docs/utilities/render.mdx: failure symptom, the SWC routing chain, three mitigations (automatic JSX runtime, drop the external for the affected entry, or force tsup back to esbuild for .tsx), and a link to the upstream tsup issue.

Testing

pnpm lint passes (one pre-existing warning unrelated to this change). Mintlify validation against the local Node version was blocked by the LTS requirement; the section uses standard markdown that Mintlify renders verbatim.

Fixes #3177


Summary by cubic

Add a note to the Render utility docs about a tsup + emitDecoratorMetadata build gotcha that can cause ReferenceError: React is not defined in production. It explains the SWC routing with classic JSX and external: ["react"] cause, and lists three fixes (use the automatic JSX runtime, remove the external for that entry, or force .tsx back to esbuild), fixing #3177.

Written for commit e822ffb. Summary will update on new commits.

When tsup is configured with `emitDecoratorMetadata: true` and
`external: ["react"]`, .tsx files get routed through SWC which defaults
to the classic JSX runtime, leaving the output referencing `React`
without importing it. Document the failure mode and three mitigations
(automatic JSX runtime, drop the external, or force esbuild for .tsx)
on the Render utility page so backend users hitting this in NestJS /
type-graphql / TypeORM stacks have somewhere to land.

Closes resend#3177

AI was used for assistance.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 5, 2026

@mvanhorn is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

⚠️ No Changeset found

Latest commit: e822ffb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Documentation-only change adding a note about tsup and decorator metadata gotcha. No code, config, or logic changes. Low risk.

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.

Flag: "React is not defined" in production builds with tsup + emitDecoratorMetadata

1 participant