rollup-plugin-filesize
Advanced tools
Comparing version 2.0.0 to 4.0.0
@@ -10,8 +10,25 @@ 'use strict'; | ||
var gzip = _interopDefault(require('gzip-size')); | ||
var brotli = _interopDefault(require('brotli-size')); | ||
var terser = _interopDefault(require('terser')); | ||
function render(opt, size, gzip$$1, bundle) { | ||
var toConsumableArray = function (arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} else { | ||
return Array.from(arr); | ||
} | ||
}; | ||
function render(opt, size, gzip$$1, brotliSize, minifiedSize, bundle) { | ||
var primaryColor = opt.theme === "dark" ? "green" : "black"; | ||
var secondaryColor = opt.theme === "dark" ? "yellow" : "blue"; | ||
return boxen("" + (bundle.file ? colors[primaryColor].bold("Destination: ") + colors[secondaryColor](bundle.file) + "\n" : "") + colors[primaryColor].bold("Bundle size: ") + colors[secondaryColor](size) + (opt.showGzippedSize ? ", " + colors[primaryColor].bold("Gzipped size: ") + colors[secondaryColor](gzip$$1) : ""), { padding: 1 }); | ||
var title = colors[primaryColor].bold; | ||
var value = colors[secondaryColor]; | ||
var values = [].concat(toConsumableArray(bundle.file ? ["" + title("Destination: ") + value(bundle.file)] : []), [title("Bundle Size: ") + " " + value(size)], [title("Minified and Gzipped Size: ") + " " + value(minifiedSize)], toConsumableArray(opt.showBrotliSize ? ["" + title("Brothli size: ") + value(brotliSize)] : [])); | ||
return boxen(values.join("\n"), { padding: 1 }); | ||
} | ||
@@ -27,3 +44,4 @@ | ||
render: render, | ||
showGzippedSize: true | ||
showGzippedSize: true, | ||
showBrotliSize: false | ||
}; | ||
@@ -39,3 +57,7 @@ | ||
var gzipSize = opts.showGzippedSize ? fileSize(gzip.sync(code), opts.format) : ""; | ||
return opts.render(opts, size, gzipSize, bundle); | ||
var brotliSize = opts.showBrotliSize ? fileSize(brotli.sync(code), opts.format) : ""; | ||
var minifiedSize = fileSize(gzip.sync(terser.minify(code).code)); | ||
return opts.render(opts, size, gzipSize, brotliSize, minifiedSize, bundle); | ||
}; | ||
@@ -42,0 +64,0 @@ |
{ | ||
"name": "rollup-plugin-filesize", | ||
"version": "2.0.0", | ||
"version": "4.0.0", | ||
"description": "A rollup plugin to show filesize in the cli", | ||
@@ -33,2 +33,3 @@ "main": "dist/index.js", | ||
"boxen": "^1.1.0", | ||
"brotli-size": "0.0.2", | ||
"colors": "^1.1.2", | ||
@@ -44,4 +45,6 @@ "deep-assign": "^2.0.0", | ||
"babel-register": "^6.7.2", | ||
"prettier": "^1.13.7", | ||
"rollup": "^0.60.1", | ||
"rollup-plugin-babel": "^3.0.4" | ||
"rollup-plugin-babel": "^3.0.4", | ||
"terser": "^3.8.0" | ||
}, | ||
@@ -48,0 +51,0 @@ "ava": { |
@@ -35,2 +35,8 @@ # rollup-plugin-filesize | ||
#### showBrotliSize | ||
type: `boolean` | ||
default: false | ||
Whether to show [Brotli](https://www.wikiwand.com/en/Brotli) size or not | ||
#### format | ||
@@ -70,2 +76,2 @@ type : `object` | ||
<a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/8CBegPnJTnjtddvd2E18Su4F/ritz078/rollup-plugin-filesize'> <img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/8CBegPnJTnjtddvd2E18Su4F/ritz078/rollup-plugin-filesize.svg' /></a> | ||
@@ -6,21 +6,22 @@ import fileSize from "filesize"; | ||
import gzip from "gzip-size"; | ||
import brotli from "brotli-size"; | ||
import terser from "terser"; | ||
function render(opt, size, gzip, bundle) { | ||
function render(opt, size, gzip, brotliSize, minifiedSize, bundle) { | ||
const primaryColor = opt.theme === "dark" ? "green" : "black"; | ||
const secondaryColor = opt.theme === "dark" ? "yellow" : "blue"; | ||
return boxen( | ||
`${bundle.file | ||
? colors[primaryColor].bold("Destination: ") + | ||
colors[secondaryColor](bundle.file) + | ||
"\n" | ||
: ""}${colors[primaryColor].bold("Bundle size: ")}${colors[ | ||
secondaryColor | ||
](size)}${opt.showGzippedSize | ||
? ", " + | ||
colors[primaryColor].bold("Gzipped size: ") + | ||
colors[secondaryColor](gzip) | ||
: ""}`, | ||
{ padding: 1 } | ||
); | ||
const title = colors[primaryColor].bold; | ||
const value = colors[secondaryColor]; | ||
const values = [ | ||
...(bundle.file ? [`${title("Destination: ")}${value(bundle.file)}`] : []), | ||
...[`${title("Bundle Size: ")} ${value(size)}`], | ||
...[`${title("Minified and Gzipped Size: ")} ${value(minifiedSize)}`], | ||
...(opt.showBrotliSize | ||
? [`${title("Brothli size: ")}${value(brotliSize)}`] | ||
: []) | ||
]; | ||
return boxen(values.join("\n"), { padding: 1 }); | ||
} | ||
@@ -33,3 +34,4 @@ | ||
render: render, | ||
showGzippedSize: true | ||
showGzippedSize: true, | ||
showBrotliSize: false | ||
}; | ||
@@ -47,7 +49,13 @@ | ||
: ""; | ||
return opts.render(opts, size, gzipSize, bundle); | ||
let brotliSize = opts.showBrotliSize | ||
? fileSize(brotli.sync(code), opts.format) | ||
: ""; | ||
let minifiedSize = fileSize(gzip.sync(terser.minify(code).code)); | ||
return opts.render(opts, size, gzipSize, brotliSize, minifiedSize, bundle); | ||
}; | ||
if (env === "test") { | ||
return getData | ||
return getData; | ||
} | ||
@@ -54,0 +62,0 @@ |
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
6411
112
76
6
8
+ Addedbrotli-size@0.0.2
+ Addedansi-regex@2.1.1(transitive)
+ Addedaproba@1.2.0(transitive)
+ Addedare-we-there-yet@1.1.7(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbrotli-size@0.0.2(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedconsole-control-strings@1.1.0(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddecompress-response@4.2.1(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addeddelegates@1.0.0(transitive)
+ Addeddetect-libc@1.0.3(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexpand-template@2.0.3(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedgauge@2.7.4(transitive)
+ Addedgithub-from-package@0.0.0(transitive)
+ Addedhas-unicode@2.0.1(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addediltorb@2.4.5(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedini@1.3.8(transitive)
+ Addedis-fullwidth-code-point@1.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedmimic-response@2.1.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addednan@2.22.0(transitive)
+ Addednapi-build-utils@1.0.2(transitive)
+ Addednode-abi@2.30.1(transitive)
+ Addednoop-logger@0.1.1(transitive)
+ Addednpmlog@4.1.2(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedprebuild-install@5.3.6(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedreadable-stream@2.3.83.6.2(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedsimple-concat@1.0.1(transitive)
+ Addedsimple-get@3.1.1(transitive)
+ Addedstring-width@1.0.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedtar-fs@2.1.1(transitive)
+ Addedtar-stream@2.2.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwhich-pm-runs@1.1.0(transitive)
+ Addedwide-align@1.1.5(transitive)
+ Addedwrappy@1.0.2(transitive)