-
Notifications
You must be signed in to change notification settings - Fork 583
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
Server Side Import #513
Comments
Do you have a repo/codesandbox to reproduce this? |
Closing due to inactivity. |
The issue here is trying to use this module in a Native ESM context. In a Native ESM application, you'd have to import the file in the dist directory (including the file extension). The solution is to use the package.json exports config. Radix had a similar problem recently and solved it that way: https://github.com/radix-ui/primitives/blob/main/packages/react/checkbox/package.json#L5 |
There is a repository that has a repro at: https://github.com/dawnmist/react-email-issue-513 This was created from Kent's Epic Stack, then modified to add react-email and a single email template. Steps to see the error:
The dev server ( |
I can confirm that adding: "exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
}, to the Given that the various component packages can be individually used rather than always through the |
Note: I discovered later that the exports in the package.json file had broken the What caused it was that I had the "types" and "default" conditions in the json snippet above the wrong way around. I've fixed the snippet above so that the default value being specified for the import and require sections is the last condition so if anyone else comes across the thread they don't copy/paste the wrong information, and the |
I am trying to import this on the serverside and am getting the following error.
import { Html } from "@react-email/html";
The text was updated successfully, but these errors were encountered: