parallax / jsPDF

Client-side JavaScript PDF generation for everyone.
https://parall.ax/products/jspdf
MIT License
29.05k stars 4.65k forks source link

Update to canvg v4 #3517

Closed JWess closed 8 months ago

JWess commented 1 year ago

With Canvg updated to version 4, would you be able to update the dependencies for jsPDF as well? It takes away lots of the warnings except for the raf. I have manually changed the optionalDepenencies for canvg to ^4.0.1. and installed the latest version of canvg independently. My project seems to work fine.

Thanks!

Originally posted by @dshakya in https://github.com/parallax/jsPDF/issues/3144#issuecomment-1192126034

yGuy commented 1 year ago

See also #3533 - it's probably not that simple. There's a reason canvg is using a new major version.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.

bwobbones commented 1 year ago

Yes still relevant

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.

bwobbones commented 1 year ago

Still relevant

fredericojesus commented 1 year ago

Would be nice to make this update to get rid of the warnings please

yGuy commented 1 year ago

What warnings are these?

fredericojesus commented 1 year ago

Check this issue.

The actual warnings from my current build:

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.array.index-of.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.array.iterator.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.array.reduce.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.array.reverse.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.promise.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.regexp.to-string.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Usersmy-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.string.ends-with.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.string.includes.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.string.match.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.string.replace.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.string.split.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.string.starts-with.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/es.string.trim.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'core-js/modules/web.dom-collections.iterator.js'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'raf'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/canvg/lib/index.es.js depends on 'rgbcolor'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/jspdf/dist/jspdf.es.min.js depends on 'dompurify'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/my-repo/node_modules/jspdf/dist/jspdf.es.min.js depends on 'html2canvas'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

I can add all those libs to allowedCommonJsDependencies but this is just a hack because these libs are not direct dependencies on my project. They are dependencies from canvg mostly.

In this comment it is said that updating to canvg v4 would most probably stop the warnings from showing up.

yGuy commented 1 year ago

Thanks. Honestly, this tells me that the benefit of doing this is relatively small (removing build tool output warnings compared to changing the implementation to use the new major, incompatible version of the dependency). Strictly speaking this might require this project to do a major version bump, too.

Still, if someone comes up with a proper pull request that implements the change, I guess the maintainers are open to review it.

github-actions[bot] commented 12 months ago

This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.

bwobbones commented 12 months ago

Yes still relevant

On September 27, 2023, Daniel Pfefferkorn @.***> wrote:

This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.

— Reply to this email directly, view it on GitHub https://github.com/parallax/jsPDF/issues/3517#issuecomment-1738325413, or unsubscribe https://github.com/notifications/unsubscribe- auth/AAFMHYL56XEQBEZCHOFHDVTX4TJNDANCNFSM6AAAAAARUPTFSY. You are receiving this because you are subscribed to this thread.Message ID: @.***>

dark0ni commented 11 months ago

@yGuy it seems to upgrade canvg to 4, is to just change the import statements, see migration guide https://canvg.js.org/docs/migration-to-v4. It must be tested after all

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.

mantou568 commented 6 months ago

Still relevant