vue-pdf icon indicating copy to clipboard operation
vue-pdf copied to clipboard

Make pdfjs as peerDependencies

Open samz-paypay-sec opened this issue 6 months ago • 5 comments

Currently the build ouputdist/index.mjs and dist/index.umd.js is about 1.4M.

The reason for the big size seems to be pdfjs is bundled, as base64 encoded string.

Image

Total size of index.mjs: 1474199 Size of encoded string: 1449652

Seems like it's mostly taken by pdfjs.

Pdfjs itself is not that big, base64 encoding will increase the size.

samz-paypay-sec avatar Jun 27 '25 08:06 samz-paypay-sec

It would be really awesome if we could easily point to the latest version of pdfjs-dist as well. Render performance on the latest release seems to be a lot better

jsormaz avatar Jun 27 '25 21:06 jsormaz

It's the pdfjs worker the one being bundled, this was made like this so the package can be used by just installing it without much configuration.

It would be really awesome if we could easily point to the latest version of pdfjs-dist as well. Render performance on the latest release seems to be a lot better

pdfjs version need to be locked to avoid issue #142, this is shame because the package need to be updated manually but let me release a new version soon :)

TaTo30 avatar Jun 29 '25 03:06 TaTo30

Ah, makes sense. And thank you for your work!

jsormaz avatar Jun 30 '25 11:06 jsormaz

pdfjs version need to be locked to avoid issue #142

Is this still the case? How may we optimize bundle size? I would love to use vue-pdf, looks amazing! But we cant have +1 mb just for pdf.js

MickL avatar Jul 31 '25 10:07 MickL

Is this still the case?

Yes, It is.

I am thinking on publish a "light" version that does not embed the worker and make it importable using something like import .. from "@tato30/vue-pdf/light" It will require some changes on the repo structure but the final bundle size are 34kb so maybe It worths.

But we cant have +1 mb just for pdf.js

Sure that is a issue but have you considered that you still need to include pdf.js in the final bundle? even if you include it in the /public folder you still will get 1mb

TaTo30 avatar Aug 01 '25 03:08 TaTo30