UNPKG

bundle-stats

Version:

In-depth bundle analyzer for webpack(bundle size, assets, modules, packages)

86 lines 2.87 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = cli; const path_1 = __importDefault(require("path")); const yargs_1 = __importDefault(require("yargs")); const update_notifier_1 = __importDefault(require("update-notifier")); const run_1 = __importDefault(require("./run")); const DEFAULT_OUTPUT_DIR = './dist'; const WEEK_IN_MS = 1000 * 60 * 60 * 24 * 7; async function cli(pkg) { const notifier = (0, update_notifier_1.default)({ pkg, updateCheckInterval: WEEK_IN_MS }); if (notifier.update) { notifier.notify(); } const { demo } = yargs_1.default.options({ demo: { type: 'boolean', default: false } }).parseSync(); if (demo) { await (0, run_1.default)({ baseline: false, compare: false, html: true, json: true, outDir: DEFAULT_OUTPUT_DIR, artifactFilepaths: [ path_1.default.resolve(__dirname, '../__fixtures__/webpack-stats.current.json'), path_1.default.resolve(__dirname, '../__fixtures__/webpack-stats.baseline.json'), ], }); return; } const args = yargs_1.default .usage('Usage: $0 OPTIONS [STATS_FILE]...') .demandCommand(1, 'Webpack stats file path is required.') .option('out-dir', { description: 'Output directory', type: 'string', default: DEFAULT_OUTPUT_DIR, }) .option('compare', { description: 'Use local saved stats for comparison', type: 'boolean', default: true, }) .option('baseline', { description: 'Save current stats as baseline', type: 'boolean', default: false, }) .option('baseline-filepath', { description: 'Baseline filepath, default: node_modules/.cache/bundle-stats/baseline.json', type: 'string', default: undefined, }) .option('html', { description: 'Save HTML report', type: 'boolean', default: true, }) .option('json', { description: 'Save JSON data', type: 'boolean', default: false, }) .option('demo', { description: 'Generate demo reports', type: 'boolean', default: false, }) .alias('d', 'out-dir') .alias('h', 'help') .alias('v', 'version') .help() .parseSync(); await (0, run_1.default)({ outDir: args.outDir, compare: args.compare, baseline: args.baseline, baselineFilepath: args.baselineFilepath, html: args.html, json: args.json, artifactFilepaths: args._, }); } //# sourceMappingURL=cli.js.map