New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rollup-plugin-analyzer

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-analyzer

Mad metrics for your rollup bundles, know all the things

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
57K
decreased by-13.48%
Maintainers
1
Weekly downloads
 
Created
Source

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

Mad metrics for your rollup bundles, know all the things

rollup-plugin-analyzer

See what's bloating your bundle, how treeshaking has treated you, and other great stuff. Perfect for console printing an analysis of your bundle or integrating in your CI workflows.

Comes in two scrumptious flavors:

rollup-plugin-analyzer

Adding as a plugin to your rollup config or build script will allow you to print a well formatted analysis to the console upon bundling or get a full analysis object for CI purposes.

rollup-config-analyzer

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

Install

$ npm install --save-dev rollup-plugin-analyzer

Usage

from rollup config

import { plugin as analyze } from 'rollup-analyzer-plugin'
const opts = {limit: 5, filter: [], root: __dirname}
export default {
  entry: 'module.js',
  dest: 'index.js',
  format: 'cjs',
  plugins: [analyze(opts)]
}

from build script

import { rollup } from 'rollup'
import { plugin as analyze } from 'rollup-analyzer-plugin'
const opts = {limit: 5, filter: [], root: __dirname}

rollup({
  entry: 'main.js',
  plugins: [analyze(opts)]
}).then(...)

results

logged to console on rollup completion

-----------------------------
Rollup File Analysis
-----------------------------
bundle size:    2.809 KB
original size:  11.384 KB
code reduction: 75.33 %
-----------------------------
file:            \test\fixtures\import-d.js
bundle space:    90.64 %
rendered size:   2.546 KB
original size:   2.57 KB
code reduction:  0.93 %
dependents:      1
  - \test\fixtures\import-c.js
-----------------------------
file:            \test\fixtures\bundle.js
bundle space:    4.27 %
rendered size:   120 Bytes
original size:   267 Bytes
code reduction:  55.06 %
dependents:      0
-----------------------------
file:            \test\fixtures\import-c.js
bundle space:    2.95 %
rendered size:   83 Bytes
original size:   161 Bytes
code reduction:  48.45 %
dependents:      1
  - \test\fixtures\import-b.js
...

Options

  • stdout - optional
    • type: Boolean
    • default: false
    • description: Print to stdout (console.log) instead of stderr (console.error)
  • 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
  • hideDeps - optional
    • type: Boolean
    • default: false
    • description: Don't itemize dependents in the formatted output
  • writeTo - optional
    • type: Function
    • default: null
    • description: Callback to be invoked with formatted string
    • callback invoked with:
      • analysisString (String)
  • onAnalysis - optional
    • type: Function
    • default: null
    • description: Callback to be invoked with analysis object
    • notes: if this is set the formatted string will not be output
    • callback invoked with:
      • analysisObject (Object)
        • bundleSize (Number) - rendered bundle size in bytes
        • bundleOrigSize (Number) - original bundle size in bytes
        • bundleReduction (Number) - percentage of rendered bundle size reduction
        • modules (Array) - array of module analysis objects
          • module (Object)
            • id (String) - path of module / rollup module id
            • size (Number) - size of rendered module code in bytes
            • origSize (Number) - size of module's original code in bytes
            • dependents (Array) - list of dependent module ids / paths
            • percent (Number) - percentage of module size relative to entire bundle
            • reduction (Number) - percentage of rendered size reduction

License

MIT © Andrew Carpenter

Keywords

FAQs

Package last updated on 08 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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