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

Support webpack@5 #186

Closed
irudoy opened this issue Mar 29, 2019 · 15 comments · Fixed by #191
Closed

Support webpack@5 #186

irudoy opened this issue Mar 29, 2019 · 15 comments · Fixed by #191

Comments

@irudoy
Copy link

irudoy commented Mar 29, 2019

TypeError: Cannot read property 'call' of undefined
    at ManifestPlugin.<anonymous> (/.../node_modules/webpack-manifest-plugin/lib/plugin.js:191:53)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/.../node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:9:1)
    at AsyncSeriesHook.lazyCompileHook (/.../node_modules/tapable/lib/Hook.js:154:20)
    at Compiler.emitAssets (/.../node_modules/webpack/lib/Compiler.js:448:19)
    at process.nextTick (/.../node_modules/webpack/lib/Compiler.js:249:10)
    at processTicksAndRejections (internal/process/next_tick.js:74:9)
(node:28406) DeprecationWarning: Compilation.chunks was changed from Array to Set (using Array method 'reduce' is deprecated)
@mAAdhaTTah
Copy link

I'm getting this error on webpack@4 w/ multiple compilers (e.g. module.exports = [... multiple configs ...]).

@xeonicca
Copy link

xeonicca commented Apr 3, 2019

I had the same problem and mine was caused by smart measure webpack plugin which may fail during incremental build.

@ycjcl868
Copy link

ycjcl868 commented Jun 19, 2019

same problems. How to solve the problem? @mastilver

@VictorQueiroz
Copy link

VictorQueiroz commented Jul 11, 2019

I also have the same problem using the multi-compiler feature. How can we fix this? [email protected]

@mastilver
Copy link
Contributor

Can you all confirm it's been fixed on 2.2.0? (thank you @ian-craig )

@mastilver mastilver reopened this Oct 2, 2019
@ian-craig
Copy link
Contributor

ian-craig commented Oct 3, 2019

Thanks @mastilver

2.2.0 with Webpack 5.0.0-alpha.26 seems to be working correctly in my project. I just have a simple setup though, so no other plugins depending on the manifest or anything.

@kirill-konshin
Copy link

There are other problems too:

✖ 「wdm」: TypeError: Cannot read property 'length' of undefined
    at /Users/dis/Sites/web-modules-core/build/node_modules/webpack-manifest-plugin/lib/plugin.js:129:39
    at Array.reduce (<anonymous>)
    at ManifestPlugin.<anonymous> (/xxx/node_modules/webpack-manifest-plugin/lib/plugin.js:116:26)
    at _next0 (eval at create (/xxx/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:19:1)
    at eval (eval at create (/xxx/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:34:1)
    at /xxx/node_modules/html-webpack-plugin/index.js:317:11
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

kirill-konshin added a commit to kirill-konshin/webpack-manifest-plugin that referenced this issue Nov 6, 2019
mastilver pushed a commit that referenced this issue Dec 5, 2019
@ceesvanegmond
Copy link

Got same problem as @kirill-konshin .

@kirill-konshin
Copy link

Seems to be working now, noticed one issue though: [email protected]" has unmet peer dependency "webpack@4".

@keeganstreet
Copy link

Hi, this error is still occurring with [email protected] and [email protected]. Here is the error message:

[DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET] DeprecationWarning: Compilation.chunks was changed from Array to Set (using Array method 'reduce' is deprecated)
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
at node_modules/webpack-manifest-plugin/lib/plugin.js:129:39
at Array.reduce (<anonymous>)
at ManifestPlugin.<anonymous> (node_modules/webpack-manifest-plugin/lib/plugin.js:116:26)

Here's the line that is treating compilation.chunks as an Array, when it is now a Set: https://github.com/danethurber/webpack-manifest-plugin/blob/master/lib/plugin.js#L87

@keeganstreet
Copy link

I wrapped compilation.chunks, chunk.files, and stats.assets in Array.from just to get a build working. Webpack is giving another warning about this module:

[DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.

@arxeiss
Copy link

arxeiss commented Aug 23, 2020

@keeganstreet Is somewhere possible to download a functional version of this plugin? No matter the Deprecation warning. I want to use some features of Webpack 5 but I want to have manifest as well.

Thanks

@arxeiss
Copy link

arxeiss commented Aug 23, 2020

So I tried to make it work as @keeganstreet suggested with Array.from wraps. And this is what I did to work with Webpack 5. It is not ideal, but acceptable for me for now.

webpack.config.js

- const ManifestPlugin = require('webpack-manifest-plugin');
+ const ManifestPlugin = require('./webpack-manifest-plugin'); // local file

Then I downloaded the current JS file from the master branch. lib/plugin.js and saved it next to webpack.config.js with name webpack-manifest-plugin.js. And updated those lines:

webpack-manifest-plugin.js

// This changes is on line 87
- var files = compilation.chunks.reduce(function(files, chunk) {
+ var files = Array.from(compilation.chunks).reduce(function(files, chunk) {

// This changes is on line 128
// From Webpack 5, I think "the hack" where this code lives is not needed.
// So I'm returning files directly. Otherwise ignore the return and use the rest
- var isEntryAsset = asset.chunks.length > 0;
+ return files;
+ var isEntryAsset = Array.from(asset.chunks || []).length > 0;

Hope this helps someone to use this plugin with Webpack 5 until the proper fix will be released. There are some pitfalls with this approach still.

@kirill-konshin
Copy link

FYI, I've successfully used "webpack-manifest-plugin": "3.0.0-rc.0".

@shellscape
Copy link
Owner

Hey folks, please see #222 for updates on v5 support.

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

Successfully merging a pull request may close this issue.