Skip to content
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

Cannot import from immer with webpack 4 #333

Closed
2 tasks
erango opened this issue Mar 13, 2019 · 6 comments
Closed
2 tasks

Cannot import from immer with webpack 4 #333

erango opened this issue Mar 13, 2019 · 6 comments
Labels

Comments

@erango
Copy link

erango commented Mar 13, 2019

🐛 Bug Report

When importing immer to React with Webpack 4, I get this exception:
Error was not caught ReferenceError: require is not defined at Module.../node_modules/immer/dist/immer.mjs (immer.mjs:1066)

To Reproduce

Use a react + webpack 4 setup, such as the default create-react-app setup.

Expected behavior

Import should work.

Environment

  • Immer version: 2.1.2
  • Occurs with setUseProxies(true)
  • Occurs with setUseProxies(false) (ES5 only)
@erango erango added the bug label Mar 13, 2019
@egoist
Copy link
Contributor

egoist commented Mar 13, 2019

Related: #331 (comment)

However I can't reproduce this using CRA and the example code.

@mweststrate
Copy link
Collaborator

mweststrate commented Mar 13, 2019 via email

@erango
Copy link
Author

erango commented Mar 13, 2019

Thanks for the lightning fast response guys! I'll keep you posted

@mohsinulhaq
Copy link

https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/webpack.config.js#L507

CRA works because of above config
I tried removing mjs from here
build with 2.1.2 fails, while 2.1.3 works

so, for me, #331 (comment)
it failed because we aren't taking care of mjs files in webpack

@mweststrate
Copy link
Collaborator

Since it seems fixed with 2.1.3, I think we can close this issue? Could you confirm @erango?

@erango
Copy link
Author

erango commented Mar 18, 2019

Yes 😄 Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants