From 878c13e246a8f085fc228220ea682b017c422139 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 28 Aug 2026 12:27:55 -0700 Subject: The bundle knows its own address: boot-critical references (entry module, manifest, service worker, touch icon) are root-absolute — a page served from /ag/… was resolving them into the subpath, getting index.html back, and dying silently on module MIME checking before a single render MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_019eA8JRq9Wr7z2fRQk99HLi --- build.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/build.js b/build.js index e566dc6..94552fa 100644 --- a/build.js +++ b/build.js @@ -114,13 +114,13 @@ self.addEventListener('fetch', (e) => { }); `; -const PWA_HEAD = ` +const PWA_HEAD = ` - + `; // Register with updateViaCache:'none' so the browser always re-fetches sw.js @@ -144,7 +144,7 @@ const SW_REGISTER = // a mismatch would reload forever. `if(_had&&!_ref&&e.data.version&&_v.charAt(0)!=='{'&&e.data.version!==_v){_ref=true;location.reload()}});` + `navigator.serviceWorker.addEventListener('controllerchange',function(){_ask(navigator.serviceWorker.controller)});` + - `addEventListener('load',function(){navigator.serviceWorker.register('sw.js',{updateViaCache:'none'}).catch(function(){})})}`; + `addEventListener('load',function(){navigator.serviceWorker.register('/sw.js',{updateViaCache:'none'}).catch(function(){})})}`; // Lazy bundles load as classic scripts into the page's global scope, where // the main bundle's minified top-level names already live — two Bun outputs @@ -383,7 +383,11 @@ export async function buildSplit({ minify = true, features = process.env.HAL_FEA }))); const css = await Bun.file('./src/style.css').text(); // module scripts defer by default; the boot shell paints while this loads - const html = (await pageHtml({ css, staging, pwa: true, scriptHtml: '' })) + const html = (await pageHtml({ css, staging, pwa: true, // root-absolute: the page can be served from any path (/ag/…, /g/…) and a + // relative src would resolve into that subpath, get the index.html + // fallback, and die on strict module MIME checking — a gift link once + // showed nothing but the boot shell this way + scriptHtml: '' })) .replaceAll('{{COMMIT}}', gitCommit()); return { html, js, chunks }; } -- cgit v1.2.3