-
-
Notifications
You must be signed in to change notification settings - Fork 563
Closed
Labels
P1Urgent issue that should be resolved before the next re-leaseUrgent issue that should be resolved before the next re-leasePRs welcomebugno-issue-activity
Description
Possibly related: #72
In order to use ZXing I need to import the library using the following statement:
import * as ZXing from "@zxing/library";
const codeReader = new ZXing.BrowserQRCodeReader();
The generated Javascript code (with AMD module generation) looks like this:
define("test", ["require", "exports", "@zxing/library"], function (require, exports, ZXing) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const codeReader = new ZXing.BrowserQRCodeReader();
});
However, the file "library/umd/index.min.js" specifies that the AMD module name is "ZXing" and not "@zxing/library". As a result, my code will compile but not run; the browser gives an error that the module "@zxing/library" cannot be found.
The fix seems easy. I added the following line in the "library/esm5/index.d.ts" at the top:
///<amd-module name='ZXing'/>
export * from './browser/BrowserQRCodeReader';
export * from './browser/BrowserDatamatrixCodeReader';
export * from './browser/BrowserQRCodeSvgWriter';
export * from './browser/BrowserBarcodeReader';
// etc...
The "amd-module" declaration changes the name in the generated Javascript code. It then looks like this:
define("test", ["require", "exports", "ZXing"], function (require, exports, ZXing) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const codeReader = new ZXing.BrowserQRCodeReader();
});
//# sourceMappingURL=compiled.js.map
The code then works fine.
futhr
Metadata
Metadata
Assignees
Labels
P1Urgent issue that should be resolved before the next re-leaseUrgent issue that should be resolved before the next re-leasePRs welcomebugno-issue-activity