Replace @iarna/toml with smol-toml to make the JS client isomorphic#89
Merged
Merged
Conversation
`@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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the
@solana-program/program-metadataJS client isomorphic (browser-compatible) by replacing the TOML parser.@iarna/tomlrelies on Node'sBufferglobal, which breaks the client in browser environments. It was the last Node-only runtime dependency in the library's import graph. This swaps it forsmol-toml— a pure-JS, zero-dependency, TOML 1.0.0-compliant parser that runs in any environment and exposes a drop-inparseexport.Changes
clients/js/src/fetchMetadataContent.ts: importparsefromsmol-tomlinstead of@iarna/tomlclients/js/package.json+ lockfile: swap the dependencyVerification
pnpm build, typecheck, andpnpm lintpass--frozen-lockfile);@iarna/tomlfully removeddist/src/index.{js,mjs}) contains no references tofs/path/node:/commander— CLI-only deps stay isolated in the separate CLI bundle entryNotes
Number.MAX_SAFE_INTEGERnow throw aTomlError(smol-toml default) rather than being returned asBigInt. This is an unlikely edge case for program metadata and arguably safer than silent precision loss.