Closed ryota-murakami closed 11 months ago
Y'know, as soon as I saw the headline I knew what the issue was here.
We really need use-sync-external-store
to include ESM files in order for this to work, don't we.
THANK YOU for reporting this! (I mean, I hate seeing more issues, but this is why we published an alpha.)
@markerikson I just thought that Vite prebuilds the dependency package as ESM, so this problem does not occur on the dev-server.
I thought that the ESM error that occurs in Jest would not occur because Vitest does the same thing, but it seems that is not the case.
If Vitest is working with Vite's dependency prebundle, it would be natural to be able to avoid this problem by setting vitest.config.ts
.
Vite and Bun are the only effective tools for CJS/ESM compatibility, so it's worth learning more about them now.
For what it's worth, I'm having the same problem with webpack when simply starting the dev server. So I haven't been able to test react-redux 9 so far because my app doesn't build at all with it.
The changes in https://github.com/facebook/react/pull/26230 seem to do the trick, but there's no sign of when that might be merged in.
For now, I'm having to use patch-package to add the changes myself (if you want to do this too, note that patch-package will exclude package.json by default, so needs that config to be overridden)
Looks like changing the imports to be "use-sync-external-store/with-selector.js"
works for now. Will do that and release alpha.2.
Nice!
Fix is out in https://github.com/reduxjs/react-redux/releases/tag/v9.0.0-beta.0 - please let me know if there's any other issues!
@markerikson Thanks!
What version of React, ReactDOM/React Native, Redux, and React Redux are you using?
What is the current behavior?
react-redux@9.0.0-alpha.0
publish as a.mjs
and importuse-sync-external-store/with-selector' without
.js` ext.That doesn't satisfy Node.js's ESM convention so lead causing bellow error.
What is the expected behavior?
Import modules following Node runtime rules about treat ESM and then disappier this error.
There is reproduction here.
https://github.com/laststance/vite-rtk-query
Installation
Which browser and OS are affected by this issue?
No response
Did this work in previous versions of React Redux?