Repository navigation
fix(themes): move chunk rules to Rolldown codeSplitting groups so shared-home holds only home code - #100
Open
HusnainMaroof wants to merge 1 commit into
Conversation
…red-home holds only home code Rolldown runs output.manualChunks as one group with includeDependenciesRecursively on, so shared-home captured the product components, the shared libraries, Swiper and the engine, and shared-product / shared-common were never emitted. The shared-common matchers also never matched the engine's prebuilt flat files. Move the rules to build.rolldownOptions.output.codeSplitting.groups with priorities: vendor-core, vendor-swiper and vendor-salla for libraries, and shared-common / shared-product / shared-home for theme code. shared-home drops from 160.4 kB to 8.5 kB gzip and total client JS from 425.4 kB to 415.6 kB. Part of SallaApp#96 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HusnainMaroof
marked this pull request as ready for review
November 1, 2026 12:56
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.
Problem
Part of #96. Thanks @fadyehabamer for the measurements.
vite.config.tsasks for three shared chunks, but onlyshared-homeis created. At 523 kB raw / 160 kB gzip it is the largest client chunk, and every page loads it.Two causes:
manualChunksas a single group withincludeDependenciesRecursively: true. WhenHomeComponentRenderer/ProductsSlidergo intoshared-home, every module they import goes with them: the theme's product components, i18next, ky, sonner, TanStack Query, Swiper and the engine. Reordering theifs does not help. Removing only theshared-homerule makesshared-productappear.shared-commonmatchers never match.@salla.sa/twilight-theme-engineships prebuilt flat files (dist/Breadcrumb-7QGTM5S5.js,dist/chunk-*.js), so no module id contains/components/common/.Fix
vite.config.tsonly. The same intent moves tobuild.rolldownOptions.output.codeSplitting.groups, which supports priorities. This is the build's own hint.preload-helper,vendor-react,vendor-routerandvendor-hookskeep their current matchersvendor-core(i18next, ky, sonner, TanStack Query/Virtual) andvendor-swipervendor-salla: only the engine modules every page loads. The engine's lazy screens keep their own route chunksshared-common,shared-productandshared-homenow each hold what their names sayresolveDependenciesis unchangedResults
Client build, gzip -9, same script on both builds:
a913dfashared-homeshared-product/shared-commonCaching also improves: a theme-only change now invalidates small theme chunks instead of the 160 kB
shared-home, and library chunks change only when a dependency is upgraded.Size budget (#63)
I ran
scripts/check-bundle.mjswithsize-budget.jsonfromfeature/quality-gates-twig-parity-auditagainst both builds:shared-homebudget by 12.6 kBshared-homebudgetpnpm size:update). Their code moved there from other chunks; nothing was addedvendor-reactis 0.3 kB over its 5% margin, because React's own dependencies are now captured with it. Turning capture off for that group breaks the SSR build (preserveEntrySignatures: 'strict')Not fixed here
Every page still loads the home blocks and Swiper, because
app/router.tsximports them statically. They are now small separate chunks rather than part of one 160 kB chunk. Making them lazy from the theme alone saved only about 4 kB more in my tests. The bigger win (up to 60 kB on cart, blog and account pages) needs engine changes:sideEffectsfield, so barrels pull inProductPage/CartPage@salla.sa/twilight-theme-engine/skeleton(every route'spendingComponent) imports about 60 engine chunksloader/head// @auto-generatedon each buildChecks
pnpm buildpasses (client and SSR), with no circular-chunk or execution-order warningspnpm test: 606/606 passpnpm typecheckpassesQuestions
masterorfeature/quality-gates-twig-parity-audit? That branch has the size budget and also changesvite.config.tssize-budget.jsonupdate to this PR?