Skip to content

Not working: Dynamic Code Evaluation #32

Open
@lopezjurip

Description

@lopezjurip

Not working on Next.js edge functions. Here is an example:

// /pages/api/edge/resend.tsx

import { default as Email } from "@repo/transactional/emails/test"; // my react template
import { Resend } from "resend";
import { renderAsync } from "@react-email/components";

const resend = new Resend(process.env.RESEND_KEY_PRIVATE);

export const config = {
  runtime: "edge",
};

// curl http://localhost:9000/api/edge/resend
const handler = async (req) => {
  const result = await resend.emails.send({
    from: "[email protected]",
    to: "[email protected]",
    subject: "Hello World",
    html: await renderAsync(<Email />),
  });

  return new Response(JSON.stringify(result), {
    status: 200,
    headers: { "content-type": "application/json" },
  });
};

export default handler;

Running next build causes:

Failed to compile.
../../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

Looks like the way it's importing Tailwind's rust compiler is not supported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions