Skip to content

Commit 9be189e

Browse files
committed
Web: improve Skiko import resolution in Karma loader
Ensure `js-reexport-symbols.mjs` is dynamically resolved from Karma-served files to avoid hardcoded paths.
1 parent c40bc14 commit 9be189e

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/web/internal/configureWebApplication.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,15 @@ private fun configureJsBrowserTestsSkikoLoading(
222222
let skikoReady = null;
223223
window.__karma__.loaded = function() {
224224
if (!skikoReady) {
225-
skikoReady = import("/base/kotlin/js-reexport-symbols.mjs")
226-
.then((mod) => mod?.api?.awaitSkiko || Promise.resolve());
225+
const servedFiles = window.__karma__.files || {};
226+
const reexportUrl = Object.keys(servedFiles)
227+
.find((url) => url.endsWith("js-reexport-symbols.mjs"));
228+
skikoReady = reexportUrl
229+
? import(reexportUrl).then((mod) => mod?.api?.awaitSkiko ?? Promise.resolve())
230+
: Promise.resolve();
227231
}
228232
skikoReady.then(() => originalLoaded()).catch((error) => {
229-
const message = error && error.stack ? error.stack : String(error);
233+
const message = error?.stack ?? String(error);
230234
window.__karma__.error(message);
231235
});
232236
};

0 commit comments

Comments
 (0)