webpack-bundle-size-analyzer
Advanced tools
Comparing version 2.4.2 to 2.5.0
@@ -6,3 +6,10 @@ "use strict"; | ||
function printStats(json, opts) { | ||
var bundleStats = JSON.parse(json); | ||
var bundleStats; | ||
try { | ||
bundleStats = JSON.parse(json); | ||
} | ||
catch (err) { | ||
console.error("Error: The input is not valid JSON.\n\nCheck that:\n - You passed the '--json' argument to 'webpack'\n - There is no extra non-JSON content in the output, such as log messages.\n\nThe parsing error was:\n\n " + err + "\n"); | ||
return; | ||
} | ||
var depTrees = size_tree.dependencySizeTree(bundleStats); | ||
@@ -16,3 +23,3 @@ if (opts.outputAsJson) { | ||
} | ||
commander.version('1.1.0') | ||
commander.version(require('../../package.json').version) | ||
.option('-j --json', 'Output as JSON') | ||
@@ -28,3 +35,8 @@ .option('--no-share-stats', 'Do not output dependency sizes as a percentage') | ||
if (commander.args[0]) { | ||
printStats(fs.readFileSync(commander.args[0]).toString(), opts); | ||
try { | ||
printStats(fs.readFileSync(commander.args[0]).toString(), opts); | ||
} | ||
catch (err) { | ||
process.exit(1); | ||
} | ||
} | ||
@@ -31,0 +43,0 @@ else if (!process.stdin.isTTY) { |
@@ -0,1 +1,6 @@ | ||
## 2.5.0 | ||
- Print a more helpful error if the input is not valid JSON. | ||
- Fix --version output | ||
## 2.4.0 | ||
@@ -2,0 +7,0 @@ |
{ | ||
"name": "webpack-bundle-size-analyzer", | ||
"version": "2.4.2", | ||
"version": "2.5.0", | ||
"description": "A utility to find how your dependencies are contributing to the size of your Webpack bundles", | ||
@@ -5,0 +5,0 @@ "main": "build/size_tree.js", |
12391
195