-
-
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
Support for node.js Dual CommonJS/ES module packages #1396
Comments
From what I've been told, adding an Changing package formats is on our list of things to look at for a 2.0 release: Actually, I'm a bit confused. Are you saying that RTK itself needs support for dual modules in its own |
As I'm building a system that involves logux, actions are processed both on the client and server, so I would want to reuse the action definitions created by |
Note for later reference - Sindre Sorhus has a big gist with instructions on switching to pure ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c |
Looks like I faced a similar problem. In my case, I use RTK in a Typescript project targeted for a browser/ESM, but at the same time I run unit tests in nodejs using a ts-node, with a |
#1960 ended up as the bigger issue, so I'm going to close this as a duplicate. Full ESM support was added in https://github.com/reduxjs/redux-toolkit/releases/tag/v2.0.0-alpha.1 - please try it out and give us feedback! |
Background: In an attempt to reduce boilerplate or duplication, I want to use the actions defined as part of createSlice() both on the client side and on the server side. That fails as node.js ignores the "module" key, and rather requires "export" to be defined (for details see here).
So any import is always treated as CommonJS, and working around this by using the default export breaks the client side...
The text was updated successfully, but these errors were encountered: