If I want a shared source set for `js` and `wasmJs...
# webassembly
e
If I want a shared source set for
js
and
wasmJs
should I just use
wasmJs
and leave out
js
entirely?
a
It depends on the use case. If you have a reach @JsExport API (classes, properties, etc), in this case you still can't drop
js
target, but if you don't have exported declarations or the exported declarations are functions - yes, you can use only
wasmJs
s
wasmJs
is a Kotlin/Wasm target that creates Wasm, which is expected to run in a JS environment.
js
is a Kotlin/JS target that produces JS. You need both if you want to support both JS and Wasm platforms.
e
So if my library only supports
wasmJs
and a Kotlin/JS consumer wanted to use it, it wouldn't be able to? i.e. it can't import it and wrap it or something like that?
s
To a large extent yes. Although it is possible, you would need to go through regular JS interop. Your library would need to export functions from Wasm to JS. And Kotlin/JS consumer would need to have
external
declarations describing your API.