|
2 | 2 |
|
3 | 3 | > Analyze file sizes of rollup bundled imports |
4 | 4 |
|
5 | | -## install |
| 5 | +## rollup-analyzer |
6 | 6 |
|
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. |
10 | 8 |
|
11 | | -## api |
| 9 | +### Comes in three scrumptious flavors: |
12 | 10 |
|
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. |
15 | 14 |
|
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. |
31 | 18 |
|
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. |
35 | 22 |
|
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 | +``` |
39 | 28 |
|
40 | | -## usage |
| 29 | +## Usage |
41 | 30 |
|
42 | 31 | ```js |
43 | 32 | const rollupAnalyzer = require('rollup-analyzer')({limit: 5}) |
@@ -68,6 +57,35 @@ dependents: 1 |
68 | 57 | */ |
69 | 58 | ``` |
70 | 59 |
|
| 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 | + |
71 | 89 | ## License |
72 | 90 |
|
73 | 91 | MIT © [Andrew Carpenter](https://github.com/doesdev) |
0 commit comments