rollup-plugin-analyzer
Advanced tools
Comparing version 3.3.0 to 4.0.0
@@ -5,2 +5,12 @@ ### Changelog | ||
### [4.0.0](https://github.com/doesdev/rollup-plugin-analyzer/compare/3.3.0...4.0.0) | ||
> 19 December 2020 | ||
- **[BREAKING]** Limit does not affect summary (unless `filterSummary === true`) | ||
- [DEV] Update dev dependencies (standard, husky) | ||
- [DEV] Fix standard style issue | ||
- [DOCS] Add FAQ to readme | ||
- [DOCS] Add TOC to readme | ||
### [3.3.0](https://github.com/doesdev/rollup-plugin-analyzer/compare/3.2.3...3.3.0) | ||
@@ -7,0 +17,0 @@ |
13
index.js
@@ -59,3 +59,3 @@ 'use strict'; | ||
formatted += summaryOnly ? `${bar}\n` : '' + | ||
const detailed = !summaryOnly && '' + | ||
`${bar}\n` + | ||
@@ -69,2 +69,4 @@ `file: ${buf}${id}\n` + | ||
formatted += summaryOnly ? `${bar}\n` : detailed; | ||
if (!hideDeps && !summaryOnly) { | ||
@@ -131,5 +133,3 @@ m.dependents.forEach((d) => { | ||
if (limit || limit === 0) modules = modules.slice(0, limit); | ||
modules = modules.map((m) => { | ||
modules = modules.map((m, i) => { | ||
m.dependents = deps[m.id] || []; | ||
@@ -140,3 +140,4 @@ m.percent = Math.min(((m.size / tmpBdlSize) * 100).toFixed(2), 100); | ||
const filtered = applyFilter && !applyFilter(filter, m); | ||
if (filtered && filterSummary) return null | ||
const limited = !Number.isNaN(+limit) && i >= limit; | ||
if ((limited || filtered) && filterSummary) return null | ||
@@ -146,3 +147,3 @@ bundleSize += m.size; | ||
return filtered ? null : m | ||
return (limited || filtered) ? null : m | ||
}).filter((m) => m); | ||
@@ -149,0 +150,0 @@ |
@@ -59,3 +59,3 @@ 'use strict' | ||
formatted += summaryOnly ? `${bar}\n` : '' + | ||
const detailed = !summaryOnly && '' + | ||
`${bar}\n` + | ||
@@ -69,2 +69,4 @@ `file: ${buf}${id}\n` + | ||
formatted += summaryOnly ? `${bar}\n` : detailed | ||
if (!hideDeps && !summaryOnly) { | ||
@@ -131,5 +133,3 @@ m.dependents.forEach((d) => { | ||
if (limit || limit === 0) modules = modules.slice(0, limit) | ||
modules = modules.map((m) => { | ||
modules = modules.map((m, i) => { | ||
m.dependents = deps[m.id] || [] | ||
@@ -140,3 +140,4 @@ m.percent = Math.min(((m.size / tmpBdlSize) * 100).toFixed(2), 100) | ||
const filtered = applyFilter && !applyFilter(filter, m) | ||
if (filtered && filterSummary) return null | ||
const limited = !Number.isNaN(+limit) && i >= limit | ||
if ((limited || filtered) && filterSummary) return null | ||
@@ -146,3 +147,3 @@ bundleSize += m.size | ||
return filtered ? null : m | ||
return (limited || filtered) ? null : m | ||
}).filter((m) => m) | ||
@@ -149,0 +150,0 @@ |
{ | ||
"name": "rollup-plugin-analyzer", | ||
"version": "3.3.0", | ||
"version": "4.0.0", | ||
"description": "Mad metrics for your rollup bundles, know all the things", | ||
@@ -50,9 +50,9 @@ "engines": { | ||
"devDependencies": { | ||
"husky": "^4.2.5", | ||
"mvt": "4.1.0", | ||
"husky": "^4.3.6", | ||
"mvt": "4.1.1", | ||
"rollup": "npm:rollup@latest", | ||
"rollup100": "npm:rollup@1.0.x", | ||
"standard": "^14.3.4" | ||
"standard": "^16.0.3" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -1,22 +0,23 @@ | ||
# rollup-plugin-analyzer [![NPM version](https://badge.fury.io/js/rollup-plugin-analyzer.svg)](https://npmjs.org/package/rollup-plugin-analyzer) [![Code Style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) [![Build Status](https://travis-ci.com/doesdev/rollup-plugin-analyzer.svg)](https://travis-ci.com/doesdev/rollup-plugin-analyzer) ![Supported Node Versions](https://img.shields.io/node/v/rollup-plugin-analyzer) | ||
# rollup-plugin-analyzer | ||
> Mad metrics for your rollup bundles, know all the things | ||
## rollup-plugin-analyzer | ||
[![npm](https://img.shields.io/npm/v/rollup-plugin-analyzer?style=for-the-badge)](https://npmjs.org/package/rollup-plugin-analyzer) [![Travis (.com)](https://img.shields.io/travis/com/doesdev/rollup-plugin-analyzer?style=for-the-badge)](https://travis-ci.com/doesdev/rollup-plugin-analyzer) [![Dependents (via libraries.io)](https://img.shields.io/librariesio/dependents/npm/rollup-plugin-analyzer?style=for-the-badge)](https://github.com/doesdev/rollup-plugin-analyzer/network/dependents) [![npm](https://img.shields.io/npm/dm/rollup-plugin-analyzer?style=for-the-badge)](https://npmcharts.com/compare/rollup-plugin-analyzer?minimal=true&interval=7) | ||
See what's bloating your bundle, how treeshaking has treated you, and other | ||
great stuff. Perfect for console printing an analysis of your bundle or | ||
integrating in your CI workflows. | ||
## TOC | ||
### Comes in two scrumptious flavors: | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
+ [Importing or Requiring](#importing-or-requiring) | ||
- [Import as ES Module](#import-as-es-module) | ||
- [Requiring as CJS](#requiring-as-cjs) | ||
+ [Usage from rollup config](#usage-from-rollup-config) | ||
+ [Usage from build script](#usage-from-build-script) | ||
+ [CI usage example](#ci-usage-example) | ||
+ [Example results](#results) | ||
+ [Example results (with `summaryOnly` enabled)](#results--with--summaryonly--enabled-) | ||
- [Options](#options) | ||
- [FAQ](#faq) | ||
- [License](#license) | ||
#### [rollup-plugin-analyzer](https://github.com/doesdev/rollup-plugin-analyzer) | ||
Adding as a plugin to your rollup config or build script will allow you to | ||
print a well formatted analysis to the console upon bundling or get a full | ||
analysis object for CI purposes. | ||
#### [rollup-config-analyzer](https://github.com/doesdev/rollup-config-analyzer) | ||
If using Rollup's CLI to bundle with no additional config, pass | ||
`-c node:rollup-config-analyzer` to print a well formatted analysis to your console. | ||
## Install | ||
@@ -160,3 +161,3 @@ | ||
- default: `false` | ||
- description: If `true` the `filter` option will also remove any filtered out module data from the summary | ||
- description: If `true` the `filter` and `limit` options will also remove any filtered out module data from the summary | ||
- **root** - *optional* | ||
@@ -218,10 +219,18 @@ - type: String | ||
## Other considerations | ||
## FAQ | ||
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. | ||
#### 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](https://github.com/TrySound/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](https://github.com/doesdev) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40027
395
235