Hello beautiful people! Not sure if this is the b...
# javascript
d
Hello beautiful people! Not sure if this is the best place to ask, but I've figured out how to run an application continuously so that the code changes automatically reflect on the browser, and on the JVM side I've managed to get a Ktor project to autoreload so that the code changes propagate without needing to rebuild. However, I am exploring a multi-platform project with a JS client and JVM server, but cannot seem to figure out how to get continuous/autoreload functionality. Has anyone figured this out or know if it's possible?
t
./gradlew run -t
-t
- continuous mode
d
Thank you for the suggestion, Victor! Much appreciated! I tried this (well,
./gradlew browserDevelopmentRun -t
) on a KotlinJS project, but it doesn't seem to translate to the multiplatform project 😞
t
AFAIK webpack dev server not supported for multiplatform
WA - create Kotlin/JS subproject with dependency on multiplatform subproject
a
in multiplatform. If you have a Js target called Js, call`./gradlew browserDevelopmentJsRun -t`
👀 2
m
@Danilo Herrera hey, it worked for me when I added webpack config as described in https://discuss.kotlinlang.org/t/react-in-kotlin-js-what-i-learned-long-but-useful-read/16168
j
I have a mpp project that can reload js just fine, I think it is
./gradlew jsBrowserDevelopmentRun --continuous
The only thing I had to do (but I think with the normal kotlin js as well) is update the webpack config
webpack.config.d
so there are no errors on automatic reload:
Copy code
var path = require('path');


// noinspection JSUnresolvedVariable
config.devServer = config.devServer || {
}; // create devServer in case it is undefined
// noinspection JSUnresolvedVariable
config.devServer.watchOptions = {
    "aggregateTimeout": 5000,
    "poll": 1000
};
âž• 1
I guess the automatic reload is a bit messed up due to recompiling, where the compiled javascript disappears for a while and webpack throws errors that during this it cannot find the js file (even though it still works)
d
[SOLVED] Thank you everyone for the suggestions! I created a new JS Client/JVM Server project and when I tried to run the server and client separately I would get a clash of ports (I could not get autoreload running with the vanilla
run
task). After ensuring that the JS client had an index.html file, changing the port of the back end, and running them individually (and continuously) on separate terminal instances, I managed to get autoreload (for backend) and continuous build (for frontend) working! Thanks again everyone!
🎉 1
c
what backend do you use?
d
@christophsturm Ktor 🙂
c
and it automatically reloads code changes when running with -t?
d
I've been working on the frontend, but your surprised reaction made me double check if I actually did get the backend to auto reload and: 1. I had to ensure I was using JDK8, because it apparently doesn't work JDK9+ according to the Ktor autoreload documentation 2. The build is retriggered on the terminal instance where I ran
./gradlew build -t
. 3. Originally, I was getting a log message indicating that there were no classpath watch patterns in the server configuration. I added the path to the
embeddedServer
watchPaths parameter and was no longer seeing that warning in the terminal window where I ran
./gradlew run
. At this point I assumed everything was working, However, trying it now I'm not actually seeing the changes reflected when I make new API calls after making code changes. Looks like I will have to wrestle some more with it.