Is there a way to incrementally migrate a TS code base to Kotlin/JS?
A bit of context. I have a Gradle multi-project build which consists of:
a Spring Boot server (in Kotlin)
a React app (in typescript) built using Create React App and the Gradle node plugin on top of it
I have recently extracted the API client code from the TS subproject into a Kotlin common (multiplatform) subproject of its own.
Now, I’d like to setup a Gradle build for the React app that can depend on the local multiplatform subproject, and that can compile the existing TS files. Is this possible?
(In the end, the goal is to migrate little by little the whole React app to Kotlin)
I’m chiming in as I have a very similar need: We have a JavaScript project (that gets build via Gradle) which shares the data model with some Kotlin code. We currently have duplicated the data model classes in Kotlin and JavaScript code. Instead of doing that, we’d like to rewrite the JavaScript code in Kotlin file-by-file.
Is there a way to setup the kotlin-js plugin in a Gradle project so that if there is JavaScript code present it is taken as-is, and if there is Kotlin code present it is transpiled to JavaScript (via TypeScript), and in the end a single web app out of both sources is build?
Yes and no, the problem lies in “make your current TS/React app depend on it”.
Yes, it is possible to publish a Kotlin/JS lib (especially since the .d.ts generation support was added), BUT my specific problem is that I can’t publish such a library because it’s a local subproject, on which I depend via Gradle’s mechanim: implementation(project("...")).
I wanted modification to the source code of the common module to affect the UI module, without having to publish a new version at every code change, especially when working locally.
Is it possible to achieve in some way? Maybe we could use a yarn- or npm-specific mechanism to depend on a local built file, and from Gradle we could ensure that the library module is compiled first, so that the distribution files are there for npm/yarn to depend on.