How do I bundle my kotlin code to a js file? Right...
# javascript
c
How do I bundle my kotlin code to a js file? Right now it's making a jar even though I'm using the kotlin js gradle plugin...
i
You need to use ‘gradle build’ and then in ‘build/distribution’ you find your bundled js
c
That folder doesn't exist
https://pastebin.com/cpvUvv7f This is my current build.gradle.kts
I tried adding kotlin2js but it kept having issues with it not being resolved
Copy code
Plugin [id: 'kotlin2js'] was not found in any of the following sources:
b
You cannot use kotlin2js anymore
it is replaced by a new approach
c
Which is?
I usually just call jsBrowserWebpack for what you are asking
c
I can't seem to be able to use kotlin-dce-js from the plugins scope, do I require the buildscript?
Nevermind, sorry it's been a long day
Thank you so much @bjonnh! Hopefully they update the docs on that, I spent wayyyy too long trying to look for a working method.
b
Yes the doc update should come with 1.3.70
❤️ 1
a lot of things changed…
c
I can tell, every source says something else
Pretty messy
b
I spent quite a few hours getting to something that work…
"work"
c
Lmao
i
c
image.png
Calling
gradle build
doesn't use webpack and the webpackTask doesn't exist by just applying the Kotlin/JS plugin
If I apply the browser target it makes a task called "browserWebpack" which does do what I want, but it should be clarified that you need to set this target and that the name isn't the same
i
Do you have ‘browserWebpack’ task?
c
And calling
gradle build
after setting that target doesn't call it by default
But to be fair, I should've noticed the new task
i
Ok, I see, we need to change name of task
And calling
gradle build
after setting that target doesn't call it by default
It is weird, in my project, it does
c
Can I see your setup?
If I apply
kotlin-dce-js
it appears to make a kotlin-js-min folder on
gradle build
but other than that I don't see what I'm doing wrong
i
https://github.com/ilgonmic/kotlinjs-multi-module/tree/b279010213cd53a3fb56c2bd239ff5a1694bfb94 You can find setup of dce in 1.3.61 Pay attention on ‘app/build.gradle.kts’ and ‘app/webpack.config.d’
c
Maybe it's due to EAP?
i
In head of commit, that I sent, it is 1.3.61, not 1.3.70 In 1.3.70 there will be dce integrated to js plugin by default
❤️ 4