fix: harden worklet caching and build guard
Un-hashed libopenmpt.worklet.js was inheriting the immutable 1-year cache from /assets/, risking stale audio on chiptune3 bumps. Add a dedicated short-cache location for it. Also fail closeBundle loudly if the worklet source vanishes, instead of silently shipping a build with hanging audio.
This commit is contained in:
@@ -10,6 +10,13 @@ server {
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header Referrer-Policy no-referrer-when-downgrade;
|
||||
|
||||
# un-hashed file copied by chiptuneWorkletFix -- must not be immutable
|
||||
location = /assets/libopenmpt.worklet.js {
|
||||
add_header Cache-Control "public, max-age=86400";
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header Referrer-Policy no-referrer-when-downgrade;
|
||||
}
|
||||
|
||||
location /assets/ {
|
||||
# add_header is not inherited once a location declares its own
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
|
||||
+5
-1
@@ -30,7 +30,11 @@ function chiptuneWorkletFix(): Plugin {
|
||||
},
|
||||
closeBundle() {
|
||||
const src = resolve('node_modules/chiptune3/libopenmpt.worklet.js')
|
||||
if (!existsSync(src)) return
|
||||
if (!existsSync(src)) {
|
||||
throw new Error(
|
||||
'chiptuneWorkletFix: libopenmpt.worklet.js not found — chiptune3 layout changed?',
|
||||
)
|
||||
}
|
||||
const dest = resolve(outDir, assetsDir, 'libopenmpt.worklet.js')
|
||||
copyFileSync(src, dest)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user