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

Publish ECMAScript module instead of CommonJS (Angular) #485

Open
WardLootens opened this issue Feb 7, 2023 · 4 comments
Open

Publish ECMAScript module instead of CommonJS (Angular) #485

WardLootens opened this issue Feb 7, 2023 · 4 comments

Comments

@WardLootens
Copy link
Contributor

When building an Angular 15 application dependent on quagga2, a warning is now shown:

Warning: path\to\component.ts depends on '@ericblade/quagga2'. CommonJS or AMD dependencies can cause optimization bailouts.

As mentioned here, Angular recommends avoiding CommonJS dependencies.

Are there any plans to convert this to an ECMAScript module?

@ericblade
Copy link
Owner

@WardLootens apologies, I don't believe I ever saw this, or I would've responded much earlier.

I suspect that making this a module in it's current state is probably quite non-trivial, but if anyone has any suggestions as to how to get there from here, that'd be awesome.

@treeder
Copy link

treeder commented Sep 20, 2023

After a quick look through your code, I would suspect you're not too far off. you're already importing and exporting everything much like ES6 (I suppose that's typescript?).

Might be worth a try to set the typescript target to ES6 and see what happens. --target es6

@ericblade
Copy link
Owner

@treeder bumping TS target up makes absolutely no change to the output that I can see. I've spent the last 2 years buried in C++ land so I'm not entirely up on what current bundling practices are.

Oh, just remembered, we're using webpack to bundle everything... and the webpack in the 1.x branch is really dated. Looks like this will have to be a 2.0 thing... maybe i'll just promote 2.0 soon, as i've pretty much stalled on the major re-writing, and make that 3.0... hmm. at least that would get us up to much more recent dependencies and tools.

@treeder
Copy link

treeder commented Oct 30, 2023

@ericblade no worries, it might not be as easy as I suggested (I was just guessing, I'm not a typescript guy). Zxing isn't even ESM ready either so likely wouldn't have been a smooth thing. We ended up taking the raw zxing library and ESMing the whole thing manually, available here: https://github.com/chainparency/zxinger

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

No branches or pull requests

3 participants