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 size when using Webpack's BannerPlugin #598

Closed
guilhermesimoes opened this issue May 22, 2023 · 5 comments
Closed

Incorrect size when using Webpack's BannerPlugin #598

guilhermesimoes opened this issue May 22, 2023 · 5 comments

Comments

@guilhermesimoes
Copy link

guilhermesimoes commented May 22, 2023

Issue description

Adding the following BannerPlugin to a build:

new BannerPlugin({
  banner: 'console.log("hello world");',
  raw: true,
}),

changes the results of webpack-bundle-analyzer.

Without using BannerPlugin:
Screenshot 2023-05-22 at 16 37 09

Using BannerPlugin:
Screenshot 2023-05-22 at 16 38 18
These results are wrong (just look at the size of src).

Do note that this happens with an entry point that is a Worker, I did not verify if this also happens with other kinds of entry points.

Technical info

  System:
    OS: macOS 13.0
    CPU: (10) arm64 Apple M1 Pro
    Memory: 1.99 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.12.1/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  npmPackages:
    copy-webpack-plugin: 9.1.0 => 9.1.0 
    fork-ts-checker-webpack-plugin: 6.3.3 => 6.3.3 
    html-webpack-plugin: 5.5.0 => 5.5.0 
    terser-webpack-plugin: 5.3.6 => 5.3.6 
    webpack: 5.75.0 => 5.75.0 
    webpack-bundle-analyzer: 4.8.0 => 4.8.0 
    webpack-cli: 4.8.0 => 4.8.0 
    webpack-dev-server: 4.3.0 => 4.3.0 
    webpack-glsl-loader: 1.0.1 => 1.0.1 
    webpack-license-plugin: 4.2.2 => 4.2.2 
    webpack-retry-chunk-load-plugin: 2.2.0 => 2.2.0 
    webpack-stats-plugin: 1.0.3 => 1.0.3 

Debug info

I use this module as a plugin, without any options:

new BundleAnalyzerPlugin()
@guilhermesimoes guilhermesimoes changed the title Incorrect size when using Webpack's BannerPlugin Incorrect size when using Webpack's BannerPlugin May 22, 2023
@valscion
Copy link
Member

What did you expect to have? Do note that the "without BannerPlugin" image does not show what the size of src is

@guilhermesimoes
Copy link
Author

You can see on the second image that a lot of code from src is simply missing.

The expected parsed size is something like 450kB.

@valscion
Copy link
Member

valscion commented May 25, 2023

Hmm yeah, I think the way we parse bundles requires the first thing in the bundle to be the start of a webpack module. So using something like BannerPlugin would indeed break things.

Source: https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/v4.8.0/src/parseUtils.js

If this is the case, then this turns to a feature request to support BannerPlugin. You can open a feature request over at the Discussions "Ideas" category here: https://github.com/webpack-contrib/webpack-bundle-analyzer/discussions/categories/ideas

@guilhermesimoes
Copy link
Author

Done! Here's the feature request: #601

I'm closing this issue then. Thank you for your guidance 🙏

@valscion
Copy link
Member

Thank you for opening the feature request ☺️. It's easier to triage issues when feature requests are in discussions instead.

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

No branches or pull requests

2 participants