-
Notifications
You must be signed in to change notification settings - Fork 661
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
All builds failing with react-email templates on Next.js 14 with error "Cannot get final name for export 'encodeXML'" #1499
Comments
Defaulted back to send the email by plain text for now so my build succeeds. If the issue keeps being unresolved, I'll probably have no option than to look into an alternative on how to handle the HTML templating and with which service. Which is a shame cause the development experience was great until it came to now having it work on production. |
Can you make an actual reproduction of this? Something I can clone and get up and running quickly because the original issue there was fixed, and it isn't present anymore. Your issue seems to be something else. |
@gabrielmfern thanks for getting back to me. I'll see if I can find time to create smth to reproduce the issue. Although I think it might also be something from the Cause I currently managed to get around it by sending the HTML email from an edge API route instead of sending the email directly from my server action on the edge runtime, so in the server action I only send a POST request to the API route to trigger the email send and this worked. |
add transpilePackages and serverComponentsExternalPackages to your next.config.js `/** @type {import('next').NextConfig} */ images: { module.exports = nextConfig` If your get ESLint rule violation, update your email template body section
|
@maldee still the same error unfortunately when trying to call it directly from the server action: |
Hi, Finally, I came with this solution. Rather than using // At my-app/transactional directory
// render.js
import { render } from "@react-email/render";
import WaitListEmail from "./emails/WaitListEmail"
export default function renderWaitList(props) {
return render(WaitListEmail(props), {
pretty: true,
});
} // At server action inside my-app/src/actions
// sendEmailAction.js
import renderWaitList from ".../../transactional/render"
const { error } = await resend.emails.send({
from,
to,
subject,
html: renderWaitList(props),
}); Hope that you could make a build success with this solution. |
In what situation does the error happen exactly? I can see this is an issue people have, but I can't reproduce at all. This also might be a more general NextJS issue vercel/next.js#60807, and if it is, it should be fixed under their canaries. |
I've been logging my findings in Discord but I'll leave them here for others too. I've stripped my project down to the bare minimum here: https://github.com/kylekz/email-repro At this point, I'm almost certain it's something to do with instantiating a new instance of // actions.ts
"use server";
import { RemovedFromOrganization } from "@repo/email/emails/removed-from-org";
import { Resend } from "resend";
// const resend = new Resend("");
// uncommenting this line fixes the error
export async function email() {
const react = RemovedFromOrganization({
baseUrl: "",
receiverName: "",
organizationName: "",
});
} // page.tsx
"use client";
export default function MyComponent() {
async function send() {
startTransition(async () => {
await email();
});
}
return <button onClick={send}>Send Email</button>;
} In my project, I have If I place an unused |
Thank you so much for making the repro @kylekz, helped out a lot. After experimenting for a bit on it, this can't be an issue on our side, as it seems really volatile about when it happens. Just importing The package it points to — If anyone wants to upgrade to Next 15's canaries, you also need to upgrade your React and React Email dependencies accordingly. So, upgrade your React Email dependencies to the canaries we have, which also support React 19 directly. |
Closing this issue as Next 15 has been out for a while, and since the issue is not on our side. |
Describe the Bug
I'm having a blocking issue for all my builds with Next.js 14.2.3:
It seems that this is already a long-standing issue that has been closed without proper resolution: #1015
The mentioned workarounds do also not work for me:
render
function to first render the react component to HTML and send the emailNot using the Edge runtime on my page
Used packages:
"@react-email/components": "^0.0.19",
"react-email": "^2.1.4",
Which package is affected (leave empty if unsure)
No response
Link to the code that reproduces this issue
private
To Reproduce
Create a next 14 project and use the following packages:
Expected Behavior
Build succeeds
What's your node version? (if relevant)
v20.13.1
The text was updated successfully, but these errors were encountered: