Socket
Socket
Sign inDemoInstall

rollup-plugin-filesize

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-filesize - npm Package Compare versions

Comparing version 2.0.0 to 4.0.0

30

dist/index.js

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

7

package.json
{
"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 @@

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