[Gradle, Js] Use dynamic import to catch exceptions during wasm compilation
This commit is contained in:
+8
-6
@@ -603,16 +603,18 @@ internal fun createLoadWasm(npmProjectDir: File, file: File): File {
|
|||||||
val static = npmProjectDir.resolve("static").also {
|
val static = npmProjectDir.resolve("static").also {
|
||||||
it.mkdirs()
|
it.mkdirs()
|
||||||
}
|
}
|
||||||
val loadJs = static.resolve("load.js")
|
val loadJs = static.resolve("load.mjs")
|
||||||
loadJs.printWriter().use { writer ->
|
loadJs.printWriter().use { writer ->
|
||||||
val relativePath = file.relativeTo(static).invariantSeparatorsPath
|
val relativePath = file.relativeTo(static).invariantSeparatorsPath
|
||||||
writer.println(
|
writer.println(
|
||||||
"""
|
"""
|
||||||
import exports from "$relativePath";
|
import( /* webpackMode: "eager" */ "$relativePath")
|
||||||
|
.then((exports) => {
|
||||||
exports.startUnitTests();
|
exports.default.startUnitTests();
|
||||||
|
window.__karma__.loaded();
|
||||||
window.__karma__.loaded();
|
}, (reason) => {
|
||||||
|
window.__karma__.error("Problem with loading", void 0, void 0, void 0, reason)
|
||||||
|
})
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-6
@@ -18,17 +18,19 @@ class KotlinKarmaTest {
|
|||||||
val loadWasm = createLoadWasm(npmProjectDir.toFile(), executableFile.toFile())
|
val loadWasm = createLoadWasm(npmProjectDir.toFile(), executableFile.toFile())
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"static/load.js",
|
"static/load.mjs",
|
||||||
loadWasm.relativeTo(npmProjectDir.toFile()).invariantSeparatorsPath
|
loadWasm.relativeTo(npmProjectDir.toFile()).invariantSeparatorsPath
|
||||||
)
|
)
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"""
|
"""
|
||||||
import exports from "../kotlin/main.mjs";
|
import( /* webpackMode: "eager" */ "../kotlin/main.mjs")
|
||||||
|
.then((exports) => {
|
||||||
exports.startUnitTests();
|
exports.default.startUnitTests();
|
||||||
|
window.__karma__.loaded();
|
||||||
window.__karma__.loaded();
|
}, (reason) => {
|
||||||
|
window.__karma__.error("Problem with loading", void 0, void 0, void 0, reason)
|
||||||
|
})
|
||||||
""".trimIndent(),
|
""".trimIndent(),
|
||||||
loadWasm.readText().trimIndent()
|
loadWasm.readText().trimIndent()
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user