canirequire

canirequireDual (CommonJS + ESM) › rollup-plugin-dts

Is rollup-plugin-dts ESM-only? Can you require() it?

A rollup plugin that will bundle up your .d.ts definition files.

Last verified Sep 9, 2026 against rollup-plugin-dts@6.5.1. JSON

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

rollup-plugin-dts publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("rollup-plugin-dts") and import "rollup-plugin-dts" both work on every supported Node.js version and in Bun.

Latest
6.5.1 (Aug 4, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
6.5.1
Native ESM since
3.0.0
TypeScript types
Bundled
Node engines
>=20
Weekly downloads
2.0M
License
LGPL-3.0-only

Does rollup-plugin-dts@6.5.1 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("rollup-plugin-dts") from a CommonJS file and import "rollup-plugin-dts" from an ES module.

Runtimerequire("rollup-plugin-dts")import "rollup-plugin-dts"
Node.js 18✗ failsError: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.✗ failsError: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.
Node.js 20✗ failsError: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.✗ failsError: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.
Node.js 22✗ failsError: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.✗ failsError: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.
Node.js 24✗ failsError: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.✗ failsError: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.
Node.js 26✗ failsError: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.✗ failsError: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.
Bun 1.4✗ failserror: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.✗ failserror: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.

A failing require() on a CommonJS package usually means the package needs a browser/DOM global, a peer dependency, or a native binary that is not available in a bare Node.js process.

How to import rollup-plugin-dts

ES modules (import)

import rollupPluginDts from "rollup-plugin-dts";

CommonJS (require)

const rollupPluginDts = require("rollup-plugin-dts");

Module format by version

Derived from the type, main and exports fields of every stable release on npm (81 versions; the newest 60 shown).

VersionsFormatFirst published
3.0.1 – 6.5.1Dual (CommonJS + ESM)Mar 7, 2021
3.0.0ESM-onlyMar 6, 2021
1.1.3 – 2.0.1CommonJSJun 21, 2019

Frequently asked

Is rollup-plugin-dts ESM-only?

rollup-plugin-dts@6.5.1 ships CommonJS and ESM builds. rollup-plugin-dts publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("rollup-plugin-dts") and import "rollup-plugin-dts" both work on every supported Node.js version and in Bun.

Can I require rollup-plugin-dts?

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

Does rollup-plugin-dts work in Bun?

Importing rollup-plugin-dts failed in Bun 1.4 on Sep 9, 2026: error: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.

Does rollup-plugin-dts ship TypeScript types?

Yes. rollup-plugin-dts bundles its own type declarations; no @types package is needed.

Links

Other dual (commonjs + esm) packages

Similar popularity