Also, is there a way to not bundle everything and ...
# javascript
t
Also, is there a way to not bundle everything and generate the stdlib in a separated file?
@Big Chungus pinging you directly on that topic if you ever know about this as well. With your plugin, is it possible to not bundle kotlin/js into the library output? I am using IR, which as you said, does it automatically.
b
What do you mean by kotlin/js in this context?
stdlib?
t
Yes
b
My plugin picks-up IR mode and automatically skips kotlin/js dependency bundling (under the assumption that relevant pieces are already in the js output). It then only declares npm dependencies from gradle into generated package.json
bundledDependencies are only used in legacy mode as a hack, since most of the kotlin.js libs are not on npm
This does mean that if your js consumer
application-js
project depends on two kotlin.js libs
lib-a-kt
and
lib-b-kt
that both in turn depend on
lib-c-kt
, you'll get stdlib and
lib-c-kt
pieces duplicated in both,
lib-a-kt
and
lib-b-kt
js outputs
Not a big problem as it only bloats dependencies size. You shouldn't encounter any conflicts or other issues when using them.
There's now a new "-Xir-per-module" compiler flag that seems to be doing exactly what you initially asked.
t
Thanks for the update. Do you know if it enables dynamic imports out of the box?
b
Not sure what you mean with dynamic imports. All this flag does is spitting out separate dce'd js pile per kotlin dependency your module has.
t
It was actually covered here 😕 https://youtrack.jetbrains.com/issue/KT-20679 I suppose such feature does not exist yet 😊