canirequire › ESM-only › size-limit
Is size-limit ESM-only? Can you require() it?
CLI tool for Size Limit
Last verified Sep 9, 2026 against size-limit@13.0.3. Markdown · JSON
ESM-only ESM-only since 10.0.0 — last CommonJS version is 9.0.0
size-limit dropped its CommonJS build in 10.0.0 (October 2023). The last version with a plain require()-able CommonJS entry is 9.0.0, published Sep 5, 2023; it declares support for Node.js ^18.0.0 || >=20.0.0.
On Node.js 22.12+ and newer (size-limit@13.0.3 declares Node.js ^22.18.0 || ^24.0.0 || >=26.0.0), require("size-limit") works with the latest version: Node.js loads synchronous ES modules through require(). Verified on Node.js 22, 24 and 26. Node.js 18 has no require(esm), and size-limit@13.0.3 declares Node.js ^22.18.0 || ^24.0.0 || >=26.0.0, so 18 is outside its supported range anyway.
size-limit@13.0.3 declares engines "^22.18.0 || ^24.0.0 || >=26.0.0", so Node.js 18, 20 are outside its supported range regardless of module format.
What to do
- On Node.js 22.12+ and newer (size-limit@13.0.3 declares Node.js ^22.18.0 || ^24.0.0 || >=26.0.0), require("size-limit") works with the latest version: Node.js loads synchronous ES modules through require(). Verified on Node.js 22, 24 and 26.
- From a CommonJS file, use a dynamic import inside an async function: const sizeLimit = await import("size-limit"). That works on every Node.js version the package supports (^22.18.0 || ^24.0.0 || >=26.0.0).
- If you need a synchronous require() or run Node.js 18: npm install size-limit@9.0.0, the last CommonJS release (published Sep 5, 2023); it declares Node.js ^18.0.0 || >=20.0.0.
- size-limit@13.0.3 declares engines "^22.18.0 || ^24.0.0 || >=26.0.0", so Node.js 18, 20 are unsupported regardless: upgrade Node.js or pin an older release.
- TypeScript: types are bundled; install nothing extra.
Does size-limit@13.0.3 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("size-limit") from a CommonJS file and import "size-limit" from an ES module.
| Runtime | require("size-limit") | import "size-limit" |
|---|---|---|
| Node.js 18 | ✗ failsERR_REQUIRE_ESM | ✓ works |
| Node.js 20 | ✓ works | ✓ works |
| Node.js 22 | ✓ works | ✓ works |
| Node.js 24 | ✓ works | ✓ works |
| Node.js 26 | ✓ works | ✓ works |
| Bun 1.4.0 | ✓ works | ✓ works |
How to import size-limit
ES modules (import)
import * as sizeLimit from "size-limit";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
// Node.js 22.12+ and newer (verified):
const sizeLimit = require("size-limit");
// Any Node.js version the package supports (^22.18.0 || ^24.0.0 || >=26.0.0), from an async function:
async function main() {
const sizeLimit = await import("size-limit");
}
// Or pin the last CommonJS release (declares Node.js ^18.0.0 || >=20.0.0):
// npm install size-limit@9.0.0Module format by version
Derived from the type, main and exports fields of every stable release on npm, corrected where a runtime test of that version contradicted them (183 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 10.0.0 – 13.0.3 | ESM-only | Oct 23, 2023 |
| 4.10.0 – 9.0.0 | CommonJS | Mar 4, 2021 |
Frequently asked
Is size-limit ESM-only?
size-limit@13.0.3 is ESM-only. size-limit dropped its CommonJS build in 10.0.0 (October 2023). The last version with a plain require()-able CommonJS entry is 9.0.0, published Sep 5, 2023; it declares support for Node.js ^18.0.0 || >=20.0.0.
Which version of size-limit still supports CommonJS / require()?
9.0.0 is the last version of size-limit with a CommonJS build; it declares Node.js ^18.0.0 || >=20.0.0. Install it with "npm install size-limit@9.0.0". Every version from 10.0.0 on is ESM-only.
How do I use size-limit from a CommonJS file?
From a CommonJS file, use a dynamic import inside an async function: const sizeLimit = await import("size-limit"). That works on every Node.js version the package supports (^22.18.0 || ^24.0.0 || >=26.0.0). On Node.js 22.12+ and newer (size-limit@13.0.3 declares Node.js ^22.18.0 || ^24.0.0 || >=26.0.0), require("size-limit") works with the latest version: Node.js loads synchronous ES modules through require(). Verified on Node.js 22, 24 and 26. Alternatively pin size-limit@9.0.0 (declares Node.js ^18.0.0 || >=20.0.0).
Does size-limit work in Bun?
Yes. import "size-limit" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does size-limit ship TypeScript types?
Yes. size-limit bundles its own type declarations; no @types package is needed.
Links
Other esm-only packages
- ansi-styles 7.0.0last CJS
5.2.0 - strip-ansi 7.2.0last CJS
6.0.1 - commander 15.0.0last CJS
14.0.3 - supports-color 11.0.0last CJS
8.1.1 - chalk 6.0.0last CJS
4.1.2 - string-width 8.2.2last CJS
4.2.3 - ansi-regex 6.3.0last CJS
5.0.1 - escape-string-regexp 5.0.0last CJS
4.0.0
Similar popularity
- rollup-plugin-postcss 4.0.2CommonJS
- normalize.css 8.0.1No entry
- babel-plugin-transform-object-rest-spread 6.26.0CommonJS
- vue-style-loader 4.1.3CommonJS
- koa-router 14.0.0CommonJS
- compression-webpack-plugin 12.0.0CommonJS
- cz-conventional-changelog 3.3.0CommonJS
- @semantic-release/changelog 7.0.0ESM-only