{"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,"search_vec":"'2':44 '4.0.0':41 'analysi':11 'analyz':4 'breakdown':30 'bundl':10,17,80 'callback':61 'ci':57,67 'code':21 'concis':73 'config':78 'consol':15 'contribut':37 'count':25 'depend':39,65 'detail':9 'differenti':62 'file':29,81 'format':47 'gate':58 'import':79 'includ':16,63 'integr':68 'javascript':75 'metric':12 'mode':71 'modul':24 'onanalysi':60 'option':50,66 'origin':19,34 'output':46,74 'per':28 'per-fil':27 'percentag':23 'plugin':3,6,77 'print':8 'reduct':22 'relat':36 'render':32 'rollup':2,5,43,76 'rollup-plugin-analyz':1 'size':18,20,33,35,82 'summari':52 'summary-on':51 'summaryon':70 'support':42 'tabl':48 'treeshak':83 'use':55 'version':40 'via':59 'view':54 'x/3.x':45 'zero':64","created_at":"2026-04-27T17:02:25.401831+00:00","updated_at":"2026-04-27T17:02:25.401831+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"http://rollup-plugin-analyzer.doesdev.com/","github":"https://github.com/doesdev/rollup-plugin-analyzer","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollup-plugin-analyzer","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}