Skip to content

Expose leanVariants on productListingPage / productListFull loaders #429

Description

@JonasJesus42

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions