[K/JS] Fix reexport with CommonJS and incremental compilation

This commit is contained in:
Artem Kobzar
2023-10-26 09:58:35 +00:00
committed by Space Team
parent 2bb3b84e7e
commit 6cd42eeb71
21 changed files with 163 additions and 5 deletions
@@ -0,0 +1,2 @@
inline fun foo() = 77
fun gaz() = 99
@@ -0,0 +1,2 @@
@JsExport inline fun foo() = 77
fun gaz() = 99
@@ -0,0 +1,2 @@
@JsName("bar") @JsExport inline fun foo() = 77
fun gaz() = 99
@@ -0,0 +1,2 @@
@JsName("baz") @JsExport inline fun foo() = 77
fun gaz() = 99
@@ -0,0 +1,2 @@
@JsName("baz") @JsExport inline fun foo() = 77
@JsExport fun gaz() = 99
@@ -0,0 +1,2 @@
@JsName("baz") @JsExport inline fun foo() = 77
@JsName("gaz77") @JsExport fun gaz() = 99
@@ -0,0 +1,2 @@
@JsName("baz") @JsExport inline fun foo() = 77
@JsName("gaz99") @JsExport fun gaz() = 99
@@ -0,0 +1,28 @@
STEP 0:
modifications:
U : l1.0.kt -> l1.kt
added file: l1.kt
STEP 1:
modifications:
U : l1.1.kt -> l1.kt
modified ir: l1.kt
STEP 2:
modifications:
U : l1.2.kt -> l1.kt
modified ir: l1.kt
STEP 3:
modifications:
U : l1.3.kt -> l1.kt
modified ir: l1.kt
STEP 4:
modifications:
U : l1.4.kt -> l1.kt
modified ir: l1.kt
STEP 5:
modifications:
U : l1.5.kt -> l1.kt
modified ir: l1.kt
STEP 6:
modifications:
U : l1.6.kt -> l1.kt
modified ir: l1.kt
@@ -0,0 +1,8 @@
@JsModule("test")
external fun test(step: Int): String
fun box(step: Int): String {
if (foo() != 77) return "Fail foo"
if (gaz() != 99) return "Fail gaz"
return test(step)
}
@@ -0,0 +1,6 @@
STEP 0:
dependencies: lib1
added file: m.kt
STEP 1..6:
dependencies: lib1
updated imports: m.kt
@@ -0,0 +1,21 @@
IGNORE_PER_FILE: true
MODULE_KIND: commonjs
MODULES: lib1, main
STEP 0:
libs: lib1, main
dirty js modules: lib1, main
dirty js files: lib1/l1, main/m, main/m.export, main
STEP 1:
libs: lib1, main
dirty js modules: lib1, main
dirty js files: lib1/l1, lib1/l1.export, lib1, main/m
STEP 2..3:
libs: lib1, main
dirty js modules: lib1, main
dirty js files: lib1/l1, lib1/l1.export, main/m
STEP 4..6:
libs: lib1, main
dirty js modules: lib1, main
dirty js files: lib1/l1, lib1/l1.export, main/m
@@ -0,0 +1,34 @@
module.exports = function (step) {
const lib1 = require("./main.js")
let result;
switch (step) {
case 0: return "OK"
case 1:
result = lib1.foo()
return result === 77 ? "OK" : `Fail 1: Expect 77 but got ${result}`
case 2:
result = lib1.bar()
return result === 77 ? "OK" : `Fail 2: Expect 77 but got ${result}`
case 3:
result = lib1.baz()
return result === 77 ? "OK" : `Fail 3: Expect 77 but got ${result}`
case 4:
result = lib1.baz()
if (result !== 77) return `Fail 4: Expect 77 but got ${result}`
result = lib1.gaz()
return result === 99 ? "OK" : `Fail 4: Expect 99 but got ${result}`
case 5:
result = lib1.baz()
if (result !== 77) return `Fail 5: Expect 77 but got ${result}`
result = lib1.gaz77()
return result === 99 ? "OK" : `Fail 5: Expect 99 but got ${result}`
case 6:
result = lib1.baz()
if (result !== 77) return `Fail 6: Expect 77 but got ${result}`
result = lib1.gaz99()
return result === 99 ? "OK" : `Fail 6: Expect 99 but got ${result}`
}
return "OK"
}