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

> rollup-plugin-serve@3.0.0 ships CommonJS and ESM builds. Dual package — require() works on Node.js 20, 22, 24 and 26, fails on 18; import works too.

Serve your rolled up bundle

Last verified Sep 9, 2026 against rollup-plugin-serve@3.0.0.

rollup-plugin-serve publishes both a CommonJS entry and a native ESM entry (ESM added in 2.0.0). require("rollup-plugin-serve") works on Node.js 20, 22, 24 and 26 but fails on Node.js 18 (ERR_REQUIRE_ESM). import "rollup-plugin-serve" works alongside it.

## What to do

1. Nothing to change. require("rollup-plugin-serve") works on Node.js 20, 22, 24 and 26 but fails on Node.js 18 (ERR_REQUIRE_ESM). import * as rollupPluginServe from "rollup-plugin-serve" works alongside it; use named imports for what the ESM entry exports.
2. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 3.0.0 (Dec 1, 2023)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 3.0.0
- Native ESM since: 2.0.0
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 51K
- License: MIT

## Runtime test results for rollup-plugin-serve@3.0.0

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

| Runtime | require("rollup-plugin-serve") | import "rollup-plugin-serve" |
|---|---|---|
| Node.js 18 | fails (ERR_REQUIRE_ESM) | 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 rollup-plugin-serve

ES modules:

```js
import * as rollupPluginServe from "rollup-plugin-serve";
```

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

CommonJS:

```js
const rollupPluginServe = require("rollup-plugin-serve");
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 2.0.0 – 3.0.0 | Dual (CommonJS + ESM) | Jun 29, 2022 |
| 0.0.1 – 1.1.1 | CommonJS | Sep 24, 2016 |

## Frequently asked

**Is rollup-plugin-serve ESM-only?**

rollup-plugin-serve@3.0.0 ships CommonJS and ESM builds. rollup-plugin-serve publishes both a CommonJS entry and a native ESM entry (ESM added in 2.0.0). require("rollup-plugin-serve") works on Node.js 20, 22, 24 and 26 but fails on Node.js 18 (ERR_REQUIRE_ESM). import "rollup-plugin-serve" works alongside it.

**Can I require rollup-plugin-serve?**

Yes. rollup-plugin-serve ships a CommonJS entry alongside the native ESM entry. require("rollup-plugin-serve") works on Node.js 20, 22, 24 and 26 but fails on Node.js 18 (ERR_REQUIRE_ESM).

**Does rollup-plugin-serve work in Bun?**

Yes. import "rollup-plugin-serve" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does rollup-plugin-serve ship TypeScript types?**

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

## Links

- [rollup-plugin-serve on npm](https://www.npmjs.com/package/rollup-plugin-serve)
- [Source repository](https://github.com/thgh/rollup-plugin-serve)
- [HTML version](https://canirequire.com/package/rollup-plugin-serve/)
- [JSON version](https://canirequire.com/package/rollup-plugin-serve.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.
