{"id":22225,"library":"rollup-plugin-sizes","title":"rollup-plugin-sizes","description":"A Rollup plugin that analyzes bundle composition by showing sizes and percentages for each module and its constituent files. Current stable version 1.1.0 (2024) supports Rollup 2, 3, and 4, and is compatible with Vite. It helps identify bloated libraries by printing a hierarchical breakdown of output chunks, optionally with per-file details. Differentiators: lightweight (only 4 dependencies), simple reporter API, and dual ESM/CJS support. Released under MIT license.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/tivac/rollup-plugin-sizes","tags":["javascript","rollup","filesizes","bundler","rollup-plugin"],"install":[{"cmd":"npm install rollup-plugin-sizes","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-sizes","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-sizes","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required as a plugin for Rollup bundler.","package":"rollup","optional":false}],"imports":[{"note":"Package works with both ESM and CJS; require is valid in Node but ESM is preferred for modern projects.","wrong":"const sizes = require('rollup-plugin-sizes')","symbol":"sizes","correct":"import sizes from 'rollup-plugin-sizes'"},{"note":"The plugin exports a default function, not a named export. Named import will result in undefined.","wrong":"import { sizes } from 'rollup-plugin-sizes'","symbol":"sizes","correct":"import sizes from 'rollup-plugin-sizes'"},{"note":"CJS require works for Node.js projects.","wrong":"","symbol":"sizes","correct":"const sizes = require('rollup-plugin-sizes')"}],"quickstart":{"code":"import sizes from 'rollup-plugin-sizes';\n\nexport default {\n  input: 'src/main.js',\n  output: {\n    dir: 'dist',\n    format: 'esm'\n  },\n  plugins: [\n    sizes({\n      details: true\n    })\n  ]\n};","lang":"javascript","description":"Shows how to add the plugin to a Rollup config, enabling per-file breakdown."},"warnings":[{"fix":"Place sizes() after all other plugins in the plugins array.","message":"Must be the last plugin in the Rollup plugin list to capture final bundle sizes.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use rollup-plugin-sizes@1.0.0 or later with Rollup >=2.","message":"Only works with Rollup 2.x, 3.x, or 4.x. Not compatible with Rollup 1.x.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure the build completes successfully before expecting output.","message":"If no bundle is generated (e.g., due to errors), the plugin will not output any size information.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set details: false (default) to see only top-level module sizes.","message":"The 'details' option may produce very verbose output for large bundles.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'npm install rollup-plugin-sizes --save-dev'.","cause":"Package not installed in node_modules.","error":"Error: Cannot find module 'rollup-plugin-sizes'"},{"fix":"Use 'import sizes from 'rollup-plugin-sizes'' instead of '{ sizes }'.","cause":"Using named import instead of default import.","error":"TypeError: sizes is not a function"},{"fix":"Move sizes() to the end of the plugins array.","cause":"Plugin order incorrect; sizes must be last to get final sizes.","error":"Error: The plugin 'sizes' must be placed after all other plugins."},{"fix":"Use 'sizes({ details: true })' with parentheses.","cause":"Likely passing options incorrectly (e.g., no parentheses).","error":"Error: [object Object] is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}