rollup-plugin-sizes
Advanced tools
Comparing version 0.5.1 to 1.0.0
121
index.js
@@ -41,3 +41,3 @@ /* eslint-disable no-console */ | ||
let input; | ||
let base; | ||
let bases; | ||
@@ -55,64 +55,77 @@ if(!options) { | ||
options : (config) => { | ||
input = config.input; | ||
base = path.dirname(config.input); | ||
const { input : original } = config; | ||
if(Array.isArray(original)) { | ||
input = original; | ||
} else if(typeof original === "object") { | ||
input = Object.values(original); | ||
} else { | ||
input = [ original ]; | ||
} | ||
bases = input.map((file) => path.dirname(file)); | ||
}, | ||
// Spit out stats during bundle generation | ||
ongenerate : (details) => { | ||
let total = 0; | ||
const data = {}; | ||
const totals = []; | ||
const ids = Object.keys(details.bundle.modules); | ||
ids.forEach((id) => { | ||
const module = details.bundle.modules[id]; | ||
let parsed; | ||
// Handle rollup-injected helpers | ||
if(id.indexOf("\u0000") === 0) { | ||
parsed = { | ||
name : "rollup helpers", | ||
basedir : "", | ||
path : id.replace("\u0000", "") | ||
}; | ||
} else { | ||
parsed = parse(id); | ||
if(!parsed) { | ||
generateBundle : (_, bundles) => { | ||
Object.values(bundles).forEach((bundle, idx) => { | ||
const base = bases[idx]; | ||
let total = 0; | ||
const data = {}; | ||
const totals = []; | ||
const ids = Object.keys(bundle.modules); | ||
ids.forEach((id) => { | ||
const module = bundle.modules[id]; | ||
let parsed; | ||
// Handle rollup-injected helpers | ||
if(id.indexOf("\u0000") === 0) { | ||
parsed = { | ||
name : "app", | ||
basedir : base, | ||
path : path.relative(base, id) | ||
name : "rollup helpers", | ||
basedir : "", | ||
path : id.replace("\u0000", ""), | ||
}; | ||
} else { | ||
parsed = parse(id); | ||
if(!parsed) { | ||
parsed = { | ||
name : "app", | ||
basedir : base, | ||
path : path.relative(base, id), | ||
}; | ||
} | ||
} | ||
} | ||
if(!(parsed.name in data)) { | ||
data[parsed.name] = []; | ||
} | ||
data[parsed.name].push(Object.assign(parsed, { size : module.originalLength })); | ||
}); | ||
// Sum all files in each chunk | ||
Object.entries(data).forEach(([ name, files ]) => { | ||
const sum = files.reduce((out, { size }) => out + size, 0); | ||
total += sum; | ||
totals.push({ | ||
name, | ||
size : sum | ||
if(!(parsed.name in data)) { | ||
data[parsed.name] = []; | ||
} | ||
data[parsed.name].push(Object.assign(parsed, { size : module.originalLength })); | ||
}); | ||
// Sum all files in each chunk | ||
Object.entries(data).forEach(([ name, files ]) => { | ||
const sum = files.reduce((out, { size }) => out + size, 0); | ||
total += sum; | ||
totals.push({ | ||
name, | ||
size : sum, | ||
}); | ||
}); | ||
report({ | ||
input : input[idx], | ||
data, | ||
totals, | ||
total, | ||
options, | ||
}); | ||
}); | ||
report({ | ||
input, | ||
data, | ||
totals, | ||
total, | ||
options | ||
}); | ||
} | ||
}, | ||
}; | ||
}; |
{ | ||
"name": "rollup-plugin-sizes", | ||
"version": "0.5.1", | ||
"version": "1.0.0", | ||
"description": "Show info about files/packages included with your rollup bundle", | ||
@@ -12,5 +12,7 @@ "main": "index.js", | ||
"lint": "eslint .", | ||
"release": "npm version -m \"v%s\"", | ||
"test": "node ./test/test.js && npm run lint", | ||
"preversion": "npm test" | ||
"test": "jest", | ||
"release": "npm version", | ||
"preversion": "npm test", | ||
"version": "conventional-changelog --preset angular --infile CHANGELOG.md --same-file && git add CHANGELOG.md", | ||
"postversion": "git push --follow-tags && npm publish" | ||
}, | ||
@@ -27,7 +29,9 @@ "keywords": [ | ||
"@tivac/eslint-config": "^2.3.1", | ||
"eslint": "^5.14.1", | ||
"rollup": "^1.2.2" | ||
"conventional-changelog-cli": "^2.0.28", | ||
"eslint": "^6.1.0", | ||
"jest": "^24.9.0", | ||
"rollup": "^1.27.8" | ||
}, | ||
"dependencies": { | ||
"filesize": "^4.1.2", | ||
"filesize": "^6.0.1", | ||
"module-details-from-path": "^1.0.3" | ||
@@ -34,0 +38,0 @@ }, |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
12133
5
104
1
5
+ Addedfilesize@6.4.0(transitive)
- Removedfilesize@4.2.1(transitive)
Updatedfilesize@^6.0.1