Skip to content

Commit 1accfe7

Browse files
committed
Update dev deps, docs, tests
1 parent 2c1fd4f commit 1accfe7

5 files changed

Lines changed: 124 additions & 210 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
44

55
### UNRELEASED
6+
- Remove Rollup 0.60.0 from tests
7+
- Fix incorrect key names in `analysisObject` docs
8+
- Clarify `filter` usage
9+
- Update dev deps
610

711
### [3.2.3](https://github.com/doesdev/rollup-plugin-analyzer/compare/3.2.2...3.2.3)
812

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ module count: 5
148148
- type: Array | String | Function
149149
- default: `null`
150150
- description: Filter module to output in analysis results.
151-
- If a string is passed, checks if module name contains the string. If array it checks the same for each string in the array. If function, return a boolean to indicate if a module should be in analysis results.
151+
- If a string is passed, checks if module name contains the string
152+
- If array it checks the same for each string in the array
153+
- If function, return a boolean to indicate if a module should be in analysis results
154+
- This only suppresses the modules details, it does not affect the summary output
155+
- If you would like it to filter from summary info as well, let us know in [#19](https://github.com/doesdev/rollup-plugin-analyzer/issues/19)
152156
- notes: Function receives `module` object specified below, should return boolean
153157
- **root** - *optional*
154158
- type: String
@@ -203,8 +207,8 @@ module count: 5
203207
- **dependents** *(Array)* - list of dependent module ids / paths
204208
- **percent** *(Number)* - percentage of module size relative to entire bundle
205209
- **reduction** *(Number)* - percentage of rendered size reduction
206-
- **usedExports** *(Array)* - list of used named exports
207-
- **unusedExports** *(Array)* - list of unused named exports
210+
- **renderedExports** *(Array)* - list of used named exports
211+
- **removedExports** *(Array)* - list of unused named exports
208212

209213
## Other considerations
210214

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@
4747
},
4848
"homepage": "http://rollup-plugin-analyzer.doesdev.com/",
4949
"devDependencies": {
50-
"husky": "^4.2.3",
50+
"husky": "^4.2.5",
5151
"mvt": "4.1.0",
5252
"rollup": "npm:rollup@latest",
5353
"rollup100": "npm:rollup@1.0.x",
54-
"rollup60": "npm:rollup@0.60.x",
55-
"standard": "^14.3.3"
54+
"standard": "^14.3.4"
5655
},
5756
"dependencies": {}
5857
}

test/test.js

Lines changed: 18 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const test = require('mvt')
44
const { analyze, formatted, plugin } = require('./../index')
55
const { resolve: resolvePath, join, basename } = require('path')
66
const { rollup: rollupLatest } = require('rollup')
7-
const { rollup: rollup60 } = require('rollup60')
87
const { rollup: rollup100 } = require('rollup100')
98

109
const skipFormatted = true
@@ -17,11 +16,6 @@ const baseOpts = {
1716
output: { format: 'cjs' }
1817
}
1918

