Skip to content

fix: grouped ledger chunk#11358

Merged
0xApotheosis merged 4 commits intodevelopfrom
maybe-fix-circ-dep
Dec 11, 2025
Merged

fix: grouped ledger chunk#11358
0xApotheosis merged 4 commits intodevelopfrom
maybe-fix-circ-dep

Conversation

@0xApotheosis
Copy link
Member

@0xApotheosis 0xApotheosis commented Dec 11, 2025

Description

Fix production white screen caused by @noble/curves circular dependency initialization error.

The hdwallet bump from 1.62.25 to 1.62.28 brought in @ledgerhq/hw-app-btc@10.13.0, which depends on @noble/curves@1.9.7, @noble/secp256k1, and @bitgo/secp256k1. The existing manualChunks config put @ledgerhq into a 'ledger' chunk, but its crypto dependencies ended up in different chunks. This created cross-chunk circular dependencies that caused Cannot access before initialization errors in the production build.

The fix bundles @noble, @scure, and @bitgo packages into the same chunk as @ledgerhq to ensure they initialize together.

Issue (if applicable)

Current release blocker.

Risk

High Risk PRs Require 2 approvals

Medium Risk - This modifies the Vite/Rollup chunking strategy. The change groups related crypto packages together, which should only improve bundle cohesion. Without this fix, production is completely broken (white screen).

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

  • Ledger wallet connections
  • Any code path that uses @noble/curves or @noble/secp256k1 for cryptographic operations
  • viem, @Solana, and other packages that depend on @noble (now bundled with ledger chunk)

Testing

Engineering

  1. Build for production: yarn build:web
  2. Serve the production build locally or deploy to preview
  3. Verify the app loads without white screen
  4. Check browser console for any initialization errors
  5. Test wallet connections (Ledger, MetaMask, WalletConnect)
  6. Verify basic transaction signing flows work

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)
  1. Deploy to preview environment
  2. Verify the app loads (no white screen/crash)
  3. Connect a Ledger hardware wallet
  4. Connect a MetaMask wallet
  5. Attempt a basic swap to verify transaction signing works
  6. Verify dashboard and portfolio pages load correctly

Screenshots (if applicable)

N/A - This is a build configuration fix with no UI changes.


Note

Updates Vite manualChunks to bundle @noble, @Scure, and @BitGo with @LedgerHQ under the ledger chunk to avoid cross-chunk issues.

  • Build config (Vite/Rollup):
    • Chunking: Replace includes('@ledgerhq') with match(/(@ledgerhq|@noble|@scure|@bitgo)/) to group related crypto deps into the ledger chunk.
    • Add clarifying comment about avoiding circular chunk dependencies.

Written by Cursor Bugbot for commit 6c9ba0a. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • Chores
    • Refined build configuration to optimize how dependencies are organized and grouped during the build process. This enhancement prevents circular dependency conflicts and improves build stability. The changes focus on better structuring related packages within the bundle. These internal optimizations increase overall reliability without affecting user-facing application features or functionality.

✏️ Tip: You can customize this high-level summary in your review settings.

@0xApotheosis 0xApotheosis requested a review from a team as a code owner December 11, 2025 01:11
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

📝 Walkthrough

Walkthrough

Expanded the chunking rule in vite.config.mts to group additional crypto dependencies (@noble, @scure, @bitgo) alongside @ledgerhq under the 'ledger' chunk. This consolidation prevents circular chunk dependencies during the build process.

Changes

Cohort / File(s) Summary
Build configuration chunking rule
vite.config.mts
Broadened the regex condition for ledger chunk grouping to include @noble, @scure, and @bitgo packages alongside the existing @ledgerhq dependency, plus added clarifying comment

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify the regex pattern correctly matches the intended package scopes
  • Confirm these packages were previously causing circular chunk dependencies
  • Ensure no unintended packages are inadvertently grouped into the ledger chunk

Possibly related PRs

Suggested reviewers

  • gomesalexandre
  • NeOMakinG

Poem

🐰 A regex so grand, with packages in hand,
\@noble, \@Scure, \@BitGo join the band,
In the ledger chunk they'll stay,
No circular loops today—hooray! 🎉

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: grouped ledger chunk' directly describes the main change: grouping additional crypto dependencies into the ledger chunk to resolve circular dependency issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch maybe-fix-circ-dep

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2804ef7 and 6c9ba0a.

