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
- 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.
- TypeScript: types are bundled; install nothing extra.
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.
| Runtime | require("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).
| 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
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- tslib 2.8.1Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
Similar popularity
- rollup-plugin-livereload 2.0.5CommonJS
- ember-ajax 5.1.2CommonJS
- mocha-lcov-reporter 1.3.0CommonJS
- @oclif/dev-cli 1.26.10CommonJS
- ember-disable-prototype-extensions 1.1.3CommonJS
- gulp-minify-css 1.2.4CommonJS
- tsdx 2.0.0ESM-only
- jasmine-node 3.0.0CommonJS