canirequire

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

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

class-variance-authority publishes both a CommonJS entry and a native ESM entry (ESM added in 0.5.0). require("class-variance-authority") and import "class-variance-authority" both work on every supported Node.js version and in Bun.

Latest
0.7.1 (Nov 26, 2024)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
0.7.1
Native ESM since
0.5.0
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
54.3M
License
Apache-2.0

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.

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

How to import class-variance-authority

ES modules (import)

import classVarianceAuthority from "class-variance-authority";

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

VersionsFormatFirst published
0.5.0 – 0.7.1Dual (CommonJS + ESM)Apr 2, 2023
0.0.0 – 0.4.0CommonJSJan 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") and import "class-variance-authority" both work on every supported Node.js version and in Bun.

Can I require class-variance-authority?

Yes. class-variance-authority ships a CommonJS entry, so require("class-variance-authority") works on every Node.js version, alongside the native ESM entry for import.

Does class-variance-authority work in Bun?

Yes. import "class-variance-authority" loaded successfully in Bun 1.4 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

Similar popularity