Stefan Oltmann
09/01/2025, 8:34 AMjs()
interop, too.
I like this to be Kotlin/WASM, but the sample (a fork from the original hello world) I found was outdated and didn't work for me.
So I appeciate if you drop me hints how to improve or helpful ressources (like sample code) how to properly work with Kotlin/JS (or even better Kotlin/WASM) on Cloudflare Workers. 🙂Edoardo Luppi
09/01/2025, 3:15 PM@EagerInitialization
annotation.
If that is the case:
1. could it be also applicable to top-level functions? This would be useful for code that has to run when the JS module is initialized. The current workaround is a property that calls a function.
2. could we instead move to an annotation that starts with @Js*
to streamline the naming? For example @JsEager
or @JsImmediate
.grahamborland
09/02/2025, 11:12 PMExecution failed for task ':kotlinNpmInstall'.
> Process 'Resolving NPM dependencies using yarn' returns 1
Unknown Syntax Error: Unsupported option name ("--network-concurrency").
Any workaround?CLOVIS
09/03/2025, 7:47 PMuseCommonJs()
. To detect that, I'm using:
val moduleKind = project.objects.property<JsModuleKind>()
project.tasks.withType<org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink> {
moduleKind.set(compilerOptions.moduleKind)
}
but by the time moduleKind
is set, it's not allowed to add a implementation(npm("foo", "1.0.0"))
anymore.
I've also tried having a : RequiresNpmDependencies
task with a dependency set that changes once moduleKind
is known, and that works without the configuration cache, but with it I get a serialization crash within the configuration cache itself.jamshedalamqaderi
09/04/2025, 9:59 AMTristan
09/04/2025, 6:17 PMjsBrowserProductionLibraryDistribution
js {
moduleName = project.name
useEsModules()
binaries.library()
}
I have the following code
@Inject
internal class InvocationHandler(
private val exposedFunctions: Map<String, Provider<ExposedFunction>>,
) {
operator fun invoke(
onInvocations: SharedFlow<Invocation>,
): Flow<Invocation> {
return onInvocations
.onEach {
val exposedFunction = exposedFunctions[it.location] ?: return@onEach
it.handle {
val fn = exposedFunction()
fn(it.parameters) // This throws an error on JS
}
}
}
}
// ...
@Inject
@ContributesIntoMap(AppScope::class)
@ExposedAtLocation(ExposedFunctionLocation.IS_FILE_CACHED)
internal class IsFileCached(private val cacheRepository: CacheRepository) : ExposedFunction {
override suspend fun invoke(args: List<Any>): Any {
val fileUrl = args[0] as? String ?: return false
return cacheRepository.isCached(fileUrl)
}
}
For the code above, I will get
TypeError: fn is not a function
And if I print with fn.toString
function (_this__u8e3s4, $completion) {
return i.v8b(_this__u8e3s4, $completion);
}
Do you know what could cause this issue?CLOVIS
09/05/2025, 6:32 PMkotlin-kotlin-stdlib.js
const DYNAMIC_MODULES_ID = '\0commonjs-dynamic-modules';
const HELPERS_ID = '\0commonjsHelpers.js';
Note the \0
.
Has anyone seen this before?Alex Styl
09/09/2025, 4:13 AMCould not locate the bindings file
when I am installing sqlite3
as a npm() dependnecy in build.gradle.kts:
implementation(npm("sqlite3", "5.1.7"))
I think it has something to do with native bindings (C ?) . The library is this one
Any pointers on how to use it in kotlin /js ?Cas Van Luijtelaar
09/09/2025, 7:22 AMe: org.jetbrains.kotlin.util.FileAnalysisException: Somewhere in file /Users/casvanluijtelaar/Projects/***/deals/DealsOfferKey.kt: java.lang.NullPointerException: null cannot be cast to non-null type org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
at org.jetbrains.kotlin.util.AnalysisExceptionsKt.wrapIntoFileAnalysisExceptionIfNeeded(AnalysisExceptions.kt:62)
at org.jetbrains.kotlin.fir.FirCliExceptionHandler.handleExceptionOnFileAnalysis(Utils.kt:251)
at org.jetbrains.kotlin.fir.resolve.transformers.FirSupertypeResolverTransformer.transformFile(FirSupertypesResolution.kt:892)
at org.jetbrains.kotlin.fir.declarations.FirFile.transform(FirFile.kt:46)
at org.jetbrains.kotlin.fir.resolve.transformers.FirTransformerBasedResolveProcessor.processFile(FirResolveProcessor.kt:48)
at org.jetbrains.kotlin.fir.resolve.transformers.FirTotalResolveProcessor.process(FirTotalResolveProcessor.kt:36)
at org.jetbrains.kotlin.fir.pipeline.AnalyseKt.runResolution(analyse.kt:24)
at org.jetbrains.kotlin.fir.pipeline.FirUtilsKt.resolveAndCheckFir(firUtils.kt:76)
when I try to build jsBrowserDevelopmentLibraryDistribution
seems to throw on any file with kotlinx-serializable imported. e.g. this file only contains:
import kotlinx.serialization.Serializable
@Serializable
data class DealsOfferKey(
val offerId: Int,
val offerInstanceUniqueId: String?,
)
removing the annotation and the import fixes the issue. but then errors on one of a million other files with serializable included.
Anyone seen this before?Edoardo Luppi
09/10/2025, 8:55 AMEdoardo Luppi
09/10/2025, 9:51 AMString.substring
approach is better because it directly calls JS' substring
, however it now produces:
substring(response, startIndex, endIndex);
Where substring
is:
function substring(_this__u8e3s4, startIndex, endIndex) {
_init_properties_stringJs_kt__bg7zye();
// Inline function 'kotlin.js.asDynamic' call
return _this__u8e3s4.substring(startIndex, endIndex);
}
If instead you bring back inline
for those two functions https://github.com/JetBrains/kotlin/blob/400e1ecadbef70744b6ee7eb6234a0a6ea8bbda8/libraries/stdlib/js/src/kotlin/text/stringJs.kt#L274-L276
you won't have to pass by the lazy initialization of the file-level properties. A similar situation is valid for Long
too as far as I can see.
Alternatively properties could be marked with EagerInitialization
.MrPowerGamerBR
09/11/2025, 7:23 PM@JsName
on properties declared on a @JsPlainObject
? I wanted to change some snake_case
variables into camelCase
, to make it look "better" in Kotlin
I tried searching for it, but the only result of someone trying to do this was this conversation: https://kotlinlang.slack.com/archives/C0B8L3U69/p1728428182216839
However after testing it, it doesn't seem to work on Kotlin 2.2.0 😞Marc
09/12/2025, 11:41 AMfun main() {
ubyteArrayOf(
*listOf(ubyteArrayOf())[0]
)
}
results in:
Unhandled JavaScript exception: listOf(...).get_c1px32_k$(...).slice is not a function
https://pl.kotl.in/nEyBqjkBZ
The same code works just fine when replacing ubyteArrayOf
with byteArrayOf
or running it on JVM instead.CLOVIS
09/13/2025, 4:01 PMedenman
09/16/2025, 8:43 PMAndreas Martin Mørch
09/19/2025, 12:22 PMimplementation(npm(package, version))
does not invalidate build cache?
Kotlin 2.2.0, Gradle 8.12
Running build before and after changing the NPM dependency shows the same build cache key for compileKotlinJs
.
I would expect this to trigger a failed build and prompt the user to run kotlinUpgradeYarnLock
like normal.Stefan Oltmann
09/21/2025, 3:03 AMBernhard
09/25/2025, 7:59 AM{GridCoordinates2D|HexagonalGridCube2D|Point} HexagonalGridCoordinates2D
and wondered, if there was a way to model that in Kotlin. Couldn't you use a marker interface for that? As in: an empty interface that all of these types extend?Jan Biedermann
09/26/2025, 6:14 AMOliver.O
09/26/2025, 12:33 PMLuv Kumar
09/26/2025, 4:56 PMinit {}
block but not only kotlin gives warning for that, it's cumbersome process to add to all exposed classes and would pollute the code as well.Horatio Thomas
09/30/2025, 10:31 AMNickolay
10/03/2025, 10:21 PMArtem Kobzar
10/07/2025, 7:00 AMEdoardo Luppi
10/07/2025, 12:25 PMNickolay
10/09/2025, 4:19 PMcommonMain
to JS that can be implemented in Typescript? - Stack Overflow](https://stackoverflow.com/questions/79786639/can-we-expose-interfaces-from-commonmain-to-js-that-can-be-implemented-in-type)MrPowerGamerBR
10/10/2025, 2:12 AMkotlin-browser
bindings for Web Components have changed quite a bit, and now I'm not able to get a custom element to workAlex Styl
10/13/2025, 9:26 AMEdoardo Luppi
10/13/2025, 9:41 AMNickolay
10/13/2025, 9:25 PMd.ts
to have KDoc comments transferred over to d.ts
from the Kotlin files?