Show info about files/packages included with your rollup bundle
94
A Rollup plugin that analyzes and categorizes modules in a bundle to help developers understand the composition of their build output.
Build a Rollup plugin that processes bundle information and categorizes each module into one of three types: npm packages, application code, or Rollup helpers. The plugin should provide a breakdown showing how many modules fall into each category and their total sizes.
The plugin must categorize each module in the bundle according to these rules:
\u0000 prefix in their module ID)Create a Rollup plugin that:
generateBundle hook to analyze bundle contents after generationFor each bundle, output to the console:
Example output format:
Bundle: src/index.js
Categories:
- npm packages: 5 modules, 125000 bytes
Packages: lodash, react, express
- app: 3 modules, 45000 bytes
- rollup helpers: 2 modules, 5000 bytesAccess module data from Rollup's bundle chunks:
modules property containing module informationid property (the module's file path or identifier)originalLength property (the original size in bytes)@generates
/**
* Creates a bundle module analyzer plugin
* @returns {object} Rollup plugin object
*/
function bundleModuleAnalyzer() {
// Returns a plugin object with:
// - name: "bundle-module-analyzer"
// - generateBundle hook that analyzes and categorizes modules
}
module.exports = bundleModuleAnalyzer;\u0000 prefix), it correctly categorizes them as "rollup helpers" @testParses module paths to identify npm packages and extract package information.
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