Skip to content

feat(emails): add --react-file flag to emails send#91

Open
pcristin wants to merge 3 commits intoresend:mainfrom
pcristin:codex/issue-73-react-file
Open

feat(emails): add --react-file flag to emails send#91
pcristin wants to merge 3 commits intoresend:mainfrom
pcristin:codex/issue-73-react-file

Conversation

@pcristin
Copy link

@pcristin pcristin commented Mar 13, 2026

Summary

Adds support for --react-file in resend emails send (issue #73), similar to --html-file.

What changed

  • Added --react-file <path> option to emails send
  • Loads the file as a module and uses its default export as react payload
  • Updated body validation to accept --react-file as a valid body source
  • Updated command help/examples to include --react-file
  • Updated README options, examples, and error-code descriptions
  • Added tests for:
    • successful --react-file usage
    • error path when react file has no default export

Behavior details

  • Body source precedence is now:
    • --react-file
    • --html-file
    • --html
    • --text
  • --react-file load failures return file_read_error

Verification

  • pnpm lint
  • pnpm typecheck
  • pnpm test tests/commands/emails/send.test.ts
  • pnpm test
  • pnpm build

All commands pass locally.

Issue

Closes #73


Summary by cubic

Adds --react-file to resend emails send to send a React-rendered template from a module’s default export. Updates help/README and tests.

  • New Features
    • Loads a React file as an ES module and uses its default export as the react payload; rejects component function defaults with file_read_error.
    • Body precedence: --react-file--html-file--html--text.
    • Errors: load failures or missing default export → file_read_error; missing body → missing_body.
    • Help/README updated with examples and error codes; tests cover success, precedence, and error paths.

Written for commit 444d592. Summary will update on new commits.

Copy link

@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.

3 issues found across 3 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="README.md">

<violation number="1" location="README.md:233">
P2: The `--react-file` documentation is ambiguous about whether it expects a React component function or a rendered React element. The README states "Path to a React module (default export)" which suggests a component function export is valid. However, the Resend SDK's `react` field expects a `React.ReactNode` (rendered element), not a component function - the SDK docs explicitly show calling the component (`EmailTemplate({userName})`). The CLI implementation passes the module's default export directly to the SDK without rendering, so if users export a component function as described, it will cause runtime failures.</violation>
</file>

<file name="tests/commands/emails/send.test.ts">

<violation number="1" location="tests/commands/emails/send.test.ts:248">
P2: Missing test coverage for precedence when --react-file is combined with other body flags. The PR documents a precedence guarantee (`--react-file` > `--html-file` > `--html` > `--text`), but the test only exercises `--react-file` in isolation. Consider adding a test that provides multiple body flags to verify the documented precedence behavior is enforced.</violation>
</file>

<file name="src/commands/emails/send.ts">

<violation number="1" location="src/commands/emails/send.ts:93">
P1: `--react-file` loads a React component but passes it to Resend without converting it to a React element. Resend's `emails.send()` expects a rendered React element (JSX/ReactNode), not a component function/class. When users provide a typical React email file with `export default function Email() {...}`, the default export is the component constructor, which will cause Resend to fail or render incorrectly. The code should wrap `mod.default` with `React.createElement()` before returning to ensure a proper React element is passed to the API.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

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

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