canirequire

canirequireDual (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. JSON

Dual (CommonJS + ESM) Dual package — both require() and import work

@sinonjs/commons publishes both a CommonJS entry and a native ESM entry. require("@sinonjs/commons") and import "@sinonjs/commons" both work on every supported Node.js version and in Bun.

Latest
4.0.0-alpha.0 (Jan 20, 2024)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
3.0.1
TypeScript types
Bundled
Node engines
not declared
License
BSD-3-Clause

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.

Runtimerequire("@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✓ works✓ works

How to import @sinonjs/commons

ES modules (import)

import commons from "@sinonjs/commons";

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 (24 versions; the newest 24 shown).

VersionsFormatFirst published
1.0.0 – 3.0.1CommonJSAug 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") and import "@sinonjs/commons" both work on every supported Node.js version and in Bun.

Can I require @sinonjs/commons?

Yes. @sinonjs/commons ships a CommonJS entry, so require("@sinonjs/commons") works on every Node.js version, alongside the native ESM entry for import.

Does @sinonjs/commons work in Bun?

Yes. import "@sinonjs/commons" loaded successfully in Bun 1.4 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

Similar popularity