feat(emails): add --react-file flag to emails send#91
Open
pcristin wants to merge 3 commits intoresend:mainfrom
Open
feat(emails): add --react-file flag to emails send#91pcristin wants to merge 3 commits intoresend:mainfrom
pcristin wants to merge 3 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 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 444d592. Summary will update on new commits.