Skip to content

refactor(pdfkit): align reference.js with upstream and switch Buffer polyfill to node-stdlib-browser#3409

Open
exoego wants to merge 1 commit intodiegomura:masterfrom
exoego:refactor/pdfkit-align-reference
Open

refactor(pdfkit): align reference.js with upstream and switch Buffer polyfill to node-stdlib-browser#3409
exoego wants to merge 1 commit intodiegomura:masterfrom
exoego:refactor/pdfkit-align-reference

Conversation

@exoego
Copy link
Copy Markdown
Contributor

@exoego exoego commented May 3, 2026

This PR keeps src/reference.js byte-identical with upstream foliojs/pdfkit (no source patches, no shim) as part of #2613

Reference file differences

The previous rollup-plugin-polyfill-node (unmaintained for ~2.5 years) bundled an outdated inline Buffer impl whose Buffer.concat rejected bare Uint8Array.
Fontkit v2.x's subset.encode() returns a Uint8Array, since they are migrating codebase to Uint8Array, so generating a PDF with embedded fonts in the browser threw "argument must be an Array of Buffers".

So, switched to node-stdlib-browser + @rollup/plugin-inject .
The newly bundled buffer@5.7+ accepts Uint8Array per current Buffer spec.

The previous rollup-plugin-polyfill-node (unmaintained for ~2.5 years)
bundled an outdated inline Buffer impl whose Buffer.concat rejected
bare Uint8Array.

Fontkit v2.x's subset.encode() returns a Uint8Array, since they are
migrating codebase to Uint8Array, so generating a PDF with embedded
fonts in the browser threw "argument must be an Array of Buffers"

So, switched to node-stdlib-browser + @rollup/plugin-inject
The bundled buffer@5.7+ accepts Uint8Array per current spec

Plus, keeps src/reference.js byte-identical with upstream foliojs/pdfkit
(no source patches, no shim)
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 3, 2026

🦋 Changeset detected

Latest commit: 671a238

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@react-pdf/pdfkit Patch
@react-pdf/font Patch
@react-pdf/renderer Patch
@react-pdf/types Patch
@react-pdf/math Patch
@react-pdf/mermaid Patch
next-14 Patch
next-15 Patch
@react-pdf/vite-example Patch
@react-pdf/layout Patch
@react-pdf/render Patch
@react-pdf/stylesheet Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@exoego exoego changed the title refactor(pdfkit): switch browser Buffer polyfill to node-stdlib-browser refactor(pdfkit): align reference.js with upstream and switch browser Buffer polyfill to node-stdlib-browser May 3, 2026
@exoego exoego changed the title refactor(pdfkit): align reference.js with upstream and switch browser Buffer polyfill to node-stdlib-browser refactor(pdfkit): align reference.js with upstream and switch Buffer polyfill to node-stdlib-browser May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant