Repository navigation
build(desktop): static export of the desktop renderer (P2.4a) - #127
Merged
7 commits merged intoNov 17, 2026
Merged
7 commits merged into
7 commits merged into
Conversation
bun run build:desktop writes the static export to out/ with NEXT_PUBLIC_APP_TARGET=desktop. Web-only route handlers become route.web.ts(x), which the desktop page extensions skip. The five web metadata files and the /privacy and /offline pages are parked in the checkout for the build and put back: Turbopack ignores pageExtensions for metadata files, and a page.web.tsx loses the root layout's font preload on the web. next.config.ts refuses a web build while anything is parked. The export fails if a web-only route, a web metadata tag or the Windows segment layout reaches out/. icon.tsx is force-static.
The worker precaches web-only pages (SHELL_PATHS has /privacy) and the desktop renderer loads from disk, so the target flag now turns registration off, as NEXT_PUBLIC_SERVICE_WORKER=0 does.
desktop/shared/export-paths.ts holds the app:// protocol handler's path rules for the shell to reuse: pages to .html, RSC payloads under their exported names, the extension-less icon as image/png, unknown types and traversal refused. scripts/serve-desktop-export.ts serves out/ with them, the desktop project checks that every request the renderer makes is answered, and nightly runs it on Linux.
After a next dev run, .next/dev/types imports the /privacy and /offline pages, which the export parks, so the export failed its type check. bun run typecheck already checks every file, desktop ones included.
…son-26e90f # Conflicts: # CHANGELOG.md
Contributor
Author
|
Merged Re-checked against 08b7663 with the same
|
Under a desktop-target next dev the web metadata files aren't parked, and output: "export" made each of them a 500 that every page links. The config is now a phase function; the web config object is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 P2.4a: the desktop renderer's static export (desktop local-first design §8.4, row P2.4; arch §3.1). The dev bridge and the
localPlaywright project are P2.4b, built after #121 and P2.1'suse-yjs-documentPR land.What it does
bun run build:desktop(scripts/build-desktop.ts) writesout/withNEXT_PUBLIC_APP_TARGET=desktopandoutput: "export"./,/about,/_not-found,/icon.rel="manifest",og:image,twitter:image,apple-touch-icon,href="/privacy") or a__next.*directory (the Windows segment layout, P2.5: Next.js Windows export writes segment-prefetch payloads under the wrong path #103) reachesout/.next.config.tsswitches three things on the literal flag:output,pageExtensionsandheaders().app/icon.tsxisforce-static.How routes leave the export
The brief asked for this without the spike's file-renaming overlay. #115's measurements rule that out for some files, so I used two mechanisms.
app/api/**,llms.txt,pwa-icons/[id]route handlersroute.web.ts(x); desktoppageExtensionsskip themroutefilessitemap,robots,manifest,opengraph-image,apple-icon.desktop-export-parked/for the buildpageExtensionsfor metadata files (S1). Withforce-staticthey'd put the manifest,og:imageandapple-touch-icontags into every desktop page (#115)/privacyand/offlinepagespage.web.tsxdrops the root layout's Inter font preload from its web HTML. Next 16.4.6'sgetPreloadableFontsstrips only the last extension, so it looks upapp/privacy/page.webin a font manifest keyedapp/privacy/page. Measured:/privacyand/offlinelost<link rel="preload" as="font">Turning the metadata files into
route.web.tshandlers with hand-writtenmetadatawould also change the web<head>: Next adds content-hash query strings toog:image,twitter:image,iconandapple-touch-icon. That fails the exit criterion.The parking follows #115's rules:
EXDEVon Windows);finallyand on SIGINT/SIGTERM;next.config.tsalso refuses a web build while anything is parked, so a SIGKILLed export can't ship a web build without its sitemap or privacy page.The desktop export skips Next's own type pass. After a
next devrun,.next/dev/typesimports the parked pages.bun run typecheckalready checks every file, desktop-only files included.#117 follow-ups
SHELL_PATHSprecaching/privacy: the desktop build never registers the service worker. The flag is compared inservice-worker-registration.tsx, not in the worker, becausesw-config.tsmust not readprocess.env. Desktop chunks contain no registration (grep sw.js: 0 files, web: 1).desktopPlaywright project in CI:next startcan't serve a static export, so the project now runs onout/.scripts/serve-desktop-export.tswith theapp://protocol handler's path rules.desktop/shared/export-paths.tsfor P2.5 to reuse:/about→about.html, RSC.txtunder their exported names,/iconasimage/png, unknown types and traversal refused. This covers the P2.4 hardening row.desktop-renderer, on Linux, where releases build the renderer). It also checksgit diff --exit-code -- appafter the export.Web build diff against
main(1ed981e), both withNEXT_PUBLIC_BUILD_ID=baselinenext buildoutput).next/staticchunks, every name and sizeserver/appfile listapp-path-routes-manifest,routes-manifest,next-font-manifest,app-paths-manifestprerender-manifest(minus random preview keys)sw.js/,/about,/privacy,/offline,/_not-found,_global-error/icon?<hash>cache-buster, which changes becauseicon.tsx's source gainedforce-static; the PNG is byte-identicalThat is the "differs only in the route flags" exit criterion.
Verification
bun run build:desktoppasses, and the output check passes. After the build,git status -- appis clean, including after a build that fails its type check.bun run test: 1,567 pass.desktop-export.test.ts(parking, leftovers, conflict, output check, every route handler underapp/api,llms.txtandpwa-iconsisroute.web.*).export-paths.test.ts(mapping, types, traversal).service-worker-registration.test.ts.bun run typecheck, ESLint and Biome (no new findings) pass.tests/unit/ci(workflow rules) passes with the nightly job.chromium(--retries=1, againstnext devand Hocus on spare ports with CI's limits): 523 passed, 22 skipped, 0 failed, 0 flaky. The renamed DELETE route answers 200 in dev.desktopon the export: 3 passed.local: not in this PR (P2.4b).Not in this PR
window.tinydocydev bridge (lib/platform/desktop/,NEXT_PUBLIC_DESKTOP_BRIDGE=dev),desktop/dev/storage-host.tsonMemoryDocStore, and thelocalPlaywright project. They follow feat(platform): add local-session, the batcher and MemoryDocStore (P2.1b) #121 and P2.1's hook PR.getPreloadableFontsmulti-dot page extension bug is worth reporting to vercel/next.js. Not filed.