Skip to content

Commit 4033a32

Browse files
authored
fix(plugin-legacy): add invoke to modern detector to avoid terser treeshaking (#14968)
1 parent 3f57b05 commit 4033a32

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/plugin-legacy/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ The legacy plugin requires inline scripts for [Safari 10.1 `nomodule` fix](https
156156

157157
- `sha256-MS6/3FCg4WjP9gwgaBGwLpRCY6fZBgwmhVCdrPrNf3E=`
158158
- `sha256-tQjf8gvb2ROOMapIxFvFAYBeUJ0v1HCbOcSmDNXGtDo=`
159-
- `sha256-4y/gEB2/KIwZFTfNqwXJq4olzvmQ0S214m9jwKgNXoc=`
159+
- `sha256-8uUkKieevHiD3yYtzjkRvyDZWt+uZkBLuGEQWNiV3+c=`
160160
- `sha256-+5XkZFazzJo8n0iOP4ti/cLCMUudTf//Mzkb7xNPXIc=`
161161

162162
<!--

packages/plugin-legacy/src/snippets.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const systemJSInlineCode = `System.import(document.getElementById('${lega
88

99
const detectModernBrowserVarName = '__vite_is_modern_browser'
1010
export const detectModernBrowserDetector =
11-
'import.meta.url;import("_").catch(()=>1);async function* g(){};'
11+
'import.meta.url;import("_").catch(()=>1);(async function* g(){})();'
1212
export const detectModernBrowserCode = `${detectModernBrowserDetector}if(location.protocol!="file:"){window.${detectModernBrowserVarName}=true}`
1313
export 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)}();`
1414

0 commit comments

Comments
 (0)