-
-
Notifications
You must be signed in to change notification settings - Fork 903
Upgrade guide from version 8.x to 9.x
All occurrences of:
-
pdf.worker.js
need to be changed topdf.worker.mjs
-
pdf.worker.min.js
need to be changed topdf.worker.min.mjs
Depending on your configuration, you may need to apply additional changes to your configuration (e.g. Webpack, Jest) to make your application work again.
No action should be required, but there is an error that's likely to pop up if you still run your tests using Jest:
SyntaxError: Unexpected token 'export'
While it is possible to work around this issue by adjusting transformIgnorePatterns
and/or enabling experimental ECMAScript modules support, I wholeheartedly recommend you migrating to Vitest. You'll see this error popping up more and more often as the industry migrates towards ESM future. Save yourself the trouble.
svg
renderMode
has been deprecated a long time ago and we actively discouraged it from being used. Unfortunately, there's no alternative at this time.
No action is required, but you should be aware that older browsers may not work correctly or even at all.
You may extend the list of supported browsers by providing additional polyfills (e.g. for Array.prototype.at
, Promise.allSettled
or Promise.withResolvers
).
In particular, you may need Promise.withResolvers
polyfill when running Node.js versions older than 22.0.0.
If your tests go as deep as to rendering actual canvas using node-canvas
, you may encounter the following error:
TypeError: Cannot read properties of undefined (reading 'createCanvas')
You may encounter this rather cryptic error because the way PDF.js imports additional packages has changed. While we work with Mozilla to establish a definite solution, the following patch for pdfjs-dist
may help:
diff --git a/build/pdf.mjs b/build/pdf.mjs
index 003035596c3797888692cafd43f9466f96607d55..e69bc909492626f188ccff66b24a8d586fd96a30 100644
--- a/build/pdf.mjs
+++ b/build/pdf.mjs
@@ -5303,8 +5303,9 @@ if (isNodeJS) {
const fs = await import( /*webpackIgnore: true*/"fs"),
http = await import( /*webpackIgnore: true*/"http"),
https = await import( /*webpackIgnore: true*/"https"),
- url = await import( /*webpackIgnore: true*/"url");
- let canvas, path2d;
+ url = await import( /*webpackIgnore: true*/"url"),
+ canvas = await import( /*webpackIgnore: true*/"canvas");
+ let path2d;
return new Map(Object.entries({
fs,
http,