canirequire

canirequireCommonJS › rollup-plugin-peer-deps-external

Is rollup-plugin-peer-deps-external ESM-only? Can you require() it?

Rollup plugin to automatically add a library's peerDependencies to its bundle's external config.

Last verified Sep 9, 2026 against rollup-plugin-peer-deps-external@2.2.4. JSON

CommonJS CommonJS — require() works on every Node.js version

rollup-plugin-peer-deps-external ships CommonJS only. require("rollup-plugin-peer-deps-external") works everywhere. import "rollup-plugin-peer-deps-external" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

It also declares a "module" field, so bundlers such as webpack, Vite and esbuild pick up an ESM build for tree-shaking.

Latest
2.2.4 (Oct 20, 2020)
Module format
CommonJS
Last CommonJS version
2.2.4
TypeScript types
@types/rollup-plugin-peer-deps-external
Node engines
not declared
Weekly downloads
343K
License
MIT

Does rollup-plugin-peer-deps-external@2.2.4 actually load? Runtime test results

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

Runtimerequire("rollup-plugin-peer-deps-external")import "rollup-plugin-peer-deps-external"
Node.js 18✓ works✓ works
Node.js 20✓ works✓ works
Node.js 22✓ works✓ works
Node.js 24✓ works✓ works
Node.js 26✓ works✓ works
Bun 1.4✓ works✓ works

How to import rollup-plugin-peer-deps-external

ES modules (import)

import rollupPluginPeerDepsExternal from "rollup-plugin-peer-deps-external";

Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.

CommonJS (require)

const rollupPluginPeerDepsExternal = require("rollup-plugin-peer-deps-external");

Module format by version

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

VersionsFormatFirst published
1.0.0 – 2.2.4CommonJSApr 12, 2017

Frequently asked

Is rollup-plugin-peer-deps-external ESM-only?

rollup-plugin-peer-deps-external@2.2.4 is a CommonJS package. rollup-plugin-peer-deps-external ships CommonJS only. require("rollup-plugin-peer-deps-external") works everywhere. import "rollup-plugin-peer-deps-external" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Can I import rollup-plugin-peer-deps-external with ES module syntax?

Yes. import rollupPluginPeerDepsExternal from "rollup-plugin-peer-deps-external" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.

Does rollup-plugin-peer-deps-external work in Bun?

Yes. import "rollup-plugin-peer-deps-external" loaded successfully in Bun 1.4 on Sep 9, 2026.

Does rollup-plugin-peer-deps-external ship TypeScript types?

Not bundled. Install the community types with "npm install -D @types/rollup-plugin-peer-deps-external".

Links

Other commonjs packages

Similar popularity