soldair / node-qrcode

qr code generator
MIT License
7.46k stars 621 forks source link

Use ECMAScript modules instead of CommonJS modules #236

Open kungufli opened 4 years ago

kungufli commented 4 years ago

Is there any chance this library to be converted to ECMAScript modules? This will allow for a better bundle size optimization at build time for Angular apps, or apps that uses webpack or similar minifiers (https://web.dev/commonjs-larger-bundles/).

mroderick commented 4 years ago

... or consider using a better bundler, or not sending so much JS to the client to begin with.

leon commented 4 years ago

Yes please update to use modern bundling in our angular app I'm getting this warning.

qrcode.component.ts depends on 'qrcode'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
mroderick commented 4 years ago

@leon that's really a problem on your end, a limitation with your bundler. (And the example used by the author of the linked article).

You can configure your build to allow certain dependencies to be CommonJS, this will remove the warning.

... or you could try an upcoming bundler, which converts everything to ESM: https://github.com/evanw/esbuild (not production ready).

sam-s4s commented 3 years ago

Any updates on this? Last commit was on 6 Nov 2019. Is this repo dead, do we need a new one?

soldair commented 2 years ago

This is by and large a do e project. New development may happen to keep things working and merging prs for features y'all need :)

Commonjs is going to continue to be the default for a while. Bundlers support it or have plugins. Esm is not suitable for serving directly to browsers. At some point it may be worth it but it's an anti goal to manage bundling optimization for every user.

pumano commented 1 year ago

@soldair looks like rollup used, you can just add few options for providing cjs (as you do) and esm format too. Just 2 formats will be presented in lib. ESM currently become default for browsers.

isoroka-plana commented 1 year ago

Tree shaking is not working with the way the lib is currently shipped. I believe that esm build should solve the problem.

soldair commented 1 year ago

Common shake is a thing. Wonder if it's still maintained

On Wed, Aug 16, 2023, 10:23 AM Ivan Soroka @.***> wrote:

Tree shaking is not working with the way the lib is currently shipped. I believe that esm build should solve the problem.

— Reply to this email directly, view it on GitHub https://github.com/soldair/node-qrcode/issues/236#issuecomment-1681004197, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA5IX6TP2ADE5H6OJWP3PTXVT6Y3ANCNFSM4OIHMONA . You are receiving this because you were mentioned.Message ID: @.***>

filipRisteski commented 1 year ago

I vote this gets converted to ESM.

iconben commented 10 months ago

ESM is the trend, would love to see this library get upgraded.

spock123 commented 10 months ago

This is dead

soldair commented 10 months ago

Not really dead. just mostly done.

On Tue, Dec 5, 2023, 3:45 AM Lars Rye Jeppesen @.***> wrote:

This is dead

— Reply to this email directly, view it on GitHub https://github.com/soldair/node-qrcode/issues/236#issuecomment-1840622703, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA5IXY2L6B5NV2ZPOD4FX3YH4CMNAVCNFSM4OIHMONKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBUGA3DEMRXGAZQ . You are receiving this because you were mentioned.Message ID: @.***>

romeguarin commented 8 months ago

bumping this up. saw a #241 . could this PR address this item?

quantuminformation commented 7 months ago

has this been done?

surfermicha commented 6 months ago

I would really like to have an solution here, as it causes a lot of bundling errors

vadimpopa commented 3 months ago

Not really dead. just mostly done.

Hi @soldair , thanks for your package we've been using for some time. How's it going with the migration ? If you still struggling with it, maybe we can help. Also now with ChatGpt is easier to convert the code to ESM.

jacobg commented 2 weeks ago

What's the workaround for this on vite? Neither optimizeDeps nor commonjsOptions seem to help.