Code Monkey home page Code Monkey logo

rollup-plugin-bundle-size's Introduction

rollup-plugin-bundle-size npm

A rollup plugin to show the size of the generated bundle(s).

Sample Output

$ rollup -c
src/project.js → dist/project.bundle.js...
Created bundle project.bundle.js: 52.53 kB → 18.29 kB (gzip)
created dist/project.bundle.js in 3.5s

Installation

npm install --save-dev rollup-plugin-bundle-size

Usage

JS API

const rollup = require('rollup');
const bundleSize = require('rollup-plugin-bundle-size');

rollup.rollup({
    entry: 'src/index.js',
    plugins: [
        bundleSize()
    ]
}).then((bundle) => {
    ...
});

Config File

import bundleSize from 'rollup-plugin-bundle-size';

export default {
    entry: 'src/index.js',
    plugins: [
        bundleSize()
    ]
}

rollup-plugin-bundle-size's People

Contributors

arkgast avatar bdougherty avatar fisherinnovation avatar qrohlf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rollup-plugin-bundle-size's Issues

TypeError: Path must be a string. Received undefined

Thanks a lot for the great plugin!

I noticed on the most recent version (0.48.2) of rollup this plugin seems to break. This is likely due to rollups changes in configurations and what gets passed into the ongenerate hook.

On 0.47 the ongenerate receives

{ bundle:
   { imports: [],
     exports: [ 'default' ],
     modules: [ [Object], [Object], [Object], [Object] ],
     generate: [Function: generate],
     write: [Function: write] },
  entry: 'src/xx.js',
  external: [ '' ],
  globals: {},
  format: 'umd',
  moduleName: 'xx',
  sourceMap: true,
  plugins:
   [ { name: 'node-resolve', resolveId: [Function: resolveId$1] },
     { name: 'babel',
       options: [Function: options$1],
       resolveId: [Function: resolveId],
       load: [Function: load],
       transform: [Function: transform$1] },
     { name: 'replace', transform: [Function: transform] },
     { name: 'uglify', transformBundle: [Function: transformBundle] },
     { name: 'rollup-plugin-bundle-size',
       ongenerate: [Function: ongenerate] } ],
  targets: [ { dest: 'dist/xxx.min.js', format: 'umd' } ],
  onwarn: [Function: add],
  dest: 'dist/xx.min.js' }

Whereas on 0.48 we receive

{ bundle:
   { imports: [],
     exports: [ 'default' ],
     modules: [ [Object], [Object], [Object], [Object] ],
     generate: [Function: generate],
     write: [Function: write] },
  extend: undefined,
  amd: {},
  banner: undefined,
  footer: undefined,
  intro: undefined,
  outro: undefined,
  sourcemap: undefined,
  name: undefined,
  globals: {},
  interop: undefined,
  legacy: undefined,
  indent: undefined,
  strict: undefined,
  noConflict: undefined,
  paths: undefined,
  format: 'cjs',
  file: 'dist/xxx.cjs.js' }

This causes the plugin to break rollup-plugin-bundle-size/index.js:9 as we forward the dest prop into path which on 0.48 will be undefined and should be the file property.

The fix seems relatively easy just not sure how the release would be handled - as what version and how peer dependencies should be pinned.

Plugin maintenance

Hey 👋

I've used this plugin in a few projects and met some limitations, latest one with using output.dir instead of output.file which results in an error.

I see this repo has a few issues and PRs. Instead of creating another same purpose package I'd like to help with support for this one. Previously I did same thing for other common rollup plugins and maintain a few of them.

What do you think?

Couldn't get to use your plugin in rollup+vue+gulp setup

It works in a normal rollup+vue setup, but once I converted everything to gulp which rollup supports your plugin breaks and I get this error

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.basename (path.js:1355:5)
    at Object.ongenerate (/Users/paulo/Sites/swaychat-widget/node_modules/rollup-plugin-bundle-size/index.js:9:32)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.