canirequire

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

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

dedent publishes both a CommonJS entry and a native ESM entry (ESM added in 1.3.0). require("dedent") and import "dedent" both work on every supported Node.js version and in Bun.

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✓ works✓ works

How to import dedent

ES modules (import)

import dedent from "dedent";

CommonJS (require)

const dedent = require("dedent");

Module format by version

Derived from the type, main and exports fields of every stable release on npm (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") and import "dedent" both work on every supported Node.js version and in Bun.

Can I require dedent?

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

Does dedent work in Bun?

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