Kotlin JS + React, unstable building

Hello! Is there any progress on the issue? I have the same problem with Kotlin version 1.3.61.

The proposed workaround is working but it’s very slow. The Kotlin compiler can rebuild my project in less than a second but I have to wait another 5 seconds because of the “aggregateTimeout”. If you changed only the color of a button, it’s very annoying. Also, it is not a robust solution. If compilation last longer than 5 seconds, the error will still happen.

I was able to fix it by redirecting the Kotlin compiler output to another file, then copying that file back to the webpack entry. It’s still a workaround, but it works better.

How to use my fix:

  1. Add copy file action in compileKotlinJs.doLast block.
compileKotlinJs {
    doLast {
        copy {
            from "$buildDir/js/packages/${project.name}/kotlin"
            into "$buildDir/js/entry/kotlin"
        }
    }
}
  1. Add file to webpack.config.d that will change the webpack entry.
// devServer is an indicator of development build.
if (config.devServer) {
    const projectName = config.output.filename.replace('.js', '');
    config.entry = config.entry.map(
        s => s.replace(`/js/packages/${projectName}/kotlin/`, "/js/entry/kotlin/"),
    );
}

This workaround works with 1.3.61 version but breaks in 1.3.70.