Hello I have a simple multi module build where web...
# compose-web
d
Hello I have a simple multi module build where webpack bundling takes more than 2 minutes. What can be done to improve the bundling time?
Copy code
<i> [webpack-dev-middleware] wait until bundle finished: /
webpack 5.93.0 compiled successfully in 147885 ms
Answer: In
build.gradle
there is the following configuration to add sources to webpack for debugging in browser:
Copy code
@OptIn(ExperimentalWasmDsl::class)
    wasmJs {
        ...
        browser {
            val rootDirPath = project.rootDir.path
            val projectDirPath = project.projectDir.path
            commonWebpackConfig {
                outputFileName = "composeApp.js"
                devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
                    static = (static ?: mutableListOf()).apply {
                        // Serve sources to debug inside browser
                        add(rootDirPath)
                        add(projectDirPath)
                    }
                }
            }
        }
        ...
    }
Previously only the
projectDirPath
has been added and webpack bundeling took around 7 seconds for me. Now, if you create a new project using the kmp wizard,
rootDirPath
is added as well, which causes the bundling time to go up to 2 minutes. I'm sure there is a reason for adding
rootDirPath
for debugging as well, but compile + 2 minutes bundeling is not acceptable. Not adding any files to webpack makes the webpage show up immediatelly.
👀 1