diegomura / diegomura/react-pdf
Cloudflare worker compatibility
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 1.3k
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 52
Description
**Is your feature request related to a problem? Please describe.**
When one tries to use react-pdf on Cloudflare Pages (for example in a NextJS project), generating PDFs fail with "Wasm code generation disallowed by embedder" due to [security restrictions](https://github.com/cloudflare/workers-sdk/issues/1366#issuecomment-1172255671). This issue arises from yoga-layout loading a wasm script. yoga-layout is imported by @react-pdf/layout.
**Describe the solution you'd like**
It would be nice, if one could specify which yoga-layout version @react-pdf/layout shall load. When manually patching @react-pdf/layout to load `yoga-layout/asmjs-sync` instead of just `yoga-layout`, the above issue can be circumvented.
**Describe alternatives you've considered**
In case the above is out of scope, I at least wanted to write it down such that others having this issue can find a solution.
**Additional context**
**UPDATE:** For a patch compatible with react-pdf v4/React 19, see [this update](https://github.com/diegomura/react-pdf/issues/2757#issuecomment-2802425424).
For reference, the patch I did:
(same for the cjs version)
Contributor guide
Assessment
This issue has not been assessed yet.