diff --git a/.gitea/workflows/docker-publish.yaml b/.gitea/workflows/docker-publish.yaml index 93ec808d..0de82d8f 100644 --- a/.gitea/workflows/docker-publish.yaml +++ b/.gitea/workflows/docker-publish.yaml @@ -74,6 +74,18 @@ jobs: restore-keys: | ${{ 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) if: matrix.service == 'web-app' run: | diff --git a/frontend/shells/meldestelle-portal/build.gradle.kts b/frontend/shells/meldestelle-portal/build.gradle.kts index 49cddb2a..aeee3543 100644 --- a/frontend/shells/meldestelle-portal/build.gradle.kts +++ b/frontend/shells/meldestelle-portal/build.gradle.kts @@ -37,12 +37,8 @@ kotlin { else KotlinWebpackConfig.Mode.DEVELOPMENT - // Source Maps Optimierung: Im Production Mode standardmäßig AUS, außer explizit gewünscht. - // Das beschleunigt den Build massiv. - if (mode == KotlinWebpackConfig.Mode.PRODUCTION && !project.hasProperty("enableSourceMaps")) { - sourceMaps = false - } - + // Source Maps: Im Production-Mode standardmäßig AUS (außer explizit via -PenableSourceMaps). + // Beschleunigt den Build massiv und reduziert Bundle-Größe. if (mode == KotlinWebpackConfig.Mode.PRODUCTION && !project.hasProperty("enableSourceMaps")) { sourceMaps = false } @@ -50,6 +46,9 @@ kotlin { webpackTask { 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 diff --git a/frontend/shells/meldestelle-portal/webpack.config.d/sqlite-config.js b/frontend/shells/meldestelle-portal/webpack.config.d/sqlite-config.js index a849f600..7af13ea6 100644 --- a/frontend/shells/meldestelle-portal/webpack.config.d/sqlite-config.js +++ b/frontend/shells/meldestelle-portal/webpack.config.d/sqlite-config.js @@ -137,36 +137,7 @@ config.devServer.devMiddleware.mimeTypes = { 'application/javascript': ['js'] }; -// 10. OPTIMIZATION: Aggressively disable ALL minimizers -// This is the ONLY stable way to prevent the Terser crash with SQLite-WASM -// in Kotlin/JS Production builds. -if (config.optimization) { - 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]; - } - } - }); -}*/ +// 10. OPTIMIZATION: Handled by z_disable-minification.js +// Minification is disabled in the alphabetically-last config file to ensure +// it cannot be overridden by any subsequent Kotlin/JS or plugin step. +// See: webpack.config.d/z_disable-minification.js diff --git a/frontend/shells/meldestelle-portal/webpack.config.d/z_disable-minification.js b/frontend/shells/meldestelle-portal/webpack.config.d/z_disable-minification.js new file mode 100644 index 00000000..c48f59df --- /dev/null +++ b/frontend/shells/meldestelle-portal/webpack.config.d/z_disable-minification.js @@ -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.");