canirequire › Dual (CommonJS + ESM) › @ungap/structured-clone
Is @ungap/structured-clone ESM-only? Can you require() it?
A structuredClone polyfill
Last verified Sep 9, 2026 against @ungap/structured-clone@1.4.0. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
@ungap/structured-clone publishes both a CommonJS entry and a native ESM entry (ESM added in 0.0.0). require("@ungap/structured-clone") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "@ungap/structured-clone" works alongside it.
What to do
- Nothing to change. require("@ungap/structured-clone") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as structuredClone from "@ungap/structured-clone" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: npm install -D @types/ungap__structured-clone
Does @ungap/structured-clone@1.4.0 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("@ungap/structured-clone") from a CommonJS file and import "@ungap/structured-clone" from an ES module.
| Runtime | require("@ungap/structured-clone") | import "@ungap/structured-clone" |
|---|---|---|
| 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 @ungap/structured-clone
ES modules (import)
import * as structuredClone from "@ungap/structured-clone";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const structuredClone = require("@ungap/structured-clone");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 (27 versions; the newest 27 shown).
| Versions | Format | First published |
|---|---|---|
| 0.0.0 – 1.4.0 | Dual (CommonJS + ESM) | Oct 29, 2021 |
Frequently asked
Is @ungap/structured-clone ESM-only?
@ungap/structured-clone@1.4.0 ships CommonJS and ESM builds. @ungap/structured-clone publishes both a CommonJS entry and a native ESM entry (ESM added in 0.0.0). require("@ungap/structured-clone") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "@ungap/structured-clone" works alongside it.
Can I require @ungap/structured-clone?
Yes. @ungap/structured-clone ships a CommonJS entry alongside the native ESM entry. require("@ungap/structured-clone") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.
Does @ungap/structured-clone work in Bun?
Yes. import "@ungap/structured-clone" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does @ungap/structured-clone ship TypeScript types?
Not bundled. Install the community types with "npm install -D @types/ungap__structured-clone".
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
- jws 4.0.1CommonJS
- typescript-eslint 8.70.0CommonJS
- jest-message-util 30.5.1Dual
- core-util-is 1.0.3CommonJS
- @vitest/mocker 5.0.0ESM-only
- cssesc 3.0.0CommonJS
- get-symbol-description 1.1.0CommonJS
- jwa 2.0.1CommonJS