Skip to content
This repository has been archived by the owner on Jul 5, 2019. It is now read-only.

doesdev/rollup-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED

Due to a number of enhancements only available in plugin hooks this module is of no value over the plugin. There are allot of new goodies avilable in the new plugin repo.

* The prior plugin module is also no longer active, in favor of using Rollup's standardized naming format for plugins.

So again, please use rollup-plugin-analyzer rather than anything listed down the page.

rollup-analyzer NPM version js-standard-style Dependency Status Build Status

Analyze file sizes of rollup bundled imports

rollup-analyzer

Rollup Analyzer gives you a quick look at what's taking up space in your bundle.

Comes in three scrumptious flavors:

Adding as a plugin to your rollup config or build script will print a well formatted analysis to the console upon bundling.

If using Rollup's CLI to bundle with no additonal config, pass -c node:rollup-analyzer-config to print a well formatted analysis to your console.

Full analysis module, giving you access to the complete analysis object or well formatted analysis text for CI and build usage.

Install

$ npm install --save-dev rollup-analyzer

Usage

import { rollup } from 'rollup'
const { formatted } from 'rollup-analyzer'

rollup({/*...*/}).then((bundle) => {
  // print console optimized analysis string
  formatted(bundle, {limit: 5}).then(console.log).catch(console.error)
})

// Results in ...
/*
-----------------------------
Rollup File Analysis
-----------------------------
bundle size: 1.146 MB
-----------------------------
file: \node_modules\html5-history-api\history.js
size: 38.502 KB
percent: 3.36%
dependents: 1
  - \app\modules\page.js
-----------------------------
file: \node_modules\pikaday\pikaday.js
size: 34.683 KB
percent: 3.03%
dependents: 1
  - \app\helpers\transformer.js
...
*/

API

Module exports analyze, formatted, and plugin functions

formatted(bundle, options)

  • arguments
    • bundle (Rollup Bundle)
    • options (Object - see below for available options)
  • returns
    • analysisText (String - well formatted for console printing)

analyze(bundle, options)

  • arguments
    • bundle (Rollup Bundle)
    • options (Object - see below for available options)
  • returns
    • analysis (Object)
      • id (String) - path of module / rollup module id
      • size (Number) - size of module in bytes
      • dependents (Array) - list of dependent module ids / paths
      • percent (Number) - percentage of module size relative to entire bundle

options Object

  • limit - optional
    • type: Number
    • default: null
    • description: Limit number of files to output analysis of, sorted by DESC size
  • filter - optional
    • type: Array | String
    • default: null
    • description: Filter to only show imports matching the specified name(s)
  • root - optional
    • type: String
    • default: process.cwd()
    • description: Application directory, used to display file paths relatively

License

MIT © Andrew Carpenter