html5-qrcode icon indicating copy to clipboard operation
html5-qrcode copied to clipboard

Please provide build instructions

Open mgedmin opened this issue 10 years ago • 6 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?

mgedmin avatar Mar 24 '14 12:03 mgedmin

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.

mgedmin avatar Mar 24 '14 14:03 mgedmin

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.

mgedmin avatar Mar 24 '14 14:03 mgedmin

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.

dwa012 avatar Mar 24 '14 15:03 dwa012

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.

mgedmin avatar Mar 24 '14 16:03 mgedmin

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.

mgedmin avatar Apr 09 '14 17:04 mgedmin

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: https://github.com/dwa012/html5-qrcode/pull/19

OACDesigns avatar Apr 14 '15 19:04 OACDesigns