Registry / devops / vite-plugin-externalize-deps

vite-plugin-externalize-deps

JSON →
library0.10.0jsnpmunverified

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.

npm install vite-plugin-externalize-deps
INSTALL
IMPORT
SIG · VITE-PLUGIN-EXTERN
V
vite-plugin-externalize-deps
devopsjavascriptv0.10.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

externalizeDeps
import { externalizeDeps } from 'vite-plugin-externalize-deps'
import externalizeDeps from 'vite-plugin-externalize-deps'
Named export only; no default export available.
VitePluginExternalizeDeps
import type { VitePluginExternalizeDeps } from 'vite-plugin-externalize-deps'
import { VitePluginExternalizeDeps } from 'vite-plugin-externalize-deps'
Type export only. Do not import as value.
externalizeDeps
const { externalizeDeps } = require('vite-plugin-externalize-deps')
const externalizeDeps = require('vite-plugin-externalize-deps')
CJS requires destructuring because it's a named export.

Add the plugin to vite.config.ts with default options. Externalizes all dependencies, peerDeps, optionalDeps, and node builtins; devDeps are bundled by default.

import { defineConfig } from 'vite'; import { externalizeDeps } from 'vite-plugin-externalize-deps'; export default defineConfig({ plugins: [ externalizeDeps({ // Defaults shown: deps: true, devDeps: false, except: [], nodeBuiltins: true, optionalDeps: true, peerDeps: true, useFile: '/path/to/package.json', }), ], });
Debug
Known issues
breakingBefore v0.5.0, only Vite 2 and 3 were supported; Vite 4 support added in v0.5.0.
fix
Upgrade plugin to v0.5.0 or later for Vite 4 compatibility, or use an older Vite.
affects: <0.5.0
breakingBefore v0.8.0, Vite 5 was not supported; Vite 5 support added in v0.8.0.
fix
Upgrade to v0.8.0+ for Vite 5.
affects: <0.8.0
breakingBefore v0.9.0, Vite 6 was not supported; Vite 6 support added in v0.9.0.
fix
Upgrade to v0.9.0+ for Vite 6.
affects: <0.9.0
breakingBefore v0.10.0, Vite 7 was not supported; Vite 7 support added in v0.10.0.
fix
Upgrade to v0.10.0+ for Vite 7.
affects: <0.10.0
gotchaThe `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.
fix
Set `devDeps: true` in the plugin options to externalize devDependencies.
affects: >=0.1.0
gotchaThe `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).
fix
Use the `include` option (added in v0.7.0) to add packages to be externalized that are not automatically detected.
affects: >=0.6.0
deprecatedThe `useFile` option is deprecated in favor of automatic package.json detection. It still works but may be removed in a future major version.
fix
Omit `useFile` to let the plugin find package.json automatically, or keep it if you need a custom path.
affects: >=0.7.0
Errors
Common errors & fixes
Cannot find module 'vite-plugin-externalize-deps'
Package not installed or missing from node_modules.
fix
Install the package as a dev dependency: npm install --save-dev vite-plugin-externalize-deps
[vite] RollupError: "externalizeDeps" is not exported by "node_modules/vite-plugin-externalize-deps/dist/index.mjs"
Using default import instead of named import.
fix
Use `import { externalizeDeps } from 'vite-plugin-externalize-deps'` (curly braces).
TypeError: externalizeDeps is not a function
Calling `new externalizeDeps()` or using it as a constructor.
fix
Remove `new` and call as `externalizeDeps()` directly.
Error: The 'except' option requires an array of strings or RegExp.
Passed a non-array value to 'except' (e.g., a string or object).
fix
Ensure `except` is an array: `except: ['package-name']`.
Upgrade
Version history
0.10.0latest on npm
Audit
Dependencies
viterequiredpeer dependency: runs as a Vite plugin
Agent activity
3 hits · last 30 days
node
3
Resources
vite-plugin-externalize-deps — npm install vite-plugin-externalize-deps · libregistry