Skip to content

feat(migrate): rewrite Tier B VTEX imports to native apps-start paths - #93

Merged
vibe-dex merged 1 commit into
mainfrom
feat/migrate-tier-b-rewrites
May 1, 2026
Merged

vibe-dex merged 1 commit into
mainfrom
feat/migrate-tier-b-rewrites

Conversation

@vibe-dex

@vibe-dex vibe-dex commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Following the apps-start clean cut-off (decocms/apps-start#23), the deco-cx/apps Fresh-era paths (vtex/loaders/intelligentSearch/*, vtex/loaders/legacy/<file>, vtex/loaders/paths/*) no longer exist in @decocms/apps. Sites being migrated need their imports rewritten to the new canonical paths.

This PR teaches deco-migrate to do that automatically.

Rewrites

Old (deco-cx/apps) New (apps-start)
apps/vtex/loaders/intelligentSearch/productList @decocms/apps/vtex/inline-loaders/productList
apps/vtex/loaders/intelligentSearch/productListingPage @decocms/apps/vtex/inline-loaders/productListingPage
apps/vtex/loaders/intelligentSearch/productDetailsPage @decocms/apps/vtex/inline-loaders/productDetailsPage
apps/vtex/loaders/intelligentSearch/suggestions @decocms/apps/vtex/inline-loaders/suggestions
apps/vtex/loaders/legacy/{productList,productListingPage,productDetailsPage,search,category} @decocms/apps/vtex/loaders/legacy (named exports)
apps/vtex/loaders/paths/* removed (TanStack Start has no static-path enumeration)
apps/vtex/utils/fetchVTEX @decocms/apps/vtex/utils/fetch (was incorrectly mapped to vtex/client)

Order: all specific rules are placed before the existing catch-all apps/vtex/loaders/(...) so they take precedence.

Test plan

  • Smoke test with synthetic input — all 7 rewrites produce the expected specifier (or remove the line)
  • npm test — 67 tests pass
  • Re-run deco-migrate against a Fresh site and confirm Tier B imports land correctly
  • Sanity-check casaevideo's existing migration is unaffected (rules are additive + pre-catch-all)

Companion PR

This change is meaningless without decocms/apps-start#23. Merge that first.

Made with Cursor


Summary by cubic

Automatically rewrites Tier B VTEX imports in deco-migrate to native apps-start paths in @decocms/apps. Fixes broken loader and utils imports after the cut-over.

  • New Features
    • apps/vtex/loaders/intelligentSearch/* -> @decocms/apps/vtex/inline-loaders/*
    • apps/vtex/loaders/legacy/{productList,productListingPage,productDetailsPage,search,category} -> @decocms/apps/vtex/loaders/legacy (named exports)
    • apps/vtex/loaders/paths/* -> removed (no static path seeds in TanStack Start)
    • apps/vtex/utils/fetchVTEX -> @decocms/apps/vtex/utils/fetch
    • Rules are placed before the catch-all apps/vtex/loaders/* so they take precedence

Written for commit d1c8346. Summary will update on new commits. Review in cubic

Following the apps-start clean cut-off (no compat layer with deco-cx/apps),
add explicit rewrites so future site migrations land directly on the
canonical apps-start paths.

Rewrites added (before the existing catch-all `apps/vtex/loaders/*`):
- apps/vtex/loaders/intelligentSearch/{productList,productListingPage,
    productDetailsPage,suggestions}     →  @decocms/apps/vtex/inline-loaders/*
- apps/vtex/loaders/legacy/{productList,productListingPage,
    productDetailsPage,search,category} →  @decocms/apps/vtex/loaders/legacy
- apps/vtex/loaders/paths/*              →  removed (no static paths in TanStack)
- apps/vtex/utils/fetchVTEX              →  @decocms/apps/vtex/utils/fetch
                                            (was incorrectly mapped to vtex/client)

Companion to decocms/apps-start#23.

Made-with: Cursor
@vibe-dex
vibe-dex merged commit 6615d26 into main May 1, 2026
1 check passed
@vibe-dex
vibe-dex deleted the feat/migrate-tier-b-rewrites branch May 1, 2026 02:44
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

vibe-dex added a commit that referenced this pull request May 1, 2026
…d shims (#107)

The `phase-cleanup` pass had four import rewrites that took perfectly
valid direct imports and pointed them at NO-OP local shims:

    from "@decocms/apps/vtex/utils/transform"          →  "~/lib/vtex-transform"
    from "@decocms/apps/vtex/utils/intelligentSearch"  →  "~/lib/vtex-intelligent-search"
    from "@decocms/apps/vtex/utils/segment"            →  "~/lib/vtex-segment"
    from "@decocms/apps/vtex/client"                   →  "~/lib/vtex-client"

These rewrites made sense when `@decocms/apps` did not export those
modules. PR #93 (and the apps-start `package.json` exports map for
`./vtex/utils/*` + `./vtex/client`) now provide them directly, so the
cleanup pass was actively regressing migrated sites. Concretely, sites
ended up with:

  - `~/lib/vtex-transform.ts`: `toProduct(p) => p as Product` (no-op cast)
  - `~/lib/vtex-segment.ts`: `getSegmentFromBag() => null`,
    `withSegmentCookie() => return arg as-is`
  - `~/lib/vtex-intelligent-search.ts`: `getISCookiesFromBag() => {}`

…instead of the real implementations that handle cookies, segment
auth, transformations, etc. Silent runtime regressions on every migrated
site.

Fix: empty the `importRewrites` array in `rewriteVtexUtilImports`.
The first-pass `transforms/imports.ts:50-52` already produces the
correct direct form via:

    /^"apps\/vtex\/utils\/([^"]+?)(?:\.ts)?"$/  →  "@decocms/apps/vtex/utils/$1"
    /^"apps\/vtex\/utils\/client(?:\.ts)?"$/    →  "@decocms/apps/vtex/client"

Kept all other transforms in the function (LabelledFuzzy inline,
generic-type strip on createHttpClient, `fetcher: fetchSafe` param
strip, inline-stub hoisting) — those still address real path/signature
mismatches.

Discovery context:
This bug surfaced while triaging dead code in baggagio-tanstack#7
(11 unused `src/lib/*` files, 235 LOC of NO-OP stubs). Tracked in
MIGRATION_TOOLING_PLAN.md.

Follow-ups (not in this PR):
- Drop the 6 VTEX shim templates from `lib-utils.ts` (they're now only
  reachable via the rare inline-stub-hoisting path; future PR can route
  those directly to `@decocms/apps/vtex/...` instead).
- Add a vitest config for `scripts/` so we can write regression tests
  for migration transforms without fs mocking gymnastics.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant