quagga2 icon indicating copy to clipboard operation
quagga2 copied to clipboard

Publish ECMAScript module instead of CommonJS (Angular)

Open WardLootens opened this issue 2 years ago • 4 comments

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?

WardLootens avatar Feb 07 '23 16:02 WardLootens

@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.

ericblade avatar Jul 19 '23 07:07 ericblade

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

treeder avatar Sep 20 '23 16:09 treeder

@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.

ericblade avatar Oct 29 '23 04:10 ericblade

@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

treeder avatar Oct 30 '23 14:10 treeder