Skip to content

Add Magento commerce app port to @decocms/apps-start #60

@JonasJesus42

Description

@JonasJesus42

Summary

@decocms/apps-start ships VTEX and Shopify ports today (per the package README and folder layout). There is no Magento port, even though deco-cx/apps has a mature Magento integration that powers multiple production sites.

This blocks migration of Magento-based Fresh storefronts to TanStack Start: deco-migrate deletes the legacy magento/ folder's imports but the new src/setup/commerce-loaders.ts has nothing to map them to, so cart / user / wishlist / PDP / PLP loaders break post-migration.

Source to port

deco-cx/apps, folder magento/ — 60 TypeScript files, structurally identical to apps/vtex/ (mod.ts, manifest.gen.ts, loaders/, actions/, hooks/, middleware.ts, utils/clientGraphql, utils/client, utils/transform.ts, utils/cache.ts).

Key entry points to port (≈54 generic files):

  • mod.ts — App definition with configureMagento + middleware
  • loaders/cart.ts, loaders/user.ts, loaders/wishlist.ts, loaders/proxy.ts
  • loaders/product/detailsPage.ts, loaders/product/listingPage.ts, loaders/product/list.ts
  • loaders/routes/*
  • actions/{cart,newsletter,product,wishlist}/*
  • hooks/{useCart,useUser,useWishlist}.ts (refactor to react-query like vtex/hooks/)
  • utils/clientGraphql/*, utils/client/*, utils/{transform,cache,graphql,cart}.ts

Required adaptations (Deno → Node)

  • $fresh/server.ts imports → TanStack/React equivalents
  • deco/* imports → @decocms/start/* and @decocms/apps-start/commerce
  • Drop .ts extension from relative imports
  • Replace Deno std/cache LRU with npm:lru-cache (mirror pattern in apps-start/vtex/utils/fetchCache.ts)
  • Wrap loaders/actions in createServerFn
  • Cookies via @decocms/apps-start/commerce helpers

CRITICAL: preserve ExtensionOf pattern

The existing Magento app accepts extensions?: ExtensionOf<T>[] on key loaders (loaders/extensions/cart, loaders/extensions/product/{detailsPage,listingPage,list}). This is how sites plug in third-party features (Livelo points, Amasty reviews, etc.) without forking the app.

Please port this pattern intact. The first consumer (granadobr-tanstack) will keep Granado-specific extensions (Livelo + Amasty) in src/apps/magento-granado/ locally — that only works if the generic Magento loaders accept and apply extensions[].

Context

Sites blocked on this:

  • granadobr-tanstack (Granado, Brazilian cosmetics) — repo: deco-sites/granadobr-tanstack
  • Future Magento migrations across the deco fleet

Companion framework issue: decocms/deco-start — Platform magento missing from migrate's enum.

Happy to send a PR — let me know the preferred patch granularity (one big PR vs split per area).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions