Webpack-bundle-analyzer: Incorrect total size in search result

Created on 14 Feb 2019  路  14Comments  路  Source: webpack-contrib/webpack-bundle-analyzer

Issue description

When I search for some modules total size isn't correct. It looks like total size is folder size + size of each file in folder

Technical info

  • Webpack Bundle Analyzer version: 3.0.3
  • Webpack version: 4.19.1
  • Node.js version: 11.9.0
  • npm/yarn version: 1.13.0
  • OS: macOS Mojave

Debug info

How do you use this module? As CLI utility or as plugin?
plugin

If plugin, what options were provided? (e.g. new BundleAnalyzerPlugin({ analyzerMode: 'disabled', generateStatsFile: true }))
{ openAnalyzer: false }

screen shot 2019-02-14 at 13 04 00

Bug

Most helpful comment

I think its a legit bug. I've overlooked this case.

All 14 comments

Hmm are you sure your lodash in 5.chunk.js isn't that large? Does it show a different size in the treeview?

I think its a legit bug. I've overlooked this case.

@th0r @valscion I think bug is here https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/d7682a655abda824c82b9d6bb7991b9576c33610/client/store.js#L153. You should check for !module.groups before adding module size

@kyriiherman it's not so easy. What if the only found item is a directory? In your case the size will be zero.

@th0r yes, this is correct behavior. in your case the directory is empty, otherwise all files inside directory are present in found modules, because files paths include directory name

@kyriiherman No, it's not. You can input a regexp that will match only directory name e.g. node_modules$ and it won't be empty.

@th0r oh, my fault( so we should check for this.searchQueryRegexp and if someone is looking for a directory then we should consider directory size, otherwise no 馃槒I can submit a pull request.

I don't think it will work either. The proper solution would be to check nesting of the found items e.g. if we have found "lodash/find.js" module then we should ignore it's size if we also found a whole "lodash" directory. So this task is not so simple and may require quite significant changes in the data structure that currently represents modules tree.

@th0r why you think solution with checking this.searchQueryRegexp isn't ok?

@kyriiherman (lodash$)|(react) is a valid RegExp that will match both lodash folder and all the react folders and modules. core\.js$ can match both core.js folder and core.js module. RegExp can't tell you what user is looking for.

@th0r so we need to filter modules tree in foundModulesByChunk, but save its structure and then in foundModules use walkModules to convert modules tree into collection. with this approach we can use tree structure to count totalSize

Just to clarify, the problem is still here, right? If yes, what do you think about this regexp, do I get the real number this way? 馃
image

Yes the problem is still there. I don't know the answer to your other question, maybe someone else knows.

same problem
1610438777186-image

Was this page helpful?
0 / 5 - 0 ratings