-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
Resolution errors may happen in server components with packages whose exports field only includes ES module import #42534
Comments
Fixes #42534 * Use eager `import()` to load page/layout to avoid esm module resolution error, eager is to make sure all the sub resources like css are also included * Fix layer detection, should use `module.layer` directly since `module.resourceResolveData` is not alway presented. It lost when switching from `require()` to `import()` for page/layout component ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md`
Hi can you try again with |
@huozhi Hi, unfortunately it doesn't work for v13.0.3-canary.3 yet :( in the repro repo above I have upgraded to canary.3 as well and it didn't work. |
Gotcha seems related to another issue, reopened |
) Should be able to resolve `exports.import` condition for esm packages only when import them in server components Fixes: #42534 ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md`
It has been fixed now, thanks! 🚀 |
@schickling Can you try |
Works 🙌 |
I had a similar issue with
|
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
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
In some ES module packages, the
exports
field inpackage.json
only includes oneimport
field. This causes some resolution errors when imported to server components. However,getStaticProps
and other data-fetching functions inpages
directory still works fine.Since it's quite vague to me, I think I will continue with the example. Clone the repo linked below.
The path
/test
(inpages
directory, withgetStaticProps
) works as intended. Meanwhile,/
(RSC inapp
directory) doesn't, with a confusing error message:That is (apparently) because
periscopic
'sexports
field is like thisAfter modifying this
exports
manually, inperiscopic
and 2 other similar modules (is-reference
andestree-walker
),then
/
works as intended.Ref: https://github.com/orgs/mdx-js/discussions/2168
Expected Behavior
/
should not crash and gives the same output as/test
in the linked reproduction repository.Link to reproduction
https://github.com/joulev/debug/tree/nextjs-42534
To Reproduce
Mentioned in the "Describe the Bug" section.
npm install
npm run dev
/
: crash/test
: works normallyThe text was updated successfully, but these errors were encountered: