quaggaJS icon indicating copy to clipboard operation
quaggaJS copied to clipboard

_typeof is not defined with Webpack

Open cedm opened this issue 5 years ago • 4 comments

Trying to use the NPM package (installed via yarn add quagga) with Webpack gives me the following error:

_typeof is not defined in the js console.

If I bypass Webpack and link the quagga.min.js file directly (using ), everything works fine.

There must be something wrong with the NPM package. I noticed commit 4c73d7669277b0364fe23ce19cc1f981f1c685fa (Declare module so webpack can do its work) might be the solution I'm looking for, but that is unreleased code sitting in the master branch, and not available on NPM.

Any chance for a new release soon?

cedm avatar Apr 17 '19 04:04 cedm

I'm having the same issue. Good to know that in the short term I can use min, thanks @cedm but I'd be interested in updating this whenever this is updated.

captDaylight avatar Apr 17 '19 21:04 captDaylight

Package maintainer is not likely to show up anytime soon to push an update. No idea if that fix will even fix the problem. Ultimately, I think it comes down to that your trying to webpack an already packed file, which turns bad. At least, that's what we've seen in the past.

I've been meaning to get to forking the project, and maintaining, but I don't know when I will have the time to do that.

ericblade avatar Apr 27 '19 04:04 ericblade

That commit may indeed not fix the issue. You're probably right when you say that the file gets double packed. Since I could get quagga to work by manually downloading it and placing it outside my packs folder, that's good enough for me already.

Just in case someone has the same issue, I can also load it via import Quagga from 'path/to/quagga', not just by using a <script> tag. But I can't store the file inside my app/javascript/packs folder and use NPM/Yarn to fetch it (I'm using Ruby On Rails).

cedm avatar Apr 27 '19 07:04 cedm

I managed to bypass this problem with the following import:

import Quagga from 'quagga/dist/quagga';

LimmaPaulus avatar Jun 11 '21 11:06 LimmaPaulus