[K/JS] Add warning for ES-modules on the klibgen stage on the uniqueness of the exported names from the module

This commit is contained in:
Artem Kobzar
2023-08-08 15:45:02 +00:00
committed by Space Team
parent 734a3e5716
commit a29fa428b3
15 changed files with 199 additions and 29 deletions
@@ -356,6 +356,19 @@ class Kotlin2JsIrGradlePluginIT : KGPBaseTest() {
}
}
@DisplayName("klib compilation with the declarations name clash")
@GradleTest
fun testProjectWithExportedNamesClash(gradleVersion: GradleVersion) {
project("kotlin-js-invalid-project-with-exported-clash", gradleVersion) {
build("compileKotlinJs") {
assertOutputContains("""
|There are clashes of declaration names that annotated with @JsExport in module 'kotlin-js-invalid-project-with-exported-clash'.
| * Next files contain declarations with @JsExport and name 'best'
""".trimMargin())
}
}
}
@DisplayName("per-file with the declarations validation")
@GradleTest
fun testPerFileProjectWithResultFilesClash(gradleVersion: GradleVersion) {
@@ -0,0 +1,16 @@
plugins {
kotlin("js")
}
repositories {
mavenLocal()
mavenCentral()
}
kotlin {
js(IR) {
useEsModules()
binaries.executable()
nodejs()
}
}
@@ -0,0 +1,7 @@
kotlin.tests.individualTaskReports=true
kotlin.incremental=false
kotlin.incremental.js=false
kotlin.incremental.js.ir=false
kotlin.incremental.js.klib=false
kotlin.incremental.multiplatform=false
kotlin.incremental.useClasspathSnapshot=false
@@ -0,0 +1,11 @@
/*
* Copyright 2010-2019 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.
*/
package first
@JsExport
fun best(): Int {
return 42
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2019 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.
*/
package second
@JsExport
@JsName("best")
public val foo = 44