20-
const multiInputOpts = {
21-
input: [join(fixtures, 'bundle-a.js'), join(fixtures, 'bundle-b.js')],
22-
output: { format: 'cjs', dir: join(fixtures, 'multi') }
23-
}
24-
2519
const expectHeader = `
2620
-----------------------------
2721
Rollup File Analysis
@@ -64,12 +58,17 @@ rollers.forEach(({ rollup, version, opts, noTreeshake }) => {
6458
assert.truthy('bundleSize' in result)
6559
assert.truthy('bundleOrigSize' in result)
6660
assert.truthy('bundleReduction' in result)
61+
assert.truthy('moduleCount' in result)
6762
assert.truthy('modules' in result)
6863
const firstModule = result.modules[0]
6964
assert.truthy('id' in firstModule)
7065
assert.truthy('size' in firstModule)
66+
assert.truthy('origSize' in firstModule)
7167
assert.truthy('dependents' in firstModule)
7268
assert.truthy('percent' in firstModule)
69+
assert.truthy('reduction' in firstModule)
70+
assert.truthy('renderedExports' in firstModule)
71+
assert.truthy('removedExports' in firstModule)
7372
})
7473

7574
test(`${version}: limit works`, async (assert) => {
@@ -144,6 +143,18 @@ rollers.forEach(({ rollup, version, opts, noTreeshake }) => {
144143
const bundle = await rollup(rollOpts)
145144
await bundle.generate({ format: 'cjs' })
146145
assert.is(results.substr(0, expectHeader.length), expectHeader)
146+
assert.contains(results, 'bundle size:')
147+
assert.contains(results, 'original size:')
148+
assert.contains(results, 'code reduction:')
149+
assert.contains(results, 'module count:')
150+
assert.contains(results, 'file:')
151+
assert.contains(results, 'bundle space:')
152+
assert.contains(results, 'rendered size:')
153+
assert.contains(results, 'original size:')
154+
assert.contains(results, 'code reduction:')
155+
assert.contains(results, 'dependents:')
156+
assert.contains(results, 'used exports:')
157+
assert.contains(results, 'unused exports:')
147158
})
148159

149160
test(`${version}: summaryOnly bar graphs as expected`, async (assert) => {
@@ -190,57 +201,8 @@ rollers.forEach(({ rollup, version, opts, noTreeshake }) => {
190201
assert.is(results.length, 1)
191202
})
192203

193-
if (version === '0.60.x') {
194-
const split1 = `${version}: writes expected heading with experimentalCodeSplitting`
195-
test(split1, async (assert) => {
196-
let results
197-
const writeTo = (r) => { results = r }
198-
const rollOpts = Object.assign(
199-
{ plugins: [plugin({ writeTo })] },
200-
multiInputOpts
201-
)
202-
rollOpts.experimentalCodeSplitting = true
203-
const bundle = await rollup(rollOpts)
204-
await bundle.generate({ format: 'cjs' })
205-
assert.is(results.substr(0, expectHeader.length), expectHeader)
206-
})
207-
208-
const split2 = `${version}: data as expected with experimentalCodeSplitting`
209-
test(split2, async (assert) => {
210-
const results = []
211-
const onAnalysis = (r) => { results.push(r.modules) }
212-
const plugins = [plugin({ onAnalysis, skipFormatted })]
213-
const rollOpts = Object.assign({}, multiInputOpts, { plugins })
214-
rollOpts.experimentalCodeSplitting = true
215-
const bundle = await rollup(rollOpts)
216-
await bundle.write(rollOpts.output)
217-
218-
const imports = [{ id: importA, size: 8238 }, { id: importB, size: 33 }]
219-
imports.forEach((imp, i) => {
220-
const result = results[i]
221-
const imported = result.find((r) => r.id.indexOf(imp.id) !== -1)
222-
assert.truthy(Math.abs(imported.size - imp.size) < 5)
223-
})
224-
})
225-
226-
test.failing(`${version}: callback is only invoked once`, async (assert) => {
227-
let count = 0
228-
const writeTo = () => ++count
229-
230-
const rollOpts = Object.assign(
231-
{ plugins: [plugin({ writeTo })] },
232-
multiInputOpts
233-
)
234-
rollOpts.experimentalCodeSplitting = true
235-
const bundle = await rollup(rollOpts)
236-
await bundle.generate({ format: 'cjs' })
237-
238-
assert.is(count, 1)
239-
})
240-
}
241-
242204
if (version === 'latest') {
243-
test(`${version}: plugin shouldn't cause much overhead`, async (assert) => {
205+
test(`${version}: plugin shouldn't slow down build`, async (assert) => {
244206
let start
245207
const runs = 20
246208
const msDiffThreshold = 50
@@ -269,17 +231,3 @@ rollers.forEach(({ rollup, version, opts, noTreeshake }) => {
269231
})
270232
}
271233
})
272-
273-
test('rollup < 1.0.0 prints warning about support', async (assert) => {
274-
let results = ''
275-
const oldCslErr = console.error
276-
console.error = (...args) => {
277-
results += args.join()
278-
}
279-
const rollOpts = Object.assign({ plugins: [plugin()] }, baseOpts)
280-
const bundle = await rollup60(rollOpts)
281-
await bundle.generate({ format: 'cjs' })
282-
const expect = 'rollup-plugin-analyzer: Rollup version not supported'
283-
assert.is(results.split('\n')[0], expect)
284-
console.error = oldCslErr
285-
})

0 commit comments

Comments
 (0)