Skip to content

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

Closed

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/[email protected]/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.

Activity

  1. valscion commented on Feb 17, 2021

    @valscion
    Collaborator

    Thanks for the issue! This might be a regression stemming from #395 where the assetHasModule previously used lodash's _.some method, which likely works better when the value given in is undefined.

  2. added 2 commits that reference this issue on Apr 11, 2021
    afb33c4
    9f19c6e
  3. added a commit that references this issue on Apr 13, 2021
    e5b617e
  4. valscion commented on Apr 13, 2021

    @valscion
    Collaborator

    Should be fixed in v4.4.1, thanks to @deanshub via #433. Let us know if the fix works for you ☺️

  5. added a commit that references this issue on Aug 19, 2021
    d531e2a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions