{"id":21220,"library":"esbuild-analyzer","title":"esbuild-analyzer","description":"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.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/shuoshubao/esbuild-analyzer","tags":["javascript","esbuild","plugin","analyze","analyzer","visualizer"],"install":[{"cmd":"npm install esbuild-analyzer","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-analyzer","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-analyzer","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required to produce metafile output; the plugin hooks into esbuild's build process","package":"esbuild","optional":false}],"imports":[{"note":"Default CommonJS export; ESM not supported. Use require or dynamic import.","wrong":"const AnalyzerPlugin = require('esbuild-analyzer')","symbol":"AnalyzerPlugin","correct":"import AnalyzerPlugin from 'esbuild-analyzer'"},{"note":"Named export for synchronous usage with buildSync; available as a named export.","wrong":"const getEsbuildAnalyzerHtml = require('esbuild-analyzer').getEsbuildAnalyzerHtml","symbol":"getEsbuildAnalyzerHtml","correct":"import { getEsbuildAnalyzerHtml } from 'esbuild-analyzer'"},{"note":"CLI usage does not require imports; runs as a binary.","wrong":"","symbol":"AnalyzerPlugin (CLI)","correct":"npx esbuild-analyzer --metafile=meta.json --outfile=report.html"}],"quickstart":{"code":"const esbuild = require('esbuild');\nconst AnalyzerPlugin = require('esbuild-analyzer');\n\nasync function build() {\n  const result = await esbuild.build({\n    entryPoints: ['src/index.js'],\n    outdir: 'dist',\n    bundle: true,\n    metafile: true,\n    write: false,\n    plugins: [AnalyzerPlugin()],\n  });\n  console.log('Analysis complete. Open generated HTML in browser.');\n}\n\nbuild().catch(console.error);","lang":"javascript","description":"Shows how to use esbuild-analyzer as a plugin during esbuild's async build, generating an interactive HTML report."},"warnings":[{"fix":"Always set `metafile: true` in your esbuild build options.","message":"The plugin requires `metafile: true` in esbuild options; otherwise it does nothing.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Pass `plugins: [AnalyzerPlugin()]` to the esbuild build call.","message":"The plugin must be listed in the `plugins` array; it does not work as a standalone function.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Import the default export: `const AnalyzerPlugin = require('esbuild-analyzer');` or use `import AnalyzerPlugin from 'esbuild-analyzer'`.","message":"Before v0.2.0, the plugin was exported as a default export only; named exports were added in v0.2.0.","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"Use `require` or dynamic import. Or wrap in a CommonJS module.","message":"The package does not support ESM; using `import` may fail in Node ESM mode.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"First run `esbuild --metafile=meta.json` then `npx esbuild-analyzer --metafile=meta.json`.","message":"The CLI expects the metafile to be generated separately; it does not run esbuild itself.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install -D esbuild-analyzer`.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'esbuild-analyzer'"},{"fix":"Use `const AnalyzerPlugin = require('esbuild-analyzer')` (CommonJS) or `import AnalyzerPlugin from 'esbuild-analyzer'` (ESM not supported).","cause":"Incorrect import style; the default export is a function.","error":"TypeError: AnalyzerPlugin is not a function"},{"fix":"Add `metafile: true` to your esbuild build configuration.","cause":"Missing `metafile: true` in esbuild options.","error":"Error: build failed with 0 errors?"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}