webpack-contrib / webpack-bundle-analyzer

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

CLI: analyzerUrl is not a function #523

Closed jon-armen closed 2 years ago

jon-armen commented 2 years ago

Issue description

Issue started on 4.6.0, does not occur on 4.5.0

Technical info

node_modules\webpack-bundle-analyzer\lib\viewer.js:91 const url = analyzerUrl({ ^

TypeError: analyzerUrl is not a function at Server. (C:\Users\jon\source\repos\hz-ui\node_modules\webpack-bundle-analyzer\lib\viewer.js:91:19) at Object.onceWrapper (node:events:641:28) at Server.emit (node:events:527:28) at emitListeningNT (node:net:1406:10) at processTicksAndRejections (node:internal/process/task_queues:82:21)

Debug info

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

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

webpack-bundle-analyzer dist/{project}/stats.json

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

What other Webpack plugins were used?

None

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.

esaesa commented 2 years ago

The same for me. I am using "dependencies": { "@angular/animations": "^14.1.3", "@angular/cdk": "^14.1.2", "@angular/common": "^14.1.3", "@angular/compiler": "^14.1.3", "@angular/core": "^14.1.3", "@angular/flex-layout": "^14.0.0-beta.40", "@angular/forms": "^14.1.3", "@angular/material": "^14.1.2", "@angular/platform-browser": "^14.1.3", "@angular/platform-browser-dynamic": "^14.1.3", "@angular/router": "^14.1.3", "@ng-select/ng-select": "^9.0.2", "chart.js": "^3.9.1", "jspdf": "^2.5.1", "jspdf-autotable": "^3.5.25", "material-icons": "^1.11.10", "ng-material-multilevel-menu": "^4.12.4", "ng-recaptcha": "^10.0.0", "ngx-cookie-service": "^14.0.1", "ngx-mat-select-search": "^4.2.1", "roboto-fontface": "^0.10.0", "rxjs": "~7.5.0", "tslib": "^2.3.0", "typeface-roboto": "^1.1.13", "xlsx": "^0.18.5", "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "^14.1.3", "@angular/cli": "~14.1.3", "@angular/compiler-cli": "^14.1.3", "@types/jasmine": "~4.0.0", "@types/jspdf": "^2.0.0", "jasmine-core": "~4.3.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.1.1", "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.0.0", "typescript": "~4.7.4", "webpack-bundle-analyzer": "^4.6.0" }

and getting the following error `D:\vhosts\purchasing\node_modules\webpack-bundle-analyzer\lib\viewer.js:91 const url = analyzerUrl({ ^

TypeError: analyzerUrl is not a function at Server. (D:\vhosts\purchasing\node_modules\webpack-bundle-analyzer\lib\viewer.js:91:19) at Object.onceWrapper (node:events:627:28) at Server.emit (node:events:513:28) at emitListeningNT (node:net:1466:10) at processTicksAndRejections (node:internal/process/task_queues:82:21) `

hassanasad commented 2 years ago

Following

Facing same issue.

Appears to be linked with this PR: https://github.com/webpack-contrib/webpack-bundle-analyzer/commit/16d8e072d0daec9053dcf505b3a98aee56885ebf

@southorange1228 If you can please review.

richerfu commented 2 years ago

Following

Facing same issue.

Appears to be linked with this PR: 16d8e07

@southorange1228 If you can please review.

My bad, i'm not realized cli mode will use this logic.So if cli mode,this field should be default.I will fix it.

valscion commented 2 years ago

This has been fixed in v4.6.1, please take it for a spin.