Skip to content

Commit

Permalink
[Gradle, JS] Fix JS export names before cross module refs
Browse files Browse the repository at this point in the history
^KT-60852 fixed
  • Loading branch information
ilgonmic authored and qodana-bot committed Aug 10, 2023
1 parent 4eb7ed6 commit 084479f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class CrossModuleDependenciesResolver(
}
}

headerToBuilder.forEach { it.value.buildExportNames() }

return headers.associateWith { headerToBuilder[it]!!.buildCrossModuleRefs() }
}
}
Expand All @@ -145,13 +147,12 @@ private class JsIrModuleCrossModuleReferenceBuilder(

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

private fun buildExportNames() {
fun buildExportNames() {
var index = 0
exportNames = exports.sorted().associateWith { index++.toJsIdentifier() }
}

fun buildCrossModuleRefs(): CrossModuleReferences {
buildExportNames()
val isImportOptional = moduleKind == ModuleKind.ES
val importedModules = mutableMapOf<JsIrModuleHeader, JsImportedModule>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,16 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
}
}
}

@DisplayName("Cross modules work correctly with compose dependency ('KT60852')")
@GradleTest
fun crossModulesWorkCorrectlyWithComposeDependencyKT60852(gradleVersion: GradleVersion) {
project("kotlin-js-compose-dependency", gradleVersion) {
build("compileDevelopmentExecutableKotlinJs") {
assertTasksExecuted(":compileDevelopmentExecutableKotlinJs")
}
}
}
}

@JsGradlePluginTests
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
id("org.jetbrains.kotlin.multiplatform")
}

repositories {
mavenLocal()
mavenCentral()
}

kotlin {
js {
binaries.executable()
nodejs {
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.jetbrains.compose.runtime:runtime:1.4.3") // commenting this out and uncommenting in jsMain fixes the issue
}
}
val jsMain by getting {
dependencies {
implementation("org.jetbrains.compose.html:html-core:1.4.3")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.js.compiler=ir
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

import org.jetbrains.compose.web.internal.runtime.ComposeWebInternalApi
import org.jetbrains.compose.web.internal.runtime.DomApplier

@OptIn(ComposeWebInternalApi::class)
fun main() {
DomApplier::class.js
}

0 comments on commit 084479f

Please sign in to comment.