{"id":21914,"library":"rollup-plugin-analyzer","title":"rollup-plugin-analyzer","description":"Rollup plugin that prints detailed bundle analysis metrics to the console, including bundle size, original size, code reduction percentage, module count, and per-file breakdown with rendered size, original size, relative contribution, and dependents. Version 4.0.0 supports Rollup 2.x/3.x. Outputs formatted tables and optional summary-only view. Useful for CI gating via onAnalysis callback. Differentiators include zero dependencies, optional CI integration, and summaryOnly mode for concise output.","status":"active","version":"4.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/doesdev/rollup-plugin-analyzer","tags":["javascript","rollup","plugin","config","import","bundle","file","size","treeshaking"],"install":[{"cmd":"npm install rollup-plugin-analyzer","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-analyzer","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-analyzer","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export only. Named import will result in undefined.","wrong":"import { analyze } from 'rollup-plugin-analyzer'","symbol":"default (analyze)","correct":"import analyze from 'rollup-plugin-analyzer'"},{"note":"CJS require style, works in Node.js < 12 or when type: 'commonjs' is set.","symbol":"default (analyze) via require","correct":"const analyze = require('rollup-plugin-analyzer')"},{"note":"onAnalysis is an option, not a separate export. Pass it as a property.","wrong":"import { onAnalysis } from 'rollup-plugin-analyzer'","symbol":"onAnalysis callback","correct":"import analyze from 'rollup-plugin-analyzer';\nanalyze({ onAnalysis: ({ bundleSize }) => { /* ... */ } })"}],"quickstart":{"code":"// rollup.config.js\nimport analyze from 'rollup-plugin-analyzer';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'cjs'\n  },\n  plugins: [\n    analyze({\n      summaryOnly: true,\n      limit: 10,\n      filter: (module) => !module.includes('node_modules'),\n      onAnalysis: ({ bundleSize, moduleCount }) => {\n        console.log(`Bundle size: ${bundleSize} bytes, modules: ${moduleCount}`);\n      }\n    })\n  ]\n};","lang":"javascript","description":"Configure rollup-plugin-analyzer with summary-only output, limiting to top 10 modules, filtering out node_modules, and calling onAnalysis callback for custom reporting."},"warnings":[{"fix":"Upgrade to Rollup 2.x or later, or pin to rollup-plugin-analyzer@3.x.","message":"Version 4.0.0 drops support for Rollup < 2.x. Ensure you are using Rollup 2 or higher.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Read documentation: rendered size is post-tree-shaking; original size is before.","message":"The module counts rendered size (after tree-shaking), not original size. Be aware when comparing numbers.","severity":"gotcha","affected_versions":"*"},{"fix":"Use `input` and `output` per Rollup 1.x+ API. Example in README may be outdated.","message":"The `entry` and `dest` options in the example are for Rollup < 1.x. Modern Rollup uses `input` and `output`.","severity":"deprecated","affected_versions":"*"},{"fix":"Rename config to rollup.config.mjs or use createRequire from 'module'.","message":"If using ESM in Node.js (e.g., type: 'module'), ensure your config file uses .mjs extension or dynamic import for CJS plugins.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import instead of require() in your rollup config, or rename file to .cjs.","cause":"Node.js trying to require an ESM module when using require() with type: 'module' or .mjs files.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module [...] from [...] not supported."},{"fix":"Use: import analyze from 'rollup-plugin-analyzer' (no braces).","cause":"Using named import { analyze } instead of default import.","error":"TypeError: analyze is not a function"},{"fix":"Run: npm install --save-dev rollup-plugin-analyzer","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'rollup-plugin-analyzer'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}