Does auto rebuild / auto reload for Kotlin/JS work...
# javascript
b
Does auto rebuild / auto reload for Kotlin/JS work in 1.3.61 or is it only supposed to work later in 1.4?
i
It should work, do you have problems with it?
b
Yes, i'm working on a fullstack kotlin example and my frontend is getting build properly without a continuous mode, but i'm getting an error when i'm trying to run the gradle Task wit
-t
option. I have the corresponding error at the end of my README.md here: https://github.com/bdudelsack/kotlin-fullstack-example
i
Do you have error only with
./gradlew :frontend:run  -t
? Without continous mode
./gradlew :frontend:run
works properly?
b
yes
i have to delete
build
and
frontend/build
directories after i ran
./gradlew :frontend:run -t
oh, i see now that consecutive runs of
./gradlew :frontend:run
do not work too
i
I think, it is related with https://youtrack.jetbrains.com/issue/KT-35197 WA can be to use non-npm dependencies, but gradle
kotlin-wrappers
instead https://bintray.com/kotlin/kotlin-js-wrappers But it is necessary to check
b
Ah, ok ... i firstly used the libraries from maven and switched to npm later. I will revert this change and check if it works.
so, i have a better result now. No missing references, but it still cannot compile it again and seems to miss the main JS-file
Copy code
ERROR in ./kotlin/kotlin-fullstack-example-frontend.js
Module build failed (from /home/bdudelsack/Projects/kotlin-fullstack-example/build/js/packages_imported/kotlin-source-map-loader/1.3.61/kotlin-source-map-loader.js):
Error: ENOENT: no such file or directory, open '/home/bdudelsack/Projects/kotlin-fullstack-example/build/js/packages/kotlin-fullstack-example-frontend/kotlin/kotlin-fullstack-example-frontend.js'
 @ multi ./kotlin/kotlin-fullstack-example-frontend.js main[0]
> Task :frontend:compileKotlinJs
> Task :frontend:processResources UP-TO-DATE
> Task :frontend:browserRun
the file is actually there when i check ... maybe some timing problem?
it actually recompiles the frontend but i have to reload the browser by myself
i
It is weird, everything is ok for me in your project with reverting
8f4b7a17ac4eb3f23053f935c5b572e7bbc1f5f5
If you have some errors in console, please print it here
n
on linux it works for me, automatically recompies and refreshes the tab
b
it does eventually reload the changes now, but there is still an error in the console:
Copy code
✖ 「wdm」: Hash: 6513f41ecb91190706be
Version: webpack 4.41.2
Time: 19ms
Built at: 2019-12-10 17:10:03
      Asset     Size  Chunks             Chunk Names
frontend.js  892 KiB    main  [emitted]  main
Entrypoint main = frontend.js
[./kotlin/kotlin-fullstack-example-frontend.js] 382 bytes {main} [built] [failed] [1 error]
    + 33 hidden modules

ERROR in ./kotlin/kotlin-fullstack-example-frontend.js
Module build failed (from /home/bdudelsack/Projects/kotlin-fullstack-example/build/js/packages_imported/kotlin-source-map-loader/1.3.61/kotlin-source-map-loader.js):
Error: ENOENT: no such file or directory, open '/home/bdudelsack/Projects/kotlin-fullstack-example/build/js/packages/kotlin-fullstack-example-frontend/kotlin/kotlin-fullstack-example-frontend.js'
 @ multi ./kotlin/kotlin-fullstack-example-frontend.js main[0]
> Task :frontend:compileKotlinJs
> Task :frontend:processResources UP-TO-DATE
> Task :frontend:browserRun
> Task :frontend:run

BUILD SUCCESSFUL in 869ms
8 actionable tasks: 2 executed, 6 up-to-date
k
I am facing the same error, but I am not sure if it's the same cause or not. I am working on a relatively big project and the :compileKotlinJs time is 18s! Thus when webpack runs the kt files are not compiled yet. When I set aggregateTimeout to 20 seconds the error disappears. But 18s for a build is too long. Is this normal? It is as if the incremental build is not enabled but it should be enabled automatically in versions 1.3.20 and above. Right?
i
Can you attach a link to your project?
k
After a lot of debugging, it seems the problem was with the version of the gradle wrapper. I was using v4.10 but when I upgraded to v6.2 compilation became instantly fast. I wish the kotlin-gradle didn't flat out work with old gradle versions; it would've saved me some time trying to figure out what the problem was.
b
I've updated my project to Gradle v6.2. But the error is still present. Project can be found here: https://github.com/bdudelsack/kotlin-fullstack-example Steps to reproduce: 1.
./gradlew :frontend:run -t
2. Change some text in
src/main/kotlin/com.bdudelsack.fullstack/Application.kt
k
Now that I've removed the aggregateTimeout from webpack config I am getting the same error as yours above. I think it is because webpack is watching the files and when they change, it tries to reload them but Kotlin hasn't finished compiling them yet. Although incremental compilation is fast enough for development, it is slower than webpack refresh speed. I think if you set sufficient aggregateTimeout in webpack config the error will disappear. But I am not sure if there is a solution to this since webpack normally handles JS files which don't need compiling.
i
There is an issue in the bagtracker — https://youtrack.jetbrains.com/issue/KT-37258