Registry / devops / esbuild-analyzer

esbuild-analyzer

JSON →
library0.2.0jsnpmunverified

A visualizer and analyzer for esbuild builds that generates an interactive HTML report from esbuild's metafile output. Version 0.2.0 is the current stable release; the package is maintained sporadically. It provides both a plugin API (for .build) and a standalone sync function (getEsbuildAnalyzerHtml) plus a CLI tool. Unlike webpack-bundle-analyzer, it is esbuild-native and does not require additional bundler integrations.

npm install esbuild-analyzer
INSTALL
IMPORT
SIG · ESBUILD-ANALYZER
E
esbuild-analyzer
devopsjavascriptv0.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.

AnalyzerPlugin
import AnalyzerPlugin from 'esbuild-analyzer'
const AnalyzerPlugin = require('esbuild-analyzer')
Default CommonJS export; ESM not supported. Use require or dynamic import.
getEsbuildAnalyzerHtml
import { getEsbuildAnalyzerHtml } from 'esbuild-analyzer'
const getEsbuildAnalyzerHtml = require('esbuild-analyzer').getEsbuildAnalyzerHtml
Named export for synchronous usage with buildSync; available as a named export.
AnalyzerPlugin (CLI)
npx esbuild-analyzer --metafile=meta.json --outfile=report.html
CLI usage does not require imports; runs as a binary.

Shows how to use esbuild-analyzer as a plugin during esbuild's async build, generating an interactive HTML report.

const esbuild = require('esbuild'); const AnalyzerPlugin = require('esbuild-analyzer'); async function build() { const result = await esbuild.build({ entryPoints: ['src/index.js'], outdir: 'dist', bundle: true, metafile: true, write: false, plugins: [AnalyzerPlugin()], }); console.log('Analysis complete. Open generated HTML in browser.'); } build().catch(console.error);
esbuild-analyzer --version
Debug
Known issues
gotchaThe plugin requires `metafile: true` in esbuild options; otherwise it does nothing.
fix
Always set `metafile: true` in your esbuild build options.
affects: >=0.1.0
gotchaThe plugin must be listed in the `plugins` array; it does not work as a standalone function.
fix
Pass `plugins: [AnalyzerPlugin()]` to the esbuild build call.
affects: >=0.1.0
breakingBefore v0.2.0, the plugin was exported as a default export only; named exports were added in v0.2.0.
fix
Import the default export: `const AnalyzerPlugin = require('esbuild-analyzer');` or use `import AnalyzerPlugin from 'esbuild-analyzer'`.
affects: <0.2.0
deprecatedThe package does not support ESM; using `import` may fail in Node ESM mode.
fix
Use `require` or dynamic import. Or wrap in a CommonJS module.
affects: >=0.1.0
gotchaThe CLI expects the metafile to be generated separately; it does not run esbuild itself.
fix
First run `esbuild --metafile=meta.json` then `npx esbuild-analyzer --metafile=meta.json`.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'esbuild-analyzer'
Package not installed or not in node_modules.
fix
Run `npm install -D esbuild-analyzer`.
TypeError: AnalyzerPlugin is not a function
Incorrect import style; the default export is a function.
fix
Use `const AnalyzerPlugin = require('esbuild-analyzer')` (CommonJS) or `import AnalyzerPlugin from 'esbuild-analyzer'` (ESM not supported).
Error: build failed with 0 errors?
Missing `metafile: true` in esbuild options.
fix
Add `metafile: true` to your esbuild build configuration.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency required to produce metafile output; the plugin hooks into esbuild's build process
Agent activity
11 hits · last 30 days
node
10
Amazon
1
Resources
esbuild-analyzer — npm install esbuild-analyzer · libregistry