{"id":21890,"library":"rollup-config-external-dependencies","title":"rollup-config-external-dependencies","description":"Rollup configuration to automatically externalize all dependencies, peerDependencies, and optionalDependencies from the bundle. v3.0.1 is current, released June 2024. Node >=18.12.0 required, ESM-only since v3. Differentiators: zero-config, respects package.json fields, works with CommonJS and ESM outputs, and supports TypeScript projects out of the box. Releases are infrequent; v3 breaking change was dropping CJS and older Node versions.","status":"active","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/christophehurpeau/rollup-config-external-dependencies","tags":["javascript"],"install":[{"cmd":"npm install rollup-config-external-dependencies","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-config-external-dependencies","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-config-external-dependencies","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin works only with Rollup","package":"rollup","optional":false}],"imports":[{"note":"Package is ESM-only since v3.0.0; use dynamic import() if needed in CommonJS.","wrong":"const externalDependencies = require('rollup-config-external-dependencies');","symbol":"externalDependencies","correct":"import { externalDependencies } from 'rollup-config-external-dependencies';"},{"note":"externalDependencies is a function that returns a plugin instance; calling it is required.","wrong":"plugins: [externalDependencies]","symbol":"externalDependencies","correct":"export default { ..., plugins: [externalDependencies()] }"},{"note":"For CommonJS or legacy Node, use dynamic import() with top-level await or async wrapper.","wrong":"","symbol":"externalDependencies","correct":"const { externalDependencies } = await import('rollup-config-external-dependencies');"}],"quickstart":{"code":"// rollup.config.js\nimport { externalDependencies } from 'rollup-config-external-dependencies';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'esm',\n  },\n  plugins: [\n    externalDependencies(),\n  ],\n};","lang":"javascript","description":"Basic Rollup config using externalDependencies to automatically exclude external packages from bundle."},"warnings":[{"fix":"Migrate config to ES modules (use import syntax) and upgrade Node to 18.12.0 or later.","message":"Dropped CommonJS support and requires Node >=18.12.0.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Add parentheses: plugins: [externalDependencies()]","message":"Plugin must be called as a function: externalDependencies(), not used directly as externalDependencies.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Check package.json dependencies/peerDependencies and adjust with options if needed.","message":"Externalization includes the package itself if it's listed as a dependency; ensure no unintended externals.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import statement or dynamic import(): import { externalDependencies } from 'rollup-config-external-dependencies' or const { externalDependencies } = await import(...).","cause":"Using CommonJS require() on an ESM-only package since v3.0.0.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Use plugins: [externalDependencies()] with parentheses.","cause":"Using the imported value without calling it (not invoking parentheses).","error":"TypeError: externalDependencies is not a function"},{"fix":"Ensure the package is installed and listed in dependencies or peerDependencies, or add it to external manually.","cause":"An external dependency is not installed or not listed in package.json, but externalization is active.","error":"RollupError: Could not resolve 'some-package' (commonjs or esm dependency...)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}