-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a42a1d1
commit 6407b64
Showing
1 changed file
with
7 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
window.addEventListener("error", (ev) => { | ||
if ( | ||
(ev.message.includes("SyntaxError") && ev.message.includes("import")) || | ||
(ev.message === "Syntax error" && ev.error.source && ev.error.source.includes("import")) | ||
) { | ||
const { message: m, error: e } = ev; | ||
if ((/SyntaxError/.test(m) && /import/.test(m)) || (/Syntax error/.test(e.message) && /import/.test(e.source))) { | ||
ev.preventDefault(); | ||
console.log("dynamic module import is not implemented. fallback..."); | ||
const es6 = document.querySelector(".index-es6"); | ||
const script = document.createElement("script"); | ||
script.src = es6.src; | ||
script.integrity = es6.integrity; | ||
script.crossOrigin = es6.crossOrigin; | ||
document.head.appendChild(script); | ||
const sc = document.createElement("script"); | ||
sc.src = es6.src; | ||
sc.integrity = es6.integrity; | ||
sc.crossOrigin = es6.crossOrigin; | ||
document.head.appendChild(sc); | ||
} | ||
}); |