canirequire โบ Dual (CommonJS + ESM) โบ class-variance-authority
Is class-variance-authority ESM-only? Can you require() it?
Class Variance Authority ๐งฌ
Last verified Sep 9, 2026 against class-variance-authority@0.7.1. Markdown ยท JSON
Dual (CommonJS + ESM) Dual package โ require() works on every Node.js version we test; import works too
class-variance-authority publishes both a CommonJS entry and a native ESM entry (ESM added in 0.5.0). require("class-variance-authority") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "class-variance-authority" works alongside it.
What to do
- Nothing to change. require("class-variance-authority") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as classVarianceAuthority from "class-variance-authority" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: types are bundled; install nothing extra.
Does class-variance-authority@0.7.1 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("class-variance-authority") from a CommonJS file and import "class-variance-authority" from an ES module.
| Runtime | require("class-variance-authority") | import "class-variance-authority" |
|---|---|---|
| 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 class-variance-authority
ES modules (import)
import * as classVarianceAuthority from "class-variance-authority";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const classVarianceAuthority = require("class-variance-authority");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 (18 versions; the newest 18 shown).
| Versions | Format | First published |
|---|---|---|
| 0.5.0 โ 0.7.1 | Dual (CommonJS + ESM) | Apr 2, 2023 |
| 0.0.0 โ 0.4.0 | CommonJS | Jan 26, 2022 |
Frequently asked
Is class-variance-authority ESM-only?
class-variance-authority@0.7.1 ships CommonJS and ESM builds. class-variance-authority publishes both a CommonJS entry and a native ESM entry (ESM added in 0.5.0). require("class-variance-authority") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "class-variance-authority" works alongside it.
Can I require class-variance-authority?
Yes. class-variance-authority ships a CommonJS entry alongside the native ESM entry. require("class-variance-authority") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.
Does class-variance-authority work in Bun?
Yes. import "class-variance-authority" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does class-variance-authority ship TypeScript types?
Yes. class-variance-authority 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
- @csstools/css-calc 3.3.0ESM-only
- @napi-rs/wasm-runtime 1.2.3Dual
- immer 11.1.18Dual
- @inquirer/type 4.1.1ESM-only
- eslint-plugin-react 7.37.5CommonJS
- @bcoe/v8-coverage 1.0.2CommonJS
- micromark-util-types 2.0.2ESM-only
- eslint-import-resolver-node 0.4.0CommonJS