-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[bug]: ESM failed to resolve with Webpack #2097
Comments
I cant see an error in the reproduction? |
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.
This comment was marked as off-topic.
This comment was marked as off-topic.
Please stop saying you're getting the error and not providing a reproduction – it's really unhelpful and doesn't make anything happen quicker. |
I'm sorry. What kind of reproduction do you want to see? For the test URL, I can't build the reproduction for you because When I do I'm not sure if this can help you, but the Node version: 16.17.1 My dependencies
|
@nongtiny, sounds like you're using CRA? So perhaps just a github repo that has CRA and |
Yes I'm using CRA. Is there any workaround to avoid or fix this problem? @joshuaellis Will do a Repo for you soon. |
It seems an issue with CRA's webpack configuration. This follows specs on delivering ESM & CJS so i'm not totally sure to be honest. |
Here you go https://github.com/nongtiny/test-cra-reactspring-issue/tree/main Thanks a lot for your fast reply and support! |
Isn't this the issue – facebook/create-react-app#11865? While I understand the The solution it seems whilst i'm not sure how you would do it, is to add: {
test: /\.m?js/,
resolve: {
fullySpecified: false
}
} to your webpack configuration... |
I have already tried this configuration in my craco.config.js file without success
|
@LoicHuart I don't think that's how you do it is it? Have you looked at the documentation? https://craco.js.org/docs/configuration/webpack/ |
@joshuaellis that indeed solves the problem. Does that mean that the distributed What I haven't been able to understand yet is why webpack is using Update: Maybe that's standard, I just haven't confirmed that via docs yet. |
I'll be honest, not totally sure! It works well with all the other bundlers 🤷🏼♀️ |
Indeed my problem came from there, here is my solution
|
Seems like there's a solution – i'm gonna close this issue but also pin it so others will see it if they have the problem. Thanks for all the responsiveness, sorry there's nothing I can do this side. |
Just ran into this problem in an ESM project. The problem here is webpack requires In my case, here's the code causing the problem https://github.com/pmndrs/react-spring/blob/master/packages/core/src/index.ts#L25-L26 export * from '@react-spring/types/animated'
export * from '@react-spring/types/interpolation' Which I believe can be fixed by appending the export * from '@react-spring/types/animated.js'
export * from '@react-spring/types/interpolation.js' @joshuaellis Would u accept a pull request to fix it? Btw, I believe the right workaround in webpack is as below: {
test: /react-spring/i,
resolve: {
fullySpecified: false,
},
}, Targeting |
Sure we can take a look at an experimental release for this! I'm wondering if we do something more similar to this – adobe/react-spectrum#4038 as this just fixes the issue at hand instead of tackling the root of the issue... |
@bpinto Can you post your final solve ? Im also having this issue and cant get my webpack configured correctly. |
Update this does in fact work. Another package also happened to have a minor version release today that caused issues. Love when that happens :) {
test: /react-spring/i,
resolve: {
fullySpecified: false,
},
}, |
You do appreciate this is due to the changes in ESM specs & webpack 4 being used? 😅 |
|
This comment was marked as outdated.
This comment was marked as outdated.
This is not a bug in Webpack or similar. ESM requires usage of explicit file extensions in import specifiers (see mandatory file extensions). This can otherwise be fixed with the use of |
I don't think anyone has said it was a bug with webpack @CodyJasonBennett :) I actually think from more research and discussion with a few devs on twitter a combination of |
This comment was marked as spam.
This comment was marked as spam.
I've tested it against the webpack.js.org repository, works fine with webpack 5. |
That didn't work on my testing, when I look at what files the package has locally, it is missing the
As you can see the package is using the correct version:
You can also confirm this via npmjs Code tab. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
Thanks for that catch. Looks like the experimental release workflow wasn't building 🤦🏼♀️ back on this issue this AM :) |
New experimental release that I believe should work – |
With 0.0.0-40ac9039be0c657954e31ea7588bee4abbf1df1f-20230227081728 local build was fixed 🕺 |
Working for me as well 👍 Thank you! 🙇 |
I've just published I'd like to thank you all for the help & patience in resolving this issue, and i'd also like to apologise that this happened. |
Hi again @joshuaellis |
- Cleanup unused (recompose & doc-tools/components) - Move dev dependencies like gulp to devDependencies - Add UI lib dependencies (UIKit) to peerDependencies and devDependencies Note: There is an issue in the last version of react-spring: pmndrs/react-spring#2097. Restore minor ranges after fix.
Which react-spring target are you using?
@react-spring/web
@react-spring/three
@react-spring/native
@react-spring/konva
@react-spring/zdog
What version of react-spring are you using?
9.7.0
What's Wrong?
ERROR in ./node_modules/@react-spring/core/dist/index.mjs 1596:0-45
Module not found: Error: Can't resolve '@react-spring/types/animated' in '.../my-app/node_modules/@react-spring/core/dist'
Did you mean 'animated.js'?
BREAKING CHANGE: The request '@react-spring/types/animated' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '.mjs' file, or a '.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
To Reproduce
Code running locally has an error
Expected Behaviour
no error
Link to repo
https://codesandbox.io/s/bold-mahavira-y26di2?file=/src/App.js
The text was updated successfully, but these errors were encountered: