fix: self-host ZXing WASM in static/ instead of ?url import

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 dcbe1d1a83
commit 76d0cd59ba
2 changed files with 3 additions and 5 deletions
+3 -5
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.