Is it possible to use the kotlin-wrappers (like ko...
# react
j
Is it possible to use the kotlin-wrappers (like kotlin-react) as a peer dependency? In my use-case I'm generating a js library to be used in a host app that already has react
t
It was NPM publication configuration
Do you need generated
package.json
change?
host app that already has react
Host app - Gradle project?
a
Yes it is possible. We are currently doing this
j
Host app is an existing react project, we're making components to use there with our kmp js project
a
We are not using it in a way of creating components in kotlin js. We create basic hooks and they get used in a plain react applications. I would love to hear your experience in creating components and exporting them to react
t
It looks like question, which require ES6, ES modules and “file to file” compilation before for normal Kotlin/JS evolution I have experience with web components exporting. We used serializers for input/output. As result - only JS types in
index.d.ts
and this issue for future. cc @aerialist @Sergei Grishchenko
File fo file (1 kt -> 1 js) compilation is requirement for component library with fine terser support.
a
@turansky Is there a file to file compilation ticket somewhere?
🙏 1
j
Ah so perhaps I'll have to write my react components in TS and just consume my kotlin js client there 🤔 Right now I'm writing the client for our server in common code and was just hoping to write components for the front end in the JS source set as react components. But it would be enough to just have the http stuff shared as common
But ideally I'd be able to consume this from my host app:
Copy code
fun renderMyWidget(id: String): JSX.Elememt
I'd also be ok with writing my own TS bindings for now, is that doable?
a
I think it is doable. Its just that I haven't done it. I don't see why it shouldn't work. (writing react components in kotlin)
👍 1
j
I'll report back with how it goes