A visualizer esbuild analyzer
npm i -D esbuild-analyzer
const esbuild = require('esbuild')
const AnalyzerPlugin = require('esbuild-analyzer')
esbuild.build({
entryPoints: ['lib/index.js'],
outdir: 'dist',
bundle: true,
metafile: true,
plugins: [AnalyzerPlugin()]
})
const { writeFileSync } = require('fs')
const esbuild = require('esbuild')
const { getEsbuildAnalyzerHtml } = require('esbuild-analyzer')
const result = esbuild.buildSync({
entryPoints: ['lib/index.js'],
outdir: 'dist',
bundle: true,
metafile: true
})
const html = getEsbuildAnalyzerHtml(result.metafile)
writeFileSync('EsbuildAnalyzer.html', html)
# https://esbuild.github.io/api/#metafile
esbuild lib/index.js --outdir=dist --bundle --metafile=meta.json
npx esbuild-analyzer
# Custom parameters
npx esbuild-analyzer --metafile=meta.json --outfile=EsbuildAnalyzer.html