webpack-bundle-analyzer: Doesn't parse child workerize'd module

Issue description

I use https://github.com/developit/workerize-loader to bundle some scripts for webworker, but bundle analizer doesn’t parse and display it.

Technical info

  • Webpack Bundle Analyzer version: 2.10.0
  • Webpack version: 3.5.5.

image

As you see there is not worker module in the map:

image

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 28 (17 by maintainers)

Commits related to this issue

Most upvoted comments

After debugging a bit, it looks like this a rendering/display issue with analyzer.js, I’ve opened a PR with the fix that generates the view for the worker bundles as well @nolanlawson , can you see if it works for you?

I think I’ve managed to track this issue down. It seems that my worker assets have asset.chunks.length === 0. So when it gets to this line of code, it gets filtered out:

https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/7cefb5821053f550754b4fef3ca5a57ce49dc957/src/analyzer.js#L39

When I remove the !_.isEmpty(asset.chunks) check, then I correctly see my worker assets in the Webpack Bundle Analyzer view. I’m not sure what this empty check was doing, though. Is it safe to remove?

@valscion , @th0r : If you could remove the repro needed tag on this bug, that would be great!.. I am not sure if it is possible to create a more minimal repro than the one presented above. Also I think that is the same as #368 , perhaps that can be closed off as a dupe of this one?

I would like to get the PR checked in if there are no issues with it, please let me know how you want to proceed.

I ran into this same issue with my OSS project Pinafore. Unfortunately I couldn’t manage to write a minimal repro; my minimal repro still shows worker.js correctly in Webpack Bundle Analyzer.

It’s not a minimal repro, but if you’d like to repro the issue, you can do:

git clone https://github.com/nolanlawson/pinafore.git
cd pinafore
git checkout 65c026a3
npm i
npm run build

Then open up ./.sapper/client/report.html to see the report.

Same issue with worker-loader

A snippet from my stats file

    {
      "name": "static/js/958ecd6b.worker.js",
      "size": 5622520,
      "chunks": [],
      "chunkNames": [],
      "emitted": true,
      "isOverSizeLimit": true
    }

Ignored because chunks is empty: (analyzer.js)

 // Picking only `*.js` assets from bundle that has non-empty `chunks` array
  bundleStats.assets = _.filter(bundleStats.assets, asset => {
    // Removing query part from filename (yes, somebody uses it for some reason and Webpack supports it)
    // See #22
    asset.name = asset.name.replace(FILENAME_QUERY_REGEXP, '');

    return _.endsWith(asset.name, '.js') && !_.isEmpty(asset.chunks);
  });

https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/master/src/analyzer.js#L34

Will try.