perf: lazy-load wagmi/viem wallet bundle via next/dynamic (Closes #258) - #381
Open
waterWang wants to merge 1 commit into
Open
perf: lazy-load wagmi/viem wallet bundle via next/dynamic (Closes #258)#381waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
…mantine-guild#258) - Create lib/wallet/wallet-bundle.tsx containing all wagmi/viem heavy imports (WagmiProvider, createConfig, viem chains, @wagmi/connectors, the entire SiweAuthProvider) - Update lib/wallet/providers.tsx to use next/dynamic() with ssr:false to load the wallet bundle only on client interaction - Public/unauthenticated pages no longer pay the ~200 kB gzipped wallet library cost until a user initiates a wallet connection - All existing imports (RootProviders, useSiweAuth, SiweAuthContext) continue to work from the same module paths
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
Code-splits the heavy wagmi/viem wallet library stack so it is only loaded on client interaction, not eagerly on every page.
Before
All wagmi / viem / @wagmi/connectors imports were bundled into the initial JS payload for every route, including public/unauthenticated pages.
After
The wallet bundle is in a separate chunk that only loads when the component first renders on the client. Public pages no longer pay the ~200 kB (gzipped) cost until a user initiates a wallet connection.
Changes
createConfig,QueryClient,SiweAuthProvider, and theWalletProviderswrapper.next/dynamicto lazy-loadWalletProviderswithssr: false. All existing exports (RootProviders,useSiweAuth,SiweAuthContext) remain available from the same module path.Testing
lib/api/mock.tsandadmin/settings/page.tsxare unrelated).@/lib/wallet/providerscontinue to work unchanged.Bundle Impact
Closes #258