karakum-team / karakum

Converter of TypeScript declaration files to Kotlin declarations
Apache License 2.0
42 stars 2 forks source link

Plugin system in Kotlin? #1

Open joffrey-bion opened 1 year ago

joffrey-bion commented 1 year ago

From what I could see, customizations of Karakum are currently done by writing plugins in TS.

The target audience for this tool seems to be people using Kotlin primarily, and who are trying to wrap typescript libraries into Kotlin externals so they can use it from Kotlin/JS. I guess it's fair to assume that those people want to write Kotlin code.

Are there any plans to add the possibility to write plugins for Karakum in Kotlin?

joffrey-bion commented 1 year ago

I imagine we could use Kotlin/JS in this case, and compile the plugin to javascript so it can be called by Karakum which is running in node (AFAICT). For this, we would need to have externals for the typescript package so we can manipulate the TypeScript AST from Kotlin. Maybe we could use Karakum to generate those externals 😄

I guess the above approach would be most relevant in Gradle projects (thus using the Karakum Gradle plugin), as I don't think it would be useful to support Kotlin plugins for "pure" NPM projects using Karakum without Gradle. Therefore, we could leverage the Kotlin JS Gradle plugin to compile the Kotlin plugins for Karakum, and do this as a dependency of the Karakum Gradle plugin's tasks. It is possible to "react" (pun intended) to the presence of the Kotlin/JS plugin to enable this behaviour in the Karakum Gradle Plugin.

turansky commented 1 year ago

For this, we would need to have externals for the typescript package

Do you mean kotlin-typescript? :)

joffrey-bion commented 1 year ago

Haha I didn't even search for it, but I'm happy to see it's already there ☺️

sgrishchenko commented 1 year ago

Maybe we could use Karakum to generate those externals

Yea, that was my intention, I converted React Router to improve Karakum, the next step - conversion of Typescript.

lppedd commented 8 months ago

I've seen @sgrishchenko is doing quite some progress with this tool!

Was the decision simply to stick to TS, or is switching to K/JS still an option?
I ask mostly because the plugin system doesn't have types, as far as I can see, so it's very difficult to use.

sgrishchenko commented 8 months ago

I am definitely going to use Kotlin at some point. Now I fully converted Node declaration to Kotlin, so I am one step closer to it. Next step - convertion of Typescript compiler declarations.

lppedd commented 8 months ago

Thanks @sgrishchenko! Looking forward to it!