David Herman
01/08/2023, 2:36 AMjsBrowserDevelopmentWebpack
? I feel like the output its producing is staleDavid Herman
01/08/2023, 2:38 AMsite
). I am running my code in continuous mode (gradlew ... -t
), and when I change some code, I have a javascript file dropped in three places:
$root/build/js/packages/myproject/kotlin/myproject.js
$root/site/build/developmentExecutable/myproject.js
$root/site/compileSync/main/developmentExecutable/kotlin/myproject.js
David Herman
01/08/2023, 2:39 AMsite/build/developmentExecutable
path is the one generated by webpack, pretty sure, but when I make a change to my code, the other js files are updated but that one isn'tDavid Herman
01/08/2023, 2:40 AMDavid Herman
01/08/2023, 2:44 AMjsBrowserRun
on my own - I have my own web server, and I want to take the distributed js
file and use it directly. I wonder if jsBrowserRun
does something interesting to make this work.
• I also generate my own index.html
file programatically. I don't write it by hand. Because of this, I compile everything into a monolithic js file, instead of a bunch of separate js files (because I couldn't ever figure out how to generate an index.html file which knows which order to specify all the broken up js files in)David Herman
01/08/2023, 4:31 AMDavid Herman
01/08/2023, 7:44 AMAdam S
01/08/2023, 10:37 AMsite
directory as a Gradle task input?
// build.gradle.kts
tasks.matching { it.name == "jsBrowserDevelopmentWebpack" }.configureEach {
inputs.dir(layout.projectDir.dir("./site")
}
David Herman
01/08/2023, 5:01 PMDavid Herman
01/08/2023, 5:02 PMDavid Herman
01/08/2023, 5:28 PMDavid Herman
01/08/2023, 5:28 PMjsBrowserDevelopmentWebtask --continuous
is busted.David Herman
01/08/2023, 5:33 PMKotlinWebpack
task is using: https://github.com/JetBrains/kotlin/blob/4af0f110c7053d753c92fd9caafb4be138fdafba/[…]org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.ktDavid Herman
01/08/2023, 5:33 PMsite
depends on which should kick off a recompilation.Adam S
01/08/2023, 5:38 PMDavid Herman
01/08/2023, 5:45 PMDavid Herman
01/08/2023, 5:45 PMDavid Herman
01/08/2023, 5:46 PMjsBrowserDevelopmentWebtask
but not in continuous mode, it works.David Herman
01/08/2023, 7:07 PMorg.gradle.caching=false
in the gradle.properties
file but still got the same behavior, sadly.David Herman
01/08/2023, 10:22 PMprivate fun Project.hackWorkaroundSinceWebpackTaskIsBrokenInContinuousMode() {
tasks.withType(KotlinWebpack::class.java).forEach { webpackTask ->
// Gradle generates subclasses via bytecode generation magic. Here, we need
// to grab the superclass to find the private field we want.
webpackTask::class.java.superclass.declaredFields
// Note: Isn't ever null for now but checking protects us against future
// changes to KotlinWebpack
.firstOrNull { it.name == "isContinuous" }
?.let { isContinuousField ->
isContinuousField.isAccessible = true
isContinuousField.setBoolean(webpackTask, false)
}
}
}
(The code above sets this value to false.)
JB folks, I appreciate that the KotlinWebpack
task is trying to do something smart in live reloading mode (probably related to performance?) but it's busted. I wonder if it's worth just always treating isContinuous
as false for now until someone on your team has a chance to dig into this further.