feat(emails): add --react-file flag to emails send#91
feat(emails): add --react-file flag to emails send#91pcristin wants to merge 4 commits intoresend:mainfrom
Conversation
There was a problem hiding this comment.
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-aiwith guidance or docs links (includingllms.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.
|
@zenorocha please, review the PR |
|
Hi, thanks for the PR. It doesn't seem to work with a React Email template file. I tested the implementation, and there's a gap between what users would expect and what export default function Welcome() {
return <Html><Text>Hello</Text></Html>;
}But this PR expects a pre-built .mjs module whose default export is an already-rendered React element, not a component function. Users would need to compile and render the template themselves before passing it to the CLI The original issue itself needs more thought. |
Summary
Adds support for
--react-fileinresend emails send(issue #73), similar to--html-file.What changed
--react-file <path>option toemails sendreactpayload--react-fileas a valid body source--react-file--react-fileusageBehavior details
--react-file--html-file--html--text--react-fileload failures returnfile_read_errorVerification
pnpm lintpnpm typecheckpnpm test tests/commands/emails/send.test.tspnpm testpnpm buildAll commands pass locally.
Issue
Closes #73
Summary by cubic
Adds
--react-filetoresend emails sendto send a React-rendered template from a module’s default export. Updates CLI help/README and tests.reactpayload; rejects component function defaults withfile_read_error.--react-file→--html-file→--html→--text.file_read_error; missing body →missing_body.Written for commit 951b069. Summary will update on new commits.