feat(migrate): dedupe exact-duplicate VTEX blocks - #215
Merged
Conversation
…r product, wrappers) Merging block trees across pages ballooned blocks.json (509 → 5242 on Electrolux) because structurally-identical block instances (a product-summary per product, repeated layout wrappers like hide-and-show) each have a distinct treePath and so weren't deduped. `dedupeVtexBlocks` now collapses EXACT duplicates (same blockName + identical props) into one representative with a `repeated` count — blocks with distinct content (e.g. banners with different images) are kept. The FastStore mapper counts via `repeated` so instance totals stay accurate. Live electrolux.com.ec: 5242 → 883 blocks (581 groups collapsed; hide-and-show ×458 etc.), same content coverage. Full suite green (1109), tsc + biome clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merged
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.
You flagged that 5242 blocks is a lot / could have repeats — correct.
Merging block trees across pages ballooned
blocks.jsonbecause structurally-identical instances (aproduct-summaryper product, repeated layout wrappers likehide-and-show) each have a distincttreePath, so the treePath-merge didn't collapse them.Fix:
dedupeVtexBlockscollapses exact duplicates (sameblockName+ identicalprops) into one representative with arepeatedcount. Blocks with distinct content (banners with different images, etc.) are kept. The FastStore mapper counts viarepeated, so instance totals stay accurate.Verification
Unit tests (collapse identical, keep distinct). Full suite green (1109), tsc + biome clean, build OK. Live
electrolux.com.ec: 5242 → 883 blocks (581 groups collapsed;hide-and-show×458), same content coverage.Off
main.🤖 Generated with Claude Code
Summary by cubic
Collapses exact-duplicate VTEX blocks during migration to shrink
blocks.jsonwithout losing coverage. Previously each instance (uniquetreePath) was counted separately; now identicalblockNamewith identicalpropsmerge into one block with arepeatedcount. Distinct-content blocks are unchanged, and FastStore mappings still reflect accurate totals viarepeated.Review notes
vtexBlocksin migrate.ts.b.repeatedwhen present.Written for commit 1964d41. Summary will update on new commits.