Show info about files/packages included with your rollup bundle
94
Build a module that calculates percentage distributions for bundle size analysis data.
Create a function that takes bundle data and calculates what percentage each package and file contributes to the total.
{
packages: [
{
name: "lodash",
size: 24000,
files: [
{ path: "core.js", size: 15000 },
{ path: "utils.js", size: 9000 }
]
},
{
name: "react",
size: 6000,
files: [
{ path: "index.js", size: 6000 }
]
}
]
}Calculate two types of percentages:
All percentages must be formatted to 2 decimal places.
{
totalSize: 30000,
packages: [
{
name: "lodash",
size: 24000,
percentage: 80.00, // 24000/30000 * 100
files: [
{ path: "core.js", size: 15000, percentage: 62.50 }, // 15000/24000 * 100
{ path: "utils.js", size: 9000, percentage: 37.50 }
]
},
{
name: "react",
size: 6000,
percentage: 20.00,
files: [
{ path: "index.js", size: 6000, percentage: 100.00 }
]
}
]
}@generates
/**
* Calculates percentage distributions for bundle analysis data
* @param {Object} bundleData - The bundle analysis data
* @param {Array} bundleData.packages - Array of package objects
* @returns {Object} Analysis summary with percentages
*/
function calculatePercentages(bundleData) {
// Implementation here
}
module.exports = { calculatePercentages };Provides bundle size analysis and visualization capabilities for Rollup bundler
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