Skip to content

Commit 675dcdc

Browse files
committed
Update from rollup-analyzer to rollup-plugin-analyzer
1 parent 97b82d1 commit 675dcdc

4 files changed

Lines changed: 68 additions & 59 deletions

File tree

README.md

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,59 @@
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
3244
import { 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
-----------------------------
4358
Rollup File Analysis
4459
-----------------------------
@@ -56,44 +71,35 @@ percent: 3.03%
5671
dependents: 1
5772
- \app\helpers\transformer.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

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const plugin = (opts = {}) => {
103103
return analyze({modules}, opts, !opts.onAnalysis).then(cb)
104104
});
105105
return {
106-
name: 'rollup-analyzer-plugin',
106+
name: 'rollup-plugin-analyzer',
107107
transformChunk: (_a, _b, chunk) => new Promise((resolve, reject) => {
108108
resolve(null);
109109
if (!chunk || !chunk.orderedModules) return

module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const plugin = (opts = {}) => {
101101
return analyze({modules}, opts, !opts.onAnalysis).then(cb)
102102
})
103103
return {
104-
name: 'rollup-analyzer-plugin',
104+
name: 'rollup-plugin-analyzer',
105105
transformChunk: (_a, _b, chunk) => new Promise((resolve, reject) => {
106106
resolve(null)
107107
if (!chunk || !chunk.orderedModules) return

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "rollup-analyzer",
3-
"version": "2.0.0-beta.3",
4-
"description": "Analyze file sizes of rollup bundled imports",
2+
"name": "rollup-plugin-analyzer",
3+
"version": "2.0.0",
4+
"description": "Mad metrics for your rollup bundles, know all the things",
55
"main": "index.js",
66
"module": "module.js",
77
"files": [
@@ -14,28 +14,31 @@
1414
},
1515
"repository": {
1616
"type": "git",
17-
"url": "git+https://github.com/doesdev/rollup-analyzer.git"
17+
"url": "git+https://github.com/doesdev/rollup-plugin-analyzer.git"
1818
},
1919
"keywords": [
2020
"rollup",
21+
"plugin",
2122
"import",
2223
"bundle",
2324
"file",
2425
"size",
26+
"treeshaking",
27+
"metrics",
2528
"analysis",
2629
"analyze",
2730
"bloat"
2831
],
2932
"author": "Andrew Carpenter (https://github.com/doesdev)",
3033
"license": "MIT",
3134
"bugs": {
32-
"url": "https://github.com/doesdev/rollup-analyzer/issues"
35+
"url": "https://github.com/doesdev/rollup-plugin-analyzer/issues"
3336
},
34-
"homepage": "https://github.com/doesdev/rollup-analyzer#readme",
37+
"homepage": "https://github.com/doesdev/rollup-plugin-analyzer#readme",
3538
"devDependencies": {
3639
"ava": "^0.25.0",
3740
"husky": "^0.14.3",
38-
"rollup": "^0.60.1",
41+
"rollup": "latest",
3942
"rollup40": "npm:rollup@0.40.x",
4043
"rollup45": "npm:rollup@0.45.x",
4144
"rollup50": "npm:rollup@0.50.x",

0 commit comments

Comments
 (0)