canirequire › ESM-only › @size-limit/preset-small-lib
Is @size-limit/preset-small-lib ESM-only? Can you require() it?
Size Limit preset for small open source libraries
Last verified Sep 9, 2026 against @size-limit/preset-small-lib@13.0.3. Markdown · JSON
ESM-only ESM-only since 10.0.0 — last CommonJS version is 9.0.0
@size-limit/preset-small-lib 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.
On Node.js 20.19+, 22.12+ and newer, require("@size-limit/preset-small-lib") works with the latest version: Node.js loads synchronous ES modules through require(). Verified on Node.js 20, 22, 24 and 26. On Node.js 18, which has no require(esm), require("@size-limit/preset-small-lib") fails with ERR_REQUIRE_ESM.
What to do
- On Node.js 20.19+, 22.12+ and newer, require("@size-limit/preset-small-lib") works with the latest version: Node.js loads synchronous ES modules through require(). Verified on Node.js 20, 22, 24 and 26.
- From a CommonJS file, use a dynamic import inside an async function: const presetSmallLib = await import("@size-limit/preset-small-lib"). That works on every Node.js version the package supports.
- If you need a synchronous require() or run Node.js 18: npm install @size-limit/preset-small-lib@9.0.0, the last CommonJS release (published Sep 5, 2023).
- TypeScript: no types are available for @size-limit/preset-small-lib; declare the module yourself if you need them.
Does @size-limit/preset-small-lib@13.0.3 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("@size-limit/preset-small-lib") from a CommonJS file and import "@size-limit/preset-small-lib" from an ES module.
| Runtime | require("@size-limit/preset-small-lib") | import "@size-limit/preset-small-lib" |
|---|---|---|
| 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/preset-small-lib
ES modules (import)
import * as presetSmallLib from "@size-limit/preset-small-lib";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
// Node.js 20.19+, 22.12+ and newer (verified):
const presetSmallLib = require("@size-limit/preset-small-lib");
// Any Node.js version the package supports, from an async function:
async function main() {
const presetSmallLib = await import("@size-limit/preset-small-lib");
}
// Or pin the last CommonJS release:
// npm install @size-limit/preset-small-lib@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 (108 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/preset-small-lib ESM-only?
@size-limit/preset-small-lib@13.0.3 is ESM-only. @size-limit/preset-small-lib 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.
Which version of @size-limit/preset-small-lib still supports CommonJS / require()?
9.0.0 is the last version of @size-limit/preset-small-lib with a CommonJS build. Install it with "npm install @size-limit/preset-small-lib@9.0.0". Every version from 10.0.0 on is ESM-only.
How do I use @size-limit/preset-small-lib from a CommonJS file?
From a CommonJS file, use a dynamic import inside an async function: const presetSmallLib = await import("@size-limit/preset-small-lib"). That works on every Node.js version the package supports. On Node.js 20.19+, 22.12+ and newer, require("@size-limit/preset-small-lib") works with the latest version: Node.js loads synchronous ES modules through require(). Verified on Node.js 20, 22, 24 and 26. Alternatively pin @size-limit/preset-small-lib@9.0.0.
Does @size-limit/preset-small-lib work in Bun?
Yes. import "@size-limit/preset-small-lib" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does @size-limit/preset-small-lib ship TypeScript types?
No. @size-limit/preset-small-lib ships no type declarations and there is no @types package for it.
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
- grunt-contrib-jshint 3.2.0CommonJS
- @babel/plugin-proposal-throw-expressions 8.0.1ESM-only
- rollup-plugin-typescript 1.0.1CommonJS
- gulp-autoprefixer 10.0.0ESM-only
- friendly-errors-webpack-plugin 1.7.0CommonJS
- gulp-clean-css 4.3.0CommonJS
- @babel/plugin-external-helpers 8.0.1ESM-only
- webpack-stream 7.0.0CommonJS