rollup-plugin-auto-external

raw JSON →
2.0.0 verified Mon Apr 27 auth: no javascript

A Rollup plugin that automatically externalizes dependencies and peerDependencies listed in package.json, keeping them out of the bundle for library development. Version 2.0.0 (latest) supports Rollup ≥0.45.2 and Node ≥6. Key differentiator: automatically parses dependencies, peerDependencies, and optionalDependencies from package.json, unlike manual external configuration or other plugins that require explicit lists. Simple to set up with zero configuration for most cases.

error Error: Unexpected key 'auto-external' found in plugins
cause Using plugin name string instead of function call.
fix
Use autoExternal() instead of 'auto-external' in plugins array.
error TypeError: autoExternal is not a function
cause Importing the plugin incorrectly (e.g., named import instead of default).
fix
Use import autoExternal from 'rollup-plugin-auto-external'.
error (!) Missing global variable name https://rollupjs.org/...
cause autoExternal externalizes a dependency but the output format (e.g., iife) requires a global variable name. The plugin does not provide globals mappings.
fix
Manually add a globals config for external dependencies or use output.format 'cjs'/'es'.
gotcha Plugins listed after autoExternal in the plugins array will still process external dependencies. Ensure autoExternal is placed before other plugins that transform code (e.g., babel) to avoid bundling dependencies.
fix Place autoExternal as the first plugin in the plugins array.
gotcha autoExternal only respects dependencies, peerDependencies, and optionalDependencies from the root package.json. It does not handle monorepo structures or workspaces. Dependencies from nested packages will not be automatically externalized.
fix Manually externalize dependencies from workspace packages or use a monorepo-aware plugin.
gotcha If your package.json has no 'dependencies', 'peerDependencies', or 'optionalDependencies' fields, autoExternal will externalize nothing. This may lead to unintended bundling of dependencies that should be external.
fix Ensure package.json contains the relevant dependency fields, or manually configure external.
breaking Version 2.0.0 dropped support for Rollup <0.45.2. Plugins may fail silently or with cryptic errors if used with older Rollup versions.
fix Upgrade Rollup to >=0.45.2.
npm install rollup-plugin-auto-external
yarn add rollup-plugin-auto-external
pnpm add rollup-plugin-auto-external

Shows minimal Rollup config using autoExternal to exclude all package.json dependencies from the bundle.

import autoExternal from 'rollup-plugin-auto-external';

export default {
  input: 'src/index.js',
  output: { file: 'dist/bundle.js', format: 'cjs' },
  plugins: [
    autoExternal()
  ]
};