aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-28 12:27:55 -0700
committerAdam Soltys <[email protected]>2026-08-28 12:27:55 -0700
commit878c13e246a8f085fc228220ea682b017c422139 (patch)
treedb3947725be2132d449f9804b3cc3e2bf957de75
parent02f673c68052aa8751aa08fd33bb71357bcd1526 (diff)
downloadcoinosv3-878c13e246a8f085fc228220ea682b017c422139.tar.gz
coinosv3-878c13e246a8f085fc228220ea682b017c422139.zip
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
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019eA8JRq9Wr7z2fRQk99HLi
-rw-r--r--build.js12
1 files 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 = `<link rel="manifest" href="manifest.webmanifest">
+const PWA_HEAD = `<link rel="manifest" href="/manifest.webmanifest">
<meta name="theme-color" content="#15171a">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="apple-mobile-web-app-title" content="Coinos">
-<link rel="apple-touch-icon" href="icon-192.png">
+<link rel="apple-touch-icon" href="/icon-192.png">
`;
// 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(){})})}</script>`;
+ `addEventListener('load',function(){navigator.serviceWorker.register('/sw.js',{updateViaCache:'none'}).catch(function(){})})}</script>`;
// 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: '<script type="module" src="app-{{VERSION}}.js"></script>' }))
+ 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: '<script type="module" src="/app-{{VERSION}}.js"></script>' }))
.replaceAll('{{COMMIT}}', gitCommit());
return { html, js, chunks };
}