Gathering detailed insights and metrics for vite-plugin-legacy
Gathering detailed insights and metrics for vite-plugin-legacy
Gathering detailed insights and metrics for vite-plugin-legacy
Gathering detailed insights and metrics for vite-plugin-legacy
@vitejs/plugin-legacy
Vite's default browser support baseline is [Native ESM](https://caniuse.com/es6-module), [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import), and [`import.meta`](https://caniuse.com/mdn-javascript_operators_import_meta). This plugin
vite-plugin-legacy-swc
Provides legacy browsers support for the production build with SWC
vite-plugin-legacy-qiankun
vite qiankun 集成插件,支持js,css沙箱
nuxt-vite-legacy
Nuxt.js legacy browsers build plugin
npm install vite-plugin-legacy
Typescript
Module System
Node Version
NPM Version
TypeScript (93.96%)
JavaScript (6.04%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
54 Stars
71 Commits
6 Forks
5 Watchers
2 Branches
1 Contributors
Updated on May 13, 2025
Latest Version
2.1.0
Package Id
vite-plugin-legacy@2.1.0
Unpacked Size
25.93 kB
Size
8.51 kB
File Count
8
NPM Version
6.14.9
Node Version
14.15.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
10
1
Easily generate a legacy bundle for outdated browser support.
Based on @babel/preset-env
Easily customize which browsers you want to support (via the targets
option).
Automatic feature detection
The injected <script>
that decides which bundle to load will check whether
ES modules (eg: import
) and the expected JavaScript version (determined by
esbuildTarget
in your Vite config) are supported by the user's browser.
If not, the legacy bundle is loaded instead!
Hassle-free polyfills
With the help of Polyfill.io, you can add polyfills without npm install
.
Just add "InteractionObserver"
to the polyfills
array, and the legacy
bundle will automatically load it. Learn more
Usage-based core-js@3
inlining
When corejs: true
is passed, modern features are detected by Babel, and only
the necessary core-js
polyfills are embedded in the legacy bundle.
Sourcemap support
Set sourcemap: true
in your Vite config to easily debug your production
bundles.
Minify support
When minify
is truthy in your Vite config, the legacy bundle (which includes
any core-js
polyfills) is minified with terser
. Customize the minifier
via the terserOption
in your Vite config.
Production only
The legacy bundle is only generated when vite build
runs, because Vite never
bundles during development (that's the whole point of Vite).
1import legacyPlugin from 'vite-plugin-legacy' 2 3export default { 4 plugins: [ 5 // The default options are listed below. Pass nothing to use them. 6 legacyPlugin({ 7 // The browsers that must be supported by your legacy bundle. 8 // https://babeljs.io/docs/en/babel-preset-env#targets 9 targets: [ 10 '> 0.5%', 11 'last 2 versions', 12 'Firefox ESR', 13 'not dead', 14 ], 15 // Define which polyfills your legacy bundle needs. They will be loaded 16 // from the Polyfill.io server. See the "Polyfills" section for more info. 17 polyfills: [ 18 // Empty by default 19 ], 20 // Toggles whether or not browserslist config sources are used. 21 // https://babeljs.io/docs/en/babel-preset-env#ignorebrowserslistconfig 22 ignoreBrowserslistConfig: false, 23 // When true, core-js@3 modules are inlined based on usage. 24 // When false, global namespace APIs (eg: Object.entries) are loaded 25 // from the Polyfill.io server. 26 corejs: false, 27 }) 28 ] 29}
The polyfills
option lets you define which APIs to load from the
Polyfill.io server. If you're using TypeScript in your Vite config, you'll
get auto-completion for all supported polyfills. The list is incomplete, so
open an issue if there's a missing polyfill that you need.
Polyfills related to global namespaces (eg: Object.entries
) are inferred
from the esbuildTarget
in your Vite config, which defaults to es2020
if
undefined. Be careful not to use an API that your target does not support.
For example, don't use Promise.prototype.finally
if your target is older
than es2018
. You can use this tool
to know when APIs were introduced.
By default, this plugin does not check if your bundle is using the global
namespace APIs before importing their polyfills from Polyfill.io. If you want
that, you can pass corejs: true
to the plugin, which only includes the
polyfills your legacy bundle needs. The downside of using corejs: true
is that
polyfills are inlined instead of being loaded separately, which allows for the
browser to reuse cached polyfills between websites. Even if you set corejs
to
true, you can still use the polyfills
option if you need APIs not supported
by core-js
(like IntersectionObserver
).
The polyfills
option allows any of the values in this list.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
30 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More