Skip to content

feat: add --react-email flag to send emails from .tsx templates#150

Open
felipefreitag wants to merge 7 commits intomainfrom
worktree-react-email-flag
Open

feat: add --react-email flag to send emails from .tsx templates#150
felipefreitag wants to merge 7 commits intomainfrom
worktree-react-email-flag

Conversation

@felipefreitag
Copy link
Contributor

@felipefreitag felipefreitag commented Mar 24, 2026

Adds a --react-email flag that bundles a React Email .tsx template with esbuild, renders it to HTML, and uses it as the email body.

Supported on emails send, emails batch, broadcasts create, broadcasts update, templates create and templates update.

Follows the same pipeline as react-email's email export command: esbuild bundle → require → render(createElement(component, {})) → HTML string

Closes #73

@felipefreitag felipefreitag requested a review from vcapretz March 24, 2026 10:58
@felipefreitag felipefreitag marked this pull request as ready for review March 24, 2026 10:59
Copy link
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.

4 issues found across 15 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/commands/broadcasts/create.ts">

<violation number="1" location="src/commands/broadcasts/create.ts:105">
P2: `--react-email` is incorrectly made mutually exclusive with `--text`/`--text-file`, which blocks valid HTML+text broadcast creation.</violation>
</file>

<file name="src/lib/react-email-bundler.ts">

<violation number="1" location="src/lib/react-email-bundler.ts:18">
P2: Clean up the temp directory when esbuild fails; current error path leaks temporary folders.</violation>
</file>

<file name="src/commands/templates/create.ts">

<violation number="1" location="src/commands/templates/create.ts:108">
P2: `--react-email` incorrectly forbids `--text`/`--text-file`, which breaks the documented plain-text fallback flow.</violation>
</file>

<file name="src/lib/react-email.ts">

<violation number="1" location="src/lib/react-email.ts:19">
P2: Calling `outputError` inside the `try`/`catch` exits the process before the `finally` cleanup runs, so temporary build directories can be leaked on failure paths.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@felipefreitag felipefreitag changed the title feat: react email flag feat: add --react-email flag to send emails from .tsx templates Mar 24, 2026
Bundles a React Email .tsx template with esbuild, renders it to HTML,
and sends it in one command — matching the react-email export pipeline.
…ands

Extracts bundle+render pipeline into shared buildReactEmailHtml() helper
and adds --react-email support to emails batch, broadcasts create,
broadcasts update, and templates create.
- Clean up temp dir on build failure (wrap both phases in single finally)
- Add file-existence check before bundling for clearer error
- Move createRequire inside function to avoid module-scope side effect
- Update all help text and error messages to mention --react-email
…r on build failure

- Narrow conflict check to only --html/--html-file (and --template for send),
  allowing --text/--text-file as a plain-text fallback alongside --react-email
- Clean up temp directory in bundleReactEmail when esbuild throws
process.exit() does not run finally blocks, so temp directories were
leaked on render failure. Now cleanup runs explicitly before outputError.
@felipefreitag felipefreitag force-pushed the worktree-react-email-flag branch from 69fe0cf to ca2d3d8 Compare March 24, 2026 12:45
- Add React Email to skill description for better triggering
- Document --react-email in emails, broadcasts, templates references
- Add react_email_build_error and react_email_render_error to error codes
- Add React Email examples to workflow recipes (send, broadcast, template)
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.

Add --react-file flag to emails send command

1 participant