From ef6b8ec1815b1b69f0a68e024c8c6a915cc18539 Mon Sep 17 00:00:00 2001 From: Shadowbroker <43977454+BigBodyCobain@users.noreply.github.com> Date: Sat, 23 May 2026 16:07:11 -0600 Subject: [PATCH] fix(desktop-build): strip layout.tsx force-dynamic on CRLF checkouts too (#320) build-frontend-export.cjs stages a desktop-only frontend export tree and strips the ``force-dynamic`` + ``revalidate`` directives from ``frontend/src/app/layout.tsx`` so Next's ``output: "export"`` can prerender every route. The strip regexes only matched LF (``\n``). Any Windows checkout without ``core.autocrlf=input`` has CRLF line endings, the strip silently no-op'd, and the desktop build failed at the static-export step: Error: Page with `dynamic = "force-dynamic"` couldn't be exported. `output: "export"` requires all pages be renderable statically because there is no runtime server to dynamically render routes in this output format. Export encountered an error on /_not-found/page: /_not-found Reaches every Windows contributor who hasn't normalized line endings locally. Replacing each ``\n`` in the strip regexes with ``\r?\n`` makes the strip CRLF-tolerant; LF behavior is unchanged. Verified by running both regexes against the actual layout.tsx (302 bytes removed, force-dynamic + revalidate both gone) and against a synthetic LF input (296 bytes removed, same outcome). Co-authored-by: Claude Opus 4.7 --- .../tauri-skeleton/scripts/build-frontend-export.cjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/desktop-shell/tauri-skeleton/scripts/build-frontend-export.cjs b/desktop-shell/tauri-skeleton/scripts/build-frontend-export.cjs index fdf0501..a67d9f3 100644 --- a/desktop-shell/tauri-skeleton/scripts/build-frontend-export.cjs +++ b/desktop-shell/tauri-skeleton/scripts/build-frontend-export.cjs @@ -46,12 +46,18 @@ function prepareBuildTree() { const stagedLayoutPath = path.join(buildFrontendDir, 'src', 'app', 'layout.tsx'); if (fs.existsSync(stagedLayoutPath)) { const layoutSource = fs.readFileSync(stagedLayoutPath, 'utf8'); + // CRLF compatibility: on Windows checkouts without ``core.autocrlf=input`` + // (the default) layout.tsx has CRLF line endings, but the original regexes + // only matched LF. The strip silently no-op'd, ``force-dynamic`` stayed, + // and Next's static-export refused to render ``/_not-found`` ("Page with + // `dynamic = \"force-dynamic\"` couldn't be exported"). Use ``\r?\n`` so + // the strip works regardless of line-ending normalization. fs.writeFileSync( stagedLayoutPath, layoutSource - .replace(/\n\/\/ The dashboard is a live local runtime[\s\S]*?client polling ever hydrates\.\n/g, '\n') - .replace(/\nexport const dynamic = ['"]force-dynamic['"];\n/g, '\n') - .replace(/\nexport const revalidate = 0;\n/g, '\n'), + .replace(/\r?\n\/\/ The dashboard is a live local runtime[\s\S]*?client polling ever hydrates\.\r?\n/g, '\n') + .replace(/\r?\nexport const dynamic = ['"]force-dynamic['"];\r?\n/g, '\n') + .replace(/\r?\nexport const revalidate = 0;\r?\n/g, '\n'), ); }