canirequire

canirequire › Dual (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. Markdown · JSON

Dual (CommonJS + ESM) Dual package on paper — require() failed in our runtime test

rollup-plugin-dts declares both a CommonJS entry and a native ESM entry (ESM added in 3.0.0), but require("rollup-plugin-dts") failed on every Node.js version in our probe: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescri…. That usually means a missing peer dependency, a browser-only global, or a package that refuses to be loaded with require(); see the runtime table below.

What to do

  1. require("rollup-plugin-dts") failed in our probe on every Node.js version (rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescri…); check the package README for peer dependencies or setup before relying on it.
  2. TypeScript: types are bundled; install nothing extra.
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✗ failsError
Node.js 20✗ failsError✗ failsError
Node.js 22✗ failsError✗ failsError
Node.js 24✗ failsError✗ failsError
Node.js 26✗ failsError✗ failsError
Bun 1.4.0✗ failsError✗ failsError

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 * as rollupPluginDts from "rollup-plugin-dts";

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS (require)

// require("rollup-plugin-dts") failed in our probe on every Node.js version we test (rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescri…); see the runtime table.
const rollupPluginDts = require("rollup-plugin-dts");

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 (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 declares CommonJS and ESM builds, but require() fails at runtime. rollup-plugin-dts declares both a CommonJS entry and a native ESM entry (ESM added in 3.0.0), but require("rollup-plugin-dts") failed on every Node.js version in our probe: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescri…. That usually means a missing peer dependency, a browser-only global, or a package that refuses to be loaded with require(); see the runtime table below.

Can I require rollup-plugin-dts?

Not in practice. rollup-plugin-dts declares a CommonJS entry, but require("rollup-plugin-dts") failed on every Node.js version in our probe: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescri…. Check the package README for peer dependencies or setup before relying on it.

Does rollup-plugin-dts work in Bun?

Importing rollup-plugin-dts failed in Bun 1.4.0 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