Show info about files/packages included with your rollup bundle
94
Build a Rollup plugin that analyzes the original, unminified sizes of modules in a bundle and exports a JSON report.
Your plugin should integrate with Rollup's build process and generate a size analysis report that captures the original source sizes of modules before any transformations or minification.
Create a plugin that:
The plugin should write a file named size-report.json to the output directory containing:
{
"totalSize": 12345,
"modules": [
{
"id": "src/main.js",
"size": 5432
},
{
"id": "node_modules/lodash/index.js",
"size": 6913
}
]
}Where:
totalSize is the sum of all module original sizesmodules is an array of module objects sorted by size (largest first)id (module path) and size (original bytes)@generates
/**
* Creates a Rollup plugin that analyzes original module sizes
*
* @returns {Object} Rollup plugin object
*/
function sizeAnalyzer() {
// Returns a plugin object with name and generateBundle hook
}
module.exports = sizeAnalyzer;Provides bundle size analysis capabilities for Rollup.
Install with Tessl CLI
npx tessl i tessl/npm-rollup-plugin-sizesdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10