Registry / devops / rollup-plugin-externals

rollup-plugin-externals

JSON →
library0.0.1jsnpmunverified

A Rollup plugin that mimics webpack's externals configuration, allowing you to mark dependencies as external and provide global variable names for bundling with script tags. Currently at v0.0.1, it is a lightweight alternative to @rollup/plugin-node-resolve combined with manual external handling. It maps module IDs to global variable names, emitting `module.exports = window.VariableName` stubs at build time. Suitable for library authors bundling for browser environments. No dependencies and ships TypeScript types.

npm install rollup-plugin-externals
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-EXTE
R
rollup-plugin-externals
devopsjavascriptv0.0.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

externals
✓ import { externals } from 'rollup-plugin-externals'
✗ import externals from 'rollup-plugin-externals'
This package only exports a named function; there is no default export.
externals (require)
✓ const { externals } = require('rollup-plugin-externals')
✗ const externals = require('rollup-plugin-externals')
CommonJS require must destructure; using it as a default will not work.
TypeScript type
✓ import type { ExternalsOptions } from 'rollup-plugin-externals'
TypeScript users can import the type for options object.

Demonstrates how to use the externals plugin in a Rollup config to map 'react' and 'react-dom' to global variables for IIFE output.

import { defineConfig } from 'rollup'; import { externals } from 'rollup-plugin-externals'; export default defineConfig({ input: 'src/index.js', output: { dir: 'dist', format: 'iife', }, plugins: [ externals({ 'react': 'React', 'react-dom': 'ReactDOM', }), ], });
Debug
Known issues
gotchaThe plugin emits `module.exports = window.VariableName` for CJS output; may cause issues with Rollup's `output.format: 'es'` if not configured correctly.
fix
Use `output.format: 'iife'` or ensure your output format supports global variable assignments.
affects: >=0.0.1
gotchaOnly works with Rollup; not compatible with other bundlers like webpack or esbuild.
fix
For webpack, use built-in `externals` config; for esbuild, use `external` option with `globalName`.
affects: >=0.0.1
deprecatedPlugin is at v0.0.1; API may change in future versions without major version bump.
fix
Pin to exact version and test upgrades thoroughly.
affects: >=0.0.1 <1.0.0
Errors
Common errors & fixes
TypeError: (0 , rp.default) is not a function
CommonJS require used without destructuring, getting the module object instead of the externals function.
fix
Use `const { externals } = require('rollup-plugin-externals')` instead of `const externals = require('rollup-plugin-externals')`.
RollupError: Could not resolve './some-internal-module' from 'node_modules/rollup-plugin-externals/index.js'
The plugin's internal import resolution fails when used as a transitive dependency or with hoisted node_modules.
fix
Ensure rollup-plugin-externals is installed as a direct devDependency, and delete node_modules/.cache if needed.
Uncaught ReferenceError: module is not defined
Using the plugin with output.format: 'es' or 'iife' but the plugin generates CJS-style stubs.
fix
Set Rollup's output.format to 'cjs' or 'iife' and ensure the target environment supports `module`.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
rollup-plugin-externals — npm install rollup-plugin-externals · libregistry