Skip to content

Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime #1105

Closed
@VaniaPopovic

Description

@VaniaPopovic

Describe the Bug

Hello, this is the one I was referring to to in the other ticket @gabrielmfern,

I have a monorepo with an auth package, an email package and my main app that consumes both of them.
My desire is for users to login through next-auth and have next-auth send out an email with resend of a login link that is styled with react email.
I have been trying to have the next-auth middleware run on edge in order to make it faster.

The problem that I'm experiencing is that the project works well on dev, but when trying to build and deploy to vercel, it fails with

./node_modules/.pnpm/@[email protected][email protected]/node_modules/@react-email/tailwind/dist/index.mjs
Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation

Import trace for requested module:
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@react-email/tailwind/dist/index.mjs
./node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@react-email/components/dist/index.mjs
./src/vercel-invite-user.tsx
./src/auth.ts

I've been using the canary versions of both @react-email/components & @react-email/render cause they contain fixes that I need to run on edge : #1079

I'm not sure if it's a regression or a problem caused by a different library eg. NextAuth or Next itsself.

It took me a while to create the reproduction because I have attempted:

  1. See if the problem occurs in a NextJS API route. It works without a problem ✅
  2. See if the problem occurs when having the renderAsync function in a RSC. It works without a problem ✅
  3. Have the function in the NextAuth configuration. It fails ❌

Which package is affected (leave empty if unsure)

@react-email/components

Link to the code that reproduces this issue

https://github.com/VaniaPopovic/react-email-repro

To Reproduce

  1. pnpm install
  2. pnpm run dev -> everything works as expected
  3. pnpm run build it fails with the aformentioned error

Expected Behavior

For it to render the email without a problem

What's your node version? (if relevant)

20.6.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions