Skip to content

Drop @react-email/preview-server from dependencies#153

Merged
damianlegawiec merged 4 commits into
mainfrom
fix/remove-react-email-preview
May 14, 2026
Merged

Drop @react-email/preview-server from dependencies#153
damianlegawiec merged 4 commits into
mainfrom
fix/remove-react-email-preview

Conversation

@damianlegawiec
Copy link
Copy Markdown
Member

@damianlegawiec damianlegawiec commented May 14, 2026

Which shipped with a lot of transitive dependencies and it's own next version (16.1.x)

Add a very lightweight development only email preview using @react-email/components

Summary by CodeRabbit

  • New Features

    • Introduced an integrated email template preview interface in development, accessible via /dev/emails page, displaying a catalog of all available email templates with sample data.
  • Documentation

    • Updated template preview instructions to reference the new built-in development preview page instead of an external tool.
  • Chores

    • Removed email preview-related npm scripts and development dependencies.

Review Change Stack

Which shipped with a lot of transitive dependencies and it's own next version (16.1.x)

Add a very lightweight development only email preview using `@react-email/components`
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
storefront Ready Ready Preview, Comment May 14, 2026 8:53pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Warning

Rate limit exceeded

@damianlegawiec has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 27 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e7e03aa9-195f-4101-b165-7350d9ab02c7

📥 Commits

Reviewing files that changed from the base of the PR and between 6d2cb47 and 38e10e3.

📒 Files selected for processing (7)
  • src/app/[country]/[locale]/(storefront)/cart/page.tsx
  • src/app/dev/emails/[template]/page.tsx
  • src/components/ui/alert.tsx
  • src/components/ui/card.tsx
  • src/components/ui/field.tsx
  • src/components/ui/input-group.tsx
  • src/components/ui/sheet.tsx

Walkthrough

This PR migrates email preview infrastructure from an external @react-email/preview-server to an internal fixture-based system. The /dev/emails route displays a preview index and dynamic template routes render email fixtures with hardcoded sample data, both gated to non-production. Dependencies and old script commands are removed accordingly.

Changes

Email Preview System Migration

Layer / File(s) Summary
Email preview fixture data contract
src/app/dev/emails/fixtures.tsx
Introduces EmailFixture interface and exports emailFixtures array with render methods for order confirmation, order canceled, shipment shipped, and password reset emails containing hardcoded sample props and a getEmailFixture() lookup function.
Dev email preview pages
src/app/dev/emails/page.tsx, src/app/dev/emails/[template]/page.tsx
Adds /dev/emails index page listing all fixtures and dynamic /dev/emails/[template] route that renders HTML preview via iframe or plain-text via <pre>, with production guard and static param generation from fixtures.
Routing and dev infrastructure
src/lib/spree/middleware.ts, next.config.ts
Updates Spree middleware to skip /dev static routes and adds 192.168.33.13 to allowed development origins.
Documentation and dependency cleanup
README.md, package.json
Updates README to direct users to /dev/emails route instead of npm run email:dev; removes email:dev script, @react-email/preview-server, and react-email dependencies; adds check:locales script.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • spree/storefront#87: Introduces the original @react-email/preview-server setup and standalone Preview exports in email modules that are now being removed and consolidated into the fixture-based system.

Poem

🐰 No more external servers, no more Preview exports floating free,
A fixture-based /dev/emails brings all templates to one cozy tree,
Sample data bundled close, in non-prod gated walls,
The storefront now previews its own email halls! 📧✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing the @react-email/preview-server dependency and replacing it with a lighter alternative using @react-email/components.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remove-react-email-preview

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/app/dev/emails/page.tsx (1)

5-8: ⚡ Quick win

Add explicit return type.

Per coding guidelines, always define explicit return types for functions.

