{"id":22021,"library":"rollup-plugin-extract-bundle-tree","title":"rollup-plugin-extract-bundle-tree","description":"Rollup plugin (v1.2.0) that exports the bundle module tree as a JSON file for analysis or visualization. It provides per-file information including chunk name, entry/dynamic entry flags, asset detection, imports, and dynamic imports. The plugin is lightweight and has no dependencies beyond Rollup >=1.9.0. It is ideal for build pipeline introspection, dependency mapping, or custom tooling.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/domingues/rollup-plugin-extract-bundle-tree","tags":["javascript","rollup-plugin","bundle"],"install":[{"cmd":"npm install rollup-plugin-extract-bundle-tree","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-extract-bundle-tree","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-extract-bundle-tree","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to function as a Rollup plugin","package":"rollup","optional":false}],"imports":[{"note":"Package is ESM-only and exports a default function. CommonJS require will not work.","wrong":"const bundleTree = require('rollup-plugin-extract-bundle-tree')","symbol":"bundleTree","correct":"import bundleTree from 'rollup-plugin-extract-bundle-tree'"},{"note":"Invalid named import; use default import.","wrong":"import { bundleTree } from 'rollup-plugin-extract-bundle-tree'","symbol":"bundleTree","correct":"import bundleTree from 'rollup-plugin-extract-bundle-tree'"},{"note":"The options object accepts a `file` string (output path) and optionally `json` for custom JSON formatting.","wrong":"","symbol":"bundleTree options","correct":"bundleTree({ file: 'tree.json' })"}],"quickstart":{"code":"// rollup.config.js\nimport bundleTree from 'rollup-plugin-extract-bundle-tree';\n\nexport default {\n  input: 'src/index.js',\n  output: { dir: 'dist', format: 'esm' },\n  plugins: [\n    bundleTree({ file: 'bundle-tree.json' })\n  ]\n}","lang":"javascript","description":"Basic Rollup configuration using the plugin to export the bundle tree to bundle-tree.json."},"warnings":[{"fix":"When parsing output, check for the existence of `chunkName` before using it or rely on `isAsset` flag.","message":"The plugin outputs a JSON file containing all modules, including assets. Assets are only identified by `isAsset: true`; the `chunkName` field may be absent for assets.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Treat `assetImports` as optional and default to an empty array if missing.","message":"The `assetImports` field in the output only appears for chunks that import assets; it is not present for all entries. This can cause confusion when iterating over the tree.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade Node.js to version 14 or higher.","message":"Removed Node.js 10 and 12 support; requires Node >=14.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import syntax or set type: 'module' in package.json, or use dynamic import().","cause":"Using CommonJS require() to import the ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"},{"fix":"Use import bundleTree from 'rollup-plugin-extract-bundle-tree'.","cause":"Using named import { bundleTree } instead of default import.","error":"TypeError: bundleTree is not a function"},{"fix":"Install rollup: npm install --save-dev rollup.","cause":"Missing peer dependency rollup.","error":"Error: Cannot find module 'rollup'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}