whybundled
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -60,1 +60,8 @@ const stripAnsi = require("strip-ansi"); | ||
}); | ||
test("should properly print stats.json with nested children second example", t => { | ||
const stats = analyze(getStats(f.find("nested-children-stats2.json"))); | ||
const logger = createPrint(); | ||
print(stats.modules, stats.chunks, {}, 0, logger); | ||
t.snapshot(logger()); | ||
}); |
@@ -9,3 +9,3 @@ /* @flow */ | ||
modules: Array<WebpackModule>, | ||
children?: Array<WebpackStats> | ||
children?: Array<WebpackStats & { id?: string }> | ||
}; | ||
@@ -87,2 +87,3 @@ | ||
const mm = require("micromatch"); | ||
const flattenStats = require("./flatten-stats"); | ||
@@ -97,3 +98,3 @@ const DEFAULT_IGNORE = ["multi *", "*-loader*"]; | ||
const getModuleName = (identifier /*: string */) => { | ||
const path = identifier.split("node_modules/").pop(); | ||
const path = (identifier || "").split("node_modules/").pop(); | ||
if (!path || path === identifier) return ""; | ||
@@ -300,21 +301,2 @@ if (path.startsWith("@")) { | ||
function joinStats(children) { | ||
const flattenChildren = (children, id = "0") => | ||
children.reduce((acc, child, index) => { | ||
child.id = `${id}.${index}`; | ||
acc = acc.concat(child); | ||
acc = acc.concat(flattenChildren(child.children || [], child.id)); | ||
}, []); | ||
return children.reduce( | ||
(acc, child) => { | ||
acc.chunks = child.chunks ? acc.chunks.concat(child.chunks) : acc.chunks; | ||
acc.modules = child.modules | ||
? acc.modules.concat(child.modules) | ||
: acc.modules; | ||
return acc; | ||
}, | ||
{ chunks: [], modules: [] } | ||
); | ||
} | ||
function getChunksData(stats /*: WebpackStats */) { | ||
@@ -338,9 +320,3 @@ return stats.chunks | ||
) { | ||
const stats = | ||
rawStats.children && | ||
rawStats.children.length && | ||
(!rawStats.chunks || !rawStats.chunks.length) | ||
? joinStats(rawStats.children) | ||
: rawStats; | ||
const stats = flattenStats(rawStats); | ||
const chunks = getChunksData(stats); | ||
@@ -347,0 +323,0 @@ const rawModules = flattenChunks(stats); |
@@ -7,2 +7,4 @@ /* @flow */ | ||
const flattenStats = require("./flatten-stats"); | ||
function has(obj) { | ||
@@ -20,10 +22,12 @@ return function(prop) { | ||
module.exports = function vlidateStatsJson(stats /*: WebpackStats */) { | ||
module.exports = function vlidateStatsJson(rawStats /*: WebpackStats */) { | ||
if ( | ||
!stats || | ||
((!stats.chunks || !stats.chunks[0].modules) && | ||
!stats.modules && | ||
(!stats.children || | ||
((!stats.children[0].chunks || !stats.children[0].chunks[0].modules) && | ||
!stats.children[0].modules))) | ||
!rawStats || | ||
((!rawStats.chunks || !rawStats.chunks || !rawStats.chunks[0].modules) && | ||
!rawStats.modules && | ||
(!rawStats.children || | ||
((!rawStats.children[0].chunks || | ||
!rawStats.children[0].chunks[0] || | ||
!rawStats.children[0].chunks[0].modules) && | ||
!rawStats.children[0].modules))) | ||
) { | ||
@@ -33,5 +37,6 @@ return false; | ||
const stats = flattenStats(rawStats); | ||
let modules = []; | ||
if (stats.modules) { | ||
if (stats.modules && stats.modules.length) { | ||
modules = stats.modules; | ||
@@ -38,0 +43,0 @@ } else if (stats.chunks) { |
{ | ||
"name": "whybundled", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Answers the question – Why the hell is this module in a bundle?", | ||
@@ -5,0 +5,0 @@ "bin": "./cli.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15613387
49
42691
1