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

Font.Register is failing after building app on TS v4.9.5, React v17 and Vite v4.4.4

Open life-engineered opened this issue 1 year ago • 0 comments

Describe the bug We have an in-house library, that use @react-pdf. This library is consumed by other applications. We are currently migrating from node v14 to node v16.

Keeping everything else constant ( build process, react, vite versions ), on running the builds with node v16, we get the error given below.

app-5b4132c0.js:1 Uncaught TypeError: Function has non-object prototype 'undefined' in instanceof check
    at [Symbol.hasInstance] (<anonymous>)
    at Object.r [as default] (app-5b4132c0.js:1:2244)
    at ue.register (styles-909510c8.js:16:345064)
    at styles-909510c8.js:232:30213

Config

For the library:

"node": "14.21.3",
"react": "17.0.2",
"typescript": "~5.0.4",
"@babel/cli": "^7.13.10",
"@babel/core": "^7.13.10",
"@react-pdf/font": "2.2.0",
"@react-pdf/layout": "3.1.1",
"@react-pdf/pdfkit": "2.3.0",
"@react-pdf/render": "3.1.0",
"@react-pdf/renderer": "2.2.0",

NOTE

  1. Babel is used for compiling the application
  2. Typescript is used only for the type definition files

For Applications that consume the library

"node": "14.21.3",
"react": "17.0.2",
"vite": "^4.3.2",

To Reproduce

Building the library and the application on Node v16 breaks the functionality.

Expected behavior

PDF should be created and rendered correctly with the layout and the fonts on Node v16

Screenshots If applicable, add screenshots to help explain your problem. Screenshot 2024-07-24 at 11 05 24 PM

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: chrome, safari
  • React-pdf version: Mentioned Above

life-engineered avatar Jul 24 '24 17:07 life-engineered