Skip to content

Commit

Permalink
feat(plugin-legacy): support file protocol (#8524)
Browse files Browse the repository at this point in the history
Co-authored-by: sapphi-red <green@sapphi.red>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
  • Loading branch information
3 people authored Apr 25, 2023
1 parent 07bd6d1 commit 7a87ff4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/plugin-legacy/src/snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const systemJSInlineCode = `System.import(document.getElementById('${lega
const detectModernBrowserVarName = '__vite_is_modern_browser'
export const detectModernBrowserDetector =
'import.meta.url;import("_").catch(()=>1);async function* g(){};'
export const detectModernBrowserCode = `${detectModernBrowserDetector}window.${detectModernBrowserVarName}=true;`
export const detectModernBrowserCode = `${detectModernBrowserDetector}if(location.protocol!="file:"){window.${detectModernBrowserVarName}=true}`
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)}();`

export const modernChunkLegacyGuard = `export function __vite_legacy_guard(){${detectModernBrowserDetector}};`

0 comments on commit 7a87ff4

Please sign in to comment.