rollup-plugin-auto-external
Rollup plugin to automatically exclude package.json dependencies and peerDependencies from your bundle.
Install
npm install --save-dev rollup-plugin-auto-external
Usage
Example rollup.config.js
import autoExternal from 'rollup-plugin-auto-external';
export default {
entry: 'index.js',
plugins: [
autoExternal(),
],
};
Example rollup.config.js
with options
import autoExternal from 'rollup-plugin-auto-external';
export default {
entry: 'index.js',
plugins: [
autoExternal({
dependencies: true,
peerDependencies: false,
builtins: false
}),
],
};
Example rollup.config.js
with external
rollup-plugin-auto-external
does not overwrite the external option. The two can happily coexist.
import autoExternal from 'rollup-plugin-auto-external';
export default {
entry: 'index.js',
external: id => id.includes('babel-runtime'),
plugins: [
autoExternal(),
],
};
Options
dependencies
boolean
: defaults to true
if the bundle format is cjs
or es
; false
otherwise.
peerDependencies
boolean
: defaults to true
.
builtins
boolean
|string
: defaults to false
. Pass true
to add all Node.js builtin modules (in the running version) as externals. Specify a string
value (e.g., '6.0.0'
) to add all builtin modules for a specific version of Node.js.
Rollup will complain if builtins
is present, and the build target is a browser. You may want rollup-plugin-node-builtins.