Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add esm build #135

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

add esm build #135

wants to merge 3 commits into from

Conversation

shrpne
Copy link

@shrpne shrpne commented Apr 25, 2019

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.

@basz
Copy link

basz commented May 12, 2020

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

@shrpne
Copy link
Author

shrpne commented May 12, 2020

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

@danimoh
Copy link

danimoh commented Jul 9, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding support for importing using ESM
3 participants