Skip to content

Commit 2a34c2d

Browse files
committed
Add info about plugin, config, v1.0.3
1 parent 596c470 commit 2a34c2d

6 files changed

Lines changed: 135 additions & 55 deletions

File tree

README.md

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,31 @@
22

33
> Analyze file sizes of rollup bundled imports
44
5-
## install
5+
## rollup-analyzer
66

7-
```sh
8-
$ npm install --save-dev rollup-analyzer
9-
```
7+
Rollup Analyzer gives you a quick look at what's taking up space in your bundle.
108

11-
## api
9+
### Comes in three scrumptious flavors:
1210

13-
### rollupAnalyzer
14-
the default exported function is identical to init, and returns the same functions as export {init, formatted, analyze}. So, you can `require('rollup-analyzer')` or `require('rollup-analyzer')({limit: 5})` and use the same functions.
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.
1514

16-
### rollupAnalyzer.init(options)
17-
set options to use in analysis (this step is optional)
18-
- **options** *(Object)*
19-
- **limit** - *optional*
20-
- type: Number
21-
- default: `null`
22-
- description: Limit number of files to output analysis of, sorted by DESC size
23-
- **filter** - *optional*
24-
- type: Array | String
25-
- default: `null`
26-
- description: Filter to only show imports matching the specified name(s)
27-
- **root** - *optional*
28-
- type: String
29-
- default: `process.cwd()`
30-
- description: Application directory, used to display file paths relatively
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.
3118

32-
### rollupAnalyzer.formatted(bundle)
33-
returns Promise which resolves with well formatted analysis string (for CLI printing)
34-
- **bundle** *(Rollup Bundle)* - *required*
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.
3522

36-
### rollupAnalyzer.analyze(bundle)
37-
returns Promise which resolves with array of objects describing each imported file
38-
- **bundle** *(Rollup Bundle)* - *required*
23+
## Install
24+
25+
```sh
26+
$ npm install --save-dev rollup-analyzer
27+
```
3928

40-
## usage
29+
## Usage
4130

4231
```js
4332
const rollupAnalyzer = require('rollup-analyzer')({limit: 5})
@@ -68,6 +57,35 @@ dependents: 1
6857
*/
6958
```
7059

60+
## API
61+
62+
### rollupAnalyzer
63+
the default exported function is identical to init, and returns the same functions as export {init, formatted, analyze}. So, you can `require('rollup-analyzer')` or `require('rollup-analyzer')({limit: 5})` and use the same functions.
64+
65+
### rollupAnalyzer.init(options)
66+
set options to use in analysis (this step is optional)
67+
- **options** *(Object)*
68+
- **limit** - *optional*
69+
- type: Number
70+
- default: `null`
71+
- description: Limit number of files to output analysis of, sorted by DESC size
72+
- **filter** - *optional*
73+
- type: Array | String
74+
- default: `null`
75+
- description: Filter to only show imports matching the specified name(s)
76+
- **root** - *optional*
77+
- type: String
78+
- default: `process.cwd()`
79+
- description: Application directory, used to display file paths relatively
80+
81+
### rollupAnalyzer.formatted(bundle)
82+
returns Promise which resolves with well formatted analysis string (for CLI printing)
83+
- **bundle** *(Rollup Bundle)* - *required*
84+
85+
### rollupAnalyzer.analyze(bundle)
86+
returns Promise which resolves with array of objects describing each imported file
87+
- **bundle** *(Rollup Bundle)* - *required*
88+
7189
## License
7290

7391
MIT © [Andrew Carpenter](https://github.com/doesdev)

build.js

Lines changed: 0 additions & 13 deletions
This file was deleted.
File renamed without changes.

package-lock.json

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
"name": "rollup-analyzer",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Analyze file sizes of rollup bundled imports",
55
"main": "index.js",
6-
"jsnext:main": "index-es6.js",
6+
"module": "module.js",
77
"files": [
88
"index.js",
9-
"index-es6.js"
9+
"module.js"
1010
],
1111
"scripts": {
12-
"test": "echo \"Error: no test specified\" && exit 1"
12+
"test": "echo \"Error: no test specified\" && exit 1",
13+
"precommit": "rollup -c && git add index.js"
1314
},
1415
"repository": {
1516
"type": "git",
@@ -21,7 +22,9 @@
2122
"bundle",
2223
"file",
2324
"size",
24-
"analysis"
25+
"analysis",
26+
"analyze",
27+
"bloat"
2528
],
2629
"author": "Andrew Carpenter (https://github.com/doesdev)",
2730
"license": "MIT",
@@ -30,13 +33,8 @@
3033
},
3134
"homepage": "https://github.com/doesdev/rollup-analyzer#readme",
3235
"devDependencies": {
33-
"ghooks": "^1.3.2",
34-
"rollup": "^0.36.4",
35-
"simple-git": "^1.63.0"
36-
},
37-
"config": {
38-
"ghooks": {
39-
"pre-commit": "node build"
40-
}
36+
"husky": "^0.14.3",
37+
"rollup": "^0.47.6",
38+
"rollup-analyzer-plugin": "^1.0.0"
4139
}
4240
}

rollup.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
// how meta
4+
import plugin from 'rollup-analyzer-plugin'
5+
export default {
6+
entry: 'module.js',
7+
dest: 'index.js',
8+
format: 'cjs',
9+
plugins: [plugin()]
10+
}

0 commit comments

Comments
 (0)