Installations
npm install rollup-plugin-analyzer
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=8.0.0
Node Version
13.14.0
NPM Version
6.14.4
Score
99.7
Supply Chain
100
Quality
76
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
Download Statistics
Total Downloads
8,829,638
Last Day
1,089
Last Week
55,314
Last Month
236,225
Last Year
3,131,399
GitHub Statistics
242 Stars
120 Commits
4 Forks
5 Watching
6 Branches
5 Contributors
Bundle Size
3.89 kB
Minified
1.76 kB
Minified + Gzipped
Package Meta Information
Latest Version
4.0.0
Package Id
rollup-plugin-analyzer@4.0.0
Size
10.86 kB
NPM Version
6.14.4
Node Version
13.14.0
Publised On
20 Dec 2020
Total Downloads
Cumulative downloads
Total Downloads
8,829,638
Last day
-3.1%
1,089
Compared to previous day
Last week
-0.3%
55,314
Compared to previous week
Last month
-6.4%
236,225
Compared to previous month
Last year
15%
3,131,399
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
rollup-plugin-analyzer
Mad metrics for your rollup bundles, know all the things
TOC
Install
1$ npm install --save-dev rollup-plugin-analyzer
Usage
Importing or Requiring
Import as ES Module
1import analyze from 'rollup-plugin-analyzer'
Requiring as CJS
1const analyze = require('rollup-plugin-analyzer')
Usage from rollup config
1export default { 2 entry: 'module.js', 3 dest: 'index.js', 4 format: 'cjs', 5 plugins: [analyze()] 6}
Usage from build script
1rollup({ 2 entry: 'main.js', 3 plugins: [analyze()] 4}).then(...)
CI usage example
1const limitBytes = 1e6 2 3const onAnalysis = ({ bundleSize }) => { 4 if (bundleSize < limitBytes) return 5 console.log(`Bundle size exceeds ${limitBytes} bytes: ${bundleSize} bytes`) 6 return process.exit(1) 7} 8 9rollup({ 10 entry: 'main.js', 11 plugins: [analyze({ onAnalysis, skipFormatted: true })] 12}).then(...)
results
logged to console on rollup completion
1----------------------------- 2Rollup File Analysis 3----------------------------- 4bundle size: 2.809 KB 5original size: 11.436 KB 6code reduction: 75.44 % 7module count: 5 8 9█████████████████████████████████████████████░░░░░ 10file: /virtual-insanity.js 11bundle space: 90.64 % 12rendered size: 2.546 KB 13original size: 2.57 KB 14code reduction: 0.93 % 15dependents: 1 16 - /jamiroquai.js 17 18██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 19file: /bundle-a.js 20bundle space: 4.27 % 21rendered size: 120 Bytes 22original size: 309 Bytes 23code reduction: 61.17 % 24dependents: 0 25 26█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 27file: /jamiroquai.js 28bundle space: 2.95 % 29rendered size: 83 Bytes 30original size: 169 Bytes 31code reduction: 50.89 % 32dependents: 1 33 - /the-alphabet-but-incomplete.js 34...
results (with summaryOnly
enabled)
1----------------------------- 2Rollup File Analysis 3----------------------------- 4bundle size: 2.809 KB 5original size: 11.436 KB 6code reduction: 75.44 % 7module count: 5 8 9/virtual-insanity.js 10█████████████████████████████████████████████░░░░░ 90.64 % (2.546 KB) 11/bundle-a.js 12██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 4.27 % (120 Bytes) 13/jamiroquai.js 14█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2.95 % (83 Bytes) 15/the-alphabet-but-incomplete.js 16░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1.17 % (33 Bytes) 17/the-declaration-of-independence.js 18░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0.96 % (27 Bytes)
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 | Function
- default:
null
- description: Filter module to output in analysis results.
- If a string is passed, checks if module name contains the string
- If array it checks the same for each string in the array
- If function, return a boolean to indicate if a module should be in analysis results
- This only suppresses the modules details, it does not affect the summary output
- If you would like it to filter from summary info as well set
filterSummary
totrue
- notes: Function receives
module
object specified below, should return boolean
- filterSummary - optional
- type: Boolean
- default:
false
- description: If
true
thefilter
andlimit
options will also remove any filtered out module data from the summary
- 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
- showExports - optional
- type: Boolean
- default:
false
- description: Show used and unused exports
- summaryOnly - optional
- type: Boolean
- default:
false
- description: Only output bundle summary and module usage bar graphs
- skipFormatted - optional
- type: Boolean
- default:
false
- description: Don't output formatted string
- writeTo - optional
- type: Function
- default:
null
- description: Callback to be invoked with formatted string
- function will be invoked with:
- analysisString (String)
- transformModuleId - optional
- type: Function
- default:
null
- description: Modify module ids
- function will be invoked with:
- id (String) - path of module / rollup module id
- function should return:
- id (String) - desired final module id to display in analysis results
- example:
(id) => id.replace(/^\0(?:commonjs-proxy:)?/, '')
- onAnalysis - optional
- type: Function
- default:
null
- description: Callback to be invoked with analysis object
- function will be 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
- moduleCount (Number) - Count of all included modules
- 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
- renderedExports (Array) - list of used named exports
- removedExports (Array) - list of unused named exports
- module (Object)
- analysisObject (Object)
FAQ
Why is the reported size not the same as the file on disk?
This module is geared towards the details of the individual modules that make up the bundle and their relative impact to bundle size. That's a detailed way of saying, it doesn't really care about size on disk. There are other options which focus on size on disk as well as delivery size which can be used alongside this module (or in place of if your concern is not per module impact). In particular rollup-plugin-size-snapshot seems like a great option for that.
Getting a bit further into the details, rather than just intent, of why the reported size differs from that on disk. We get the module data from Rollup which reports it after chunk (module) resolution and tree-shaking, but before post-processing (such as minification and compression). We then add the sizes of each of those modules together, this is the bundle size
that we report.
That means it won't account for post-processing from other plugins and also won't account for post-processing by Rollup itself, which includes boilerplate / shims depending on what the output format is (CJS, ESM, iife, etc...).
Why am I seeing multiple analysis outputs emitted?
Rollup allows you to output to multiple files. If you are outputting to multiple files you will get a distinct analysis for each output file. Each analysis will contain data on the files imported by the respective target.
License
MIT © Andrew Carpenter
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
5 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/24 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 9 are checked with a SAST tool
Score
2.4
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More