size-limit-node-esbuild

raw JSON →
0.4.0 verified Fri May 01 auth: no javascript

Node esbuild plugin for Size Limit, a lightweight tool to measure JavaScript bundle sizes. Current stable version is 0.4.0, released with major bump to size-limit v11. This plugin enables size-limit to process Node.js bundles using esbuild, an extremely fast bundler and minifier. It integrates with size-limit's configuration system and supports ESM and CJS outputs. Key differentiators: leverages esbuild's speed for CI size checks, supports modern Node.js (^12.20.0 || ^14.18.0 || >=16.0.0), ships TypeScript types, and is part of the un-ts/size-limit ecosystem. Release cadence is irregular, with major breaking changes tracking size-limit major updates. Compared to alternatives like webpack or rollup plugins, it offers faster builds for Node-focused targets.

error ERR_REQUIRE_ESM: require() of ES Module
cause Trying to require('size-limit-node-esbuild') with CommonJS after v0.3.0.
fix
Use import statement or dynamic import(). If using CommonJS, downgrade to v0.2.x or use a dynamic import wrapper.
error Cannot find module 'size-limit-node-esbuild'
cause Package not installed or not listed in dependencies.
fix
Run pnpm add -D size-limit-node-esbuild (or npm/yarn equivalent).
error Invalid plugin: must be a function or an object with a 'name' property
cause Plugin exported incorrectly (e.g., import { sizeLimitNodeEsbuild } instead of default import).
fix
Use import sizeLimitNodeEsbuild from 'size-limit-node-esbuild' (default export).
breaking v0.3.0 migrated to ESM only, breaking CommonJS require()
fix Use ES module imports (import) or switch to dynamic import().
breaking v0.4.0 bumped size-limit peer dependency to v11, breaking compatibility with older size-limit versions
fix Upgrade size-limit to v11 or later.
breaking v0.2.0 upgraded to size-limit v8, breaking configurations for v7
fix Use size-limit v8 or later, or stick with size-limit-node-esbuild@0.1.x.
deprecated No deprecation warnings known for this package.
gotcha Plugin must be placed in the 'plugin' array of size-limit config, not 'plugins'
fix Use 'plugin' (singular) in the config object, as size-limit expects.
gotcha The plugin inherits default esbuild config but may need explicit 'target' for Node version
fix Adjust esbuild options or upgrade to v0.3.1+ which inherits default config properly.
npm install size-limit-node-esbuild
yarn add size-limit-node-esbuild
pnpm add size-limit-node-esbuild

Shows how to configure size-limit with the esbuild plugin to check a Node bundle size.

// Install: pnpm add -D size-limit @size-limit/preset-app size-limit-node-esbuild
// size-limit.config.js
import sizeLimitNodeEsbuild from 'size-limit-node-esbuild';

export default [
  {
    path: "dist/index.js",
    plugin: [sizeLimitNodeEsbuild],
    limit: "10 KB",
  },
];

// Run: npx size-limit