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

spierce7

06/23/2022, 1:49 PM
I’m trying kotlin-js again for the first time in a while. I have a simple module with some JS code compiling using the new IR compiler. What’s the easiest way for me to provide a separate isolated piece of js code for a team to use in a browser?
b

Big Chungus

06/23/2022, 2:09 PM
As in js npm package for them to consume via yarn or npm?
s

spierce7

06/23/2022, 2:15 PM
that’s a worst case scenario
a best case scenario is that I just have a separate artifact hosted somewhere that they can pull into a page dynamically
b

Big Chungus

06/23/2022, 2:19 PM
Oh, then it's even simpler. Use binaries.executable() and then run jsBrowserDistribution task. Afterwards you'll find your js file in build/distribution
s

spierce7

06/23/2022, 2:20 PM
jsBrowserDistribution
will that be properly minified etc?
and compiled for production?
b

Big Chungus

06/23/2022, 2:21 PM
Yes
s

spierce7

06/23/2022, 2:21 PM
I’m a little disappointed that I ran that compilation and the file generated is 173kb
the app does nothing so far lol
It’s including a bunch of stuff that I don’t really use
b

Big Chungus

06/23/2022, 2:23 PM
That's expected. Kjs has quite some initial bloat which becomes less significant as your app grows
s

spierce7

06/23/2022, 2:39 PM
I need to configure it to compile to plain js right?
b

Big Chungus

06/23/2022, 2:44 PM
Shouldn't need to
2 Views