JsBarcode icon indicating copy to clipboard operation
JsBarcode copied to clipboard

The size in webpack

Open bowencool opened this issue 8 years ago • 8 comments

The parsed size is too huge.(webpack^2.6.1) tim 20171107173147

# It doesn't work. 
# How to import a single sub library?
import JsBarcode from 'jsbarcode/bin/barcodes/CODE128'

bowencool avatar Nov 07 '17 09:11 bowencool

Is this really before any tree shaking has been made? I see a lot of things that should be automatically removed by webpack while compiling.

lindell avatar Nov 07 '17 09:11 lindell

Like this? tim 20171108084819

bowencool avatar Nov 08 '17 00:11 bowencool

@lindell correct me if I am wrong but I don't believe dead code elimination is a silver bullet here. How would the code be be eliminated if all barcode types are loaded in the main file (see: https://github.com/lindell/JsBarcode/blob/master/src/JsBarcode.js)? That would require some serious introspection I doubt UglifyJS can actually do. I might be wrong, but from what I can see in the bundle that we're pulling through it it is still present afterwards.

screen shot 2018-04-10 at 16 13 39

Perhaps it would make sense to use a setup where one can load the different bar codes & renderers in a modular fashion?

jonkoops avatar Apr 10 '18 14:04 jonkoops

I suppose the main part/api of the library should be rewritten to support tree shaking.

SanichKotikov avatar Apr 10 '18 14:04 SanichKotikov

These are my findings, perhaps it would be good to check to be certain I am not operating on false assumptions.

jonkoops avatar Apr 10 '18 15:04 jonkoops

Can you share the tool which build an analysis image? Looks cool.

yangjocy avatar Jul 29 '18 12:07 yangjocy

@yangjocy webpack-bundle-analyzer

bowencool avatar Jul 30 '18 00:07 bowencool

+1 How to import a single sub-library?

Tusko avatar Dec 05 '18 08:12 Tusko