dwa012 / html5-qrcode

A cross platform HTML5 QR code reader.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please provide build instructions

mgedmin opened this issue · comments

I'm trying to reproduce a working build of a minified .js file containing all of jsqrcode and html5-qrcode.js because I need source maps for our internal error tracking system (Sentry).

I got as far as

uglifyjs src/jsqrcode/src/{grid,version,detector,formatinf,errorlevel,bitmat,datablock,bmparser,datamask,rsdecoder,gf256poly,gf256,decoder,QRCode,findpat,alignpat,databr}.js\
         src/html5-qrcode.js \
         -o lib/html5-qrcode.min.js \
         --source-map lib/html5-qrcode.min.map \
         -p relative

(by taking the order of the jsqrcode script files from src/jsqrcode/README).

Unfortunately the JS I get fails to work: it displays one webcam image and then stops updating, with an ReferenceError: localMediaStream is not defined error on line 3 of my minified .js file (and for bonus points Chrome fails to find the .min.map file so I don't get a sane traceback).

Could you please document your build process?

Unfortunately the JS I get fails to work: it displays one webcam image and then stops updating, with an ReferenceError: localMediaStream is not defined error on line 3 of my minified .js file (and for bonus points Chrome fails to find the .min.map file so I don't get a sane traceback).

That was an actual bug that I fixed in #6.

So, for the record, that uglifyjs command I supplied works.

It'd still be nice to have official docs on the build -- or even a Makefile or something.

If you want to do a pull request with the instructions, I can merge it in.

I am not a JS developer and not aware of all the tools. I built this for another bigger project and put the source up for others to be able to build upon.

It so happens that I'm not a JS developer myself, and so I'm unaware of best practices in the field.

The uglifyjs command I provided works for me (but produces a larger .min.js than the one you had). You can get uglifyjs with sudo npm install -g uglifyjs if you have node.js and npm installed on your system.

but produces a larger .min.js than the one you had

That would be because uglifyjs doesn't enable compression and minification by default. I need to also supply -m and -c on the command line to enable those.

Kinda old, I know, but I've started using this in one of my projects.
I also had the need to build minified versions, so I've added in a Grunt config along with dev instructions.
I've also fixed some issues (there was no way to cancel the video stream or the timeouts doing the scanning), which I've also documented in the Readme.

Pull request: #19