From c27cb84f28f300dabebc9d6dc5ecb7edbd9a9d99 Mon Sep 17 00:00:00 2001 From: Till JS Date: Tue, 7 Apr 2026 22:29:55 +0200 Subject: [PATCH] fix(mana/web): bundle rrule into SSR build to fix /calendar 500 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `rrule@2.8.1` ships dual CJS/ESM builds but its `package.json` has no `exports` field, so the SvelteKit Node adapter resolves it to the CJS bundle at runtime. The named import `import { RRule } from 'rrule'` then throws `SyntaxError: Named export 'RRule' not found` whenever `/calendar` SSRs, which crashed every render of the route in production. Adding `'rrule'` to `ssr.noExternal` forces Vite to bundle rrule into the server output, where its CJS↔ESM interop layer handles the named import correctly. The source files using rrule (`time-blocks/recurrence.ts` and `calendar/components/CustomRecurrenceBuilder.svelte`) need no change. Surfaced via the rebuilt `health-check.sh` ingress walk after a postgres restart cycle pushed mana-app-web into a 500 state. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/mana/apps/web/vite.config.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/mana/apps/web/vite.config.ts b/apps/mana/apps/web/vite.config.ts index f28100240..510b5ad16 100644 --- a/apps/mana/apps/web/vite.config.ts +++ b/apps/mana/apps/web/vite.config.ts @@ -48,7 +48,13 @@ export default defineConfig({ strictPort: true, }, ssr: { - noExternal: [...MANA_SHARED_PACKAGES, ...APP_SHARED_PACKAGES], + // `rrule@2` ships dual CJS/ESM but its package.json has no `exports` + // field, so the SvelteKit Node adapter resolves it to the CJS bundle + // at runtime — and `import { RRule } from 'rrule'` then throws + // `Named export 'RRule' not found` when /calendar SSRs. Bundling rrule + // into the server build forces Vite's interop layer to handle the + // CJS↔ESM mismatch correctly. + noExternal: [...MANA_SHARED_PACKAGES, ...APP_SHARED_PACKAGES, 'rrule'], external: ['@mlc-ai/web-llm'], }, optimizeDeps: {