Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

whybundled

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whybundled - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

fixtures/nested-children-stats2.json

7

lib/__tests__/print.js

@@ -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());
});

32

lib/analyze.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc