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
Target ESM over CommonJS #117
Comments
PR welcome |
I just ran into this issue also. I solved it by setting {"type": "module"} in the package.json for node_modules/use-immer (In other words for anyone else with the issue, add that line to the package.json of the installed use-immer package within the node_modules folder). I've never had an issue with the package until building a react-based 'ink' cli tool for node. |
It appears that |
The way I see it, there's 2 PRs open regarding this. I don't know or care if they work to solve the problem, but I see that they don't have any comments or any signs life really. I will not be making a 3rd just to also get ignored.
Thanks for this. Simply adding Went from this error
to no error in 2 minutes. I'm using this on top of a Remix 2.8 project, FWIW. We tried to migrate to ESM almost six months ago. We failed, because of this package. It was the only dependency that did not play well with ESM. Now we're in a situation where we can't keep using CJS as we're migrating to Vite. I have fixed the problem for now using I'm fine with this solution. I just find it kinda sad that I have to do this.
|
@k1sul1 I was able to fix this by telling remix to bundle it with the server: I love immer and I hope this package gets some ESM love someday. Thank you @mweststrate for all your hard work over the years! |
Currently the module target is set as CommonJS.
Nowadays ESM is a lower common denominator than CommonJS as it's supported in both Node and browser runtimes.
I have a pure ESM library which I serve unbundled (only tsc output) and the usage of the use-immer's
require
causes some trouble.The text was updated successfully, but these errors were encountered: