vite-plugin-external weekly downloads statistics
By fengxinming (2 listings) · npm · Vite plugins
Excludes specified module dependencies from runtime code and built bundles.
vite-plugin-external has 14,233 recorded weekly downloads on npm, a decrease of 16.6% over the past 30 days, ranking #1157 of 3,247 tracked listings.
About vite-plugin-external
vite-plugin-external
Excludes specified module dependencies from runtime code and built bundles. Vite >= 8.0
Documentation
For detailed usage instructions and API references, please visit the official documentation:
Quick Start
Prerequisite: provide the globals in index.html
Global-name externals (e.g. react: 'React') only take effect if the global variable actually exists at runtime — the plugin rewrites the import to a global lookup, it does not download anything. So load the UMD builds in index.html before writing the config, and keep the window names aligned with the values in externals:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo</title>
<!-- CDN UMD builds provide window.React / window.ReactDOM -->
<script crossorigin src="https://unpkg.com/umd-react/dist/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/umd-react/dist/react-dom.production.min.js"></script>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
The same rule applies to per-mode (development / production) overrides: every mode's global names must exist on window in that environment. Externals whose value is an ESM CDN URL are the exception — nothing to add manually: in a build the bundle imports the absolute CDN URLs directly and the plugin injects <link rel="modulepreload"> for first-paint prefetching; with importmap: true (example 5 below) the addresses move out of the bundle into an injected <script type="importmap">.
1. IIFE build with global variables (application build)
import { defineConfig } from 'vite';
import pluginExternal from 'vite-plugin-external';
export default defineConfig({
plugins: [
pluginExternal({
externals: {
react: 'React',
'react-dom': 'ReactDOM',
'react-dom/client': 'ReactDOM'
}
})
],
build: {
rolldownOptions: {
output: {
format: 'iife'
}
}
}
});
2. Function-style externals (dynamic mapping, lib build)
(source, importer, isResolved) — return a string (global name / CDN URL), an ExternalEsConfig ({ format: 'es', url, exports? }, where exports is 'auto' | 'named' | 'default' | 'none'), true (pure external), or a falsy value to let it resolve normally. IIFE lib builds need build.lib.name:
import { defineConfig } from 'vite';
import pluginExternal from 'vite-plugin-external';
export default defineConfig({
plugins: [
pluginExternal({
externals(source) {
if (source.startsWith('@scope/')) {
const name = source.split('/').pop();
return `Scope${name.charAt(0).toUpperCase()}${name.slice(1)}`;
}
if (source === 'react') return 'React';
if (source === 'react-dom/client') return 'ReactDOM';
return null;
}
})
],
build: {
lib: {
entry: 'src/main.tsx',
formats: ['iife'],
name: 'ScopedApp'
}
}
});
3. ESM CDN URLs (auto <link rel="modulepreload"> injection)
import { defineConfig } from 'vite';
import pluginExternal from 'vite-plugin-external';
export default defineConfig({
plugins: [
pluginExternal({
externals: {
react: 'https://esm.sh/react@19.3.1',
'react-dom/client': 'https://esm.sh/react-dom@19.3.1/client',
// the automatic JSX runtime is a separate module id — list it too
'react/jsx-runtime': 'https://esm.sh/react@19.3.1/jsx-runtime'
}
})
]
});
4. externalizeDeps — pure external without shim (dev and build)
import { defineConfig } from 'vite';
import pluginExternal from 'vite-plugin-external';
export default defineConfig({
plugins: [
pluginExternal({
externalizeDeps: ['lodash', 'dayjs', /^@babel\//]
})
],
build: {
lib: {
entry: 'src/main.ts',
formats: ['es'],
fileName: 'my-lib'
}
}
});
Pure external leaves a bare specifier, so the consumer has to supply the address itself:
a Node host resolves it from node_modules, and a dev-server page needs a
<script type="importmap"> whose keys match what the browser actually requests — Vite 8 rewrites
an externalized bare specifier to /@id/<specifier>, so the keys must carry that prefix
({"imports": {"/@id/lodash": "https://esm.sh/lodash@4.18.1"}}).
5. importmap: true — CDN externals become an import map
import { defineConfig } from 'vite';
import pluginExternal from 'vite-plugin-external';
export default defineConfig({
plugins: [
pluginExternal({
externals: {
lodash: 'https://esm.sh/lodash@4.18.1',
dayjs: 'https://esm.sh/dayjs@1.11.23'
},
importmap: true
})
]
});
```…
Description from the npm listing.
- vite
- vite-plugin
- vite-plugin-external
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Vite plugins plugins
All 20 vite-plugin-external alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/vite-plugin-external. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.
