feat(react-email): added configuration handling for react-email and preview server#2984
Open
Shubhdeep12 wants to merge 3 commits intoresend:canaryfrom
Open
feat(react-email): added configuration handling for react-email and preview server#2984Shubhdeep12 wants to merge 3 commits intoresend:canaryfrom
Shubhdeep12 wants to merge 3 commits intoresend:canaryfrom
Conversation
|
@Shubhdeep12 is attempting to deploy a commit to the resend Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 0e97d76 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
6 issues found across 21 files
Confidence score: 3/5
- There is a concrete regression risk in
packages/react-email/src/index.ts: exportingdefineConfigfrom a side-effectful CLI entrypoint can trigger startup/arg parsing during import, which can break expected library-style usage. - Several medium-severity, high-confidence issues affect runtime robustness (
packages/react-email/src/commands/dev.ts,packages/react-email/src/commands/build.ts,packages/react-email/src/commands/init.ts), including unvalidated port values, path handling mismatches, and--forcebehavior that may not actually override active JS/MJS/CJS configs. - Given the concentration of 5-7/10 issues with high confidence and user-facing failure modes, this looks mergeable only with some caution rather than low-risk.
- Pay close attention to
packages/react-email/src/index.ts,packages/react-email/src/commands/dev.ts,packages/react-email/src/commands/build.ts,packages/react-email/src/commands/init.ts,packages/react-email/src/utils/load-config.ts,packages/preview-server/src/utils/load-preview-config.ts- side effects and missing runtime validation can propagate malformed config into startup/build failures.
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="packages/react-email/src/utils/load-config.ts">
<violation number="1" location="packages/react-email/src/utils/load-config.ts:32">
P2: Runtime config is type-cast without validation, allowing malformed user config values to propagate and break downstream path/port handling.</violation>
</file>
<file name="packages/react-email/src/commands/dev.ts">
<violation number="1" location="packages/react-email/src/commands/dev.ts:16">
P2: Port parsing from CLI/config lacks validation, allowing malformed values to reach server startup.</violation>
</file>
<file name="packages/react-email/src/commands/init.ts">
<violation number="1" location="packages/react-email/src/commands/init.ts:41">
P2: `init --force` claims to overwrite existing config files but only writes `react-email.config.json`, leaving higher-priority JS/MJS/CJS configs active.</violation>
</file>
<file name="packages/react-email/src/commands/build.ts">
<violation number="1" location="packages/react-email/src/commands/build.ts:181">
P2: `emailsDir` from CLI/config is not constrained to relative paths, but later logic treats it as relative, causing directory mismatch and possible build failures.</violation>
</file>
<file name="packages/preview-server/src/utils/load-preview-config.ts">
<violation number="1" location="packages/preview-server/src/utils/load-preview-config.ts:30">
P2: User-authored config is cast with TypeScript assertions only, so invalid runtime shapes can propagate and cause runtime failures when consumed.</violation>
</file>
<file name="packages/react-email/src/index.ts">
<violation number="1" location="packages/react-email/src/index.ts:17">
P1: `defineConfig` is exported from a side-effectful CLI entrypoint, so importing it can execute CLI startup/parse logic instead of acting like a pure utility import.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…tion - Refactored email directory resolution logic to ensure fallback to a default path. - Enhanced configuration validation for `react-email` to handle various edge cases. - Updated imports to use `env.client` for compatibility across components. - Added utility functions for better handling of project paths and port parsing.
commit: |
Contributor
There was a problem hiding this comment.
6 issues found across 12 files (changes from recent commits).
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="packages/react-email/src/utils/load-config.ts">
<violation number="1" location="packages/react-email/src/utils/load-config.ts:60">
P2: JSON config read/parse errors are swallowed, causing broken config files to fail silently without warning.</violation>
</file>
<file name="packages/preview-server/src/utils/load-preview-config.ts">
<violation number="1" location="packages/preview-server/src/utils/load-preview-config.ts:58">
P2: JSON config read/parse errors are swallowed, so malformed config files fail silently without the warning in loadReactEmailConfig.</violation>
</file>
<file name="packages/react-email/src/commands/dev.ts">
<violation number="1" location="packages/react-email/src/commands/dev.ts:18">
P2: Port parsing now rejects 0 and silently falls back to 3000, preventing use of ephemeral ports (server.listen(0)) and changing behavior for users/configs that set port 0.</violation>
</file>
<file name="packages/react-email/src/commands/build.ts">
<violation number="1" location="packages/react-email/src/commands/build.ts:30">
P2: Windows cross-drive absolute paths bypass the outside-project check, causing malformed `path.join` results and incorrect directory resolution.</violation>
<violation number="2" location="packages/react-email/src/commands/build.ts:30">
P2: Build silently rewrites absolute external emailsDir to `./emails`, overriding user intent and potentially building the wrong templates.</violation>
</file>
<file name="packages/react-email/src/index.ts">
<violation number="1" location="packages/react-email/src/index.ts:25">
P1: Entrypoint detection uses brittle path equality and can fail for symlink/bin shim invocation, causing the CLI startup path to be skipped entirely.</violation>
</file>
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.
react-email.config.(mjs/cjs/js/json)as the unified configuration source for the CLI and preview server in a repository.email initcommand to generate the config.related To have a unified config for react-email #2985
Summary by cubic
Adds a unified react-email.config.* for the CLI and preview server, plus a new init command to scaffold it. CLI commands now use config defaults for emailsDir and port, with flags as overrides.
New Features
Migration
Written for commit 0e97d76. Summary will update on new commits.