@vitejs/plugin-legacy 8.0.0-beta.3 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/index.js +19 -29
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ npm add -D terser
|
|
|
49
49
|
### `modernTargets`
|
|
50
50
|
|
|
51
51
|
- **Type:** `string | string[]`
|
|
52
|
-
- **Default:** [`'edge>=
|
|
52
|
+
- **Default:** [`'edge>=105, firefox>=106, chrome>=105, safari>=16.4, chromeAndroid>=105, iOS>=16.4'`](https://browsersl.ist/#q=edge%3E%3D105%2C+firefox%3E%3D106%2C+chrome%3E%3D105%2C+safari%3E%3D16.4%2C+chromeAndroid%3E%3D105%2C+iOS%3E%3D16.4)
|
|
53
53
|
|
|
54
54
|
It's passed on to [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env#targets) when collecting polyfills for **modern chunks**. The value set here will override the `build.target` option.
|
|
55
55
|
|
|
@@ -138,13 +138,13 @@ npm add -D terser
|
|
|
138
138
|
The legacy plugin offers a way to use widely-available features natively in the modern build, while falling back to the legacy build in browsers with native ESM but without those features supported (e.g. Legacy Edge). This feature works by injecting a runtime check and loading the legacy bundle with SystemJS runtime if needed. There are the following drawbacks:
|
|
139
139
|
|
|
140
140
|
- Modern bundle is downloaded in all ESM browsers
|
|
141
|
-
- Modern bundle throws
|
|
141
|
+
- Modern bundle throws an error in browsers without those features support
|
|
142
142
|
|
|
143
|
-
The following
|
|
143
|
+
The following features are considered as widely-available:
|
|
144
144
|
|
|
145
145
|
- dynamic import
|
|
146
|
-
- `import.meta`
|
|
147
146
|
- async generator
|
|
147
|
+
- `import.meta.resolve`
|
|
148
148
|
|
|
149
149
|
## Polyfill Specifiers
|
|
150
150
|
|
|
@@ -183,7 +183,7 @@ The current values are:
|
|
|
183
183
|
|
|
184
184
|
- `sha256-MS6/3FCg4WjP9gwgaBGwLpRCY6fZBgwmhVCdrPrNf3E=`
|
|
185
185
|
- `sha256-tQjf8gvb2ROOMapIxFvFAYBeUJ0v1HCbOcSmDNXGtDo=`
|
|
186
|
-
- `sha256-
|
|
186
|
+
- `sha256-w36slEqa9euNKxfvkw+LLGsDIr++3rsZXpZxtmRh8Aw=`
|
|
187
187
|
- `sha256-+5XkZFazzJo8n0iOP4ti/cLCMUudTf//Mzkb7xNPXIc=`
|
|
188
188
|
|
|
189
189
|
<!--
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import { build, normalizePath } from "vite";
|
|
6
6
|
import MagicString from "magic-string";
|
|
7
7
|
import browserslist from "browserslist";
|
|
8
|
-
|
|
9
8
|
//#region \0rolldown/runtime.js
|
|
10
9
|
var __create = Object.create;
|
|
11
10
|
var __defProp = Object.defineProperty;
|
|
@@ -15,16 +14,12 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
15
14
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
15
|
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
17
16
|
var __copyProps = (to, from, except, desc) => {
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
18
|
+
key = keys[i];
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
20
|
+
get: ((k) => from[k]).bind(null, key),
|
|
21
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
22
|
+
});
|
|
28
23
|
}
|
|
29
24
|
return to;
|
|
30
25
|
};
|
|
@@ -32,10 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
27
|
value: mod,
|
|
33
28
|
enumerable: true
|
|
34
29
|
}) : target, mod));
|
|
35
|
-
|
|
36
30
|
//#endregion
|
|
37
|
-
//#region
|
|
38
|
-
var
|
|
31
|
+
//#region src/snippets.ts
|
|
32
|
+
var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
39
33
|
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
40
34
|
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
41
35
|
let formatter = (open, close, replace = open) => (input) => {
|
|
@@ -100,21 +94,17 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
100
94
|
};
|
|
101
95
|
module.exports = createColors();
|
|
102
96
|
module.exports.createColors = createColors;
|
|
103
|
-
}));
|
|
104
|
-
|
|
105
|
-
//#endregion
|
|
106
|
-
//#region src/snippets.ts
|
|
107
|
-
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
97
|
+
})))(), 1);
|
|
108
98
|
const safari10NoModuleFix = `!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();`;
|
|
109
99
|
const legacyPolyfillId = "vite-legacy-polyfill";
|
|
110
100
|
const legacyEntryId = "vite-legacy-entry";
|
|
111
101
|
const systemJSInlineCode = `System.import(document.getElementById('${legacyEntryId}').getAttribute('data-src'))`;
|
|
112
102
|
const detectModernBrowserVarName = "__vite_is_modern_browser";
|
|
103
|
+
const detectImportMetaResolveSupportModule = "data:text/javascript,if(!import.meta.resolve)throw Error(\"import.meta.resolve not supported\")";
|
|
113
104
|
const detectModernBrowserDetector = `import.meta.url;import("_").catch(()=>1);(async function*(){})().next()`;
|
|
114
|
-
const detectModernBrowserCode =
|
|
105
|
+
const detectModernBrowserCode = `import'${detectImportMetaResolveSupportModule}';${detectModernBrowserDetector};window.${detectModernBrowserVarName}=true`;
|
|
115
106
|
const dynamicFallbackInlineCode = `!function(){if(window.${detectModernBrowserVarName})return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("${legacyPolyfillId}"),n=document.createElement("script");n.src=e.src,n.onload=function(){${systemJSInlineCode}},document.body.appendChild(n)}();`;
|
|
116
|
-
const modernChunkLegacyGuard = `export function __vite_legacy_guard(){${detectModernBrowserDetector}};`;
|
|
117
|
-
|
|
107
|
+
const modernChunkLegacyGuard = `import'${detectImportMetaResolveSupportModule}';export function __vite_legacy_guard(){${detectModernBrowserDetector}};`;
|
|
118
108
|
//#endregion
|
|
119
109
|
//#region src/index.ts
|
|
120
110
|
let babel;
|
|
@@ -161,12 +151,13 @@ const nonLeadingHashInFileNameRE = /[^/]+\[hash(?::\d+)?\]/;
|
|
|
161
151
|
const prefixedHashInFileNameRE = /\W?\[hash(?::\d+)?\]/;
|
|
162
152
|
const modernTargetsEsbuild = [
|
|
163
153
|
"es2020",
|
|
164
|
-
"
|
|
165
|
-
"
|
|
166
|
-
"
|
|
167
|
-
"
|
|
154
|
+
"edge105",
|
|
155
|
+
"firefox106",
|
|
156
|
+
"chrome105",
|
|
157
|
+
"safari16.4",
|
|
158
|
+
"ios16.4"
|
|
168
159
|
];
|
|
169
|
-
const modernTargetsBabel = "edge>=
|
|
160
|
+
const modernTargetsBabel = "edge>=105, firefox>=106, chrome>=105, safari>=16.4, chromeAndroid>=105, iOS>=16.4";
|
|
170
161
|
const outputOptionsForLegacyChunks = /* @__PURE__ */ new WeakSet();
|
|
171
162
|
function viteLegacyPlugin(options = {}) {
|
|
172
163
|
let config;
|
|
@@ -618,6 +609,5 @@ Object.assign(viteLegacyPluginCjs, {
|
|
|
618
609
|
default: viteLegacyPluginCjs,
|
|
619
610
|
detectPolyfills
|
|
620
611
|
});
|
|
621
|
-
|
|
622
612
|
//#endregion
|
|
623
|
-
export { cspHashes, viteLegacyPlugin as default, detectPolyfills, viteLegacyPluginCjs as "module.exports" };
|
|
613
|
+
export { cspHashes, viteLegacyPlugin as default, detectPolyfills, viteLegacyPluginCjs as "module.exports" };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-legacy",
|
|
3
|
-
"version": "8.0.0
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Evan You",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@babel/plugin-transform-dynamic-import": "^7.27.1",
|
|
33
33
|
"@babel/plugin-transform-modules-systemjs": "^7.29.0",
|
|
34
34
|
"@babel/preset-env": "^7.29.0",
|
|
35
|
-
"babel-plugin-polyfill-corejs3": "^0.14.
|
|
36
|
-
"babel-plugin-polyfill-regenerator": "^0.6.
|
|
35
|
+
"babel-plugin-polyfill-corejs3": "^0.14.1",
|
|
36
|
+
"babel-plugin-polyfill-regenerator": "^0.6.7",
|
|
37
37
|
"browserslist": "^4.28.1",
|
|
38
38
|
"browserslist-to-esbuild": "^2.1.1",
|
|
39
39
|
"core-js": "^3.48.0",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"terser": "^5.16.0",
|
|
46
|
-
"vite": "^
|
|
46
|
+
"vite": "^8.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"acorn": "^8.
|
|
49
|
+
"acorn": "^8.16.0",
|
|
50
50
|
"picocolors": "^1.1.1",
|
|
51
51
|
"tsdown": "^0.20.3",
|
|
52
|
-
"vite": "8.0.0
|
|
52
|
+
"vite": "8.0.0"
|
|
53
53
|
},
|
|
54
54
|
"compatiblePackages": {
|
|
55
55
|
"schemaVersion": 1,
|