Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 0.2.1 to 0.3.1

screen.png

24

package.json
{
"name": "rollup-plugin-filesize",
"version": "0.2.1",
"version": "0.3.1",
"description": "A rollup plugin to show filesize in the cli",

@@ -8,5 +8,6 @@ "main": "dist/index.js",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "ava test/**/*.test.js",
"build": "rollup -c",
"prebuild": "rm -rf dist/*"
"pretest": "npm run build",
"prepublish": "npm run test"
},

@@ -29,10 +30,21 @@ "repository": {

"chalk": "^1.1.1",
"filesize": "^3.2.0",
"lodash": "^4.0.1"
"deep-assign": "^2.0.0",
"filesize": "^3.2.0"
},
"devDependencies": {
"ava": "^0.11.0",
"ava": "^0.13.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-es2015-rollup": "^1.1.1",
"babel-register": "^6.7.2",
"rollup-plugin-babel": "^2.3.9"
},
"ava": {
"require": "babel-register",
"babel": "inherit"
},
"babel": {
"presets": [
"es2015"
]
}
}

@@ -5,2 +5,4 @@ # rollup-pugin-filesize

![](screen.png)
## Installation

@@ -42,3 +44,3 @@

filesize(
render : function (size){
render : function (options, size){
return size;

@@ -45,0 +47,0 @@ }

@@ -7,3 +7,4 @@ import babel from 'rollup-plugin-babel';

babel({
presets: [ 'es2015-rollup' ]
babelrc:false,
presets: [ 'es2015-rollup' ]
})

@@ -10,0 +11,0 @@ ],

import fileSize from 'filesize';
import boxen from 'boxen';
import Chalk from 'chalk';
import _ from 'lodash';
import deepAssign from 'deep-assign';
var chalk = new Chalk.constructor({enabled:true});
var chalk = new Chalk.constructor({ enabled: true });
export default function filesize(options = {}){
return {
transformBundle(code){
export default function filesize (options = {}) {
let defaultOptions = {
format:{},
theme : 'dark',
render:render
};
function render (opt, size) {
return opt.theme == 'dark' ? (
boxen(chalk.green.bold('Bundle size : ') + chalk.yellow.bold(size), { padding: 1 })
) : (
boxen(chalk.black.bold('Bundle size : ') + chalk.blue.bold(size), { padding: 1 })
);
}
let opts = _.defaultsDeep(options, defaultOptions);
let defaultOptions = {
format: {},
theme : 'dark',
render: render
};
function render(size){
return opts.theme == 'dark' ? (
boxen(chalk.green.bold('Bundle size : ') + chalk.yellow.bold(size), { padding: 1 })
) : (
boxen(chalk.black.bold('Bundle size : ') + chalk.blue.bold(size), { padding: 1 })
);
}
let opts = deepAssign({}, defaultOptions, options);
if(options.render){
opts.render = options.render;
}
return {
transformBundle(code){
let size = fileSize(Buffer.byteLength(code), opts.format);
console.log(opts.render(size))
}
}
console.log(opts.render(opts, size));
return opts.render(opts, size);
}
}
};

Sorry, the diff of this file is not supported yet

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