webpack-emit-all-plugin
webpack-emit-all-plugin copied to clipboard
TypeError: Cannot read property '_value' of null
[1] const source = mod._source._value;
[1] ^
[1]
[1] TypeError: Cannot read property '_value' of null
[1] at modules.forEach.mod (/Users/.../node_modules/webpack-emit-all-plugin/index.js:28:48)
[1] at Array.forEach (<anonymous>)
[1] at compiler.hooks.afterCompile.tapAsync (/Users/.../node_modules/webpack-emit-all-plugin/index.js:19:25)
[1] at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:20:1)
[1] at AsyncSeriesHook.lazyCompileHook (/Users/.../node_modules/tapable/lib/Hook.js:154:20)
[1] at compilation.seal.err (/Users/.../node_modules/webpack/lib/Compiler.js:628:31)
[1] at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
[1] at AsyncSeriesHook.lazyCompileHook (/Users/.../node_modules/tapable/lib/Hook.js:154:20)
[1] at hooks.optimizeAssets.callAsync.err (/Users/.../node_modules/webpack/lib/Compilation.js:1329:35)
[1] at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1
[1] npm ERR! [email protected] client: `webpack-dev-server --mode development --devtool inline-source-map --hot`
[1] npm ERR! Exit status 1
[1] npm ERR!
[1] npm ERR! Failed at the [email protected] client script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.```
encountering this as well
encountered using webpack v4.29.6
Greetings. Excellent plugin. Any updates on this matter?
Thank you!
Encountered using webpack v4.39.1
I added some console logs, to see when _source is null or not. This is my output
mod NormalModule has Source? true
mod NormalModule has Source? true
mod NormalModule has Source? true
mod ConcatenatedModule has Source? false
Appears like if a ConcatenatedModule is received, mod._source is null.
Encountered using webpack
v4.39.1I added some console logs, to see when
_sourceis null or not. This is my outputmod NormalModule has Source? true mod NormalModule has Source? true mod NormalModule has Source? true mod ConcatenatedModule has Source? falseAppears like if a
ConcatenatedModuleis received,mod._sourceis null.
I am also encountering this issue and can verify @breautek's discovery.
Adding a line similar to how MultiModule is being handled makes the error goes away. However, I'm not sure if this is the proper approach or if the two types can be handled the same.
if (mod.constructor.name === 'ConcatenatedModule') return;
or
if (['MultiModule', 'ConcatenatedModule'].includes( mod.constructor.name)) return;
In the meantime, configuring webpack to not concatenate modules by default will fix the issue. However, depending on how big your project is this might affect performance, I believe, as this method of concatenating modules is meant to rollup dependent modules into one closure function for faster execution in the browser.
Here's an example:
module.exports = {
mode: 'production',
entry: {
main: './index.js'
},
plugins: [
new EmitAllPlugin(),
],
optimization: {
concatenateModules: false // set this to false
}
};
The same error. Webpack 4.40.1, Node 10.16.3
any fix? assuming new webpack version broke this, don't know much about wp plugins but i'll dig in if no one else answers
I found a fork of webpack-emit-all-plugin that works with WebPack 4.41.6.
https://github.com/bv-loveholidays/webpack-emit-all-plugin/blob/master/index.js
However, this plugin looks like a hack, it doesn't generate correctly source maps and doesn't resolve all imports properly.