From 0a4ae29d39310acf090d92f4fe224b06b38ace34 Mon Sep 17 00:00:00 2001 From: Lea Verou Date: Wed, 14 Feb 2024 21:55:28 -0500 Subject: [PATCH] Fix import URL --- src/prism-live.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/prism-live.js b/src/prism-live.js index 9484dde..c3684b7 100644 --- a/src/prism-live.js +++ b/src/prism-live.js @@ -1,8 +1,17 @@ { - let url = document.currentScript?.src; - url = new URL(url, location); - let importURL = new URL("./prism-live.mjs", url); - importURL.search = url.search; - import(importURL).then(m => Prism.Live = m.default); + let url; + // Fall back to loading all languages + let search = "?load=css,javascript,markup"; + + try { + url = document.currentScript?.src ?? eval("import.meta.url"); + } + catch(e) {} + + if (url) { + search = new URL(url).search; + } + + import("./prism-live.mjs" + search).then(m => Prism.Live = m.default); }