Skip to content

Commit 084479f

Browse files
ilgonmicSpace Team
authored and
Space Team
committed
[Gradle, JS] Fix JS export names before cross module refs
^KT-60852 fixed
1 parent 4eb7ed6 commit 084479f

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/JsIrProgramFragment.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ class CrossModuleDependenciesResolver(
128128
}
129129
}
130130

131+
headerToBuilder.forEach { it.value.buildExportNames() }
132+
131133
return headers.associateWith { headerToBuilder[it]!!.buildCrossModuleRefs() }
132134
}
133135
}
@@ -145,13 +147,12 @@ private class JsIrModuleCrossModuleReferenceBuilder(
145147

146148
private lateinit var exportNames: Map<String, String> // tag -> index
147149

148-
private fun buildExportNames() {
150+
fun buildExportNames() {
149151
var index = 0
150152
exportNames = exports.sorted().associateWith { index++.toJsIdentifier() }
151153
}
152154

153155
fun buildCrossModuleRefs(): CrossModuleReferences {
154-
buildExportNames()
155156
val isImportOptional = moduleKind == ModuleKind.ES
156157
val importedModules = mutableMapOf<JsIrModuleHeader, JsImportedModule>()
157158

libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,16 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
620620
}
621621
}
622622
}
623+
624+
@DisplayName("Cross modules work correctly with compose dependency ('KT60852')")
625+
@GradleTest
626+
fun crossModulesWorkCorrectlyWithComposeDependencyKT60852(gradleVersion: GradleVersion) {
627+
project("kotlin-js-compose-dependency", gradleVersion) {
628+
build("compileDevelopmentExecutableKotlinJs") {
629+
assertTasksExecuted(":compileDevelopmentExecutableKotlinJs")
630+
}
631+
}
632+
}
623633
}
624634

625635
@JsGradlePluginTests
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
plugins {
2+
id("org.jetbrains.kotlin.multiplatform")
3+
}
4+
5+
repositories {
6+
mavenLocal()
7+
mavenCentral()
8+
}
9+
10+
kotlin {
11+
js {
12+
binaries.executable()
13+
nodejs {
14+
}
15+
}
16+
sourceSets {
17+
val commonMain by getting {
18+
dependencies {
19+
implementation("org.jetbrains.compose.runtime:runtime:1.4.3") // commenting this out and uncommenting in jsMain fixes the issue
20+
}
21+
}
22+
val jsMain by getting {
23+
dependencies {
24+
implementation("org.jetbrains.compose.html:html-core:1.4.3")
25+
}
26+
}
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kotlin.js.compiler=ir
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4+
*/
5+
6+
import org.jetbrains.compose.web.internal.runtime.ComposeWebInternalApi
7+
import org.jetbrains.compose.web.internal.runtime.DomApplier
8+
9+
@OptIn(ComposeWebInternalApi::class)
10+
fun main() {
11+
DomApplier::class.js
12+
}

0 commit comments

Comments
 (0)