canirequire › Dual (CommonJS + ESM) › tiny-invariant
Is tiny-invariant ESM-only? Can you require() it?
A tiny invariant function
Last verified Sep 9, 2026 against tiny-invariant@1.3.3. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
tiny-invariant publishes both a CommonJS entry and a native ESM entry (ESM added in 1.3.0). require("tiny-invariant") and import "tiny-invariant" both work on every supported Node.js version and in Bun.
Does tiny-invariant@1.3.3 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("tiny-invariant") from a CommonJS file and import "tiny-invariant" from an ES module.
| Runtime | require("tiny-invariant") | import "tiny-invariant" |
|---|---|---|
| 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 tiny-invariant
ES modules (import)
import tinyInvariant from "tiny-invariant";CommonJS (require)
const tinyInvariant = require("tiny-invariant");Module format by version
Derived from the type, main and exports fields of every stable release on npm (16 versions; the newest 16 shown).
| Versions | Format | First published |
|---|---|---|
| 1.3.0 – 1.3.3 | Dual (CommonJS + ESM) | Sep 28, 2022 |
| 0.0.1 – 1.2.0 | CommonJS | Apr 17, 2018 |
Frequently asked
Is tiny-invariant ESM-only?
tiny-invariant@1.3.3 ships CommonJS and ESM builds. tiny-invariant publishes both a CommonJS entry and a native ESM entry (ESM added in 1.3.0). require("tiny-invariant") and import "tiny-invariant" both work on every supported Node.js version and in Bun.
Can I require tiny-invariant?
Yes. tiny-invariant ships a CommonJS entry, so require("tiny-invariant") works on every Node.js version, alongside the native ESM entry for import.
Does tiny-invariant work in Bun?
Yes. import "tiny-invariant" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does tiny-invariant ship TypeScript types?
Yes. tiny-invariant 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
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- jest-regex-util 30.5.0Dual
- safe-array-concat 1.1.4CommonJS
- clone 2.1.2CommonJS
- tsconfig-paths 4.2.0CommonJS
- @emnapi/runtime 1.11.3Dual
- is-negative-zero 2.0.3CommonJS
- for-each 0.3.5CommonJS
- normalize-path 3.0.0CommonJS