react-spring: [bug]: ESM failed to resolve with Webpack
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
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 7
- Comments: 37 (16 by maintainers)
Commits related to this issue
- fix(general): better deps - Cleanup unused (recompose & doc-tools/components) - Move dev dependencies like gulp to devDependencies - Add UI lib dependencies (UIKit) to peerDependencies and devDepende... — committed to gravity-ui/blog-constructor by DC-RomanKarpov a year ago
- Comeon, webpack https://github.com/pmndrs/react-spring/issues/2097#issuecomment-1443395326 — committed to NullVoxPopuli/embroider by NullVoxPopuli a year ago
I’ve just published
9.7.1
.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.
Isn’t this the issue – https://github.com/facebook/create-react-app/issues/11865? While I understand the
react-spring
has caused the break the fault lies with CRA. Our ESM / CJS implementation was incorrect so it’s been fixed properly… 🤔The solution it seems whilst i’m not sure how you would do it, is to add:
to your webpack configuration…
New experimental release that I believe should work –
0.0.0-40ac9039be0c657954e31ea7588bee4abbf1df1f-20230227081728
if people are interested in trying it out need more verification it works in the wild! 🤞🏼@bpinto Can you post your final solve ? Im also having this issue and cant get my webpack configured correctly.
Indeed my problem came from there, here is my solution Thanks for your help
Working for me as well 👍 Thank you! 🙇
With 0.0.0-40ac9039be0c657954e31ea7588bee4abbf1df1f-20230227081728 local build was fixed 🕺
Thanks for that catch. Looks like the experimental release workflow wasn’t building 🤦🏼♀️ back on this issue this AM 😃
That didn’t work on my testing, when I look at what files the package has locally, it is missing the
dist
folder:As you can see the package is using the correct version:
You can also confirm this via npmjs Code tab.
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.
Please stop saying you’re getting the error and not providing a reproduction – it’s really unhelpful and doesn’t make anything happen quicker.