canirequire › Dual (CommonJS + ESM) › @sinonjs/commons
Is @sinonjs/commons ESM-only? Can you require() it?
Simple functions shared among the sinon end user libraries
Last verified Sep 9, 2026 against @sinonjs/commons@4.0.0-alpha.0. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
@sinonjs/commons publishes both a CommonJS entry and a native ESM entry. require("@sinonjs/commons") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "@sinonjs/commons" works alongside it.
What to do
- Nothing to change. require("@sinonjs/commons") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as commons from "@sinonjs/commons" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: types are bundled; install nothing extra.
Does @sinonjs/commons@4.0.0-alpha.0 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("@sinonjs/commons") from a CommonJS file and import "@sinonjs/commons" from an ES module.
| Runtime | require("@sinonjs/commons") | import "@sinonjs/commons" |
|---|---|---|
| Node.js 18 | ✓ works | ✓ 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 @sinonjs/commons
ES modules (import)
import * as commons from "@sinonjs/commons";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const commons = require("@sinonjs/commons");Module 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 (24 versions; the newest 24 shown).
| Versions | Format | First published |
|---|---|---|
| 1.0.0 – 3.0.1 | CommonJS | Aug 3, 2018 |
Frequently asked
Is @sinonjs/commons ESM-only?
@sinonjs/commons@4.0.0-alpha.0 ships CommonJS and ESM builds. @sinonjs/commons publishes both a CommonJS entry and a native ESM entry. require("@sinonjs/commons") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "@sinonjs/commons" works alongside it.
Can I require @sinonjs/commons?
Yes. @sinonjs/commons ships a CommonJS entry alongside the native ESM entry. require("@sinonjs/commons") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.
Does @sinonjs/commons work in Bun?
Yes. import "@sinonjs/commons" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does @sinonjs/commons ship TypeScript types?
Yes. @sinonjs/commons bundles its own type declarations; no @types package is needed.
Links
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- tslib 2.8.1Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
Similar popularity
- terser-webpack-plugin 5.6.1CommonJS
- @radix-ui/react-scroll-area 1.2.18Dual
- glob-to-regexp 0.4.1CommonJS
- @hookform/resolvers 5.9.1Dual
- @smithy/util-middleware 4.5.2CommonJS
- bluebird 3.7.2CommonJS
- @aws-sdk/middleware-recursion-detection 3.972.46CommonJS
- @jest/test-result 30.5.1Dual