Describe 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)<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):
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.
Stale issue message
This is still relevant for me. We're currently using a gross hack in our release build to remove the offending "ZXing" parameter. I'd love to be able to take that out.
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're currently using 0.17.1. I'll try 0.18.1 and let you know how it goes.
There's an even newer release, v0.18.2. I'll try to setup an AMD load test in future versions as it is a very important thing that fails sometimes.
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.
Most helpful comment
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.