/* Kotlin js output assumes window exists, which it won't on Workers. Hack around it */
(new File("$projectDir/index.js")).text = "const window=this; " + file("$projectDir/build/distributions/${rootProject.name}.js").getText()
How do I write this in build.gradle.kts?
Copy code
File("$projectDir/index.js").text
Where .text seem to be some kind of extension to the File object that is not available in Kotlin?
PS. I don't know why they use kotlin.target.browser and not target.nodejs but maybe it is to get access to org.w3c.* stuff.
Thanks!
e
eskatos
07/30/2020, 5:54 PM
file.text
=>
file.readText()
file.text = "some"
=>
file.writeText("some")
🤩 2
👆 2
K 2
👍 2
d
David Eriksson
07/30/2020, 5:56 PM
Thanks a lot @eskatos, seems obvious in hindsight but I really had googled 🙂
simple smile 2
g
gildor
08/04/2020, 3:58 AM
It actually looks as wrong config, not clear why they do target browser,
kotlin.target.browser
it probably should be
kotlin.target.nodejs
)
So it will not require any hacks
gildor
08/04/2020, 3:59 AM
If you have some working example, I would instead try to fix it