Plugin breaks on webpack 5 with multiple compilers
See original GitHub issueThe stacktrace is
$ /Users/evan/Coding/refresh-example/node_modules/.bin/webpack --config=webpack.config.js
internal/crypto/hash.js:82
throw new ERR_INVALID_ARG_TYPE('data',
^
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
at Hash.update (internal/crypto/hash.js:82:11)
at BulkUpdateDecorator.update (/Users/evan/Coding/refresh-example/node_modules/webpack/lib/util/createHash.js:49:14)
at NormalModule.updateHash (/Users/evan/Coding/refresh-example/node_modules/webpack/lib/NormalModule.js:1062:8)
at Compilation.createModuleHashes (/Users/evan/Coding/refresh-example/node_modules/webpack/lib/Compilation.js:2769:12)
at /Users/evan/Coding/refresh-example/node_modules/webpack/lib/Compilation.js:2107:11
at Hook.eval [as callAsync] (eval at create (/Users/evan/Coding/refresh-example/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/evan/Coding/refresh-example/node_modules/tapable/lib/Hook.js:18:14)
at /Users/evan/Coding/refresh-example/node_modules/webpack/lib/Compilation.js:2067:36
at Hook.eval [as callAsync] (eval at create (/Users/evan/Coding/refresh-example/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/evan/Coding/refresh-example/node_modules/tapable/lib/Hook.js:18:14) {
code: 'ERR_INVALID_ARG_TYPE'
}
I’ve prepared a small reproduction repo here:
git clone git@gist.github.com:5510cedee2cfefac9bef8526a268da88.git react-refresh-webpack5-error
cd react-refresh-webpack5-error
# Webpack will build fine
yarn webpack --config webpack.config.no-refresh.js
# When using react-refresh plugin it fails
yarn webpack --config webpack.config.js
I’m obviously having this issue on a much larger repository, but this is a very simple case, that afaict should work.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Webpack 5 release (2020-10-10)
Webpack 5 adds a new feature called "Module Federation", which allows multiple webpack builds to work together. From runtime perspective ...
Read more >React Projekt!! Webpack 4 -> Webpack 5 == compiler error ...
I tried to change and update the loaders but all off it didn´t worked for me ... const path = require('path'); const HtmlWebpackPlugin...
Read more >webpack Tutorial: How to Set Up webpack 5 From Scratch
Create a plugins property of your config and you'll add the plugin, filename to output ( index.html ), and link to the template...
Read more >Getting Started With Webpack - Smashing Magazine
Bundling code refers to combining and optimizing multiple modules into ... The use of plugins allows webpack compiler to perform tasks on ...
Read more >A mostly complete guide to webpack 5 (2020)
For example there are plugins for extracting HTML, CSS, or for setting up environment variables. Mode. webpack has two modes of operations: ...
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
I fixed this by adding the
HotModuleReplacementPlugin
to both compiler configs.I had actually originally removed them from both of my compilers while switching to
webpack-plugin-serve
, which injects theHotModuleReplacementPlugin
for you. but you do not declare the plugin in both compilers, since you would not want two servers running, so you must still include the compiler that doesn’t declare the server plugin.I’m going to leave this issue open though as it appears the helpful error message isn’t bubbling it’s way up.
I also got this error when using Cypress with
@cypress/webpack-preprocessor
, in thewebpackOptions
I was also including@pmmmwh/react-refresh-webpack-plugin
on accident. Removing this from my cypress webpack config resolved the error.