esbuild-plugin-filesize
raw JSON → 0.4.0 verified Mon Apr 27 auth: no javascript
An ESBuild plugin that displays filesize information for output bundles after build. Current stable version is 0.4.0. The plugin integrates seamlessly with ESBuild and shows file sizes in kilobytes with color-coded output. It is part of the LinbuduLab nx-plugins ecosystem. Unlike other filesize plugins, this one is specifically tailored for ESBuild's plugin API and provides immediate visual feedback in the console. Releases follow semantic versioning but the package is maintained as part of a monorepo with occasional updates.
Common errors
error Error: Cannot find module 'esbuild-plugin-filesize' ↓
cause Package not installed or not in node_modules.
fix
Run npm install esbuild-plugin-filesize --save-dev
error TypeError: filesizePlugin is not a function ↓
cause Imported as named export instead of default export.
fix
Use: import filesizePlugin from 'esbuild-plugin-filesize'
Warnings
gotcha Plugin must be called as a function even with no options: filesizePlugin() not filesizePlugin. ↓
fix Use filesizePlugin() with parentheses.
breaking Version 0.3.0 changed default from showing only uncompressed size to showing both uncompressed and gzipped sizes. ↓
fix Set showGzipped: false to revert to old behavior.
gotcha The plugin does not support ESBuild's 'write: false' mode because it reads files after writing. ↓
fix Ensure 'write' is true or use a different method to get file sizes.
Install
npm install esbuild-plugin-filesize yarn add esbuild-plugin-filesize pnpm add esbuild-plugin-filesize Imports
- default wrong
const filesizePlugin = require('esbuild-plugin-filesize')correctimport filesizePlugin from 'esbuild-plugin-filesize' - filesizePlugin wrong
const { filesizePlugin } = require('esbuild-plugin-filesize')correctimport filesizePlugin from 'esbuild-plugin-filesize' - FilesizePluginOptions (type) wrong
import { FilesizePluginOptions } from 'esbuild-plugin-filesize'correctimport type { FilesizePluginOptions } from 'esbuild-plugin-filesize'
Quickstart
import esbuild from 'esbuild';
import filesizePlugin from 'esbuild-plugin-filesize';
await esbuild.build({
entryPoints: ['app.js'],
bundle: true,
outfile: 'out.js',
plugins: [filesizePlugin()],
// Optional: filesizePlugin({ showGzipped: true })
});