fix: self-host ZXing WASM in static/ instead of ?url import
All checks were successful
CI / update (push) Successful in 4m32s
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:
@@ -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;
|
||||
},
|
||||
},
|
||||
|
||||
BIN
static/fitness/zxing_reader.wasm
Normal file
BIN
static/fitness/zxing_reader.wasm
Normal file
Binary file not shown.
Reference in New Issue
Block a user