-
-
Notifications
You must be signed in to change notification settings - Fork 853
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
esm uses process.node.env causing an error. #557
Comments
You've just used the wrong reference. I think using |
Unfortunately, that reference doesn't export any functions and can't be used as an esm module. |
Closing this issue. |
Just my 2 cents. Immer is a great approach to immutable, and something that naturally fit client and server. Having something special to handle between client and server does add friction and unfortunate workarounds. We are using rollup/typescript, and I am not sure how to use the umd version, and the default setting seems to pickup the esm version by default. Anyway, for now, we have the following workaround in our code, and had to put it very high in the call stack. // WORKAROUND for immer.js esm (see https://github.com/immerjs/immer/issues/557)
window.process = {
env: {
NODE_ENV: "production"
}
}; Hope to understand how to setup immer with the rollup/typescript. I might be missing something obvious. |
After the Immer upgrade, the Karma unit tests would fail with: "Uncaught ReferenceError: process is not defined at node_modules/immer/dist/immer.esm.js" Tests are run using ES modules, without bundling or minifying. It seems the assumption is the the Node env check would be compiled out. Similar to the workaround in index.html, needed to init |window.process| before any tests are run. See immerjs/immer#557 (comment).
After the Immer upgrade, the Karma unit tests would fail with: "Uncaught ReferenceError: process is not defined at node_modules/immer/dist/immer.esm.js" Tests are run using ES modules, without bundling or minifying. It seems the assumption is the the Node env check would be compiled out. Similar to the workaround in index.html, needed to init |window.process| before any tests are run. See immerjs/immer#557 (comment).
This is the last version that works with our rollup config w/o introducing hacks by defining `window.process`. See: immerjs/immer#557
see: immerjs/immer#557 wip: documentation
🐛 Bug Report
When using immer.esm.js on browser. We get
Uncaught ReferenceError: process is not defined
Declaring the variable ahead of time fixes the issue.
Link to repro
Couldn't use code-sandbox because it wanted to import all modules as
node modules instead of as an esm module.
repo
To Reproduce
Observed behavior
On import, throws
Uncaught ReferenceError: process is not defined
Expected behavior
Not throwing an exception
Environment
We only accept bug reports against the latest Immer version.
setUseProxies(true)
setUseProxies(false)
(ES5 only)The text was updated successfully, but these errors were encountered: