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