♻️ Proposed fix
-export default function EmailPreviewIndex() {
+export default function EmailPreviewIndex(): JSX.Element {
   if (process.env.NODE_ENV === "production") {
     notFound();
   }

As per coding guidelines: "Use strict TypeScript type checking. Always define explicit return types for functions."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/app/dev/emails/page.tsx` around lines 5 - 8, Add an explicit return type
to the EmailPreviewIndex function signature (e.g., : React.JSX.Element) to
satisfy strict TypeScript rules; update the declaration of EmailPreviewIndex to
include this return type while keeping the existing notFound() guard and JSX
body intact so the function still returns the page element.
src/app/dev/emails/[template]/page.tsx (1)

11-13: ⚡ Quick win

Add explicit return types.

Per coding guidelines, always define explicit return types for functions.

♻️ Proposed fix
-export async function generateStaticParams() {
+export async function generateStaticParams(): Promise<Array<{ template: string }>> {
   return emailFixtures.map((f) => ({ template: f.slug }));
 }

-export default async function EmailPreviewPage({
+export default async function EmailPreviewPage({
   params,
   searchParams,
-}: PreviewPageProps) {
+}: PreviewPageProps): Promise<JSX.Element> {

As per coding guidelines: "Use strict TypeScript type checking. Always define explicit return types for functions."

Also applies to: 15-18

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/app/dev/emails/`[template]/page.tsx around lines 11 - 13,
generateStaticParams currently lacks an explicit return type; change its
signature to declare the precise Promise return type, e.g. export async function
generateStaticParams(): Promise<{ template: string }[]> { ... }, and likewise
add explicit return types to the other async functions in this module so every
function has an explicit TypeScript return annotation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/app/dev/emails/`[template]/page.tsx:
- Around line 34-50: The view logic in page.tsx is inverted: when format ===
"html" the code calls render(element, { plainText: true }) and returns the
plain-text <pre>, while the UI link reads "View plain text"; change the
condition so the branch that renders the plain-text output runs when format
indicates plain/text (e.g., format === "plain" or format === "text") or rename
the parameter to format === "plain"; update the conditional around
render(element, { plainText: true }) and the associated link label (the "View
plain text"/"View HTML" toggle) so the format value always represents what to
display rather than what to convert from.

---

Nitpick comments:
In `@src/app/dev/emails/`[template]/page.tsx:
- Around line 11-13: generateStaticParams currently lacks an explicit return
type; change its signature to declare the precise Promise return type, e.g.
export async function generateStaticParams(): Promise<{ template: string }[]> {
... }, and likewise add explicit return types to the other async functions in
this module so every function has an explicit TypeScript return annotation.

In `@src/app/dev/emails/page.tsx`:
- Around line 5-8: Add an explicit return type to the EmailPreviewIndex function
signature (e.g., : React.JSX.Element) to satisfy strict TypeScript rules; update
the declaration of EmailPreviewIndex to include this return type while keeping
the existing notFound() guard and JSX body intact so the function still returns
the page element.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4a95738c-c96b-43c9-b5a8-6d98b8a1f8b7

📥 Commits

Reviewing files that changed from the base of the PR and between 54978b2 and 6d2cb47.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (11)
  • README.md
  • emails/order-canceled.tsx
  • emails/order-confirmation.tsx
  • emails/password-reset.tsx
  • emails/shipment-shipped.tsx
  • next.config.ts
  • package.json
  • src/app/dev/emails/[template]/page.tsx
  • src/app/dev/emails/fixtures.tsx
  • src/app/dev/emails/page.tsx
  • src/lib/spree/middleware.ts
💤 Files with no reviewable changes (4)
  • emails/order-canceled.tsx
  • emails/shipment-shipped.tsx
  • emails/password-reset.tsx
  • emails/order-confirmation.tsx

Comment thread src/app/dev/emails/[template]/page.tsx Outdated
@damianlegawiec damianlegawiec merged commit 782efaf into main May 14, 2026
6 checks passed
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.

1 participant