[Wasm] Inline _importModule
^KT-59556 fixed
This commit is contained in:
committed by
Space Team
parent
1ad0a662fd
commit
d865202bd5
@@ -193,7 +193,7 @@ fun WasmCompiledModuleFragment.generateAsyncJsWrapper(
|
||||
.sorted()
|
||||
.joinToString("") {
|
||||
val moduleSpecifier = it.toJsStringLiteral()
|
||||
" $moduleSpecifier: await _importModule($moduleSpecifier),\n"
|
||||
" $moduleSpecifier: imports[$moduleSpecifier] ?? await import($moduleSpecifier),\n"
|
||||
}
|
||||
|
||||
val referencesToQualifiedAndImportedDeclarations = jsModuleAndQualifierReferences
|
||||
@@ -205,7 +205,7 @@ fun WasmCompiledModuleFragment.generateAsyncJsWrapper(
|
||||
append(it.jsVariableName)
|
||||
append(" = ")
|
||||
if (module != null) {
|
||||
append("(await _importModule(${module.toJsStringLiteral()}))")
|
||||
append("(imports[${module.toJsStringLiteral()}] ?? await import(${module.toJsStringLiteral()}))")
|
||||
if (qualifier != null)
|
||||
append(".")
|
||||
}
|
||||
@@ -231,10 +231,6 @@ export async function instantiate(imports={}, runInitializer=true) {
|
||||
externrefBoxes.set(ref, ifNotCached);
|
||||
return ifNotCached;
|
||||
}
|
||||
|
||||
async function _importModule(x) {
|
||||
return imports[x] ?? await import(x);
|
||||
}
|
||||
|
||||
$referencesToQualifiedAndImportedDeclarations
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// TARGET_BACKEND: WASM
|
||||
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 12_946
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_579
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_456
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// TARGET_BACKEND: WASM
|
||||
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 47_948
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_605
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_482
|
||||
|
||||
fun box(): String {
|
||||
println("Hello, World!")
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// TARGET_BACKEND: WASM
|
||||
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 14_307
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_134
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 6_011
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// TARGET_BACKEND: WASM
|
||||
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 18_621
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_451
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_328
|
||||
|
||||
object Simple
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// TARGET_BACKEND: WASM
|
||||
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 12_988
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_451
|
||||
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 5_328
|
||||
|
||||
fun box() = "OK"
|
||||
Reference in New Issue
Block a user