{"id":22659,"library":"vite-plugin-externalize-deps","title":"vite-plugin-externalize-deps","description":"A Vite plugin that automatically externalizes dependencies from your bundle during build, including subpath patterns. Current stable version is 0.10.0, released 2024-12-15. Supports Vite 2 through 7. Key differentiators: handles subpath exports, provides fine-grained control over which dependencies are externalized (deps, devDeps, peerDeps, optionalDeps, nodeBuiltins), and allows both inclusion and exception patterns via strings or regexes.","status":"active","version":"0.10.0","language":"javascript","source_language":"en","source_url":"https://github.com/voracious/vite-plugin-externalize-deps","tags":["javascript","dependencies","dev","utils","vite","vite-plugin","typescript"],"install":[{"cmd":"npm install vite-plugin-externalize-deps","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-externalize-deps","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-externalize-deps","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: runs as a Vite plugin","package":"vite","optional":false}],"imports":[{"note":"Named export only; no default export available.","wrong":"import externalizeDeps from 'vite-plugin-externalize-deps'","symbol":"externalizeDeps","correct":"import { externalizeDeps } from 'vite-plugin-externalize-deps'"},{"note":"Type export only. Do not import as value.","wrong":"import { VitePluginExternalizeDeps } from 'vite-plugin-externalize-deps'","symbol":"VitePluginExternalizeDeps","correct":"import type { VitePluginExternalizeDeps } from 'vite-plugin-externalize-deps'"},{"note":"CJS requires destructuring because it's a named export.","wrong":"const externalizeDeps = require('vite-plugin-externalize-deps')","symbol":"externalizeDeps","correct":"const { externalizeDeps } = require('vite-plugin-externalize-deps')"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport { externalizeDeps } from 'vite-plugin-externalize-deps';\n\nexport default defineConfig({\n  plugins: [\n    externalizeDeps({\n      // Defaults shown:\n      deps: true,\n      devDeps: false,\n      except: [],\n      nodeBuiltins: true,\n      optionalDeps: true,\n      peerDeps: true,\n      useFile: '/path/to/package.json',\n    }),\n  ],\n});","lang":"typescript","description":"Add the plugin to vite.config.ts with default options. Externalizes all dependencies, peerDeps, optionalDeps, and node builtins; devDeps are bundled by default."},"warnings":[{"fix":"Upgrade plugin to v0.5.0 or later for Vite 4 compatibility, or use an older Vite.","message":"Before v0.5.0, only Vite 2 and 3 were supported; Vite 4 support added in v0.5.0.","severity":"breaking","affected_versions":"<0.5.0"},{"fix":"Upgrade to v0.8.0+ for Vite 5.","message":"Before v0.8.0, Vite 5 was not supported; Vite 5 support added in v0.8.0.","severity":"breaking","affected_versions":"<0.8.0"},{"fix":"Upgrade to v0.9.0+ for Vite 6.","message":"Before v0.9.0, Vite 6 was not supported; Vite 6 support added in v0.9.0.","severity":"breaking","affected_versions":"<0.9.0"},{"fix":"Upgrade to v0.10.0+ for Vite 7.","message":"Before v0.10.0, Vite 7 was not supported; Vite 7 support added in v0.10.0.","severity":"breaking","affected_versions":"<0.10.0"},{"fix":"Set `devDeps: true` in the plugin options to externalize devDependencies.","message":"The `devDeps` option defaults to `false`, so development dependencies are NOT externalized by default. This can cause them to be bundled, which may be unexpected if you want to externalize them as well.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use the `include` option (added in v0.7.0) to add packages to be externalized that are not automatically detected.","message":"The `except` option only works for dependencies that would otherwise be externalized. It does not enable externalization of packages not in the plugin's scope (e.g., if a package is not in any of `deps`, `peerDeps`, etc., using `except` has no effect).","severity":"gotcha","affected_versions":">=0.6.0"},{"fix":"Omit `useFile` to let the plugin find package.json automatically, or keep it if you need a custom path.","message":"The `useFile` option is deprecated in favor of automatic package.json detection. It still works but may be removed in a future major version.","severity":"deprecated","affected_versions":">=0.7.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install the package as a dev dependency: npm install --save-dev vite-plugin-externalize-deps","cause":"Package not installed or missing from node_modules.","error":"Cannot find module 'vite-plugin-externalize-deps'"},{"fix":"Use `import { externalizeDeps } from 'vite-plugin-externalize-deps'` (curly braces).","cause":"Using default import instead of named import.","error":"[vite] RollupError: \"externalizeDeps\" is not exported by \"node_modules/vite-plugin-externalize-deps/dist/index.mjs\""},{"fix":"Remove `new` and call as `externalizeDeps()` directly.","cause":"Calling `new externalizeDeps()` or using it as a constructor.","error":"TypeError: externalizeDeps is not a function"},{"fix":"Ensure `except` is an array: `except: ['package-name']`.","cause":"Passed a non-array value to 'except' (e.g., a string or object).","error":"Error: The 'except' option requires an array of strings or RegExp."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}