Migrate @solana/react to import from @solana/kit#1706
Conversation
BundleMonFiles updated (25)
Unchanged files (122)
Total files change +3.95KB +0.75% Final result: ✅ View report in BundleMon website ➡️ |
|
Documentation Preview: https://kit-docs-c2wzlsuff-anza-tech.vercel.app |
72a4b00 to
af665ca
Compare
6f4954b to
f0123e1
Compare
🦋 Changeset detectedLatest commit: 543f1d9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 47 packages
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 |
🦋 Changeset detectedLatest commit: f0123e1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 47 packages
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 |
f0123e1 to
31b62af
Compare
trevor-cortex
left a comment
There was a problem hiding this comment.
Mechanical migration of @solana/react's source/test/typetest imports from the individual @solana/* sub-packages onto the @solana/kit umbrella, plus the corresponding package.json dependency swap. All re-exports check out — every symbol pulled in (Address, address, bytesEqual, SignatureBytes, Client, MessageModifyingSigner, TransactionModifyingSigner, TransactionSendingSigner, getCompiledTransactionMessageDecoder, getTransactionCodec, getTransactionEncoder, assertIsTransactionWithinSizeLimit, getTransactionLifetimeConstraintFromCompiledTransactionMessage, Transaction, TransactionWithinSizeLimit, TransactionWithLifetime, Slot, Blockhash, SolanaRpcResponse, UnwrapRpcResponse, splitSolanaRpcResponse, SOLANA_ERROR__*, SolanaError, isSolanaError, createClient, VariableSizeEncoder/Codec/Decoder) is reachable via kit/src/index.ts's export * chain (with bytesEqual and the variable-size codec types flowing through @solana/codecs). The changeset's justification for keeping @solana/promises and @solana/subscribable as direct deps is correct — neither is re-exported by Kit.
The test-mock change from jest.mock('@solana/transactions') / jest.mock('@solana/transaction-messages') to factory-style jest.mock('@solana/kit', () => ({ ...jest.requireActual('@solana/kit'), ... })) is the right call — auto-mocking the whole Kit barrel would replace SolanaError, the SOLANA_ERROR__* constants, bytesEqual, Address, etc., breaking the very assertions these tests rely on. The set of stubbed functions in each file matches the runtime-callable Kit imports of the corresponding SUT.
Main thing worth a follow-up: several touched source/test files end up with multiple import { ... } from '@solana/kit' statements stacked next to each other (the migration was done line-by-line). eslint-plugin-simple-import-sort doesn't merge duplicate sources, but useClientCapability.ts shows the intended end-state with everything (incl. the type Client) collapsed into one statement. See inline comments for the worst offenders.
Minor nit out of scope: the README example for useWalletAccountMessageSigner still imports createSignableMessage from @solana/signers while the matching JSDoc example was updated to @solana/kit in this PR. Worth a follow-up sweep of the README examples (@solana/signers, @solana/codecs-strings, @solana/promises) for consistency with the new orientation, but not blocking here.
Notes for subsequent reviewers:
- The one-line change in
useAction-test.browser.tsx(removing a blank line) is unrelated to the migration. Harmless. - This PR sets up the next one which will consume
createReactiveStoreWithInitialValueAndSlotTrackingfrom@solana/kit— that symbol is defined inpackages/kit/src/create-reactive-store-with-initial-value-and-slot-tracking.tsand exported from the barrel, so the path is ready.
trevor-cortex
left a comment
There was a problem hiding this comment.
Inline notes on the duplicate-import pattern — same point applies to a few other touched files (useClient.ts, the two wallet-signer tests).
31b62af to
80771de
Compare
Switch the `@solana/react` package to take a single `@solana/kit` workspace dep instead of pinning each consumed sub-package individually. The kit barrel already re-exports `@solana/addresses`, `@solana/errors`, `@solana/keys`, `@solana/plugin-core`, `@solana/signers`, `@solana/transaction-messages`, `@solana/transactions`, `@solana/rpc-types`, and (transitively via `@solana/codecs`) `@solana/codecs-core` — so the granular deps are redundant. `@solana/subscribable` and `@solana/promises` stay as direct deps because they aren't re-exported by Kit.
The migration is mechanical — every `import { … } from '@solana/<sub-package>'` in `src/` becomes `import { … } from '@solana/kit'`. No behavior change; consumers' transitive dep tree is unchanged because `@solana/kit` itself depends on the same sub-packages.
Two wallet-signer tests switched from full-module auto-mocks (`jest.mock('@solana/transactions')` / `jest.mock('@solana/transaction-messages')`) to factory-style mocks (`jest.mock('@solana/kit', () => ({ ...jest.requireActual('@solana/kit'), getTransactionCodec: jest.fn(), … }))`). The bundled `@solana/kit` output doesn't propagate jest's auto-mock through its `export *` re-exports, so listing the specific functions to stub keeps everything else (notably `SolanaError`, error constants, and `bytesEqual`) as the real implementation.
Positions `@solana/react` symmetrically with how a third-party `@solana/vue` / `@solana/svelte` / etc. binding would depend on Kit: one umbrella dep, one place to import from.
80771de to
543f1d9
Compare
| "@solana/errors": "workspace:*", | ||
| "@solana/keys": "workspace:*", | ||
| "@solana/plugin-core": "workspace:*", | ||
| "@solana/kit": "workspace:*", |
There was a problem hiding this comment.
Do we want to make it a peer dependency instead if it's a purely additive package? Similar to what we do with the program clients.
| } from '@solana/kit'; | ||
| import { createClient } from '@solana/kit'; |
There was a problem hiding this comment.
nit: Let's combine these in a single import statement (I think that's the only instance of that behaviour in the PR).

Summary of Changes
This PR changes the imports of
@solana/reactto use@solana/kitinstead of the individual sub-packages (addresses, transactions, etc) wherever possibleThis explicitly makes
@solana/kita dependency of@solana/react. This is ok because we will never want to export@solana/reactfrom@solana/kitbecause of its react dependency.We do this because a following PR will use
createReactiveStoreWithInitialValueAndSlotTrackingfrom@solana/kit. This is a separate PR to make reviewing easier and keep that one focused.