https://kotlinlang.org logo
#javascript
Title
# javascript
m

mbonnin

11/06/2023, 12:13 PM
If I'm writing code that's only targeting nodeJS, can I exclude the Browser APIs? I have
kotlin-dom-api-compat
in my dependencies but I'm not sure where it's coming from?
e

Edoardo Luppi

11/06/2023, 1:05 PM
AFAIK it's part of the K/JS stdlib (
kotlin-stdlib
). You may be able to exclude it using the usual Gradle way.
m

mbonnin

11/06/2023, 1:06 PM
Was a bit afraid of that...
Did a bit more digging, looks like it's added by KGP
I wonder how come Browser & Node are not different targets like iosArm64 and macosArm64
JS is the binary format, just like mach-o. What APIs are available is something else
e

Edoardo Luppi

11/06/2023, 1:13 PM
Copy code
project.configurations.all {
  exclude(group = "org.jetbrains.kotlin", module = "kotlin-dom-api-compat")
}
Something like this seem to work to avoid getting it into the classpath.
If you find out a better way, let me know
👍 1
m

mbonnin

11/06/2023, 1:16 PM
This works too:
Copy code
kotlin.js.stdlib.dom.api.included=false
Still this is a weird default
e

Edoardo Luppi

11/06/2023, 1:16 PM
That's a lot better
Did you find the key in the documentation?
m

mbonnin

11/06/2023, 1:16 PM
Good old grep 😅 , it's here
e

Edoardo Luppi

11/06/2023, 1:17 PM
Ahhhh good job. I guess in the current JS status it's worth of a mention in the docs.
m

mbonnin

11/06/2023, 1:20 PM
Just realized it also relates to your comment here. Being able to have 2 sources sets with different dependencies would be cool
e

Edoardo Luppi

11/06/2023, 1:20 PM
Btw, thanks for this. Removing that library exposed a couple of references to the browser
Document
💙 1
Yeah I hope the split happens soon. For the piece of mind of every multiplatform library developer.
Also, the longer it takes to happen, the more messier the transition/conversion will be
👍 1
t

turansky

11/06/2023, 8:15 PM
In Kotlin
1.9.20
I also saw related task property
noStdlib
👀 1
i

Ilya Goncharov [JB]

11/07/2023, 10:07 AM
Hi, Indeed
kotlin-dom-api-compat
earlier was part of stdlib, and during extraction of DOM API from stdlib, we were aware of backward compatibility and that’s why this dependency included by defult. Yes this default can be changed via
kotlin.js.stdlib.dom.api.included=false
We consider possibility to change default and not include this dependency by default
👍 2
💙 1
e

Edoardo Luppi

11/07/2023, 12:15 PM
If it's just a matter of setting
kotlin.js.stdlib.dom.api.included=false
by default, then I agree.
If there is a lot of work to do, I'd just leave it as it is.
3 Views