decocms / decocms/blocks

Expose `leanVariants` on productListingPage / productListFull loaders

Open
#429 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5
Forks
2
Avg merge
20h 12m
Merged PRs (30d)
36

Description

apps-start: expose leanVariants on listing/shelf loaders

Repo: decocms/blocks (monorepo; VTEX code ships as @decocms/apps-vtex)

Problem

productListingPage and productListFull (shelf) transform every product with
FULL variants, producing multi-MB hydration payloads on PLPs and product shelves.

  • src/loaders/intelligentSearch/productListingPage.ts:450
    toProduct(p, sku, 0, { baseUrl, priceCurrency: "BRL" }) — no leanVariants
  • src/loaders/productListFull.ts:147
    toProduct(p, preferredSku, 0, { baseUrl, priceCurrency: "BRL" }) — no leanVariants

The lean transform already exists (src/utils/transform.ts: toProductVariant,
ProductOptions.leanVariants, variantIncludeImage, variantIncludeInventory)
but ONLY productDetailsPage.ts opts in — the two loaders that generate the
biggest payloads don't.

Impact (miess-01-tanstack, /linha-noite, 36 products)

Each product shipped ~24 SKUs each with: nested isVariantOf.hasVariant (N²),
full priceSpecification installment ladder (~27 entries/SKU), full image
gallery, full additionalProperty. Human PLP HTML = 14 MB; PDP = 9.4 MB.
Worked around at site level with a trimProductForShelf util (lean variants) →
PLP 2.84 MB, PDP 4 MB. That util should not need to exist.

Proposed fix

Support leanVariants on productListingPage/productListFull (a Props flag,
or default-on for listing/shelf contexts). Reuse the existing toProductVariant.

Opt-in requirement

Must not regress sites whose ProductCards read full variant data (color/size
swatches from additionalProperty, per-SKU images). Ship as opt-in (prop, or a
default that sites can disable) — do not silently change existing behavior.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the call sites in src/loaders/intelligentSearch/productListingPage.ts:450 and src/loaders/productListFull.ts:147, then compare how src/loaders/productDetailsPage.ts uses the existing lean transform in src/utils/transform.ts. Trace the relevant loader props and ProductOptions, and verify that full variant data remains available unless the new behavior is explicitly enabled. Done means both loaders can produce lean variants without silently changing existing ProductCard behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, performance
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.