fix: self-host ZXing WASM in static/ instead of ?url import
All checks were successful
CI / update (push) Successful in 4m32s

The zxing-wasm ?url import fails in Rollup production builds. Copy the
WASM binary to static/fitness/ and reference it via absolute path in
prepareZXingModule locateFile.
This commit is contained in:
2026-04-05 12:28:05 +02:00
parent 3daa5b65c5
commit 3b0b1d08e4
2 changed files with 3 additions and 5 deletions

View File

@@ -216,13 +216,11 @@
const mod = await import('barcode-detector/ponyfill');
BarcodeDetector = mod.BarcodeDetector;
// Point ZXing WASM to our self-hosted copy via Vite ?url import
const { prepareZXingModule } = await import('barcode-detector/ponyfill');
const wasmModule = await import('zxing-wasm/reader/zxing_reader.wasm?url');
prepareZXingModule({
// Point ZXing WASM to our self-hosted copy in /static
mod.prepareZXingModule({
overrides: {
locateFile: (path, prefix) => {
if (path.endsWith('.wasm')) return wasmModule.default;
if (path.endsWith('.wasm')) return '/fitness/zxing_reader.wasm';
return prefix + path;
},
},

Binary file not shown.