From c489db447d0962fe750475477835ebf709802e07 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 21 Apr 2026 20:11:07 +0200 Subject: [PATCH] Fail vite build on rolldown warnings via NODE_ENV=test (#37270) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fail the vite build on any rolldown warnings when `NODE_ENV=test` is set. This gate is set on the CI `make frontend` steps (compliance and e2e workflows) and on the local `make test-e2e` target, so warnings fail the build both in CI and when running e2e tests locally. Regular `make frontend` / production builds are unaffected. Example output: ``` [plugin test-warning-injector] first synthetic warning [plugin test-warning-injector] second synthetic warning transforming...✗ Build failed in 14ms error during build: Build failed with 1 error: [plugin fail-on-warnings] Error: 2 warnings present at PluginContextImpl.buildEnd (vite.config.ts:50:13) ... ``` --- This PR was written with the help of Claude Opus 4.7 --------- Signed-off-by: silverwind Co-authored-by: Claude (Opus 4.7) Co-authored-by: Nicolas --- vite.config.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index d3080a5d12b..53717813a10 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -38,10 +38,25 @@ const webComponents = new Set([ 'text-expander', ]); +function failOnWarningsPlugin(): Rolldown.Plugin { + let warningCount = 0; + return { + name: 'fail-on-warnings', + onLog(level) { + if (level === 'warn') warningCount++; + }, + buildEnd() { + if (!warningCount) return; + throw new Error(`${warningCount} warnings present`); + }, + }; +} + const commonRolldownOptions: Rolldown.RolldownOptions = { checks: { pluginTimings: false, }, + ...(env.CI ? {plugins: [failOnWarningsPlugin()]} : {}), }; function commonViteOpts({build, ...other}: InlineConfig): InlineConfig {