jsQR icon indicating copy to clipboard operation
jsQR copied to clipboard

add esm build

Open shrpne opened this issue 5 years ago • 3 comments

fixes #107 and #111

This PR can be a breaking change for people who use Webpack with Babel and target ES5 browsers because it introduces module field. By default, Webpack will start to use the file specified in the module, which is ES2015. And Babel by default will not transpile it because it ignores node_modules. So bundled js will contain ES2015 code and may fail in old browsers like IE11.

So I suggest to release it under 2.0.0 and migration path will be to configure Babel properly if needed.

shrpne avatar Apr 25 '19 13:04 shrpne

an es module would be much appreciated... currently using https://github.com/danimoh/jsQR but that lags behind with updates.

basz avatar May 12 '20 13:05 basz

I have added browser field targeting UMD version. Webpack will use it by default: https://webpack.js.org/configuration/resolve/#resolvemainfields

So this PR can be merged without breaking change. But still allows using module version by importing it directly:

import jsQR from 'jsQR/dist'

Or by changing Webpack's resolve.mainFields to prefer module field instead of browser

shrpne avatar May 12 '20 17:05 shrpne

@basz FYI: https://github.com/danimoh/jsQR is now fully updated again and also includes several additional PR's which are still open here.

danimoh avatar Jul 09 '20 15:07 danimoh