Build breaks on Webpack 5
See original GitHub issueBuild breaks on Webpack 5 due to babel-runtime imports not following ESM Strict mode requirements.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Build fails with the following errors:
> yarn build
yarn build
yarn run v1.22.5
$ cross-env NODE_ENV=production webpack --config=config/webpack.config.js
[webpack-cli] Compilation finished
assets by status 580 KiB [cached] 3 assets
orphan modules 782 KiB [orphan] 201 modules
runtime modules 6.08 KiB 10 modules
modules by path ./node_modules/@material-ui/ 1.22 MiB 202 modules
modules by path ./node_modules/@babel/runtime/helpers/ 7.4 KiB 19 modules
modules by path ./node_modules/prop-types/ 2.58 KiB 3 modules
modules by path ./src/ 79.5 KiB 2 modules
modules by path ./node_modules/react/ 6.48 KiB 2 modules
modules by path ./node_modules/react-dom/ 119 KiB 2 modules
modules by path ./node_modules/scheduler/ 4.91 KiB 2 modules
modules by path ./node_modules/react-is/ 2.69 KiB 2 modules
modules by path ./node_modules/react-transition-group/esm/ 18.2 KiB
./node_modules/react-transition-group/esm/Transition.js + 1 modules 18.1 KiB [built] [code generated]
./node_modules/react-transition-group/esm/TransitionGroupContext.js 68 bytes [built] [code generated]
9 modules
ERROR in ./node_modules/@babel/runtime/helpers/esm/inherits.js 1:0-46
Module not found: Error: Can't resolve './setPrototypeOf' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'setPrototypeOf.js'?
BREAKING CHANGE: The request './setPrototypeOf' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/RootRef/RootRef.js 3:0-60 50:2-11
@ ./node_modules/@material-ui/core/esm/RootRef/index.js 1:0-36 1:0-36
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js 1:0-74
Module not found: Error: Can't resolve './objectWithoutPropertiesLoose' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'objectWithoutPropertiesLoose.js'?
BREAKING CHANGE: The request './objectWithoutPropertiesLoose' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/Typography/Typography.js 2:0-90 172:14-38
@ ./node_modules/@material-ui/core/esm/Typography/index.js 1:0-39 1:0-39
@ ./src/pages/Login/Login.js 4:0-54 39:38-48 42:59-69
@ ./src/App.js 6:0-40 17:15-20
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js 1:0-47
Module not found: Error: Can't resolve '../../helpers/esm/typeof' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'typeof.js'?
BREAKING CHANGE: The request '../../helpers/esm/typeof' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/RootRef/RootRef.js 4:0-94 7:379-405
@ ./node_modules/@material-ui/core/esm/RootRef/index.js 1:0-36 1:0-36
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js 2:0-60
Module not found: Error: Can't resolve './assertThisInitialized' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'assertThisInitialized.js'?
BREAKING CHANGE: The request './assertThisInitialized' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/RootRef/RootRef.js 4:0-94 7:379-405
@ ./node_modules/@material-ui/core/esm/RootRef/index.js 1:0-36 1:0-36
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js 1:0-46
Module not found: Error: Can't resolve './arrayWithHoles' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'arrayWithHoles.js'?
BREAKING CHANGE: The request './arrayWithHoles' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/Zoom/Zoom.js 2:0-70 57:20-34
@ ./node_modules/@material-ui/core/esm/Zoom/index.js 1:0-33 1:0-33
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js 2:0-58
Module not found: Error: Can't resolve './iterableToArrayLimit' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'iterableToArrayLimit.js'?
BREAKING CHANGE: The request './iterableToArrayLimit' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/Zoom/Zoom.js 2:0-70 57:20-34
@ ./node_modules/@material-ui/core/esm/Zoom/index.js 1:0-33 1:0-33
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js 3:0-48
Module not found: Error: Can't resolve './nonIterableRest' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'nonIterableRest.js'?
BREAKING CHANGE: The request './nonIterableRest' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/Zoom/Zoom.js 2:0-70 57:20-34
@ ./node_modules/@material-ui/core/esm/Zoom/index.js 1:0-33 1:0-33
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/toArray.js 1:0-46
Module not found: Error: Can't resolve './arrayWithHoles' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'arrayWithHoles.js'?
BREAKING CHANGE: The request './arrayWithHoles' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/ExpansionPanel/ExpansionPanel.js 2:0-58 138:31-39
@ ./node_modules/@material-ui/core/esm/ExpansionPanel/index.js 1:0-43 1:0-43
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/toArray.js 2:0-48
Module not found: Error: Can't resolve './iterableToArray' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'iterableToArray.js'?
BREAKING CHANGE: The request './iterableToArray' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/ExpansionPanel/ExpansionPanel.js 2:0-58 138:31-39
@ ./node_modules/@material-ui/core/esm/ExpansionPanel/index.js 1:0-43 1:0-43
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/toArray.js 3:0-48
Module not found: Error: Can't resolve './nonIterableRest' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'nonIterableRest.js'?
BREAKING CHANGE: The request './nonIterableRest' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/ExpansionPanel/ExpansionPanel.js 2:0-58 138:31-39
@ ./node_modules/@material-ui/core/esm/ExpansionPanel/index.js 1:0-43 1:0-43
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js 1:0-52
Module not found: Error: Can't resolve './arrayWithoutHoles' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'arrayWithoutHoles.js'?
BREAKING CHANGE: The request './arrayWithoutHoles' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/GridListTile/GridListTile.js 3:0-78 51:72-90 53:71-89 57:74-92 59:71-89
@ ./node_modules/@material-ui/core/esm/GridListTile/index.js 1:0-41 1:0-41
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js 2:0-48
Module not found: Error: Can't resolve './iterableToArray' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'iterableToArray.js'?
BREAKING CHANGE: The request './iterableToArray' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/GridListTile/GridListTile.js 3:0-78 51:72-90 53:71-89 57:74-92 59:71-89
@ ./node_modules/@material-ui/core/esm/GridListTile/index.js 1:0-41 1:0-41
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
ERROR in ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js 3:0-52
Module not found: Error: Can't resolve './nonIterableSpread' in '/home/elias/dev/acto/react-template/node_modules/@babel/runtime/helpers/esm'
Did you mean 'nonIterableSpread.js'?
BREAKING CHANGE: The request './nonIterableSpread' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@ ./node_modules/@material-ui/core/esm/GridListTile/GridListTile.js 3:0-78 51:72-90 53:71-89 57:74-92 59:71-89
@ ./node_modules/@material-ui/core/esm/GridListTile/index.js 1:0-41 1:0-41
@ ./node_modules/@material-ui/core/index.js
@ ./src/pages/LoginError.js 4:0-59 5:18-28 23:42-46
@ ./src/App.js 8:0-44 25:15-25
@ ./src/index.js 3:0-24 9:7-10
webpack 5.3.0 compiled with 13 errors in 7265 ms
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Expected Behavior 🤔
Build finishes without errors.
Steps to Reproduce 🕹
- Setup a React project with MUI and Webpack 5
- Build project
- 💥
Context 🔦
Migration from Webpack 4 -> 5, which imposes stricter requirements for package modules.
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | v4.11.0 |
React | v17.0.1 (also happens with newest v16 release) |
Browser | N/A |
TypeScript | N/A |
Webpack | 5.3.0 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
Broken build Storybook 6.3.7 + Webpack 5 #15882 - GitHub
There are 2 issues which come up after trying to start it, sometimes it's: ERR! Error: For the selected environment is no default...
Read more >To v5 from v4 - webpack
This guide aims to help you migrating to webpack 5 when using webpack directly. If you are using a higher level tool to...
Read more >Webpack 5 splitChunks breaks WebpackDevServer
I don't know how to fix it with webpack@5, but downgrading to previous version of react-app is enough for me. Just add explicit...
Read more >Webpack 5 errors | ImmutableX Documentation
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if...
Read more >How to polyfill node core modules in webpack 5 - Alchemy
In this tutorial, you'll learn how to polyfill node core modules in webpack version 5 and above using the react-app-rewired package, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@anthonyferreol Try deleting your lock file and reinstall your projects dependencies. It did the trick for me, for some reason.
@EliasJorgensen
This worked for me Thanks!