New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.4.3 to 1.5.0

26

cli.js

@@ -73,12 +73,20 @@ #!/usr/bin/env node

if (flags.by) {
byCommand(input[0], flags, input[1], reporter, updateProgressBar);
} else {
defaultCommand(input[0], flags, input[1], reporter, updateProgressBar);
}
(async () => {
if (flags.by) {
await byCommand(input[0], flags, input[1], reporter, updateProgressBar);
} else {
await defaultCommand(
input[0],
flags,
input[1],
reporter,
updateProgressBar
);
}
const timing = (Date.now() - start) / 1000;
const rounded = Math.round(timing * 100) / 100;
const timing = (Date.now() - start) / 1000;
const rounded = Math.round(timing * 100) / 100;
console.log(`🏁 Done in ${rounded}s.`);
process.exit(0);
console.log(`🏁 Done in ${rounded}s.`);
process.exit(0);
})();

@@ -41,3 +41,3 @@ /* @flow */

module.exports = function byCommand(
module.exports = async function byCommand(
statsFilePath /*: string */,

@@ -49,3 +49,3 @@ flags /*: { limit: number, by: string, only?: boolean, ignore?: string } */,

) {
const stats = normalizeStats(getStats(statsFilePath));
const stats = normalizeStats(await getStats(statsFilePath));
if (!validate(stats.modules)) {

@@ -52,0 +52,0 @@ log(invalidStatsJson(statsFilePath));

@@ -25,3 +25,3 @@ /* @flow */

module.exports = function defaultCommand(
module.exports = async function defaultCommand(
statsFilePath /*: string */,

@@ -33,3 +33,3 @@ flags /*: Flags */,

) {
const stats = normalizeStats(getStats(statsFilePath));
const stats = normalizeStats(await getStats(statsFilePath));
if (!validate(stats.modules)) {

@@ -36,0 +36,0 @@ log(invalidStatsJson(statsFilePath));

@@ -8,3 +8,3 @@ const test = require("ava");

test("should call updateProgressBar correct number of times", t => {
test("should call updateProgressBar correct number of times", async t => {
let calls = 0;

@@ -15,3 +15,3 @@ const updateProgressBar = ({ progress }) => {

const stats = analyze(
normalizeStats(getStats(f.find("valid-with-multiple-modules.json"))),
normalizeStats(await getStats(f.find("valid-with-multiple-modules.json"))),
[],

@@ -23,7 +23,7 @@ updateProgressBar

test("should handle stats file with a chunk which has empty modules", t => {
test("should handle stats file with a chunk which has empty modules", async t => {
t.snapshot(
analyze(
normalizeStats(
getStats(f.find("valid-with-empty-modules-in-chunks.json"))
await getStats(f.find("valid-with-empty-modules-in-chunks.json"))
),

@@ -30,0 +30,0 @@ [],

@@ -6,14 +6,9 @@ const test = require("ava");

test("should load stats file", t => {
const stats = getStats(f.find("empty-stats.json"));
test("should load stats file", async t => {
const stats = await getStats(f.find("empty-stats.json"));
t.truthy(stats);
});
test("should load stats file with an extra output before the json", t => {
const stats = getStats(f.find("with-output-before-stats-json.json"));
t.truthy(stats);
test("should throw an error if stats file doesn't exist", async t => {
await t.throwsAsync(async () => await getStats("not_existing_file.json"));
});
test("should throw an error if stats file doesn't exist", t => {
t.throws(() => getStats("not_existing_file.json"));
});

@@ -8,20 +8,24 @@ const test = require("ava");

test(`should return false for an invalid stats file that doesn't have "reasons" for modules`, t => {
const stats = normalizeStats(getStats(f.find("invalid-no-reasons.json")));
test(`should return false for an invalid stats file that doesn't have "reasons" for modules`, async t => {
const stats = normalizeStats(
await getStats(f.find("invalid-no-reasons.json"))
);
t.falsy(validate(stats.modules));
});
test(`should return false for an invalid stats file that doesn't have niether chunks nor modules`, t => {
const stats = normalizeStats(getStats(f.find("empty-stats.json")));
test(`should return false for an invalid stats file that doesn't have niether chunks nor modules`, async t => {
const stats = normalizeStats(await getStats(f.find("empty-stats.json")));
t.falsy(validate(stats.modules));
});
test("should return true for a valid stats file", t => {
const stats = normalizeStats(getStats(f.find("valid.json")));
test("should return true for a valid stats file", async t => {
const stats = normalizeStats(await getStats(f.find("valid.json")));
t.truthy(validate(stats.modules));
});
test("should return true for a valid stats file with children", t => {
const stats = normalizeStats(getStats(f.find("valid-with-children.json")));
test("should return true for a valid stats file with children", async t => {
const stats = normalizeStats(
await getStats(f.find("valid-with-children.json"))
);
t.truthy(validate(stats.modules));
});

@@ -5,2 +5,3 @@ /* @flow */

const fs = require("fs");
const { parseChunked } = require("@discoveryjs/json-ext");

@@ -11,15 +12,15 @@ /*::

const getAbsoultePath = (filePath /*: string */) =>
const getAbsolutePath = (filePath /*: string */) =>
path.isAbsolute(filePath) ? filePath : path.join(process.cwd(), filePath);
module.exports = function getStats(
module.exports = async function getStats(
statsFilePath /*: string */
) /*: WebpackStats */ {
) /*: Promise<WebpackStats> */ {
try {
// $FlowFixMe
const fileContent = fs.readFileSync(getAbsoultePath(statsFilePath), "utf8");
const indexOfTheFirstBrace = fileContent.indexOf("{");
const cleanContent = fileContent.substr(indexOfTheFirstBrace);
const fileStream = fs.createReadStream(getAbsolutePath(statsFilePath), {
encoding: "utf8",
autoClose: true
});
try {
return JSON.parse(cleanContent) /* as WebpackStats */;
return parseChunked(fileStream); /* as Promise<WebpackStats> */
} catch (e) {

@@ -26,0 +27,0 @@ throw new Error(`Stats file "${statsFilePath}" is not a valid json...`);

{
"name": "whybundled",
"version": "1.4.3",
"version": "1.5.0",
"description": "Answers the question – Why the hell is this module in a bundle?",

@@ -22,2 +22,3 @@ "bin": "./cli.js",

"ci:test:coverage": "nyc --reporter=lcov npm test",
"ci:github-release": "conventional-github-releaser -p angular",
"test": "ava --verbose",

@@ -66,2 +67,3 @@ "test:coverage": "nyc npm test",

"dependencies": {
"@discoveryjs/json-ext": "^0.5.2",
"chalk": "^3.0.0",

@@ -74,2 +76,3 @@ "meow": "^6.0.1",

"ava": "^3.4.0",
"conventional-github-releaser": "^3.1.3",
"coveralls": "^3.0.9",

@@ -85,2 +88,2 @@ "fixturez": "^1.1.0",

}
}
}

@@ -25,6 +25,2 @@ <div align="center">

<a href="https://travis-ci.org/d4rkr00t/whybundled">
<img src="https://img.shields.io/travis/d4rkr00t/whybundled.svg" alt="Travis Status">
</a>
<a href='https://coveralls.io/github/d4rkr00t/whybundled'>

@@ -91,6 +87,6 @@ <img src='https://coveralls.io/repos/github/d4rkr00t/whybundled/badge.svg' alt='Coverage Status' />

* Outputs list of all modules/files included in the bundle in from most imported to least imported order.
* Builds a chain of dependencies for transitive dependencies.
* Shows all files that were included for particular module.
* Shows all reasons why particular module was included.
- Outputs list of all modules/files included in the bundle in from most imported to least imported order.
- Builds a chain of dependencies for transitive dependencies.
- Shows all files that were included for particular module.
- Shows all reasons why particular module was included.

@@ -97,0 +93,0 @@ ```sh

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