Hey all! I am currently doing some investigation into the feasibility of compiling
ktlint
wrapped up into a wasm file for a formatting framework, see this. I figure before I do too much deep diving it might be good to ask the experts if this is possible 🙂. From the brief investigation I have done so far it looks like using kotlin native might be the best option but I still haven’t determined how complete that is and if it would work for this use case.
s
Svyatoslav Kuzmich [JB]
11/22/2022, 8:54 AM
Hey! Kotlin/Native Wasm target currently relies on having a JavaScript environment to run. This probably won’t change in the near future, as it’s no longer being actively developed.
After having a quick look at dprint plugin system, a native plugin, that bridges Rust <=> C <=> Kotlin/Native (w/o Wasm) could be an option.
Svyatoslav Kuzmich [JB]
11/22/2022, 9:11 AM
Also, porting a big JVM-only project to a different Kotlin platform can be a challenge.
r
Ryan Rushton
11/22/2022, 11:39 PM
Thanks @Svyatoslav Kuzmich [JB]! Yeah my fallback was to process/native plugin but I am worried that starting up a new JVM for each format would be pretty slow. I might see if I can do the
C
bridge like you pointed out rather than trying to keep a JVM running over an extended period.
s
Svyatoslav Kuzmich [JB]
11/23/2022, 7:38 AM
It seems that ktlint heavily depends on Kotlin compiler, which is not ported to Kotlin/Native. “C” bridge is probably not an option after all
r
Ryan Rushton
12/02/2022, 9:13 AM
Ah damn, that means my only option is running it as an daemon/server and communicating via a bitstream or something. I was hoping to not have to do that