I'm working on a project with an online CMS, and a...
# compose-web
m
I'm working on a project with an online CMS, and as part of that I want to be able to allow custom scripting in Kotlin/JS. Is there any way to apply Compose on those kotlin scripts or would I need to bundle all of gradle and configurations for that?
a
it’s possible to apply compiler plugins with some hacks https://youtrack.jetbrains.com/issue/KT-47384, so you could try looking into applying the Compose plugin the same way Alternatively, create a custom scripting host https://kotlinlang.org/docs/custom-script-deps-tutorial.html But I suspect that IntelliJ will struggle, even if one of those two options is compilable
m
Hmm, I haven't been able to find how to set this up with a JS host. Do you know where I can find documentation on this?
n
"JS host" - I think scripting is JVM-only...
m
Hmm, so there's no way to let users write composable functions for web that get compiled and executed at runtime?
a
I think it would be possible, but certainly not easy! Try looking through how the Kotlin Playground works https://github.com/JetBrains/kotlin-playground It has a ‘JUnit’ mode, so it’s possible to add new dependencies. I’m just not certain how it will react to adding a compiler plugin. You could open a feature request?
h
It does not work in the browser, the Kotlin compiler is JVM only. The playground sends the input to a JVM backend, which compiles and executes the code, and returns the results. You could do the same though.
m
Yeah I'm currently looking through it, though I'm unsure how I'm supposed to add dependencies to the classpath when I've added them as
implementation
on the backend
It feels like the best solution is to just create a temporary directory and set up an entire gradle project to build the JS file