-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
Import MJML breaks the new app router #50042
Comments
Had the same issue with other dependencies. |
This comment was marked as off-topic.
This comment was marked as off-topic.
I'm having the same issue when trying to use mailing.run, which uses |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Maybe we can try using react email instead. |
This is what I ended up doing and it works flawlessly. |
Been fighting this in various different ways for a few days. It took a while to identify that importing mjml, or even using a function that depended upon it, inside of the authOptions object is what caused everything to crash. For us it was a custom sendgrid magicLink provider and the createUser event. We prevailed by setting up an internal API endpoint that receives email and magicLink as parameters, and then called this endpoint in a fetch request inside the sendgrid magicLink sendVerificationRequest function. Best of luck! |
Hi, after having a closer look at this, this is not related to Turbopack. The issue is similar to what is described in #52876 (comment) So adding the following to module.exports = {
experimental: {
serverComponentsExternalPackages: ["mjml"],
},
}; will solve the issue. (Note, we are currently exploring if we can detect these cases automatically) I verified that the reproduction works with the suggested change. If this is not the case for you, please open a new issue with your (minimal) reproduction, thanks! |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 Binaries: Node: 18.10.0 npm: 8.19.2 Yarn: 1.22.19 pnpm: N/A Relevant packages: next: 13.4.3-canary.3 eslint-config-next: 13.4.1 react: 18.2.0 react-dom: 18.2.0 typescript: 5.0.4
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Turbopack (--turbo)
Link to the code that reproduces this issue or a replay of the bug
https://github.com/razvanbretoiu/nextjs-mjml-bug
To Reproduce
1.. Install
mjml
library (npm install mjml
)2. Create a route in the
app
directory for the/api/email
path3. In the route use the
mjml2html(template)
to convert the mjml template into HTMLlocalhost:3000/api/email
routeDescribe the Bug
I cannot use the MJML library with
app router
, because when I try to access themjml
library, the server throws the below error:This is the code used in the
app/api/email/route.ts
fileI've tried to use the MJML library in a server component and it's not working as well. The server throws the following error when I'm trying to access a RSC page
Pages Router working fine
I've run the same code using
pages router
and it's working fine.So, the problem is happening only in the App Router and not in the Pages Router
Expected Behavior
The application should compile and navigate successfully to the
/api/email
app route, same as the/api/email-v2
which is using the pages routerWhich browser are you using? (if relevant)
Chrome
How are you deploying your application? (if relevant)
locally
WEB-1078
The text was updated successfully, but these errors were encountered: