1- # rollup-analyzer [ ![ NPM version] ( https://badge.fury.io/js/rollup-analyzer.svg )] ( https://npmjs.org/package/rollup-analyzer ) [ ![ js-standard-style] ( https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat )] ( https://github.com/feross/standard ) [ ![ Dependency Status] ( https://dependencyci.com/github/doesdev/rollup-analyzer/badge )] ( https://dependencyci.com/github/doesdev/rollup-analyzer ) [ ![ Build Status] ( https://travis-ci.com/doesdev/rollup-analyzer.svg )] ( https://travis-ci.com/doesdev/rollup-analyzer )
1+ # rollup-plugin- analyzer [ ![ NPM version] ( https://badge.fury.io/js/rollup-plugin- analyzer.svg )] ( https://npmjs.org/package/rollup-plugin- analyzer ) [ ![ js-standard-style] ( https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat )] ( https://github.com/feross/standard ) [ ![ Dependency Status] ( https://dependencyci.com/github/doesdev/rollup-plugin- analyzer/badge )] ( https://dependencyci.com/github/doesdev/rollup-plugin- analyzer ) [ ![ Build Status] ( https://travis-ci.com/doesdev/rollup-plugin- analyzer.svg )] ( https://travis-ci.com/doesdev/rollup-plugin -analyzer )
22
3- > Analyze file sizes of rollup bundled imports
3+ > Mad metrics for your rollup bundles, know all the things
44
5- ## rollup-analyzer
5+ ## rollup-plugin- analyzer
66
7- Rollup Analyzer gives you a quick look at what's taking up space in your bundle.
7+ See what's bloating your bundle, how treeshaking has treated you, and other
8+ great stuff. Perfect for console printing an analysis of your bundle or
9+ integrating in your CI workflows.
810
9- ### Comes in three scrumptious flavors:
11+ ### Comes in two scrumptious flavors:
1012
11- #### [ rollup-analyzer-plugin] ( https://github.com/doesdev/rollup-analyzer-plugin )
12- Adding as a plugin to your rollup config or build script will print a well
13- formatted analysis to the console upon bundling.
13+ #### [ rollup-plugin-analyzer] ( https://github.com/doesdev/rollup-plugin-analyzer )
14+ Adding as a plugin to your rollup config or build script will allow you to
15+ print a well formatted analysis to the console upon bundling or get a full
16+ analysis object for CI purposes.
1417
15- #### [ rollup-analyzer-config] ( https://github.com/doesdev/rollup-analyzer-config )
16- If using Rollup's CLI to bundle with no additonal config, pass
17- ` -c node:rollup-analyzer-config ` to print a well formatted analysis to your console.
18-
19- #### [ rollup-analyzer] ( https://github.com/doesdev/rollup-analyzer )
20- Full analysis module, giving you access to the complete analysis object or well
21- formatted analysis text for CI and build usage.
18+ #### [ rollup-config-analyzer] ( https://github.com/doesdev/rollup-config-analyzer )
19+ If using Rollup's CLI to bundle with no additional config, pass
20+ ` -c node:rollup-config-analyzer ` to print a well formatted analysis to your console.
2221
2322## Install
2423
2524``` sh
26- $ npm install --save-dev rollup-analyzer
25+ $ npm install --save-dev rollup-plugin- analyzer
2726```
2827
2928## Usage
3029
30+ ### from rollup config
31+ ``` js
32+ import { plugin as analyze } from ' rollup-analyzer-plugin'
33+ const opts = {limit: 5 , filter: [], root: __dirname }
34+ export default {
35+ entry: ' module.js' ,
36+ dest: ' index.js' ,
37+ format: ' cjs' ,
38+ plugins: [analyze (opts)]
39+ }
40+ ```
41+
42+ ### from build script
3143``` js
3244import { rollup } from ' rollup'
33- const { formatted } from 'rollup -analyzer '
45+ import { plugin as analyze } from ' rollup-analyzer-plugin'
46+ const opts = {limit: 5 , filter: [], root: __dirname }
3447
35- rollup ({/* ...*/ }).then ((bundle ) => {
36- // print console optimized analysis string
37- formatted (bundle, {limit: 5 }).then (console .log ).catch (console .error )
38- })
48+ rollup ({
49+ entry: ' main.js' ,
50+ plugins: [analyze (opts)]
51+ }).then (... )
52+ ```
3953
40- // Results in ...
41- /*
54+ ### results
55+ logged to console on rollup completion
56+ ``` sh
4257-----------------------------
4358Rollup File Analysis
4459-----------------------------
@@ -56,44 +71,35 @@ percent: 3.03%
5671dependents: 1
5772 - \a pp\h elpers\t ransformer.js
5873...
59- */
6074```
6175
62- ## API
76+ ## Options
77+
78+ - ** stdout** - * optional*
79+ - type: Boolean
80+ - default: ` false `
81+ - description: Print to stdout (console.log) instead of stderr (console.error)
82+ - ** limit** - * optional*
83+ - type: Number
84+ - default: ` null `
85+ - description: Limit number of files to output analysis of, sorted by DESC size
86+ - ** filter** - * optional*
87+ - type: Array | String
88+ - default: ` null `
89+ - description: Filter to only show imports matching the specified name(s)
90+ - ** root** - * optional*
91+ - type: String
92+ - default: ` process.cwd() `
93+ - description: Application directory, used to display file paths relatively
6394
64- Module exports ` analyze ` , ` formatted ` , and ` plugin ` functions
65-
66- ### formatted(bundle, options)
67- - arguments
68- - ** bundle** * (Rollup Bundle)*
69- - ** options** * (Object - see below for available options)*
70- - returns
71- - ** analysisText** * (String - well formatted for console printing)*
7295
73- ### analyze(bundle, options)
74- - arguments
75- - ** bundle** * (Rollup Bundle)*
76- - ** options** * (Object - see below for available options)*
7796- returns
7897 - ** analysis** * (Object)*
7998 - ** id** * (String)* - path of module / rollup module id
8099 - ** size** * (Number)* - size of module in bytes
81100 - ** dependents** * (Array)* - list of dependent module ids / paths
82101 - ** percent** * (Number)* - percentage of module size relative to entire bundle
83102
84- #### options ` Object `
85- - ** limit** - * optional*
86- - type: Number
87- - default: ` null `
88- - description: Limit number of files to output analysis of, sorted by DESC size
89- - ** filter** - * optional*
90- - type: Array | String
91- - default: ` null `
92- - description: Filter to only show imports matching the specified name(s)
93- - ** root** - * optional*
94- - type: String
95- - default: ` process.cwd() `
96- - description: Application directory, used to display file paths relatively
97103
98104## License
99105
0 commit comments