Unable to load module via requirejs or dojo loader
See original GitHub issueDescribe the bug
I want to use @zxing/library
in a project that loads dependencies asynchronously using a call to require()
. We actually depend on the dojo loader, but I have also tried requirejs. In both cases, the umd/index.min.js
file is loaded, but the variable that is expected to contain ZXing
is undefined
.
To Reproduce Steps to reproduce the behavior:
npm install @zxing/library
(or yarn or whatever)- Create a new html page.
- Attempt to load ZXing via require, something like this: (this is the dojo configuration syntax)
<script type="text/javascript">
require({
packages: [
{
name: "@zxing/library",
location: "./node_modules/@zxing/library",
main: "umd/index.min"
}
]
});
require(["@zxing/library"], function(ZXing) {
console.log(ZXing);
});
</script>
Expected behavior
I expect the console to log an object of the ZXing module. Instead I get undefined
.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Windows 10
- Browser Firefox
- Version 79.0
Additional context
A colleague suggested editing the umd/index.min.js
file and removing the “ZXing” parameter from the call to define()
. This allowed it to load for me. This would suggest that the use of a module name is complicating things.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Have you tryied v0.18.1 out? I completely changed the build system used for the UMD bundle. Maybe this will help out. I’d love some help on testing it anyway, it seems to work throught HTML script tags tho.
We’ve updated to 0.18.2 and it now works without the hack. Nice!
We’ll keep watching the updates with interest as we’ve observed inconsistent results with certain barcodes and I see some recent changes in your history to address that.