-
Notifications
You must be signed in to change notification settings - Fork 28
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
Imports from @react-email/components break with import-in-the-middle #62
Comments
I've made some attempt to debug what is going on, though it's only been partially successful. Replacing line: https://github.com/DataDog/import-in-the-middle/blob/c3c2c52c1915b47994af59d507c59029c1f1fae9/hook.js#L157 With: const isNodeModule = !(modFile.startsWith('.') || modFile.startsWith('/') || modFile.startsWith('file:'))
const modUrl = isNodeModule
? new URL(require.resolve(modFile, {
paths: [new URL(srcUrl).pathname]
}), srcUrl).toString()
: new URL(modFile, srcUrl).toString() This allows import-in-the-middle to get the correct url for submodule/child node_module library imports, however there is still an issue in that when it is processing those submodules import-in-the-middle fails to retrieve the submodule's exports. This results in the parent module being unable to re-export the submodule's exports as it does not know about the items being exported (the In terms of the |
@react-email/components
is a metapackage that re-exports the individual component libraries from@react-email
such as@react-email/body
,@react-email/html
,@react-email/tailwind
, etc.It does this using
export * from <package>
in its index.mjs file, and the following (compiled) code for index.js:I have created an example minimal reproduction at: https://github.com/dawnmist/import-in-the-middle-react-email-issue
Expected Behavior
The application should be able to import any of the individual components directly from the
@react-email/components
library.Actual Behavior
When
import-in-the-middle
is used as an--experimental-loader
, the import paths for the@react-email
components get incorrectly mapped as subdirectories/siblings of the index.js/index.mjs files of the@react-email/components
library, resulting in file not found import errors:Yarn 4 (nodeLinker=pnpm):
Yarn 3 (nodeLinker=pnpm):
Steps to Reproduce the Problem
I have created an example reproduction at: https://github.com/dawnmist/import-in-the-middle-react-email-issue
yarn install
yarn build
yarn start
- server will run without using import-in-the-middleyarn start:import
- the same server will fail to run at all when usingimport-in-the-middle
as an experimental-loader, throwing the error above where the @react-email/body library is instead attempted to be loaded as a subdirectory of the @react-email/components library instead of being treated as a separate npm library.Specifications
The text was updated successfully, but these errors were encountered: