Skip to content

Stats parsing is broken when using "all: true" and Webpack 5 #417

Closed
@slavafomin

Description

@slavafomin

Hello!

Thank you for this great tool!

Issue description

However, I've encountered a situation when stats file parsing is broken when using the following stats configuration:

const statsConfig = {
  all: true,
  context: projectPath,
  source: false,
}

and Webpack 5.22.0.

Technical info

The problem is in the assetHasModule function:

function assetHasModule(statAsset, statModule) {
  // Checking if this module is the part of asset chunks
  return statModule.chunks.some(moduleChunk => statAsset.chunks.includes(moduleChunk));
}

It raises the following error:

TypeError: Cannot read property 'some' of undefined

because statModule.chunks is undefined in this case.

In my example the module stat object has the following structure:

{
  "type": "modules by path",
  "name": "…node_modules/.pnpm/core-js@3.8.3/node_modules/core-js/internals/*.js",
  "children": [
    // A big list of modules here
  ],
  "size": 22868,
  "sizes": {
    "javascript": 22868
  }
}

Also, when I change the stats config to use "verbose" preset, the error goes away, but when I view the bundle layout in "parsed" format, it only renders the entry point module. I think something is broken on a more fundamental level.


I've uploaded the obfuscated version of my stats.json file generated with the latest version of the Webpack using "verbose" preset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions