Skip to content

Cloudflare worker compatibility #2757

@stephtr

Description

@stephtr

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. 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.
For reference, the patch I did:
image
(same for the cjs version)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions