Skip to content

fix(js-legacy): work without a global Buffer - #1612

Merged
joncinque merged 2 commits into
solana-program:mainfrom
aelmanaa:fix/js-legacy-explicit-buffer
Nov 21, 2026
Merged

joncinque merged 2 commits into
solana-program:mainfrom
aelmanaa:fix/js-legacy-explicit-buffer

Conversation

@aelmanaa

@aelmanaa aelmanaa commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1611.

Imports Buffer explicitly from buffer in the src files that used the global, so bundlers include it instead of relying on a global polyfill. buffer was already a dependency. No API changes.

Changes

  • import { Buffer } from 'buffer' in 62 src files; import type { Buffer } from 'buffer' in the 3 that only use the type. That is the whole diff: 65 lines, no other changes.

The @solana/buffer-layout-utils / bigint-buffer replacement from the first version is dropped, as asked. bigint-buffer's browser build still reads the global Buffer, so a fully polyfill-free browser bundle needs that separately; I can open it as its own PR if you want it.

Checks

  • pnpm format, pnpm lint, pnpm build, pnpm test:unit: 108 passing.
  • e2e tests not run locally (they need a test validator).

@aelmanaa

Copy link
Copy Markdown
Contributor Author

@joncinque related to #453: this removes bigint-buffer by dropping buffer-layout-utils entirely, with byte-identical encodings. It's also the last piece for using js-legacy in browsers without a Buffer polyfill.

@aelmanaa

Copy link
Copy Markdown
Contributor Author

@joncinque gentle ping. CI hasn't run yet: the workflows are waiting for approval (first-time contributor).

@joncinque

Copy link
Copy Markdown
Contributor

This PR is doing two things at once -- let's fix the Buffer import with this PR and drop the rest of the changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aelmanaa

Copy link
Copy Markdown
Contributor Author

@joncinque done in 32629fe: the PR now only adds the explicit Buffer imports (65 lines in 65 files, nothing else). The buffer-layout-utils / bigint-buffer replacement is dropped; I can send it as a separate PR if you want it. Could you take another look?

@joncinque joncinque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@joncinque
joncinque merged commit d441f2c into solana-program:main Nov 21, 2026
46 checks passed
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.

2 participants