Open vdshb opened 8 months ago
What is your use case? Which types you need in wasmJs?
@turansky I'm creating a KMP class which starts child process in different targets. It supports kotlin/js and uses
node.childProcess.ChildProcess
node.events.Event
from kotlin-wrappers.
I'm also looking for WASM interop with Node.js modules. An example of what I'd like to replace with proper types is:
@Suppress("UNUSED_PARAMETER")
private fun readFileSync(name: String): String =
js(
"""
{
const fs = require('fs');
return fs.readFileSync(name, {
encoding: 'utf8'
});
}
"""
)
public actual fun readBenchmarkFile(name: String): String =
readFileSync("$basePath$name")
Why readFileSync
isn't declared as external
?
@turansky because I'm waiting for kotlin-wrappers to offer external types 😆
I personally use following scripts
js
calls are fine/ I think the main point here is kotlin-wrappers already have those externals, so why rewrite them?
We should find a way to share them between the js
and wasmJs
source sets.
already have those externals, so why rewrite them?
Because they aren't compatible with wasmJs
as I know
We should find a way to share them between the js and wasmJs source sets.
If you need all Node.js declarations probably Kotlin/JS is what you need? :)
If you need all Node.js declarations probably Kotlin/JS is what you need? :)
I don't need all of them, but I guess being WASM is interoperable with JS, people will adopt it by moving incrementally, only some bits, while still calling JS-first APIs.
Because they aren't compatible with wasmJs as I know
That's true. Looks like on WASM, external JS types must derive from JsAny
.
So I think the best approach would be to wait for the K/WASM team to relax the externals requirements.
Maybe you can let them know about this?
wasmJs
KMP target became available in NodeJs. This is a proposal to makekotlin-node
wrappers available on this new target.