webpack-contrib / webpack-bundle-analyzer

Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap
MIT License
12.58k stars 488 forks source link

`analyzerMode: 'static'` doesn't seem to be working anymore. #356

Closed yursha closed 2 years ago

yursha commented 4 years ago

Issue description

analyzerMode: 'static' doesn't seem to be working anymore. No report file is generated and the web server is started.

Technical info

Debug info

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

Plugin

If CLI, what command was used? (e.g. webpack-bundle-analyzer -O path/to/stats.json)

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

new BundleAnalyzerPlugin({ analyzerMode: 'static'})

What other Webpack plugins were used?

It would be nice to also attach webpack stats file. It can be generated using these options:

new BundleAnalyzerPlugin({
  analyzerMode: 'disabled',
  generateStatsFile: true,
  // Excludes module sources from stats file so there won't be any sensitive data
  statsOptions: { source: false }
})

stats.json will be created in Webpack bundle output directory.

valscion commented 4 years ago

Can you test which earlier version of webpack-bundle-analyzer does work for you?

hbobenicio commented 4 years ago

Same issue here. Downgrading to 3.7 and 3.6 didn't work either. I'm running the build with webpack-dev-server.

After some debugging, I don't know it this is a regression issue but what I saw is this:

viewer.js

          fs.writeFileSync(reportFilepath, reportHtml);

I think this is not supposed to work with webpack-dev-server, right? Is webpack-bundle-analyzer only emitting files with the fs module? Isn't it a webpack plugin api for emitting files to the output directory? (for loaders, I known at least there is this.emitFile) I'm using webpack-bundle-analyzer as a plugin like this:

const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

const webpackConfig = {
    //...
    plugins: [
        //...
        new BundleAnalyzerPlugin({
          analyzerMode: 'static',
          openAnalyzer: false,
        }),
    ]
}

So the question is:

th0r commented 4 years ago
  • Can this plugin work with webpack-dev-server (with ram files) or only with webpack cli?

No, it can't work with WBA (virtual file system).

th0r commented 4 years ago

@yursha does this issue still valid? I so, could you please create a reproduction repo.

valscion commented 2 years ago

Closing as there hasn't been a reproduction.