What's up wiwth browserDevelopmentRun, is there a ...
# javascript
g
What's up wiwth browserDevelopmentRun, is there a way to avoid webpack and dce... just trying to debug here, tired of waiting on webpack...lol, because I'm missing something obvious
Kotlin JS takes 100 times longer to compile than kotlin JVM, lol
g
do you use developer mode of compilation?
g
I don't think so, if you have a recommended task could help
i
browserDevelopmentRun should use dce and webpack in dev mode, it doesn’t spend a lot of time. If you use
production
tasks, it enables dce and webpack
g
Maybe you could share a Gradle build scan
g
Here is the gradle build --scan results:https://scans.gradle.com/s/757mpik3ynqhy Again with a clean build folder: https://gradle.com/s/elob54t6lnaya General Question: When I publish this build scan, it's just statistics correct? Nothing proprietary or project specific gets transfered and shared publicly correct, I hope... FYI: I have three.js, metro4, and grapesjs libs in my resources folder ATM. I've been trying to delete them and replace them with implementation(npm("package")) but it hasn't been going well at all. I was able to npm("grapes") without breaking anything and I made an external interface for it and that works, but three.js already has a kotlin wrapper and metro4 isn't working either. Everything works when I have these libs in the resources folder, but stops working when the resources libs are deleted and replaced with npm.
g
According to your build scan you run
build
task which executes also prod packaging, which consumes most of build time
g
dah... trying again
g
Also I would recommend enable parallel build, now everything is building sequentially
g
hmm, okay I'll need to look into that, thought gradle did that for me
g
Parallel build disabled by default
g
okay, real build scan is running now... will run another after adding
Copy code
org.gradle.parallel=true
to properties file.
g
Build scan includes some info about project, like name of tasks, info about your machine etc You can delete it if you want, bit this scan is available only if you know link, rest of info I believe is just used by Gradle for statistics
g
okay, wouldn't mind obfuscation with pr**** or something, but I guess it's not a big deal. browserProductionWebpack: https://gradle.com/s/2zlvueg2scby2 browserDevelopmentWebpack: https://gradle.com/s/5fso7qon5j6v4 hmmm... that is faster
seems they it should skip DCE and do minimal webpacking if any
I think I see... I need to make the copy task NOT depend on build rather just depend on the file being there somehow... then in the last task I can use browserDevelopmentRun and it won't use the prod webpack:
Copy code
tasks {
    register<Copy>("copyJsBundleToKtor") {
        group = "app"
        dependsOn("srcFrontend:build", "srcBackend:build")
        mustRunAfter("srcFrontend:build", "srcBackend:build")
        from("$buildDir/frontend/distributions/")
        include("**/*.*")
        into("$buildDir/backend/resources/main/web")
    }
    register("prodFatJarBuild"){
        group = "app"
        dependsOn("copyJsBundleToKtor", "srcBackend:fatJarBuild")
        mustRunAfter("copyJsBundleToKtor", "srcBackend:fatJarBuild")
    }
    register<JavaExec>("prodFatJarRunLocal") {
        group = "app"
        dependsOn("prodFatJarBuild")
        mustRunAfter("prodFatJarBuild")
        classpath = getByPath("srcBackend:fatJarBuild").outputs.files
    }
    register("devRunLocal") {
        //TODO: Make faster for startup & testing (see tasks: run & browserDevelopmentRun); add w w/o tests option
        group = "app"
        dependsOn("copyJsBundleToKtor", "srcBackend:classRunLocal")
        shouldRunAfter("copyJsBundleToKtor")
    }
}
g
Strange that npm is not up to date on your production build scan
g
hmmm... wonder if that is why NPM is giving such problems...
not even sure where to configure it
But I think I got this working... I just needed to use mustRunAfter better:
Copy code
tasks {
    register<Copy>("copyJsBundleToKtor") {
        group = "app"
        //dependsOn("srcFrontend:build", "srcBackend:build", "srcFrontend:browserDevelopmentWepack")
        mustRunAfter("srcFrontend:build", "srcFrontend:browserDevelopmentWebpack", "srcFrontend:browserProductionWebpack", "srcBackend:build")
        from("$buildDir/frontend/distributions/")
        include("**/*.*")
        into("$buildDir/backend/resources/main/web")
    }
    register("prodFatJarBuild"){
        group = "app"
        dependsOn("copyJsBundleToKtor", "srcBackend:fatJarBuild")
        mustRunAfter("copyJsBundleToKtor", "srcBackend:fatJarBuild")
    }
    register<JavaExec>("prodFatJarRunLocal") {
        group = "app"
        dependsOn("prodFatJarBuild")
        mustRunAfter("prodFatJarBuild")
        classpath = getByPath("srcBackend:fatJarBuild").outputs.files
    }
    register("devRunLocal") {
        //TODO: Make faster for startup & testing (see tasks: run & browserDevelopmentRun); add w w/o tests option
        group = "app"
        dependsOn("srcFrontend:browserDevelopmentWebpack", "copyJsBundleToKtor", "srcBackend:classRunLocal")
        shouldRunAfter("copyJsBundleToKtor")
    }
}
g
I don't think that you need dependency on build, it anyway doesn't cover all other cases, such as assemble task or check task and should already work
g
ok, I thin your right the line can be rremoved
g
Yeah, NPM task there is part of Kotlin gradle plugin, just strange that it not up to date in this case, maybe some dependencies are updated
g
maybe... if it's part of the kotlin("js") plugin, not sure
Not bad... full devRunLocal startup time is like 20 seconds. still slower than saving a JS file and pressing refresh on the browser... but a big improvment, thanks due... 10% of what it was.
g
It still spent most of build time on webpack bundle?
g
hard to tell, how do you publish a run task... I press cntrl C to exit and I think that prevents it from publishing
hard to tell, how do you publish a run task... I press cntrl C to exit and I think that prevents it from publishing
wait, I got idea
https://scans.gradle.com/s/xwaqjf3eaa2qc Plus about 3 seconds for this finalizedBy task I disabled, to startup (fastest method?): Master:
Copy code
register("devRunLocal") {
    //TODO: Make faster for startup & testing (see tasks: run & browserDevelopmentRun); add w w/o tests option
    group = "app"
    dependsOn("srcFrontend:browserDevelopmentWebpack", "copyJsBundleToKtor")
    //finalizedBy("srcBackend:classRunLocal")
}
Child:
Copy code
register<JavaExec>("classRunLocal") {
    group = "app-backend"
    setMain("com.myapp.BackendAppKt")
    classpath = main.runtimeClasspath
}
How fast should webpack be? 6secs seems pretty good for crunching tons of JS but much is new to me. If it is slower than usually maybe its the stuff in resources folder... my main task ATM, other than making this faster (thank you), is getting implementation(npm("three")) to work... and 2 others... think I mentioned this... so maybe it's crunching some stuff twice or two much I don't know.
hmmm... I might not need my custom copy function... this is running.. no description, lol, wtf.
Copy code
Detailed task information for brDisRe

Path
     :srcFrontend:browserDistributeResources

Type
     Copy (org.gradle.api.tasks.Copy)

Description
     -

Group
     -
hmmm... I wrote that for the fatJar task... maybe not needed in this one... lets see
Think not, suspect that's just resources... well thanks man, I will try to leave you alone. Gave me a new useful tool... "teach a man to fish", sincerely helpful, thanks.
g
Yeah, I don't know how fast it should be, but it's slower than compilation, so it's now the main target for optimization. I would expect that it should be faster, but if it has a lot of resources, maybe there is a way to bundle them somehow separately, at least for development, just a random guess
g
Thanks. Yeah, trying to get that npm stuff working, I think that is supposed to replace resources with node modules