canirequire

canirequire › Dual (CommonJS + ESM) › rollup-plugin-serve

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

Serve your rolled up bundle

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

Dual (CommonJS + ESM) Dual package — require() works on Node.js 20, 22, 24 and 26, fails on 18; import works too

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.
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

Does rollup-plugin-serve@3.0.0 actually load? Runtime test results

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.

Runtimerequire("rollup-plugin-serve")import "rollup-plugin-serve"
Node.js 18✗ failsERR_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

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-serve

ES modules (import)

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 (require)

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

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 (22 versions; the newest 22 shown).

VersionsFormatFirst published
2.0.0 – 3.0.0Dual (CommonJS + ESM)Jun 29, 2022
0.0.1 – 1.1.1CommonJSSep 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

Other dual (commonjs + esm) packages

Similar popularity