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 4.0.1 to 5.0.0

25

dist/index.js

@@ -11,3 +11,3 @@ 'use strict';

var brotli = _interopDefault(require('brotli-size'));
var terser = _interopDefault(require('terser'));
var minify = _interopDefault(require('babel-minify'));

@@ -24,3 +24,3 @@ var toConsumableArray = function (arr) {

function render(opt, size, gzip$$1, brotliSize, minifiedSize, bundle) {
function render(opt, bundle, sizes) {
var primaryColor = opt.theme === "dark" ? "green" : "black";

@@ -32,3 +32,3 @@ var secondaryColor = opt.theme === "dark" ? "yellow" : "blue";

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)] : []));
var values = [].concat(toConsumableArray(bundle.file ? ["" + title("Destination: ") + value(bundle.file)] : []), [title("Bundle Size: ") + " " + value(sizes.bundleSize)], toConsumableArray(sizes.minSize ? [title("Minified Size: ") + " " + value(sizes.minSize)] : []), toConsumableArray(sizes.gzipSize ? [title("Gzipped Size: ") + " " + value(sizes.gzipSize)] : []), toConsumableArray(sizes.brotliSize ? ["" + title("Brothli size: ") + value(sizes.brotliSize)] : []));

@@ -47,3 +47,4 @@ return boxen(values.join("\n"), { padding: 1 });

showGzippedSize: true,
showBrotliSize: false
showBrotliSize: false,
showMinifiedSize: true
};

@@ -57,9 +58,14 @@

var getData = function getData(bundle, code) {
var size = fileSize(Buffer.byteLength(code), opts.format);
var gzipSize = opts.showGzippedSize ? fileSize(gzip.sync(code), opts.format) : "";
var brotliSize = opts.showBrotliSize ? fileSize(brotli.sync(code), opts.format) : "";
var sizes = {};
sizes.bundleSize = fileSize(Buffer.byteLength(code), opts.format);
var minifiedSize = fileSize(gzip.sync(terser.minify(code).code));
sizes.brotliSize = opts.showBrotliSize ? fileSize(brotli.sync(code), opts.format) : "";
return opts.render(opts, size, gzipSize, brotliSize, minifiedSize, bundle);
if (opts.showMinifiedSize || opts.showGzippedSize) {
var minifiedCode = minify(code).code;
sizes.minSize = opts.showMinifiedSize ? fileSize(minifiedCode.length, opts.format) : "";
sizes.gzipSize = opts.showGzippedSize ? fileSize(gzip.sync(minifiedCode), opts.format) : "";
}
return opts.render(opts, bundle, sizes);
};

@@ -72,2 +78,3 @@

return {
name: "filesize",
ongenerate: function ongenerate(bundle, _ref) {

@@ -74,0 +81,0 @@ var code = _ref.code;

{
"name": "rollup-plugin-filesize",
"version": "4.0.1",
"version": "5.0.0",
"description": "A rollup plugin to show filesize in the cli",

@@ -32,9 +32,9 @@ "main": "dist/index.js",

"dependencies": {
"boxen": "^1.1.0",
"brotli-size": "0.0.2",
"colors": "^1.1.2",
"babel-minify": "^0.5.0",
"boxen": "^2.0.0",
"brotli-size": "0.0.3",
"colors": "^1.3.2",
"deep-assign": "^2.0.0",
"filesize": "^3.5.6",
"gzip-size": "^3.0.0",
"terser": "^3.8.0"
"filesize": "^3.6.1",
"gzip-size": "^5.0.0"
},

@@ -41,0 +41,0 @@ "devDependencies": {

@@ -29,2 +29,8 @@ # rollup-plugin-filesize

#### showMinifiedSize
type: `boolean`
default: true
Whether to show minified size or not
#### showGzippedSize

@@ -56,4 +62,4 @@ type: `boolean`

filesize({
render : function (options, size){
return size;
render : function (options, bundle, { minSize, gzipSize, brotliSize, bundleSize }){
return minSize;
}

@@ -60,0 +66,0 @@ })

@@ -7,5 +7,5 @@ import fileSize from "filesize";

import brotli from "brotli-size";
import terser from "terser";
import minify from "babel-minify";
function render(opt, size, gzip, brotliSize, minifiedSize, bundle) {
function render(opt, bundle, sizes) {
const primaryColor = opt.theme === "dark" ? "green" : "black";

@@ -19,7 +19,6 @@ const secondaryColor = opt.theme === "dark" ? "yellow" : "blue";

...(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)}`]
: [])
...[`${title("Bundle Size: ")} ${value(sizes.bundleSize)}`],
...(sizes.minSize ? [`${title("Minified Size: ")} ${value(sizes.minSize)}`] : []),
...(sizes.gzipSize ? [`${title("Gzipped Size: ")} ${value(sizes.gzipSize)}`] : []),
...(sizes.brotliSize ? [`${title("Brothli size: ")}${value(sizes.brotliSize)}`] : [])
];

@@ -36,3 +35,4 @@

showGzippedSize: true,
showBrotliSize: false
showBrotliSize: false,
showMinifiedSize: true
};

@@ -46,13 +46,20 @@

const getData = function(bundle, code) {
let size = fileSize(Buffer.byteLength(code), opts.format);
let gzipSize = opts.showGzippedSize
? fileSize(gzip.sync(code), opts.format)
: "";
let brotliSize = opts.showBrotliSize
const sizes = {};
sizes.bundleSize = fileSize(Buffer.byteLength(code), opts.format);
sizes.brotliSize = opts.showBrotliSize
? fileSize(brotli.sync(code), opts.format)
: "";
let minifiedSize = fileSize(gzip.sync(terser.minify(code).code));
if (opts.showMinifiedSize || opts.showGzippedSize) {
const minifiedCode = minify(code).code;
sizes.minSize = opts.showMinifiedSize
? fileSize(minifiedCode.length, opts.format)
: "";
sizes.gzipSize = opts.showGzippedSize
? fileSize(gzip.sync(minifiedCode), opts.format)
: "";
}
return opts.render(opts, size, gzipSize, brotliSize, minifiedSize, bundle);
return opts.render(opts, bundle, sizes);
};

@@ -65,2 +72,3 @@

return {
name: "filesize",
ongenerate(bundle, { code }) {

@@ -67,0 +75,0 @@ console.log(getData(bundle, code));

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