Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lazy load @react-email/render to avoid Edge Runtime warnings in … #468

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

mzubair481
Copy link

@mzubair481 mzubair481 commented Feb 4, 2025

Fix Edge Runtime Warning Due to Unconditional @react-email/render Import

Note: This is a resubmission of #466 with the same changes, as the previous PR couldn't be reopened.
Note: This is just a workaround to avoid the edge runtime issues and only works for text based emails

Description

This PR fixes the Edge Runtime warning that occurs in Next.js 15 projects when using the Resend SDK, even when not using React components for emails. The warning was caused by unconditional importing of @react-email/render.

Changes

  • Moved React email rendering logic to a separate render.ts file
  • Implemented lazy loading of @react-email/render only when needed
  • Added proper type safety and error handling
  • Improved Edge Runtime compatibility
  • Maintained backward compatibility

Testing

  • Added tests for React email rendering functionality
  • Verified Edge Runtime compatibility in Next.js 15
  • Tested backward compatibility with existing code
  • All existing tests passing

Breaking Changes

None. This is a backward-compatible improvement that only affects the internal implementation.

Related Issues

#467

@mzubair481 mzubair481 requested a review from a team as a code owner February 4, 2025 09:04
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