Make instascan module-friendly and greatly reduce package size#176
Open
ArcanoxDragon wants to merge 11 commits into
Open
Make instascan module-friendly and greatly reduce package size#176ArcanoxDragon wants to merge 11 commits into
ArcanoxDragon wants to merge 11 commits into
Conversation
# Conflicts: # .travis.yml
Author
|
Pardon all the little commits; not super familiar with Travis |
|
hey @briman0094, I am using this pull request on my project. I have to say the reduced package size is pretty impressive. This should get merged with main package as well. There are other fixes for this in newer pull requests like this one, #206 Any chances you can take a look? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was having issues with this library due to its dependency on
babel-polyfill, as I needed to referencebabel-polyfillon my own before this library. This was causing an error because that module insists on only being imported once. I also stumbled across #158 while searching for a solution, so I decided to take it upon myself to try and clean up the package a bit and make it more friendly in terms of compatibility with other modules and Webpack.I changed everything to TypeScript, as this allows the usage of features such as
async/awaitwithout needingbabel-polyfill(TypeScript usesregenerator-runtime, which is perfectly happy to be imported more than once). This also provides typings for users who consume this as a module. Most of the code is functionally identical; it's just TypeScript-ified somewhat.The biggest change I made was to switch from the 2 MB
zxing.jslibrary to the@zxing/librarypackage, which reduced the minified bundle size of this module to 373 KB (which was the post-gzipped size mentioned in #158; it now becomes around 100 KB once gzipped).I only made one change to the API, which is that the
startfunction does not accept a camera. The camera can either be set using the{ camera: Camera }property on the Scanner options, or can be changed later by settingscanner.cameraand calling.start()again. This change was due to the way the new@zxing/librarymodule consumes the video stream and should be fairly easy to migrate.I made sure to update the documentation and the demo to reflect the changes. The demo was tested using a locally compiled
instascan.min.js, and should work once published as long as therawgitURL points to the new build artifact.