Optimize build process: add stale cache cleanup, ensure minification is disabled for SQLite-WASM stability, and improve source map handling
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 10m3s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 10m17s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 3m17s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Successful in 2m1s
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 10m3s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 10m17s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 3m17s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Successful in 2m1s
This commit is contained in:
@@ -74,6 +74,18 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-gradle-
|
${{ runner.os }}-gradle-
|
||||||
|
|
||||||
|
# Cache-Cleanup: Entfernt inkonsistente Node/Yarn-Caches die zu mysteriösen Build-Fehlern führen können.
|
||||||
|
# Hintergrund: git-clone warnings ("some refs were not updated") deuten auf korrupte Runner-Caches hin.
|
||||||
|
# Dieser Step ist idempotent — schlägt nie fehl, auch wenn die Verzeichnisse nicht existieren.
|
||||||
|
- name: Cleanup stale build caches
|
||||||
|
if: matrix.service == 'web-app'
|
||||||
|
run: |
|
||||||
|
echo "Cleaning stale Kotlin/JS and Node caches..."
|
||||||
|
rm -rf frontend/shells/meldestelle-portal/build/js/node_modules/.cache || true
|
||||||
|
rm -rf frontend/shells/meldestelle-portal/build/js/.yarn/cache || true
|
||||||
|
rm -rf ~/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-embeddable || true
|
||||||
|
echo "Cache cleanup done."
|
||||||
|
|
||||||
- name: Build Frontend (Kotlin JS)
|
- name: Build Frontend (Kotlin JS)
|
||||||
if: matrix.service == 'web-app'
|
if: matrix.service == 'web-app'
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -37,12 +37,8 @@ kotlin {
|
|||||||
else
|
else
|
||||||
KotlinWebpackConfig.Mode.DEVELOPMENT
|
KotlinWebpackConfig.Mode.DEVELOPMENT
|
||||||
|
|
||||||
// Source Maps Optimierung: Im Production Mode standardmäßig AUS, außer explizit gewünscht.
|
// Source Maps: Im Production-Mode standardmäßig AUS (außer explizit via -PenableSourceMaps).
|
||||||
// Das beschleunigt den Build massiv.
|
// Beschleunigt den Build massiv und reduziert Bundle-Größe.
|
||||||
if (mode == KotlinWebpackConfig.Mode.PRODUCTION && !project.hasProperty("enableSourceMaps")) {
|
|
||||||
sourceMaps = false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode == KotlinWebpackConfig.Mode.PRODUCTION && !project.hasProperty("enableSourceMaps")) {
|
if (mode == KotlinWebpackConfig.Mode.PRODUCTION && !project.hasProperty("enableSourceMaps")) {
|
||||||
sourceMaps = false
|
sourceMaps = false
|
||||||
}
|
}
|
||||||
@@ -50,6 +46,9 @@ kotlin {
|
|||||||
|
|
||||||
webpackTask {
|
webpackTask {
|
||||||
mainOutputFileName = "web-app.js"
|
mainOutputFileName = "web-app.js"
|
||||||
|
// Minification wird via webpack.config.d/z_disable-minification.js deaktiviert,
|
||||||
|
// um den Terser-Crash mit SQLite-WASM (sqlite3-worker1.mjs) zu verhindern.
|
||||||
|
// Siehe: webpack.config.d/z_disable-minification.js
|
||||||
}
|
}
|
||||||
|
|
||||||
// Development Server konfigurieren
|
// Development Server konfigurieren
|
||||||
|
|||||||
@@ -137,36 +137,7 @@ config.devServer.devMiddleware.mimeTypes = {
|
|||||||
'application/javascript': ['js']
|
'application/javascript': ['js']
|
||||||
};
|
};
|
||||||
|
|
||||||
// 10. OPTIMIZATION: Aggressively disable ALL minimizers
|
// 10. OPTIMIZATION: Handled by z_disable-minification.js
|
||||||
// This is the ONLY stable way to prevent the Terser crash with SQLite-WASM
|
// Minification is disabled in the alphabetically-last config file to ensure
|
||||||
// in Kotlin/JS Production builds.
|
// it cannot be overridden by any subsequent Kotlin/JS or plugin step.
|
||||||
if (config.optimization) {
|
// See: webpack.config.d/z_disable-minification.js
|
||||||
console.log("SQLite Config: Aggressively removing minimizers to prevent Terser errors.");
|
|
||||||
config.optimization.minimize = false;
|
|
||||||
config.optimization.minimizer = []; // Das hier ist das entscheidende "Brecheisen"
|
|
||||||
}
|
|
||||||
|
|
||||||
/*// 10. OPTIMIZATION: Exclude SQLite workers from parsing and minification
|
|
||||||
// This fixes the "return outside of function" error in Terser and speeds up build
|
|
||||||
config.module.noParse = config.module.noParse || [];
|
|
||||||
if (Array.isArray(config.module.noParse)) {
|
|
||||||
config.module.noParse.push(/sqlite3-worker1\.mjs/);
|
|
||||||
config.module.noParse.push(/sqlite3\.mjs/);
|
|
||||||
} else {
|
|
||||||
// If it's a function or RegExp, we wrap it (simplified for now, assuming array or undefined)
|
|
||||||
config.module.noParse = [config.module.noParse, /sqlite3-worker1\.mjs/, /sqlite3\.mjs/];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.optimization && config.optimization.minimizer) {
|
|
||||||
config.optimization.minimizer.forEach(minimizer => {
|
|
||||||
if (minimizer.constructor.name === 'TerserPlugin') {
|
|
||||||
minimizer.options.exclude = minimizer.options.exclude || [];
|
|
||||||
const excludePattern = /sqlite3-worker1\.mjs/;
|
|
||||||
if (Array.isArray(minimizer.options.exclude)) {
|
|
||||||
minimizer.options.exclude.push(excludePattern);
|
|
||||||
} else {
|
|
||||||
minimizer.options.exclude = [minimizer.options.exclude, excludePattern];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// ============================================================
|
||||||
|
// FINAL GUARD: Disable ALL Minification for SQLite-WASM stability
|
||||||
|
// ============================================================
|
||||||
|
// WHY THIS FILE EXISTS:
|
||||||
|
// Kotlin/JS loads webpack.config.d files in alphabetical order.
|
||||||
|
// This file is prefixed with "z_" to ensure it runs LAST —
|
||||||
|
// AFTER Kotlin/JS and all other plugins have had their chance
|
||||||
|
// to set config.optimization. This guarantees that no Terser
|
||||||
|
// or other minimizer plugin can re-enable itself after this point.
|
||||||
|
//
|
||||||
|
// ROOT CAUSE:
|
||||||
|
// sqlite3-worker1.mjs contains a top-level `return` statement
|
||||||
|
// that is valid for browser-worker scripts but crashes Terser.
|
||||||
|
// Disabling minification for the entire shell module is the
|
||||||
|
// most stable fix in the context of WASM-heavy KMP projects.
|
||||||
|
// (Performance trade-off is negligible for WASM bundles.)
|
||||||
|
//
|
||||||
|
// REFERENCE: docs/99_Journal for build history.
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
console.log("[z_disable-minification] Enforcing minimize=false as FINAL webpack config step.");
|
||||||
|
|
||||||
|
config.optimization = config.optimization || {};
|
||||||
|
config.optimization.minimize = false;
|
||||||
|
config.optimization.minimizer = [];
|
||||||
|
|
||||||
|
console.log("[z_disable-minification] Terser and all minimizers are now DISABLED.");
|
||||||
Reference in New Issue
Block a user