question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load module via requirejs or dojo loader

See original GitHub issue

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:

  1. npm install @zxing/library (or yarn or whatever)
  2. Create a new html page.
  3. 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:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
odahcamcommented, Oct 21, 2020

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.

1reaction
kenlyoncommented, Oct 28, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot load Dojo modules with RequireJs - Stack Overflow
If you want to use Dojo with a different loader, I believe you want to be using the Source/SDK download from their download...
Read more >
Provide a facility for easily recognizing that a module failed to ...
Dojo 1's loader has an entire event system that IIRC is pretty obtuse to use for this particular purpose. require.on("error", function(e){ if(e.
Read more >
Common Errors - RequireJS
If you use the loader plugins or anonymous modules (modules that call define() with no string ID) but do not use the RequireJS...
Read more >
The Dojo Loader — The Dojo Toolkit - Reference Guide
The AMD API is new for Dojo 1.7. It is the same API implemented by RequireJS, curl, and bdLoad (the dojo implementation is...
Read more >
Using esri with requirejs and without dojo causing errors
SO I'm working on getting esri geolocation library separated from using dojo and it's require modules to make it more compatible with my ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found