Skip to content

fix: production build size - #11284

Merged
NeOMakinG merged 3 commits into
developfrom
fix-build-nov
Dec 4, 2025
Merged

fix: production build size#11284
NeOMakinG merged 3 commits into
developfrom
fix-build-nov

Conversation

@NeOMakinG

@NeOMakinG NeOMakinG commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

Description

This extract more bundles from our main js bundle:

  • Asset data extraction is making the main bundle a LOT smaller
  • Extracting chain-adapters make us win 5mb of source map weight
  • A few other libraries extractions helps to reduce the final sourcemap height too

Note:

  • Some chunks needs to be at the end of the import order, prefixing them with z makes it work properly, its mainly because they heavily rely on some previous bundles exports

Issue (if applicable)

Spotted while releasing

Risk

High as build could completely break

High Risk PRs Require 2 approvals

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

Testing

  • Clear your cache
  • use yarn preview:prod and globally test the app to ensure it works as expected (accounts, swappers execution, assets icons/data)
  • use yarn preview:dev and same tests
  • use yarn dev and same tests but shouldn't be changed on this side, just paranoia
  • Ensure https://github.com/shapeshift/web/actions/runs/19932766929 is passing and deployed correctly

Engineering

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

https://jam.dev/c/b40b6871-fbf6-43f1-8469-41f4689b88d4

Summary by CodeRabbit

  • Chores
    • Reorganized build configuration module bundling logic with expanded dependency mappings and new specialized chunk groupings
    • Reordered existing module-to-chunk associations and adjusted import ordering heuristics
    • Introduced late-binding chunk configurations to manage inter-dependency relationships
    • Enhanced module separation strategy and dependency sequencing across application bundles

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

@NeOMakinG
NeOMakinG requested a review from a team as a code owner December 4, 2025 14:39
@coderabbitai

coderabbitai Bot commented Dec 4, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Modified vite.config.mts to expand module-to-chunk mappings, introducing new specialized chunk groups for dependencies, adding "z-" prefixed chunks for heavy dependencies requiring late imports, reordering existing associations, and refining import ordering heuristics to handle interdependencies.

Changes

Cohort / File(s) Change Summary
Vite build configuration - Module chunking
vite.config.mts
Expanded manualChunks logic with numerous new module-to-chunk mappings. Added specialized chunk groups for carousel (embla-carousel), charts (lightweight-charts), qr-scanner (html5-qrcode), react-scan, styled-components, protobuf, date-fns, and ledger (ledgerhq). Introduced "z-" prefixed late-load chunks for @cetusprotocol and graphql. Migrated @cetusprotocol from standard to z-@CetusProtocol chunk. Removed direct hdwallet-vultisig mapping. Added new mappings for valibot, graphqllsp (with z-graphqllsp variant), localAssetData, and z-chain-adapters to optimize load order and resolve inter-chunk dependencies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify z-prefixed chunks load in the correct sequence and don't cause timing issues
  • Check for any circular dependencies introduced by the new chunk assignments
  • Validate that removed/migrated mappings (hdwallet-vultisig, @cetusprotocol) don't break builds
  • Confirm inter-chunk dependencies are properly resolved with new late-binding assignments

Possibly related PRs

Suggested reviewers

  • gomesalexandre
  • 0xApotheosis
  • premiumjibles

Poem

🐰 Chunks are ordered, dependencies aligned,
Heavy dancers wait their turn in line,
Z-prefixes whisper "load me last,"
A hoppy optimization, steady and fast!
Bundles dance in harmony divine,

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: production build size' directly aligns with the main objective of the PR, which is to extract additional bundles to reduce production build size.
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 fix-build-nov

📜 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 6107811 and ea74272.

