canirequire › Dual (CommonJS + ESM) › @swc/helpers
Is @swc/helpers ESM-only? Can you require() it?
External helpers for the swc project.
Last verified Sep 9, 2026 against @swc/helpers@0.5.23. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
@swc/helpers publishes both a CommonJS entry and a native ESM entry (ESM added in 0.4.15). require("@swc/helpers") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "@swc/helpers" works alongside it.
What to do
- Nothing to change. require("@swc/helpers") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as helpers from "@swc/helpers" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: no types are available for @swc/helpers; declare the module yourself if you need them.
Does @swc/helpers@0.5.23 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("@swc/helpers") from a CommonJS file and import "@swc/helpers" from an ES module.
| Runtime | require("@swc/helpers") | import "@swc/helpers" |
|---|---|---|
| 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 @swc/helpers
ES modules (import)
import * as helpers from "@swc/helpers";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const helpers = require("@swc/helpers");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 (81 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 0.4.15 – 0.5.23 | Dual (CommonJS + ESM) | Aug 17, 2023 |
| 0.3.6 – 0.4.14 | CommonJS | Feb 27, 2022 |
Frequently asked
Is @swc/helpers ESM-only?
@swc/helpers@0.5.23 ships CommonJS and ESM builds. @swc/helpers publishes both a CommonJS entry and a native ESM entry (ESM added in 0.4.15). require("@swc/helpers") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "@swc/helpers" works alongside it.
Can I require @swc/helpers?
Yes. @swc/helpers ships a CommonJS entry alongside the native ESM entry. require("@swc/helpers") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.
Does @swc/helpers work in Bun?
Yes. import "@swc/helpers" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does @swc/helpers ship TypeScript types?
No. @swc/helpers ships no type declarations and there is no @types package for it.
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
- ee-first 1.1.1CommonJS
- has-property-descriptors 1.0.2CommonJS
- css-tree 3.2.1Dual
- internmap 2.0.3ESM-only
- internal-slot 1.1.0CommonJS
- is-string 1.1.1CommonJS
- es-to-primitive 1.3.4CommonJS
- sax 1.6.1CommonJS