Closed lukellmann closed 4 months ago
For Node.js applications you need use CommonJS or ES module (both modular).
kotlin {
js {
useCommonJs()
// useEsModules() (fine default for Node and Browser)
}
}
also you configure module kind like here
The usage is in context of a Kotlin/JS library targetting nodejs. Is choosing one of CommonJS or ES modules instead of UMD going to impact Kotlin/JS applications using the library? I.e. will it force the chosen module system on them?
I.e. will it force the chosen module system on them?
Partially. You can force modular module system (CommonJS or ESM) via declarations - like we do. Module kind of library isn't important, because it doesn't affect klib.
In Kotlin Wrappers we support modular declarations only.
@JsNonModule
means, that your library is available in global.
But how it will be called?
I.e. will it force the chosen module system on them?
Partially. You can force modular module system (CommonJS or ESM) via declarations - like we do. Module kind of library isn't important, because it doesn't affect klib.
Alright, this doesn't apply to my case, the Kotlin/JS library only exports Kotlin declarations (which are handled by klib if I understand correctly) and doesn't have any public external
declarations. So I'll choose useCommonJs()
.
Should I close this issue?
I get this compilation error when trying to use
node.process.process
:Am I doing something wrong or is this a problem with
kotlin-node
? The suggestedJsNonModule
annotation is missing onprocess
: https://github.com/JetBrains/kotlin-wrappers/blob/6444bd21d4146d7d9115c5300d14f573c92e720a/kotlin-node/src/jsMain/kotlin/node/process/process.export.kt