canirequire

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

  1. 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.
  2. TypeScript: types are bundled; install nothing extra.
Latest
1.7.2 (Mar 1, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
1.7.2
Native ESM since
1.3.0
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
47.1M
License
MIT

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.

Runtimerequire("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).

VersionsFormatFirst published
1.3.0 – 1.7.2Dual (CommonJS + ESM)Jul 27, 2023
0.1.0 – 1.2.0CommonJSJan 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

Similar popularity