-
Notifications
You must be signed in to change notification settings - Fork 335
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
Export QRCodeSVG and QRCodeCanvas directly. #56
Conversation
Thanks for bringing this up. I was thinking about this too, going back to when I added the SVG version.
To be fair, I think we could just add Now to the real point… it's kind of an awkward API. I was tempted to split out of the single file and just expose That said, seems like a reasonable path forward. I guess let's do it. Does this mean we'd be able to keep the |
True 😄
The difference is named vs default exports. Named exports work fine with Webpack when mixing CJS and ESM, default exports don't. |
@zpao Any news on this one? |
67922b8
to
57b57cf
Compare
57b57cf
to
2261569
Compare
Rebased for current master. |
2261569
to
bc79558
Compare
Hi @zpao, I dug this old PR out as I'd still love to see it merged.
Of course the true value will be once there's an ESM build as it'd allow tree-shaking the unused renderer. |
This makes it possible to ship an ESM, potentially allowing Webpack to tree shake out the unused component. It also removes a level of indirection and helps editors discover the propTypes for the components.
bc79558
to
c0e75dd
Compare
@realityking I have this fixes here too https://github.com/devmehq/react-qr-code |
Will be doing this in #174. Leaving the default export in for now. Sorry I never got to it sooner! |
I was thinking a bit more about #49 and how to publish this component as an ESM. The best way to guarantee compatibility between CommonJs and ESM right now is to only use named exports.
This PR is obviously a breaking but it not only adds the ability to eventually use ESM it also removes a level of indirection and helps editors discover the propTypes for the components. Once shipping with ESM it should also allow bundles to tree shake out the unused module.
WDYT?