📒 Files selected for processing (1)
  • vite.config.mts (2 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10231
File: src/components/MultiHopTrade/components/TradeInput/components/HighlightedTokens.tsx:14-14
Timestamp: 2025-08-08T15:00:22.321Z
Learning: In shapeshift/web reviews for NeOMakinG, avoid nitpicks to change deep-relative imports to '@/…' alias paths within feature/non-refactor PRs; defer such style-only changes to a dedicated follow-up refactor unless they fix an issue.
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: 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: 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: 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.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10323
File: src/pages/RFOX/components/Stake/components/StakeSummary.tsx:112-114
Timestamp: 2025-08-22T13:00:44.879Z
Learning: NeOMakinG prefers to keep PR changes minimal and focused on the core objectives, avoiding cosmetic or defensive code improvements that aren't directly related to the PR scope, even when they would improve robustness.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10128
File: .cursor/rules/error-handling.mdc:266-274
Timestamp: 2025-07-29T10:35:22.059Z
Learning: NeOMakinG prefers less nitpicky suggestions on documentation and best practices files, finding overly detailed suggestions on minor implementation details (like console.error vs logger.error) too granular for cursor rules documentation.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10380
File: src/pages/Dashboard/components/AccountList/AccountTable.tsx:60-0
Timestamp: 2025-09-02T08:34:08.157Z
Learning: NeOMakinG prefers code review comments to focus only on actual PR changes, not pre-existing code issues, unless there are critical security or correctness concerns directly related to the new functionality.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10234
File: src/components/MultiHopTrade/hooks/useGetTradeQuotes/hooks/useTrackTradeQuotes.ts:42-86
Timestamp: 2025-08-08T11:41:22.794Z
Learning: NeOMakinG prefers not to include refactors in move-only PRs; such suggestions should be deferred to follow-up issues instead of being applied within the same PR.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10380
File: src/components/Table/Table.theme.ts:177-180
Timestamp: 2025-09-02T12:38:46.940Z
Learning: NeOMakinG prefers to defer technical debt and CSS correctness issues (like improper hover selectors) to follow-up PRs when the current PR is already large and focused on major feature implementation, even when the issues are valid from a usability/technical perspective.
📚 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
📚 Learning: 2025-08-29T18:09:45.982Z
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.

Applied to files:

  • vite.config.mts
📚 Learning: 2025-11-24T21:20:04.979Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T21:20:04.979Z
Learning: Applies to **/*.{ts,tsx} : Import types from `shapeshiftoss/caip` for chain/account/asset IDs

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). (1)
  • GitHub Check: Call / Static
🔇 Additional comments (3)
vite.config.mts (3)

179-187: LGTM - Good chunk extractions for build optimization.

These additions effectively isolate heavyweight dependencies into dedicated chunks. The explicit id.includes() matching aligns with the established pattern in this file. Based on learnings, this explicit approach is preferred over pattern-based matching for granular control.


199-204: Verify the z-prefix chunk ordering works as intended.

The ordering of checks is correct—@0noco/graphqllsp on line 200 must precede the generic graphql check on line 204 to prevent misclassification.

The z-prefix naming convention to enforce late loading is clever but relies on implicit alphabetical ordering behavior. Please verify the final build output confirms these chunks load after their dependencies.


211-214: LGTM - Good extraction for significant bundle size reduction.

Extracting localAssetData and chain-adapters into separate chunks addresses the PR objectives. The z-prefix for chain-adapters ensures proper load order since it relies on exports from earlier bundles.


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.

@NeOMakinG
NeOMakinG enabled auto-merge (squash) December 4, 2025 14:42
@NeOMakinG
NeOMakinG disabled auto-merge December 4, 2025 14:42
@NeOMakinG
NeOMakinG enabled auto-merge (squash) December 4, 2025 14:54
@NeOMakinG
NeOMakinG disabled auto-merge December 4, 2025 14:55
@NeOMakinG
NeOMakinG merged commit 7eee9a6 into develop Dec 4, 2025
4 checks passed
@NeOMakinG
NeOMakinG deleted the fix-build-nov branch December 4, 2025 14:55
NeOMakinG added a commit that referenced this pull request Dec 4, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Dec 11, 2025
1 task
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