Skip to content

Commit 84d683f

Browse files
committed
docs: cache-bust app and worker with build sha
1 parent 58ce8c8 commit 84d683f

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

.github/workflows/pages.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
- name: Build docs bundle
3737
run: deno task docs:bundle
3838

39+
- name: Stamp build SHA (cache bust)
40+
run: sed -i "s/__BUILD_SHA__/${GITHUB_SHA}/g" docs/index.html
41+
3942
- name: Configure Pages
4043
uses: actions/configure-pages@v5
4144

docs/app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ let activeEntEl = null;
164164
let cardPinned = false;
165165
let cardHideTimer = 0;
166166

167+
const BUILD = globalThis.__TS_DUCKLING_BUILD__ || "dev";
168+
167169
const ATOMIC_KINDS = new Set([
168170
"ip",
169171
"url",
@@ -251,7 +253,9 @@ const setSelection = (set) => {
251253

252254
const ensureWorker = () => {
253255
if (worker) return worker;
254-
worker = new Worker(new URL("./worker.js", import.meta.url), {
256+
const u = new URL("./worker.js", import.meta.url);
257+
u.searchParams.set("v", BUILD);
258+
worker = new Worker(u, {
255259
type: "module",
256260
});
257261
worker.onmessage = (ev) => {

docs/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ <h2 class="text-sm font-semibold tracking-wide text-slate-900">
375375
</div>
376376
</div>
377377

378-
<script type="module" src="./app.js?v=20260208-1"></script>
378+
<script>
379+
globalThis.__TS_DUCKLING_BUILD__ = "__BUILD_SHA__";
380+
</script>
381+
<script type="module" src="./app.js?v=__BUILD_SHA__"></script>
379382
</body>
380383
</html>

docs/worker.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ const loadModule = () => {
77
// Prefer local bundle for development/preview, but fall back to esm.sh for
88
// production (GitHub Pages) or when the bundle is missing.
99
modPromise = (async () => {
10-
const local = new URL("./vendor/ts-duckling.js", import.meta.url).href;
10+
const build = globalThis.__TS_DUCKLING_BUILD__ || "dev";
11+
const local = new URL(
12+
`./vendor/ts-duckling.js?v=${encodeURIComponent(build)}`,
13+
import.meta.url,
14+
).href;
1115
try {
1216
return await import(local);
1317
} catch {

0 commit comments

Comments
 (0)