webpack-contrib / webpack-bundle-analyzer

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

#No Bundles Parsed# #340

Closed Romicodes closed 4 years ago

Romicodes commented 4 years ago

Issue description

... @valscion Getting the following error message when trying to create a npm run build

No bundles were parsed. Analyzer will show only original module sizes from stats file.

Webpack Bundle Analyzer is started at http://127.0.0.1:8888
Use Ctrl+C to close it

Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.

Hash: 4968172b96b83b06dca5
Version: webpack 4.42.0
Time: 58ms
Built at: 03/16/2020 4:48:31 PM

ERROR in Entry module not found: Error: Can't resolve './src' in 'C:\Users\romibabe\documents\firefox**********************

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 }))

const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
  plugins: [
    new BundleAnalyzerPlugin()
  ]
}

What other Webpack plugins were used?

"webpack": "^4",
    "webpack-bundle-analyzer": "^3.6.1",
    "webpack-cli": "^3",
    "webpack-dev-server": "^3"

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

Hi, thanks for opening the issue.

This part of the command output seems interesting:

Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.

It seems like webpack itself is unable to generate your bundle. When webpack fails to generate a bundle, webpack-bundle-analyzer won't have output files to read the bundle contents from.

Romicodes commented 4 years ago

Hello @valscion , Thank you for your feedback! I did make a couple of changes ,end up with a successful compile and the following, but still no parsed files?

$ npm run start

> platform-health-dashboard@0.0.1 start C:\Users\romibabe\docu
> webpack-dev-server --mode development

i 「wds」: Project is running at http://localhost:8080/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from C:\Users\romi
Webpack Bundle Analyzer is started at http://127.0.0.1:8888
Use Ctrl+C to close it
i 「wdm」: Hash: 7d4f68754733837952ff
Version: webpack 4.42.0
Time: 536ms
Built at: 03/17/2020 11:12:10 PM
  Asset     Size  Chunks             Chunk Names
main.js  363 KiB    main  [emitted]  main
Entrypoint main = main.js
[0] multi (webpack)-dev-server/client?http://localhost:8080 ./
[./node_modules/ansi-html/index.js] C:/Users/romibabe/Document
[./node_modules/html-entities/index.js] C:/Users/romibabe/Docu
[./node_modules/loglevel/lib/loglevel.js] C:/Users/romibabe/Do
[./node_modules/url/url.js] C:/Users/romibabe/Documents/firefo
[./node_modules/webpack-dev-server/client/index.js?http://loca
[./node_modules/webpack-dev-server/client/overlay.js] (webpack
[./node_modules/webpack-dev-server/client/socket.js] (webpack)
[./node_modules/webpack-dev-server/client/utils/createSocketUr
[./node_modules/webpack-dev-server/client/utils/log.js] (webpa
[./node_modules/webpack-dev-server/client/utils/reloadApp.js]
[./node_modules/webpack-dev-server/client/utils/sendMessage.js
[./node_modules/webpack-dev-server/node_modules/strip-ansi/ind
[./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync
./src/index.js] 29 bytes {main} [built]
   + 18 hidden modules
 「wdm」: Compiled successfully.
th0r commented 4 years ago

Read Troubleshooting section of the readme please.

valscion commented 4 years ago

th0r is referencing this section: https://github.com/webpack-contrib/webpack-bundle-analyzer#i-dont-see-gzip-or-parsed-sizes-it-only-shows-stat-size

Looks like you're using webpack-dev-server. That's why you don't have bundles to parse, as no files are emitted. See the readme, https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/191 and https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/147 for example.

HAOFUYANG commented 5 months ago

When I used npm scripts to build my Vue 2 project, the JavaScript files in the 'dist' directory were not minified, and remained at their original size,only stat,not have parsed and gzip