rollup-plugin-analyzer
Advanced tools
Comparing version 2.0.3 to 2.0.4
29
index.js
@@ -117,24 +117,19 @@ 'use strict'; | ||
if (opts.onAnalysis) cb = opts.onAnalysis; | ||
let written; | ||
let modules; | ||
let depMap = {}; | ||
let runAnalysis = (out, bundle, isWrite) => new Promise((resolve, reject) => { | ||
resolve(); | ||
if (written) return | ||
written = true; | ||
if (out.bundle) bundle = out.bundle; | ||
let modules = bundle.modules; | ||
if (!Array.isArray(bundle.modules)) { | ||
modules.forEach((m) => { | ||
let bm = bundle.modules[m.id]; | ||
bm.id = bm.id || m.id; | ||
bm.usedExports = bm.renderedExports || m.renderedExports; | ||
bm.unusedExports = bm.removedExports || m.removedExports; | ||
bm.dependencies = m.dependencies || []; | ||
}); | ||
modules = Object.keys(bundle.modules).map((k) => bundle.modules[k]); | ||
} else { | ||
modules = bundle.modules; | ||
if (Array.isArray(modules)) { | ||
return analyze({modules}, opts, !opts.onAnalysis).then(cb) | ||
} | ||
modules = Object.keys(modules).map((k) => { | ||
let module = Object.assign(modules[k], depMap[k] || {}); | ||
module.usedExports = module.renderedExports; | ||
module.unusedExports = module.removedExports; | ||
return module | ||
}); | ||
return analyze({modules}, opts, !opts.onAnalysis).then(cb) | ||
@@ -148,4 +143,4 @@ }); | ||
if (!chunk || !chunk.orderedModules) return | ||
modules = chunk.orderedModules.map((m) => { | ||
return {id: m.id, dependencies: m.dependencies.map((d) => d.id)} | ||
chunk.orderedModules.forEach(({id, dependencies}) => { | ||
depMap[id] = {id, dependencies: dependencies.map((d) => d.id)}; | ||
}); | ||
@@ -152,0 +147,0 @@ }), |
@@ -115,24 +115,19 @@ 'use strict' | ||
if (opts.onAnalysis) cb = opts.onAnalysis | ||
let written | ||
let modules | ||
let depMap = {} | ||
let runAnalysis = (out, bundle, isWrite) => new Promise((resolve, reject) => { | ||
resolve() | ||
if (written) return | ||
written = true | ||
if (out.bundle) bundle = out.bundle | ||
let modules = bundle.modules | ||
if (!Array.isArray(bundle.modules)) { | ||
modules.forEach((m) => { | ||
let bm = bundle.modules[m.id] | ||
bm.id = bm.id || m.id | ||
bm.usedExports = bm.renderedExports || m.renderedExports | ||
bm.unusedExports = bm.removedExports || m.removedExports | ||
bm.dependencies = m.dependencies || [] | ||
}) | ||
modules = Object.keys(bundle.modules).map((k) => bundle.modules[k]) | ||
} else { | ||
modules = bundle.modules | ||
if (Array.isArray(modules)) { | ||
return analyze({modules}, opts, !opts.onAnalysis).then(cb) | ||
} | ||
modules = Object.keys(modules).map((k) => { | ||
let module = Object.assign(modules[k], depMap[k] || {}) | ||
module.usedExports = module.renderedExports | ||
module.unusedExports = module.removedExports | ||
return module | ||
}) | ||
return analyze({modules}, opts, !opts.onAnalysis).then(cb) | ||
@@ -146,4 +141,4 @@ }) | ||
if (!chunk || !chunk.orderedModules) return | ||
modules = chunk.orderedModules.map((m) => { | ||
return {id: m.id, dependencies: m.dependencies.map((d) => d.id)} | ||
chunk.orderedModules.forEach(({id, dependencies}) => { | ||
depMap[id] = {id, dependencies: dependencies.map((d) => d.id)} | ||
}) | ||
@@ -150,0 +145,0 @@ }), |
{ | ||
"name": "rollup-plugin-analyzer", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Mad metrics for your rollup bundles, know all the things", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -32,3 +32,3 @@ # 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) | ||
```js | ||
import { plugin as analyze } from 'rollup-analyzer-plugin' | ||
import { plugin as analyze } from 'rollup-plugin-analyzer' | ||
@@ -46,3 +46,3 @@ export default { | ||
import { rollup } from 'rollup' | ||
import { plugin as analyze } from 'rollup-analyzer-plugin' | ||
import { plugin as analyze } from 'rollup-plugin-analyzer' | ||
@@ -58,3 +58,3 @@ rollup({ | ||
import { rollup } from 'rollup' | ||
import { plugin as analyze } from 'rollup-analyzer-plugin' | ||
import { plugin as analyze } from 'rollup-plugin-analyzer' | ||
const limitBytes = 1e6 | ||
@@ -165,4 +165,10 @@ | ||
## Other considerations | ||
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) |
17809
171
260