Is there any documentation for the `binaries.libra...
# javascript
b
Is there any documentation for the
binaries.library()
configuration? I understand at a high level what it does (produce a distributable node library), but I can't seem to find any documentation for it, or any official information about how/when to use it.
e
Indeed, I can't find a reference about
library
in the docs. Generally speaking,
executable
will set up additional tasks compared to
library
, mostly related to being able to execute the project via Gradle. An executable for the browser will also end up being minified in production runs.
library
is ok when the code will have to be imported somewhere else (e.g. from JS or TS). Note that if your project will be consumed by other Kotlin projects only, you actually don't need to specify the binary type, as you don't need a distribution.
b
Yeah, I am indeed writing a library that will be imported into other typescript projects via npm So, I am using
library
. It works fine. I was really just curious as to what it's doing and how it works.
e
library
will set up a binary object and its associated tasks to create a distribution, which is basically the built package you could upload to npm.
a
There is little bit of some documentation here: https://kotlinlang.org/docs/js-project-setup.html#execution-environments
The instruction
binaries.executable()
explicitly instructs the Kotlin compiler to emit executable
.js
files. Omitting
binaries.executable()
will cause the compiler to only generate Kotlin-internal library files, which can be used from other projects, but not run on their own.
For some context: having a 'binaries' option for JS was influenced by Native also having 'binaries', so that's the origin of the name, but it's a confusing abstraction.
e
Tho you can potentially have multiple compilations and multiple associated binaries. It makes sense to some degree I think, at least there is extensibility.
Insert deprecated multiple same targets complaint 😭