Holla, I wanna ask something regarding <https://y...
# javascript
a
Holla, I wanna ask something regarding https://youtrack.jetbrains.com/issue/KT-47038. Its an issue about allowing The kotlin/JS compiler to target multiple platforms just like how kotlin/native does. Lately I have been supplying JS bundled libraries to users who are consuming it in react native, and I can tell that, react native is neither a browser environment nor a node environment, even more it tends to switch context when running on chrome debugger (browser) vs on mobile (JavaScriptCore). So having only (jsBrowser & jsNode) targets as suggested on the issue won't be targeting all potential targets. This made me look for other targets as well, I discovered something like jsdom which runs in node but tries to mimic the browser. There are also others like NativeScript e.t.c This made me ponder on the question, as to how many targets will suffice? Should we just have all of them? what could/would the compiler offer on such targets?? your thoughts on this?
c
My understanding is that the solution JetBrains aims for is to allow platform modules to depend on each other of the same type, so you could have multiple js source sets with different dependencies, and then you'd be able to create whatever variants you want
j
I guess there are 2 goals: 1. limit usages of platform bindings to the correct JS environments: browser stuff like
window
should not be available in node environment, and
process
should not be available in browser environment. Maybe other targets exist, but the more important thing is that those platform specific Kotlin bindings are only present in the right places (to avoid stupid runtime errors) 2. share common Kotlin/JS code among all JS targets (node, browser, etc.), and declare independent sets of dependencies for different targets