webpack-bundle-analyzer
Advanced tools
Comparing version 4.6.1 to 4.7.0
@@ -15,2 +15,7 @@ # Changelog | ||
## 4.7.0 | ||
* **New Feature** | ||
* Add the ability to filter to displaying only initial chunks per entrypoint ([#519](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/519) by [@pas-trop-de-zele](https://github.com/pas-trop-de-zele)) | ||
## 4.6.1 | ||
@@ -17,0 +22,0 @@ |
@@ -158,14 +158,20 @@ "use strict"; | ||
}, {}); | ||
return Object.entries(assets).map(([filename, asset]) => ({ | ||
label: filename, | ||
isAsset: true, | ||
// Not using `asset.size` here provided by Webpack because it can be very confusing when `UglifyJsPlugin` is used. | ||
// In this case all module sizes from stats file will represent unminified module sizes, but `asset.size` will | ||
// be the size of minified bundle. | ||
// Using `asset.size` only if current asset doesn't contain any modules (resulting size equals 0) | ||
statSize: asset.tree.size || asset.size, | ||
parsedSize: asset.parsedSize, | ||
gzipSize: asset.gzipSize, | ||
groups: _.invokeMap(asset.tree.children, 'toChartData') | ||
})); | ||
const chunkToInitialByEntrypoint = getChunkToInitialByEntrypoint(bundleStats); | ||
return Object.entries(assets).map(([filename, asset]) => { | ||
var _chunkToInitialByEntr; | ||
return { | ||
label: filename, | ||
isAsset: true, | ||
// Not using `asset.size` here provided by Webpack because it can be very confusing when `UglifyJsPlugin` is used. | ||
// In this case all module sizes from stats file will represent unminified module sizes, but `asset.size` will | ||
// be the size of minified bundle. | ||
// Using `asset.size` only if current asset doesn't contain any modules (resulting size equals 0) | ||
statSize: asset.tree.size || asset.size, | ||
parsedSize: asset.parsedSize, | ||
gzipSize: asset.gzipSize, | ||
groups: _.invokeMap(asset.tree.children, 'toChartData'), | ||
isInitialByEntrypoint: (_chunkToInitialByEntr = chunkToInitialByEntrypoint[filename]) !== null && _chunkToInitialByEntr !== void 0 ? _chunkToInitialByEntr : {} | ||
}; | ||
}); | ||
} | ||
@@ -204,2 +210,21 @@ | ||
return root; | ||
} | ||
} | ||
function getChunkToInitialByEntrypoint(bundleStats) { | ||
if (bundleStats == null) { | ||
return {}; | ||
} | ||
const chunkToEntrypointInititalMap = {}; | ||
Object.values(bundleStats.entrypoints || {}).forEach(entrypoint => { | ||
for (const asset of entrypoint.assets) { | ||
var _chunkToEntrypointIni; | ||
chunkToEntrypointInititalMap[asset.name] = (_chunkToEntrypointIni = chunkToEntrypointInititalMap[asset.name]) !== null && _chunkToEntrypointIni !== void 0 ? _chunkToEntrypointIni : {}; | ||
chunkToEntrypointInititalMap[asset.name][entrypoint.name] = true; | ||
} | ||
}); | ||
return chunkToEntrypointInititalMap; | ||
} | ||
; |
@@ -48,2 +48,3 @@ "use strict"; | ||
chartData, | ||
entrypoints, | ||
defaultSizes, | ||
@@ -70,2 +71,3 @@ mode | ||
window.chartData = ${escapeJson(chartData)}; | ||
window.entrypoints = ${escapeJson(entrypoints)}; | ||
window.defaultSizes = ${escapeJson(defaultSizes)}; | ||
@@ -72,0 +74,0 @@ </script> |
@@ -45,2 +45,3 @@ "use strict"; | ||
generateJSONReport, | ||
getEntrypoints, | ||
// deprecated | ||
@@ -67,2 +68,3 @@ start: startServer | ||
let chartData = getChartData(analyzerOpts, bundleStats, bundleDir); | ||
const entrypoints = getEntrypoints(bundleStats); | ||
if (!chartData) return; | ||
@@ -79,2 +81,3 @@ const sirvMiddleware = sirv(`${projectRoot}/public`, { | ||
chartData, | ||
entrypoints, | ||
defaultSizes, | ||
@@ -151,2 +154,3 @@ enableWebSocket: true | ||
}, bundleStats, bundleDir); | ||
const entrypoints = getEntrypoints(bundleStats); | ||
if (!chartData) return; | ||
@@ -157,2 +161,3 @@ const reportHtml = renderViewer({ | ||
chartData, | ||
entrypoints, | ||
defaultSizes, | ||
@@ -212,2 +217,10 @@ enableWebSocket: false | ||
return chartData; | ||
} | ||
function getEntrypoints(bundleStats) { | ||
if (bundleStats === null || bundleStats === undefined) { | ||
return []; | ||
} | ||
return Object.values(bundleStats.entrypoints || {}).map(entrypoint => entrypoint.name); | ||
} |
{ | ||
"name": "webpack-bundle-analyzer", | ||
"version": "4.6.1", | ||
"version": "4.7.0", | ||
"description": "Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap", | ||
@@ -5,0 +5,0 @@ "author": "Yury Grunin <grunin.ya@ya.ru>", |
[![npm][npm]][npm-url] | ||
[![node][node]][node-url] | ||
[![deps][deps]][deps-url] | ||
[![tests][tests]][tests-url] | ||
@@ -214,5 +213,2 @@ [![downloads][downloads]][downloads-url] | ||
[deps]: https://david-dm.org/webpack-contrib/webpack-bundle-analyzer.svg | ||
[deps-url]: https://david-dm.org/webpack-contrib/webpack-bundle-analyzer | ||
[tests]: http://img.shields.io/travis/webpack-contrib/webpack-bundle-analyzer.svg | ||
@@ -219,0 +215,0 @@ [tests-url]: https://travis-ci.org/webpack-contrib/webpack-bundle-analyzer |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1282754
2523
222