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

> rollup-plugin-dts@6.5.1 declares CommonJS and ESM builds, but require() fails at runtime. Dual package on paper — require() failed in our runtime test.

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

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

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.

## Facts

- 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

## Runtime test results for rollup-plugin-dts@6.5.1

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.

| Runtime | require("rollup-plugin-dts") | import "rollup-plugin-dts" |
|---|---|---|
| Node.js 18 | fails (Error) | fails (Error) |
| Node.js 20 | fails (Error) | fails (Error) |
| Node.js 22 | fails (Error) | fails (Error) |
| Node.js 24 | fails (Error) | fails (Error) |
| Node.js 26 | fails (Error) | fails (Error) |
| Bun 1.4.0 | fails (Error) | fails (Error) |

## How to import rollup-plugin-dts

ES modules:

```js
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:

```js
// 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 (81 versions; the newest 60 shown).

| Versions | Format | First published |
|---|---|---|
| 3.0.1 – 6.5.1 | Dual (CommonJS + ESM) | Mar 7, 2021 |
| 3.0.0 | ESM-only | Mar 6, 2021 |
| 1.1.3 – 2.0.1 | CommonJS | Jun 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

- [rollup-plugin-dts on npm](https://www.npmjs.com/package/rollup-plugin-dts)
- [Source repository](https://github.com/Swatinem/rollup-plugin-dts)
- [HTML version](https://canirequire.com/package/rollup-plugin-dts/)
- [JSON version](https://canirequire.com/package/rollup-plugin-dts.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
