schmich / instascan

HTML5 QR code scanner using your webcam
https://schmich.github.io/instascan/
MIT License
2.96k stars 863 forks source link

Compile to ES5 before publishing to NPM #42

Open radavis opened 7 years ago

radavis commented 7 years ago

It would be helpful if this was compiled to ES5. Webpack/Babel isn't able to compile it when added as a dependency to package.json.

http://stackoverflow.com/questions/43417654/create-react-app-and-javascript-dependency-that-is-using-async-await-fails-to-co/43418589#43418589

schmich commented 7 years ago

Thanks, I completely overlooked this. There are a handful of breaking changes coming in for a 2.0 release, so I will be sure to precompile the library to ES5 before publishing the new package.

adrienshen commented 7 years ago

Yes, was not able to use this today because async/await not support by create-react-app. What solution do you recommend in order to use this from npm.

schmich commented 7 years ago

@adrienshen This was a bad mistake on my part. There's nothing you can reasonably do right now unless you want to clone the source, build the library, and manually use it in your project (probably not worth the hassle).

I'm working on a fix now and should have something published this week.

schmich commented 7 years ago

Apologies for the delay here, guys. JS source packaging and distribution is a mess of complexity, in my opinion, between needing to support the various build systems, environments, package managers, and module loaders.

After doing some research, it appears the correct approach is to provide both precompiled and vanilla source in the same package.

By doing this, you can either:

I'm hoping to have a reasonable solution soon. Thanks for your patience.

scmx commented 7 years ago

👋 I ran into the same problem. Here's an example project that reproduces an error using it. https://github.com/scmx/experiment-instascan-babel-brunch/commits/master I tried to work around it by having brunch transpile it for me, but I didn't succeed.

scmx commented 7 years ago

Uncaught Error: only one instance of babel-polyfill is allowed

http://stackoverflow.com/a/41797876 Generally only overall applications should be loading global plugins. If you're writing a library like a Babel plugin, you should either assume the user of your library will load it for you, or you should use transform-runtime.

pacoccino commented 7 years ago

@scmx I managed to get mine working with your branch https://github.com/scmx/instascan/tree/replace-babel-polyfill-with-transform-runtime merged from master.

Make a PR ;)

Thx

scmx commented 7 years ago

@pakokrew Pull request against 1.0.0 or latest master?

pacoccino commented 7 years ago

If think I tried with latest master @scmx

brunoschuermans commented 7 years ago

schmich, when do you think your release 2 will be ready and particularly this point? Greets

minatonda commented 7 years ago

i'm having same problem =/

augustosamame commented 6 years ago

Any updates? So is this working on react-native? Would like confirmation before making the plunge ;)