Skip to content

Conversation

@gabrielmfern
Copy link
Member

@gabrielmfern gabrielmfern commented Jan 23, 2024

Background

As we need to pre-import the modules from Node into the app before loading them with vm
we also need to define the context in which the code will run for us to get the email's component,
this means that we need to pass in a few other global things like Buffer that the global
dynamically doesn't contain.

What was the issue?

That being said, something that was missing from the global context was the URL class,
which this PR adds. Closes #1229

How can I test to make sure it's fixed?

  1. Run npx tsx ../../packages/react-email/src/cli/index.ts dev inside of ./apps/demo
  2. Modify the email at ./apps/demo/emails/airbnb-review.tsx by adding the following:
console.log(new URL(""));
  1. Open http://localhost:3000/preview/airbnb-review.tsx
  2. Verify that this errors with "Invalid path" instead of with URL is not defined

@vercel
Copy link

vercel bot commented Jan 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-email ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2024 0:32am
react-email-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2024 0:32am

@ZiBuDo
Copy link

ZiBuDo commented Feb 21, 2024

URLSearchParams I get this not defined in my env, wondering if this can be added as well?

@pkit
Copy link

pkit commented Feb 21, 2024

@ZiBuDo as you can see even the current PR is un-merged yet. lol

@gabrielmfern gabrielmfern requested review from vcapretz and removed request for bukinoshita March 4, 2024 16:09
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.

URL is not defined during email rendering in react-email v2

6 participants