You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've been using this package for a while & it works great for us. we're currently looking at switching our projects build tasks in an attempt to get off of babel. Our old test script basically converted all of our import/export syntax back to commonjs before running our tests. Now that we're leaving those, we get errors consuming this package. here's a simplified example.
& i run node index.mjs, I get the following error:
import {createSlice} from '@reduxjs/toolkit';
^^^^^^^^^^^
SyntaxError: Named export 'createSlice' not found. The requested module '@reduxjs/toolkit' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@reduxjs/toolkit';
const {createSlice} = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:213:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async loadESM (node:internal/process/esm_loader:34:7)
at async handleMainPromise (node:internal/modules/run_main:66:12)
Node.js v20.9.0
I can get around that by doing what the error message says but looking at your package.json file, you already have an esm version of the script prepared exposed thru the "module" field but that's not understood by node. Have you considered adding exports to the package.json file? That allows me to get around around this error if I update your package.json to expose your dist/redux-toolkit.esm.js thru the package.json exports field & switch it's extension to .mjs.
We've been using this package for a while & it works great for us. we're currently looking at switching our projects build tasks in an attempt to get off of babel. Our old test script basically converted all of our import/export syntax back to commonjs before running our tests. Now that we're leaving those, we get errors consuming this package. here's a simplified example.
if i have this file
& i run
node index.mjs
, I get the following error:I can get around that by doing what the error message says but looking at your package.json file, you already have an esm version of the script prepared exposed thru the "module" field but that's not understood by node. Have you considered adding exports to the package.json file? That allows me to get around around this error if I update your package.json to expose your
dist/redux-toolkit.esm.js
thru the package.json exports field & switch it's extension to.mjs
.so:
The text was updated successfully, but these errors were encountered: