Registry / devops / rollup-plugin-extract-bundle-tree

rollup-plugin-extract-bundle-tree

JSON →
library1.2.0jsnpmunverified

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.

npm install rollup-plugin-extract-bundle-tree
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-EXTR
R
rollup-plugin-extract-bundle-tree
devopsjavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

bundleTree
import bundleTree from 'rollup-plugin-extract-bundle-tree'
const bundleTree = require('rollup-plugin-extract-bundle-tree')
Package is ESM-only and exports a default function. CommonJS require will not work.
bundleTree
import bundleTree from 'rollup-plugin-extract-bundle-tree'
import { bundleTree } from 'rollup-plugin-extract-bundle-tree'
Invalid named import; use default import.
bundleTree options
bundleTree({ file: 'tree.json' })
The options object accepts a `file` string (output path) and optionally `json` for custom JSON formatting.

Basic Rollup configuration using the plugin to export the bundle tree to bundle-tree.json.

// rollup.config.js import bundleTree from 'rollup-plugin-extract-bundle-tree'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'esm' }, plugins: [ bundleTree({ file: 'bundle-tree.json' }) ] }
Debug
Known issues
gotchaThe 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.
fix
When parsing output, check for the existence of `chunkName` before using it or rely on `isAsset` flag.
affects: >=1.0.0
gotchaThe `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.
fix
Treat `assetImports` as optional and default to an empty array if missing.
affects: >=1.0.0
breakingRemoved Node.js 10 and 12 support; requires Node >=14.
fix
Upgrade Node.js to version 14 or higher.
affects: >=2.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using CommonJS require() to import the ESM-only package.
fix
Use import syntax or set type: 'module' in package.json, or use dynamic import().
TypeError: bundleTree is not a function
Using named import { bundleTree } instead of default import.
fix
Use import bundleTree from 'rollup-plugin-extract-bundle-tree'.
Error: Cannot find module 'rollup'
Missing peer dependency rollup.
fix
Install rollup: npm install --save-dev rollup.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
rolluprequiredpeer dependency required to function as a Rollup plugin
Agent activity
23 hits · last 30 days
node
18
OpenAI (training)
2
Resources
rollup-plugin-extract-bundle-tree — npm install rollup-plugin-extract-bundle-tree · libregistry