serratus / quaggaJS

An advanced barcode-scanner written in JavaScript
https://serratus.github.io/quaggaJS/
MIT License
5.08k stars 978 forks source link

_typeof is not defined with Webpack #370

Open cedm opened 5 years ago

cedm commented 5 years ago

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?

captDaylight commented 5 years ago

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.

ericblade commented 5 years ago

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.

cedm commented 5 years ago

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).

LimmaPaulus commented 3 years ago

I managed to bypass this problem with the following import:

import Quagga from 'quagga/dist/quagga';