@vitejs/plugin-legacy 4.0.1 → 4.0.3
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 +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.mjs +2 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -159,8 +159,8 @@ The legacy plugin requires inline scripts for [Safari 10.1 `nomodule` fix](https
|
|
|
159
159
|
|
|
160
160
|
- `sha256-MS6/3FCg4WjP9gwgaBGwLpRCY6fZBgwmhVCdrPrNf3E=`
|
|
161
161
|
- `sha256-tQjf8gvb2ROOMapIxFvFAYBeUJ0v1HCbOcSmDNXGtDo=`
|
|
162
|
-
- `sha256-
|
|
163
|
-
- `sha256
|
|
162
|
+
- `sha256-p7PoC97FO+Lu90RNjGWxhbm13yALSR4xzV8vaDhaQBo=`
|
|
163
|
+
- `sha256-+5XkZFazzJo8n0iOP4ti/cLCMUudTf//Mzkb7xNPXIc=`
|
|
164
164
|
|
|
165
165
|
<!--
|
|
166
166
|
Run `node --input-type=module -e "import {cspHashes} from '@vitejs/plugin-legacy'; console.log(cspHashes.map(h => 'sha256-'+h))"` to retrieve the value.
|
package/dist/index.cjs
CHANGED
|
@@ -82,7 +82,7 @@ const legacyEntryId = "vite-legacy-entry";
|
|
|
82
82
|
const systemJSInlineCode = `System.import(document.getElementById('${legacyEntryId}').getAttribute('data-src'))`;
|
|
83
83
|
const detectModernBrowserVarName = "__vite_is_modern_browser";
|
|
84
84
|
const detectModernBrowserDetector = 'import.meta.url;import("_").catch(()=>1);async function* g(){};';
|
|
85
|
-
const detectModernBrowserCode = `${detectModernBrowserDetector}window.${detectModernBrowserVarName}=true
|
|
85
|
+
const detectModernBrowserCode = `${detectModernBrowserDetector}if(location.protocol!="file:"){window.${detectModernBrowserVarName}=true}`;
|
|
86
86
|
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)}();`;
|
|
87
87
|
const modernChunkLegacyGuard = `export function __vite_legacy_guard(){${detectModernBrowserDetector}};`;
|
|
88
88
|
|
|
@@ -142,7 +142,7 @@ function toAssetPathFromHtml(filename, htmlPath, config) {
|
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
144
|
const legacyEnvVarMarker = `__VITE_IS_LEGACY__`;
|
|
145
|
-
const _require = node_module.createRequire((typeof document === 'undefined' ?
|
|
145
|
+
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
146
146
|
function viteLegacyPlugin(options = {}) {
|
|
147
147
|
let config;
|
|
148
148
|
let targets;
|
|
@@ -181,7 +181,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
181
181
|
const legacyConfigPlugin = {
|
|
182
182
|
name: "vite:legacy-config",
|
|
183
183
|
config(config2, env) {
|
|
184
|
-
if (env.command === "build") {
|
|
184
|
+
if (env.command === "build" && !config2.build?.ssr) {
|
|
185
185
|
if (!config2.build) {
|
|
186
186
|
config2.build = {};
|
|
187
187
|
}
|
|
@@ -561,7 +561,7 @@ async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, build
|
|
|
561
561
|
const res = await vite.build({
|
|
562
562
|
mode,
|
|
563
563
|
// so that everything is resolved from here
|
|
564
|
-
root: path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ?
|
|
564
|
+
root: path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)))),
|
|
565
565
|
configFile: false,
|
|
566
566
|
logLevel: "error",
|
|
567
567
|
plugins: [polyfillsPlugin(imports, excludeSystemJS)],
|
package/dist/index.mjs
CHANGED
|
@@ -78,7 +78,7 @@ const legacyEntryId = "vite-legacy-entry";
|
|
|
78
78
|
const systemJSInlineCode = `System.import(document.getElementById('${legacyEntryId}').getAttribute('data-src'))`;
|
|
79
79
|
const detectModernBrowserVarName = "__vite_is_modern_browser";
|
|
80
80
|
const detectModernBrowserDetector = 'import.meta.url;import("_").catch(()=>1);async function* g(){};';
|
|
81
|
-
const detectModernBrowserCode = `${detectModernBrowserDetector}window.${detectModernBrowserVarName}=true
|
|
81
|
+
const detectModernBrowserCode = `${detectModernBrowserDetector}if(location.protocol!="file:"){window.${detectModernBrowserVarName}=true}`;
|
|
82
82
|
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)}();`;
|
|
83
83
|
const modernChunkLegacyGuard = `export function __vite_legacy_guard(){${detectModernBrowserDetector}};`;
|
|
84
84
|
|
|
@@ -177,7 +177,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
177
177
|
const legacyConfigPlugin = {
|
|
178
178
|
name: "vite:legacy-config",
|
|
179
179
|
config(config2, env) {
|
|
180
|
-
if (env.command === "build") {
|
|
180
|
+
if (env.command === "build" && !config2.build?.ssr) {
|
|
181
181
|
if (!config2.build) {
|
|
182
182
|
config2.build = {};
|
|
183
183
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-legacy",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Evan You",
|
|
6
6
|
"files": [
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@babel/core": "^7.
|
|
44
|
+
"@babel/core": "^7.21.3",
|
|
45
45
|
"@babel/preset-env": "^7.20.2",
|
|
46
|
-
"browserslist": "^4.21.
|
|
47
|
-
"core-js": "^3.
|
|
48
|
-
"magic-string": "^0.
|
|
46
|
+
"browserslist": "^4.21.5",
|
|
47
|
+
"core-js": "^3.29.1",
|
|
48
|
+
"magic-string": "^0.30.0",
|
|
49
49
|
"regenerator-runtime": "^0.13.11",
|
|
50
|
-
"systemjs": "^6.
|
|
50
|
+
"systemjs": "^6.14.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"terser": "^5.4.0",
|