I am trying to port a kotlin.gradle.kts that used ...
# gradle
j
I am trying to port a kotlin.gradle.kts that used
id("org.jetbrains.kotlin.js") version "1.4.10"
to something more modern, and I am deeply confused. Is there any guidance anywhere on how to translate the old syntax to something newer?
No matter what I do, I keep getting "Unresolved reference: implementation" errors.
I assume I should be trying to port to "multiplatform"
👌 1
t
change
js
to
multiplatform
and enable
js()
target in the build script
j
I have a kotlin { js().browser { ... } } block in the code, is that what you mean?
t
yes
j
I still get the errors about implementation for my dependencies
t
Are you adding them via this DSL?
Copy code
kotlin {
    sourceSets["jsMain"].dependencies {
        implementation("com.example:something:12.3")
    }
}
j
That did it! That doesn't look at all like any of the documentation I could find online, though, so I'm not sure how I could have figured that out?
t
Kind of here, but it is for Android. Generally applies to any target platform specific dependencies
j
Do I no longer need the
binaries.executable()
, or does it go somewhere else?
t
should be available inside
js {}
DSL
just change
js()
to
js { }
j
Now it's telling me
Copy code
KotlinSourceSet with name 'jsMain' not found.
🤔 1
I renamed my
src/main
directory as
src/jsMain
but that didn't help
h
Did you actually create the js target:
Copy code
kotlin {
  js {
    browser()
    binaries.executable()
  }
  sourcesets["jsMain"].dependencies {
    implementation() 
  }
}
t
be sure to create JS target before trying to use source sets to add dependencies
j
Ah, the js{} block needs to go before the dependencies block?
👌 1
h
yes