📒 Files selected for processing (1)
  • vite.config.mts (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11170
File: patches/@shapeshiftoss+bitcoinjs-lib+7.0.0-shapeshift.0.patch:9-19
Timestamp: 2025-11-25T21:43:10.838Z
Learning: In shapeshift/web, gomesalexandre will not expand PR scope to fix latent bugs in unused API surface (like bitcoinjs-lib patch validation methods) when comprehensive testing proves the actual used code paths work correctly, preferring to avoid costly hdwallet/web verdaccio publish cycles and full regression testing for conceptual issues with zero runtime impact.
Learnt from: premiumjibles
Repo: shapeshift/web PR: 10361
File: src/pages/Markets/components/CardWithSparkline.tsx:83-92
Timestamp: 2025-08-25T23:32:13.876Z
Learning: In shapeshift/web PR #10361, premiumjibles considered the nested button accessibility issue (ChartErrorFallback retry Button inside Card rendered as Button in CardWithSparkline.tsx) out of scope for the error boundaries feature PR, consistent with deferring minor a11y improvements to follow-up PRs.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10323
File: src/components/ButtonWalletPredicate/ButtonWalletPredicate.tsx:7-7
Timestamp: 2025-08-27T09:47:06.275Z
Learning: In shapeshift/web project, NeOMakinG consistently prefers to defer UI/UX improvements and refactoring work (like the Drawer.Close hack fix in ButtonWalletPredicate.tsx) to follow-up PRs rather than expanding the scope of feature PRs, even when the improvements would enhance robustness.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10231
File: src/components/AssetSearch/components/AssetList.tsx:2-2
Timestamp: 2025-08-08T15:00:49.887Z
Learning: Project shapeshift/web: NeOMakinG prefers avoiding minor a11y/UI nitpicks (e.g., adding aria-hidden to decorative icons in empty states like src/components/AssetSearch/components/AssetList.tsx) within feature PRs; defer such suggestions to a follow-up instead of blocking the PR.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/modals/EIP712MessageDisplay.tsx:21-24
Timestamp: 2025-09-12T13:16:27.004Z
Learning: gomesalexandre declined to add error boundaries to WalletConnect modals in PR #10461, stating "no error boundaries in this pr ser", consistent with his preference to keep PR scope focused and defer tangential improvements to separate efforts.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11078
File: src/setupVitest.ts:11-15
Timestamp: 2025-11-20T12:00:45.005Z
Learning: In shapeshift/web, src/setupVitest.ts must redirect 'ethers' to 'ethers5' for shapeshiftoss/hdwallet-trezor (and -trezor-connect), same as ledger and shapeshift-multichain. Removing 'trezor' from the regex causes CI/Vitest failures due to ethers v6 vs v5 API differences.
Learnt from: kaladinlight
Repo: shapeshift/web PR: 10263
File: vite.config.mts:133-134
Timestamp: 2025-08-12T17:52:34.672Z
Learning: In vite.config.mts for shapeshift/web, the team prefers explicit package names in manualChunks configuration rather than pattern-based matching with path boundaries. They want granular control over which specific packages go into each chunk.
Learnt from: kaladinlight
Repo: shapeshift/web PR: 10263
File: vite.config.mts:133-133
Timestamp: 2025-08-12T17:53:56.322Z
Learning: In vite.config.mts for shapeshift/web, kaladinlight prefers to avoid changing working chunk configurations even for better categorization when there's risk of breaking the build. They prioritize build stability over perfect semantic grouping in the short term.
Learnt from: kaladinlight
Repo: shapeshift/web PR: 10376
File: vite.config.mts:136-137
Timestamp: 2025-08-29T18:09:45.982Z
Learning: In the ShapeShift web repository vite.config.mts, the commonjsOptions.exclude configuration using bare package name strings like ['shapeshiftoss/caip', 'shapeshiftoss/types'] works correctly for excluding specific packages from CommonJS transformation, despite theoretical concerns about module ID matching patterns.
📚 Learning: 2025-08-12T17:52:34.672Z
Learnt from: kaladinlight
Repo: shapeshift/web PR: 10263
File: vite.config.mts:133-134
Timestamp: 2025-08-12T17:52:34.672Z
Learning: In vite.config.mts for shapeshift/web, the team prefers explicit package names in manualChunks configuration rather than pattern-based matching with path boundaries. They want granular control over which specific packages go into each chunk.

Applied to files:

  • vite.config.mts
📚 Learning: 2025-08-12T17:53:56.322Z
Learnt from: kaladinlight
Repo: shapeshift/web PR: 10263
File: vite.config.mts:133-133
Timestamp: 2025-08-12T17:53:56.322Z
Learning: In vite.config.mts for shapeshift/web, kaladinlight prefers to avoid changing working chunk configurations even for better categorization when there's risk of breaking the build. They prioritize build stability over perfect semantic grouping in the short term.

Applied to files:

  • vite.config.mts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Call / Static
  • GitHub Check: Cursor Bugbot
🔇 Additional comments (1)
vite.config.mts (1)

187-188: Line numbers are outdated; verify chunk rule evaluation order actually fixes the issue.

The review references lines 187-188, but the code snippet appears at lines 178-179 in the current file. More importantly, the ledger chunking rule (line 179) includes @noble to consolidate it with @ledgerhq, but the viem rule at line 176 also matches @noble with the pattern /@noble|wagmi|viem/. Since Vite's manual chunks function returns on the first matching condition, the viem rule would assign @noble modules to the 'viem' chunk before the ledger rule is ever evaluated for them.

Verify that either:

  1. The viem rule was also modified to exclude @noble from its pattern, or
  2. The ledger rule was reordered to execute before the viem rule

Without one of these changes, @noble packages would not actually be bundled with @ledgerhq as intended, and the circular dependency may persist. Confirm the complete scope of changes to the manualChunks function in the actual PR diff.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@0xApotheosis 0xApotheosis merged commit a834359 into develop Dec 11, 2025
8 of 9 checks passed
@0xApotheosis 0xApotheosis deleted the maybe-fix-circ-dep branch December 11, 2025 01:15
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.

1 participant