{"id":15311721,"url":"https://github.com/alloc/vite-plugin-legacy","last_synced_at":"2025-05-03T00:31:36.796Z","repository":{"id":54323278,"uuid":"305545684","full_name":"alloc/vite-plugin-legacy","owner":"alloc","description":"Vite-generated legacy bundles","archived":false,"fork":false,"pushed_at":"2021-03-19T13:12:43.000Z","size":350,"stargazers_count":54,"open_issues_count":5,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-19T13:51:06.593Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alloc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-20T00:24:19.000Z","updated_at":"2025-01-02T07:26:24.000Z","dependencies_parsed_at":"2022-08-13T12:00:51.732Z","dependency_job_id":null,"html_url":"https://github.com/alloc/vite-plugin-legacy","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fvite-plugin-legacy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fvite-plugin-legacy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fvite-plugin-legacy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fvite-plugin-legacy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alloc","download_url":"https://codeload.github.com/alloc/vite-plugin-legacy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252126559,"owners_count":21698964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T08:34:17.942Z","updated_at":"2025-05-03T00:31:36.048Z","avatar_url":"https://github.com/alloc.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Helpers"],"readme":"# vite-plugin-legacy\n\nEasily generate a legacy bundle for outdated browser support.\n\n\u003e Consider trying the official plugin first:\n\u003e https://github.com/vitejs/vite/tree/main/packages/plugin-legacy\n\n### Features\n\n- **Based on `@babel/preset-env`**  \n  Easily customize which browsers you want to support (via the `targets` option).\n\n- **Automatic feature detection**  \n  The injected `\u003cscript\u003e` that decides which bundle to load will check whether\n  ES modules (eg: `import`) and the expected JavaScript version (determined by\n  `esbuildTarget` in your Vite config) are supported by the user's browser.\n  If not, the legacy bundle is loaded instead!\n\n- **Hassle-free polyfills**  \n  With the help of [Polyfill.io], you can add polyfills without `npm install`.\n  Just add `\"InteractionObserver\"` to the `polyfills` array, and the legacy\n  bundle will automatically load it. [Learn more](#polyfills)\n\n- **Usage-based `core-js@3` inlining**  \n  When `corejs: true` is passed, modern features are detected by Babel, and only\n  the necessary [`core-js`] polyfills are embedded in the legacy bundle.\n\n- **Sourcemap support**  \n  Set `sourcemap: true` in your Vite config to easily debug your production\n  bundles.\n\n- **Minify support**  \n  When `minify` is truthy in your Vite config, the legacy bundle (which includes\n  any `core-js` polyfills) is minified with [`terser`]. Customize the minifier\n  via the `terserOption` in your Vite config.\n\n- **Production only**  \n  The legacy bundle is only generated when `vite build` runs, because Vite never\n  bundles during development (that's the whole point of Vite).\n\n[`core-js`]: https://www.npmjs.com/package/core-js\n[`terser`]: https://www.npmjs.com/package/terser\n\n\u0026nbsp;\n\n### Example\n\n```ts\nimport legacyPlugin from 'vite-plugin-legacy'\n\nexport default {\n  plugins: [\n    // The default options are listed below. Pass nothing to use them.\n    legacyPlugin({\n      // The browsers that must be supported by your legacy bundle.\n      // https://babeljs.io/docs/en/babel-preset-env#targets\n      targets: [\n        '\u003e 0.5%',\n        'last 2 versions',\n        'Firefox ESR',\n        'not dead',\n      ],\n      // Define which polyfills your legacy bundle needs. They will be loaded\n      // from the Polyfill.io server. See the \"Polyfills\" section for more info.\n      polyfills: [\n        // Empty by default\n      ],\n      // Toggles whether or not browserslist config sources are used.\n      // https://babeljs.io/docs/en/babel-preset-env#ignorebrowserslistconfig\n      ignoreBrowserslistConfig: false,\n      // When true, core-js@3 modules are inlined based on usage.\n      // When false, global namespace APIs (eg: Object.entries) are loaded\n      // from the Polyfill.io server.\n      corejs: false,\n    })\n  ]\n}\n```\n\n\u0026nbsp;\n\n### Polyfills\n\nThe `polyfills` option lets you define which APIs to load from the\n[Polyfill.io] server. If you're using TypeScript in your Vite config, you'll\nget auto-completion for all supported polyfills. The list is incomplete, so\nopen an issue if there's a missing polyfill that you need.\n\nPolyfills related to global namespaces (eg: `Object.entries`) are inferred\nfrom the `esbuildTarget` in your Vite config, which defaults to `es2020` if\nundefined. Be careful not to use an API that your target does not support.\nFor example, don't use `Promise.prototype.finally` if your target is older\nthan `es2018`. You can use [this tool](http://kangax.github.io/compat-table/es2016plus)\nto know when APIs were introduced.\n\nBy default, this plugin does **not** check if your bundle is using the global\nnamespace APIs before importing their polyfills from [Polyfill.io]. If you want\nthat, you can pass `corejs: true` to the plugin, which only includes the\npolyfills your legacy bundle needs. The downside of using `corejs: true` is that\npolyfills are inlined instead of being loaded separately, which allows for the\nbrowser to reuse cached polyfills between websites. Even if you set `corejs` to\ntrue, you can still use the `polyfills` option if you need APIs not supported\nby `core-js` (like `IntersectionObserver`).\n\nThe `polyfills` option allows any of the values in [this list](https://github.com/alloc/vite-plugin-legacy/blob/master/src/polyfills.ts).\n\n[Polyfill.io]: https://polyfill.io/v3/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falloc%2Fvite-plugin-legacy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falloc%2Fvite-plugin-legacy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falloc%2Fvite-plugin-legacy/lists"}