shikhar
06/03/2025, 8:17 PMBernhard
06/04/2025, 8:13 AMBradleycorn
06/04/2025, 2:18 PMbinaries.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.Bradleycorn
06/04/2025, 3:23 PM@JsExport
indicate that we cannot:
@ExperimentalJsExport
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.FILE])
expect annotation class JsExport(source)
Exports top-level declaration on JS platform.
Compiled module exposes declarations that are marked with this annotation without name mangling.
This annotation can be applied to either files or top-level declarations.
It is currently prohibited to export the following kinds of declarations:
expect declarations
inline functions with reified type parameters
suspend functions
secondary constructors without @JsName
extension properties
enum classes
annotation classes
When I add @JsExport
to a basic enum enum class Num { ONE, TWO, THREE }
... it compiles OK, but when I try to use it in javascript (typesript) code, I get a runtime error Cannot read properties of undefined
when I import and use it, like const one = Num.ONE;
Alex Styl
06/05/2025, 8:57 AMEdoardo Luppi
06/05/2025, 6:16 PM> Task :fmproto:compileTestDevelopmentExecutableKotlinJs
00:12:48.789 e: java.lang.IllegalStateException: IrClassSymbolImpl is unbound. Signature: kotlin.js/Promise|null[0]
00:12:48.789 at org.jetbrains.kotlin.ir.symbols.impl.IrSymbolBase.getOwner(IrSymbolImpl.kt:37)
00:12:48.789 at org.jetbrains.kotlin.ir.types.IrTypesKt.getDefaultType(irTypes.kt:173)
00:12:48.789 at org.jetbrains.kotlin.ir.backend.js.lower.TestGenerator.generateCodeForTestMethod(TestGenerator.kt:206)
00:12:48.789 at org.jetbrains.kotlin.ir.backend.js.lower.TestGenerator.generateTestCalls(TestGenerator.kt:120)
00:12:48.789 at org.jetbrains.kotlin.ir.backend.js.lower.TestGenerator.createTestContainer$lambda$5$lambda$4(TestGenerator.kt:67)
00:12:48.789 at org.jetbrains.kotlin.ir.backend.js.WholeWorldStageController.restrictTo(WholeWorldStageController.kt:29)
00:12:48.789 at org.jetbrains.kotlin.ir.backend.js.lower.TestGenerator.createTestContainer(TestGenerator.kt:66)
00:12:48.789 at org.jetbrains.kotlin.ir.backend.js.lower.TestGeneratorKt.generateJsTests(TestGenerator.kt:42)
00:12:48.789 at org.jetbrains.kotlin.ir.backend.js.JsIrCompilerWithIC.compile(compilerWithIC.kt:94)
00:12:48.789 at org.jetbrains.kotlin.ir.backend.js.ic.CacheUpdater.compileDirtyFiles(CacheUpdater.kt:716)
00:12:48.789 at org.jetbrains.kotlin.ir.backend.js.ic.CacheUpdater.loadIrAndMakeIrFragmentGenerators(CacheUpdater.kt:816)
00:12:48.789 at org.jetbrains.kotlin.ir.backend.js.ic.CacheUpdater.actualizeCaches(CacheUpdater.kt:848)
00:12:48.789 at org.jetbrains.kotlin.cli.js.IcCachesKt.prepareIcCaches(IcCaches.kt:118)
Bernhard
06/06/2025, 7:28 AMYassine Abou
06/09/2025, 3:00 PMactual val platformModule = module {
single {
val driver = WebWorkerDriver(
Worker(
js("""new URL("@cashapp/sqldelight-sqljs-worker/sqljs.worker.js", import.meta.url)""") // :x: Error here
)
)
LlmsDatabaseWrapper(driver, LlmsDatabase(driver))
}
}
how could I fix this issue?bod
06/10/2025, 2:51 PMprintln
would go a long wayEdoardo Luppi
06/10/2025, 3:08 PMrequire
inline fun <T : Any> jsRequire(name: String): T =
js("require(name)")
The JS output is something like:
var name = 'something'
return require(name)
The problem here is tools like esbuild do not analyze what name
is, and thus don't correctly bundle the required dependency.
Is there a way to workaround this, that is not unwrapping the require
call?Volodymyr Galandzij
06/10/2025, 5:19 PMPromise<List<Item>>
is exported to TypeScript as Promise<any>
while Promise<JsArray<Item>>
preserves both the container and item types?
Is it expected behavior and we should use `JsArray`/`JsReadonlyArray` to preserve list item type in the Typescript declarations?
// JsItemsRepository.kt file
@OptIn(ExperimentalJsCollectionsApi::class)
class JsItemsRepository() {
fun getAllArrayAsync(): Promise<JsReadonlyArray<Item>> = scope.promise { … }
fun getAllListAsync(): Promise<List<Item>> = scope.promise { … }
fun getFirstAsync(): Promise<Item> = scope.promise { … }
}
// mymodule.d.ts file
class JsItemsRepository {
getAllArrayAsync(): Promise<ReadonlyArray<com.test.my.Item>>;
getAllListAsync(): Promise<any/* kotlin.collections.KtList<com.test.my.Item> */>;
getFirstAsync(): Promise<com.test.my.Item>;
}
hellovass
06/11/2025, 1:57 AMhellovass
06/11/2025, 2:02 AMAlex Styl
06/12/2025, 6:13 AMstripe
package. do i need to create my own external interfaces(or use with dynamic) every time?Luv Kumar
06/13/2025, 7:53 PMsuspend fun foo(): String
should get converted to foo(): Promise<string>;
in Js. From what i know there is no native support for this. I was able to reach a Js signature fooAsync(): Promise<String>;
using kotlin-suspend-transform-compiler-plugin , but i would want to have the same signature(without async) as it would be easier for all 3 targets(android, ios and js) to follow the generated docs and use it.
Is there a way to achieve this ? other obv option is to have duplicate exported api interfaces for only js, but i really don't wish to go that route.
I was also thinking if this plugin or some other plugin could help me generate a synthetic function
@JsExport
@JsName("foo")
fun fooSynthetic(): Promise<String> // generated synthetic function
@JsName("_foo")
suspend fun foo(): String // original function defined in api
If somehow above could be achieved, i was thinking it could work ? (Please correct me if my thought process is wrong here, i am new to KMP)
Thanks.shikhar
06/15/2025, 3:33 AMRemy Benza
06/16/2025, 8:05 AMGenis Lin
06/16/2025, 1:14 PMEdoardo Luppi
06/16/2025, 6:47 PMtsgo
this might become even easier as it won't require a Node instance to be running.PHondogo
06/18/2025, 8:46 PMphteven
06/19/2025, 11:06 AMoutputFileName = “main.bundle-[contenthash].js”
Volodymyr Galandzij
06/19/2025, 6:25 PMHildebrandt Tobias
06/19/2025, 9:34 PMuseQuery<Array<DocumentationElementDto>?, Error, Array<DocumentationElementDto>, QueryKey>(
options = UseQueryOptions(
queryKey = DOCUMENTATION_QUERY_KEY.plus(subCategory),
queryFn = QueryFunction {
secureApi(DocumentationEndpoints
.getDocumentationElement
.copy(optionalQueryParams = pairListOf("category" to subCategory))
)},
refetchOnMount = { _ -> false },
refetchOnWindowFocus = { _ -> false },
refetchOnReconnect = { _ -> false },
refetchInterval = 0,
refetchIntervalInBackground = false,
)
)
In this case
refetchOnMount = { _ -> false },
refetchOnWindowFocus = { _ -> false },
refetchOnReconnect = { _ -> false },
doesn't work, but these two:
refetchInterval = 0,
refetchIntervalInBackground = false,
behave as expected.
I also tried useCallback { _ -> false }
, but it isn't accepted by the compiler.Martin Janči
06/22/2025, 2:38 PMHildebrandt Tobias
06/24/2025, 8:44 PM<http://vis.gl/react-google-maps|vis.gl/react-google-maps>
, but I also loaded googlemaps/js-api-loader
.
If you look at the Marker example there is:
new google.maps.Marker({
position: map.getCenter(),
icon: {
path: google.maps.SymbolPath.CIRCLE,
scale: 10,
},
draggable: true,
map: map,
});
But I can't figure out how to aquire the predefined google.maps.SymbolPath.CIRCLE
constant? object?
Just providing the path as a string doesn't work it says unexpected g at position 0 (the g from google I guess).
I tried
@file:JsModule("@googlemaps/js-api-loader")
@file:JsNonModule
package shared.utils.maps
@JsName("CIRCLE")
external val CIRCLE: dynamic
But that also doesn't work.
I know I can provide my own SVG and PNG and such, but it kinda irks me, someone got an idea?
Edit: Okay I added the npm https://www.npmjs.com/package/google-maps and added:
@file:JsModule("google-maps")
@file:JsNonModule
package shared.utils.maps
@JsName("CIRCLE")
external val CIRCLE: dynamic
But it seems that CIRCLE
is null
when I access it.Hildebrandt Tobias
06/25/2025, 9:07 PM2025.6.11
and now I get
org.jetbrains.kotlin.util.FileAnalysisException: While analysing Authentication.kt:47:1: org.jetbrains.kotlin.utils.exceptions.KotlinIllegalArgumentExceptionWithAttachments: Exception in declaration checker
Caused by: java.lang.IllegalStateException: Symbol for Any not found
For every top level object
declaration like
object Foo {
val bar: Bar
}
where there is no Any
?
EDIT Okay I cleaned and invalidated everything and it doesn't come up for now. I'll check back once the migration is fixed.
Edit2 I get the error with Kotlin 2.1.0, but not with 2.2.0, but migrating to 2.2.0 is much work now. sigh.CLOVIS
06/27/2025, 8:55 PMSargun Vohra
07/01/2025, 5:16 PMconst { PokeApi } = require('pokekotlin').co.pokeapi.pokekotlin
Is there any way to override that namespacing so JS users can use my library like:
const { PokeApi } = require('pokekotlin')
Or alternatively, is there a way to include some custom js and .d.ts in my Kotlin/JS library export? So I can define an index.js myself that re-exports my declarations from the root
My goal is to have a single KMP library with an idiomatic API for Kotlin, Java, JS/TS, and Swift/ObjC, but the package name being exposed to JS is awkward there. It’s more than just the import syntax; LSP tooling like automatic imports and stuff don’t work well when the importable declarations are buried under a package hierarchy.CLOVIS
07/05/2025, 5:27 PMjsBrowserDevelopmentRun
, I get:
• build/js/packages/example-simple/kotlin/example-simple.js
• build/js/packages/example-simple/kotlin/example-simple.js.map
The second one contains:
{
"version": 3,
"sources": [
"../../../../../src/jsMain/kotlin/Main.kt",
"../../../../compileSync/js/main/developmentExecutable/kotlin/src/kotlin/util/Standard.kt"
],
// …
The Main.kt
file refers to my own source code, fine.
However, I don't understand that Standard.kt
file. The build/compileSync/js/main/developmentExecutable/kotlin
folder does NOT contain a src/
folder, and there is no Standard.kt
file anywhere in the build/
directory.
What's going on here?Zyle Moore
07/06/2025, 12:45 AM> Task :web:jsBrowserProductionWebpack
asset web.js 221 KiB [emitted] [minimized] (name: main) 2 related assets
modules by path ../../node_modules/ 539 KiB
modules by path ../../node_modules/react-dom/ 512 KiB 4 modules
modules by path ../../node_modules/react/ 16.9 KiB
../../node_modules/react/index.js 186 bytes [built] [code generated]
../../node_modules/react/cjs/react.production.js 16.7 KiB [built] [code generated]
modules by path ../../node_modules/scheduler/ 10.1 KiB
../../node_modules/scheduler/index.js 194 bytes [built] [code generated]
../../node_modules/scheduler/cjs/scheduler.production.js 9.94 KiB [built] [code generated]
modules by path ./kotlin/*.js 158 KiB
./kotlin/prison-web.js 16.2 KiB [built] [code generated] [3 warnings]
./kotlin/kotlin-kotlin-stdlib.js 124 KiB [built] [code generated] [64 warnings]
./kotlin/kotlin-react.js 2.92 KiB [built] [code generated] [5 warnings]
./kotlin/kotlin-react-core.js 6.69 KiB [built] [code generated] [6 warnings]
./kotlin/prison-core.js 3.82 KiB [built] [code generated]
./kotlin/kotlin-react-dom.js 4.5 KiB [built] [code generated] [6 warnings]
webpack 5.94.0 compiled successfully in 4535 ms