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

Incorrect total size in search result #251

Open
kyriiherman opened this issue Feb 14, 2019 · 14 comments
Open

Incorrect total size in search result #251

kyriiherman opened this issue Feb 14, 2019 · 14 comments

Comments

@kyriiherman
Copy link

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

@valscion
Copy link
Member

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

@th0r
Copy link
Collaborator

th0r commented Feb 14, 2019

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

@kyriiherman
Copy link
Author

@th0r @valscion I think bug is here

(summ, module) => summ + module[this.activeSize],
. You should check for !module.groups before adding module size

@th0r
Copy link
Collaborator

th0r commented Feb 14, 2019

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

@kyriiherman
Copy link
Author

kyriiherman commented Feb 14, 2019

@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

@th0r
Copy link
Collaborator

th0r commented Feb 14, 2019

@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.

@kyriiherman
Copy link
Author

kyriiherman commented Feb 14, 2019

@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.

@th0r
Copy link
Collaborator

th0r commented Feb 14, 2019

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.

@kyriiherman
Copy link
Author

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

@th0r
Copy link
Collaborator

th0r commented Feb 15, 2019

@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.

@kyriiherman
Copy link
Author

@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

@anatoliyarkhipov
Copy link

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

@valscion
Copy link
Member

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

@ppJuan
Copy link

ppJuan commented Jan 12, 2021

same problem
1610438777186-image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants