Has someone tried to build kotlin-js project on 1....
# eap
a
Has someone tried to build kotlin-js project on 1.9? For me all
npm
dependencies are not resolved:
Copy code
> Could not resolve all dependencies for configuration ':visionforge-threejs:npm'.
  The project declares repositories, effectively ignoring the repositories you have declared in the settings.
  You can figure out how project repositories are declared by configuring your build to fail on project repositories.
  See <https://docs.gradle.org/8.1.1/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories> for details.
   > Could not find three:0.143.0:.
     Required by:
         project :visionforge-threejs
   > Could not find three-csg-ts:3.1.10:.
     Required by:
         project :visionforge-threejs
   > Could not find three.meshline:1.4.0:.
     Required by:
         project :visionforge-threejs
a
cc @Ilya Goncharov [JB]
a
It seems that repository resolution is changed somehow. The secondary call to
repositories
breaks something
The same problem occurs in KMath when I use additional custom repository added in the root project via
Copy code
allprojects {
    repositories {
        maven("<https://repo.kotlin.link>")
        maven("<https://oss.sonatype.org/content/repositories/snapshots>")
        mavenCentral()
    }
i
Do you have branch where it can be reproduced?
a
Ah, JVM is OK. it is problem with the dependency itself.
@Ilya Goncharov [JB] I will create one soon.
i
Just for note
:visionforge-threejs:npm
is path of Gradle configuration, which resolving all JS dependencies, it does not mean that it is related with NPM dependencies directly. But this
Could not find three:0.143.0
looks like npm dependencies is tried to find in maven repo, but not in NPM
a
Indeed. For some reason it is missing npm repository completely
i
Usually it should not be resolved by maven repositories 🤔 It is dependency with special type
NpmDependency
which is used inside our own NPM integration infrsatructure
a
All Js dependencies are not resolved. There are no changes in the plugin related to JS.
I even tried to change to MPP project as recommended, it did not help.
i
I see 2 problems here If I use standard
kotlin.js
plugin and explicitly set version to
kotlin-wrappers
, configuration works for me (for testing purpose I just leave only
:ui:ring
in
settings.gradle.kts
) So if I remove explicit version of
kotlin-wrappers
, I get following error
Copy code
The project declares repositories, effectively ignoring the repositories you have declared in the settings.
  You can figure out how project repositories are declared by configuring your build to fail on project repositories.
  See <https://docs.gradle.org/8.1.1/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories> for details.
   > Could not find org.jetbrains.kotlin-wrappers:kotlin-ring-ui:.
     Required by:
         project :ui:ring
In fact, we declare repository (as Ivy one) on project to download
Node.JS
and
Yarn
(but it was that earlier as well). So possibly the
dependencyResolutionManagement
has problem here. Another problem is with NPM dependencies If I change
id("org.jetbrains.kotlin.js")
->
id("space.kscience.gradle.js")
I get
Copy code
Could not determine the dependencies of task ':ui:ring:packageJson'.
> Could not resolve all dependencies for configuration ':ui:ring:npm'.
   > Could not find core-js:3.12.1:.
     Required by:
         project :ui:ring
   > Could not find file-saver:2.0.2:.
     Required by:
         project :ui:ring
And it looks like some custom job with dependencies in such plugin, because by default
NpmDependency
type is not in Gradle resolution process. So if you have this, maybe you rely on what
NpmDependency
type was inherited from, but in
1.9.0
it was a bit changed Current version of NpmDependency is here (https://github.com/JetBrains/kotlin/blob/9d8e7991a84222abef7db0e3ba4e059efdf627b7/[…]lin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependency.kt)
a
I get errors even for artifacts not related to kotlin-wrappers.
The only non-standard thing I do in the plugin is this:
Copy code
(project.tasks.findByName("jsProcessResources") as? Copy)?.apply {
                fromJsDependencies("jsRuntimeClasspath")
            }
Copy code
internal fun Copy.fromJsDependencies(configurationName: String) = project.run {
    val configuration = configurations[configurationName]
        ?: error("Configuration with name $configurationName could not be resolved.")
    val projectDeps = configuration.allDependencies.filterIsInstance<ProjectDependency>().map {
        it.dependencyProject
    }
    projectDeps.forEach { dep ->
        dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
            dep.tasks.findByName("jsProcessResources")?.let { task ->
                dependsOn(task)
                from(task)
            }
        }
        dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
            dep.tasks.findByName("processResources")?.let { task ->
                dependsOn(task)
                from(task)
            }
        }
    }
}
It is done to make Js dependencies behave the same way as JVM in terms of resources
But removing it does not solve the problem
i
Ok, looks I find the issue about NPM dependencies, but not with
repositories
, I am not sure that it is related with JS specific (only one thing, is that we add
repository
with nodeJs to project repositories) I am not sure why it started to reproduced only now, but anyway With js plugin, configuration called “npm”, and that forces Gradle to create accessor
fun npm()
and call of
core-js
in
ui:ring
is resolved into this accessor, not onto our wrapper, which just create
NpmDependency
And if change your plugin on standard
org.jetbrains.kotlin.js
,
npm()
resolved to our wrapper. So, that is reason to rename configuration from
npm
to something new to get rid of ambiguity And using of
mpp
plugin should help in this case (because in
mpp
configuration called
jsNpm
instead of just
npm
)
a
It seems to be failing on MPP as well
Ah, sorry, it is failing on js, not mpp. I will check if it works with all projects transformed into mpp
It seems like JS dependencies are fine on MPP. There are still some conflicts, but they are not related to JS.
i
Yes, I am going to fix this by rename configuration, but think it will not be in 1.9.0, but in next versions
m
@altavir Could you please fill YT issue?