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)
Is there a way to setup the
Indeed, that’s basically what I’m asking as well.
I’d love to be able to have
src/main/js and setup Gradle to use both.
Did you guys find a solution?
Unfortunately no, I gave up and migrated the whole react application in one go.
You can see my whole project here, if it’s any help:
sw-ui subproject is the react UI.
Is it not possible to create an intermediate kotlin-JS lib ? Make your current TS/React app depend on it, and slowly convert components to it ?
I do not know how JS/React projects work, so maybe it’s impossible, or involves too many complexities, but I am curious
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:
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.
I know this is old, but that sounds like a job for
yarn link (or
npm link) which allow you to use local/dev versions of packages