canirequire › Dual (CommonJS + ESM) › dedent
Is dedent ESM-only? Can you require() it?
A string tag that strips indentation from multi-line strings. ⬅️
Last verified Sep 9, 2026 against dedent@1.7.2. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
dedent publishes both a CommonJS entry and a native ESM entry (ESM added in 1.3.0). require("dedent") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "dedent" works alongside it.
What to do
- Nothing to change. require("dedent") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as dedent from "dedent" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: types are bundled; install nothing extra.
Does dedent@1.7.2 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("dedent") from a CommonJS file and import "dedent" from an ES module.
| Runtime | require("dedent") | import "dedent" |
|---|---|---|
| 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 dedent
ES modules (import)
import * as dedent from "dedent";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const dedent = require("dedent");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 (24 versions; the newest 24 shown).
| Versions | Format | First published |
|---|---|---|
| 1.3.0 – 1.7.2 | Dual (CommonJS + ESM) | Jul 27, 2023 |
| 0.1.0 – 1.2.0 | CommonJS | Jan 13, 2015 |
Frequently asked
Is dedent ESM-only?
dedent@1.7.2 ships CommonJS and ESM builds. dedent publishes both a CommonJS entry and a native ESM entry (ESM added in 1.3.0). require("dedent") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "dedent" works alongside it.
Can I require dedent?
Yes. dedent ships a CommonJS entry alongside the native ESM entry. require("dedent") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.
Does dedent work in Bun?
Yes. import "dedent" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does dedent ship TypeScript types?
Yes. dedent 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
- postcss-load-config 6.0.1CommonJS
- char-regex 2.0.2ESM-only
- decimal.js-light 2.5.1CommonJS
- is-binary-path 3.0.0ESM-only
- @rollup/pluginutils 5.4.0Dual
- get-package-type 0.1.0CommonJS
- rfdc 1.4.1CommonJS
- @tanstack/query-core 5.102.8Dual