From 1009e14a442a7acee74e3f61a92c80e29119e240 Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Tue, 11 Aug 2026 21:00:19 +0200 Subject: [PATCH] build(web): silence rollup's "use client" directive warnings in the nitro pass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The nitro server build re-bundles the whole dep tree (`noExternals: true`), so every React package shipping a `"use client"` banner earns a MODULE_LEVEL_DIRECTIVE warning — ~150 locally, ~800 in CI — which buries the warnings worth reading. Ignoring the banner is correct rather than papered over: this bundle is the Bun/Nitro server, not an RSC module graph, and TanStack Start splits client from server with its own transform, so nothing downstream consults it. Supplying `onwarn` replaces nitro's own handler, so its three filters (CIRCULAR_DEPENDENCY, EVAL, "Unsupported source map comment") are restated. Verified: `bun run build` drops from 148 such lines to 0 with no other log delta; `tsc --noEmit` and `biome check` clean. --- web/vite.config.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/web/vite.config.ts b/web/vite.config.ts index 028e2d7b..c67c82f2 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -211,6 +211,29 @@ export default defineConfig({ compatibilityDate: "2026-06-10", // Scan server/{middleware,routes} for the auth gate + the /api proxy. scanDirs: [serverDir], + // Silence rollup's MODULE_LEVEL_DIRECTIVE noise. Because `noExternals` re-bundles the + // whole dep tree into the server output, every React package that ships a `"use client"` + // banner — @tanstack/react-router, radix-ui, framer-motion under @unom/ui — earns one + // "directive was ignored" line, ~800 of them per build, which buries the warnings worth + // reading. Ignoring is the CORRECT outcome here and not a papered-over bug: this bundle is + // the Bun/Nitro server, not an RSC module graph, and Start splits client/server with its + // own transform, so nothing downstream ever consults the banner. + // + // Supplying `onwarn` REPLACES nitro's own (it defu-merges ours over its default), so + // nitro's three filters are restated here — drop this and CIRCULAR_DEPENDENCY comes back. + rollupConfig: { + onwarn(warning, defaultHandler) { + if ( + ["CIRCULAR_DEPENDENCY", "EVAL", "MODULE_LEVEL_DIRECTIVE"].includes( + warning.code ?? "", + ) || + warning.message.includes("Unsupported source map comment") + ) { + return; + } + defaultHandler(warning); + }, + }, }), // Must come AFTER tanstackStart — provides the React JSX transform + Refresh runtime // that Start's dev mode requires (omitting it leaves the client JS unable to load).