diegomura / diegomura/react-pdf
imported font crashes js after updating pdf-renderer to latest
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 1.3k
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 52
Description
Hi,
This only happens on a server running production code. When the react project is launched using visual studio chrome launch option via debugger, it works as expected.
The error message in console was `Uncaught TypeError: fb is on a constructor` on the font.ttf file.
The font.ttf file in chrome debug window was `export default _VITE_ASSET_DAXvI0Ge_`
codesandbox of the error: https://codesandbox.io/p/devbox/ytrgy9
I have a npm react project built with vite.
I have a js file which uses the react-pdf/renderer with some fonts imported locally e.g.,
```
import customFont from './fonts/customFont.ttf'
Font.register({source: customFont})
```
This works with current setup.
```
package.json
{
"@react-pdf/renderer: "^3.1.12",
"@react-pdf/font": "^2.3.6",
"@react-pdf/font":"^3.0.4",
"vite": "^5.2.13",
"react": "18.2",
}
```
On changing this to the following and running `npm install`, `npm run build` the javascript files crashed showing the error from the font .ttf file "acbd is not the constructor" etc
```
package.json
{
"@react-pdf/renderer: "latest",
"@react-pdf/font": "latest",
"@react-pdf/font":"latest",
"vite": "^5.2.13",
"react": "18.2",
}
```
The same error happens if I run `npm update @react-pdf/renderer` the `npm run build`
Contributor guide
Assessment
This issue has not been assessed yet.