Skip to content

Replace @iarna/toml with smol-toml to make the JS client isomorphic#89

Merged
lorisleiva merged 2 commits into
solana-program:mainfrom
hoodieshq:js-isomorphic-toml
Jun 17, 2026
Merged

Replace @iarna/toml with smol-toml to make the JS client isomorphic#89
lorisleiva merged 2 commits into
solana-program:mainfrom
hoodieshq:js-isomorphic-toml

Conversation

@askov

@askov askov commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes the @solana-program/program-metadata JS client isomorphic (browser-compatible) by replacing the TOML parser.

@iarna/toml relies on Node's Buffer global, which breaks the client in browser environments. It was the last Node-only runtime dependency in the library's import graph. This swaps it for smol-toml — a pure-JS, zero-dependency, TOML 1.0.0-compliant parser that runs in any environment and exposes a drop-in parse export.

Changes

  • clients/js/src/fetchMetadataContent.ts: import parse from smol-toml instead of @iarna/toml
  • clients/js/package.json + lockfile: swap the dependency

Verification

  • pnpm build, typecheck, and pnpm lint pass
  • ✅ Lockfile consistent (--frozen-lockfile); @iarna/toml fully removed
  • ✅ Confirmed the shipped library bundle (dist/src/index.{js,mjs}) contains no references to fs/path/node:/commander — CLI-only deps stay isolated in the separate CLI bundle entry

Notes

  • Behavioral nuance: integers above Number.MAX_SAFE_INTEGER now throw a TomlError (smol-toml default) rather than being returned as BigInt. This is an unlikely edge case for program metadata and arguably safer than silent precision loss.

askov added 2 commits June 17, 2026 14:41
`@iarna/toml` relies on Node's `Buffer` global, which prevents the
client from running in the browser. `smol-toml` is a pure-JS,
zero-dependency, TOML 1.0.0-compliant parser that works in any
environment and exposes a drop-in `parse` export.

This was the last Node-only runtime dependency in the library's import
graph, so the published `index` bundle is now isomorphic. CLI-only
dependencies remain isolated in the separate CLI bundle entry.

@lorisleiva lorisleiva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@lorisleiva lorisleiva merged commit 38549be into solana-program:main Jun 17, 2026
21 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