Repository navigation
feat(migrate): rewrite Tier B VTEX imports to native apps-start paths - #93
Merged
Merged
Conversation
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
|
🎉 This PR is included in version 2.2.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
5 tasks
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
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.
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-migrateto do that automatically.Rewrites
apps/vtex/loaders/intelligentSearch/productList@decocms/apps/vtex/inline-loaders/productListapps/vtex/loaders/intelligentSearch/productListingPage@decocms/apps/vtex/inline-loaders/productListingPageapps/vtex/loaders/intelligentSearch/productDetailsPage@decocms/apps/vtex/inline-loaders/productDetailsPageapps/vtex/loaders/intelligentSearch/suggestions@decocms/apps/vtex/inline-loaders/suggestionsapps/vtex/loaders/legacy/{productList,productListingPage,productDetailsPage,search,category}@decocms/apps/vtex/loaders/legacy(named exports)apps/vtex/loaders/paths/*apps/vtex/utils/fetchVTEX@decocms/apps/vtex/utils/fetch(was incorrectly mapped tovtex/client)Order: all specific rules are placed before the existing catch-all
apps/vtex/loaders/(...)so they take precedence.Test plan
npm test— 67 tests passdeco-migrateagainst a Fresh site and confirm Tier B imports land correctlyCompanion 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-migrateto nativeapps-startpaths in@decocms/apps. Fixes broken loader and utils imports after the cut-over.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/fetchapps/vtex/loaders/*so they take precedenceWritten for commit d1c8346. Summary will update on new commits. Review in cubic