This is not related to Kotlin but for running the ...
# javascript
t
This is not related to Kotlin but for running the code while development a Kotlin JS project (or KMP with JS). I would like to share another solution for build and hot reload the new code with NodeJS instead of Gradle
Copy code
// package.json
{
    "devDependencies": {
        "live-server": "^1.2.2",
        "nodemon": "^2.0.22",
        "npm-run-all": "^4.1.5"
    },
    "scripts": {
        "watch": "nodemon",
        "serve": "live-server --host=localhost --port=8080 build/developmentExecutable/",
        "dev": "run-p watch serve"
    },
    "nodemonConfig": {
        "verbose": true,
        "ignore": [
            "**/src/test/**",
            "**/build/**"
        ],
        "ext": "kt,scss,html",
        "exec": "./gradlew browserDevelopmentExecutableDistribution",
        "delay": 2500
    }
}
I came up with this solution since while developing my app (MonoSketch)
./gradlew browserDevelopmentRun --continuous
(also
jsBrowserRun
for KMP when I tried to convert the project to KMP) does not reflex the new code. I tried several way to fix (like
-Dorg.gradle.parallel=false
) but after a day or two, it does not work again. The solution with NodeJS works more stable and does not auto reload whenever I just save the code (
browserDevelopmentRun
triggers hot reload on save before the code is compiled).
On MonoSketch (~17k LOC Kotlin), the build speed with cache is quite fast and also similar to
browserDevelopmentRun
when it works well.