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

[Bug] assets.chunks is undefined webpack@5.0.0 #219

Closed
kyoncy opened this issue Oct 12, 2020 · 6 comments
Closed

[Bug] assets.chunks is undefined webpack@5.0.0 #219

kyoncy opened this issue Oct 12, 2020 · 6 comments

Comments

@kyoncy
Copy link

kyoncy commented Oct 12, 2020

Environment

webpack: v5.0.0

Error Log

✖ 「wdm」: TypeError: Cannot read property 'length' of undefined
    at /Users/xxx/project/node_modules/webpack-manifest-plugin/lib/plugin.js:129:39
    at Array.reduce (<anonymous>)
    at ManifestPlugin.<anonymous> (/Users/xxx/project/node_modules/webpack-manifest-plugin/lib/plugin.js:116:26)
    at Hook.eval [as callAsync] (eval at create (/Users/xxx/project/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/xxx/project/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
    at Compiler.emitAssets (/Users/xxx/project/node_modules/webpack/lib/Compiler.js:736:19)
    at /Users/xxx/project/node_modules/webpack/lib/Watching.js:80:21
    at processTicksAndRejections (internal/process/task_queues.js:79:11)

add to https://github.com/shellscape/webpack-manifest-plugin/blob/master/lib/plugin.js#L127 the code below

console.log(assets.chunks)     // undefined
console.log(assets.chunkNames) // [ 'bundle' ]

Because of webpack changes, chunk is undefined.

Suggestion

var isEntryAsset = asset.chunks.length > 0;

I suggest chunks to chunkNames.

Passed when using webpack@4.44.2.
But, I haven't tried webpack@2.x.x, webpack@3.x.x.

@shellscape
Copy link
Owner

Thanks for opening an issue. We've just undeprecated the package and are working on getting everything setup to continue development.

@shellscape
Copy link
Owner

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

@0x78f1935
Copy link

0x78f1935 commented Oct 29, 2020

I've read the updates and I'm happy talented people are keeping this package alive.
I do however would like to suggest to re-open this issue. It seems to be still relevant for webpack V5.

[webpack-cli] TypeError: Cannot read property 'length' of undefined
    at D:\Work\portal\node_modules\webpack-manifest-plugin\lib\plugin.js:129:39
    at Array.reduce (<anonymous>)
    at ManifestPlugin.<anonymous> (D:\Work\portal\node_modules\webpack-manifest-plugin\lib\plugin.js:116:26)
    at _next0 (eval at create (D:\Work\portal\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at eval (eval at create (D:\Work\portal\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:35:1)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

This only happens when adding this code to webpack.config.js

plugins: [
        new Manifest({
            // fileName: './manifest.json',
            // publicPath: '/static/react/',
        }),
]

The suggestion by OP works but I don't see a PR which relates to this issue and one which is still open.


Issue seems to be webpack5. Universal chunks are not implemented yet.
webpack/webpack#11660

#224

@mixa9269
Copy link

mixa9269 commented Nov 5, 2020

Any updates?

@lornally
Copy link

i meet this too. only with this:

new Manifest(),

Repository owner deleted a comment from Mati365 Dec 2, 2020
@0x78f1935
Copy link

Boys! It seems to be fixed 100cbe2

I can confirm it works again on webpack5!

Thanks @shellscape !

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

No branches or pull requests

5 participants