Repository navigation
perf: avoid bundling validators for lightweight SDK imports - #349
Merged
Merged
Conversation
Separate the app bindings and method tables so lightweight SDK imports do not pull in runtime validation. Omit unused validator declarations from the tarball and check representative consumer bundles in CI.
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.
Importing
PROTOCOL_VERSIONfrom the stable v1 entrypoint used to pull in nearly the same JavaScript as importingclient. The entrypoint also initialized the protocol bindings and their Zod validators. This separates app bindings, method tables, and lightweight helpers into modules that bundlers can drop independently, and marks the package as side-effect-free.Separately, the npm package no longer ships four internal
zod.gen.d.tsfiles that none of the public declarations reference. All runtime validators still ship, as do the NES validator declarations exposed byexperimental/nes.Size impact
Single-export browser bundles, esbuild 0.28.2, minified ESM, dependencies included:
PROTOCOL_VERSIONmethodsndJsonStreamclientclientThe npm tarball goes from 867 kB to 661 kB (9.80 MB to 4.90 MB unpacked). The full v1 client still needs wire validation; the largest bundle savings are for consumers of individual helpers.
Compatibility and verification
NodeNextandBundlerwithskipLibCheck: false. Also ran a client–agent initialize round trip from the tarball.npm run checkpassed, including all 668 tests.package:checknow bundles representative public imports for all four protocol entrypoints and fails if a lightweight import starts including Zod or a client pulls in another lane’s validators.