Repository navigation
fix(migrate): convert $store/ alias imports to ~/ - #64
Merged
Merged
Conversation
The $store/ alias (common in Deno import maps) was not being rewritten during migration, causing Vite "Failed to resolve import" errors at runtime. Now handled identically to site/ → ~/ conversion. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
🎉 This PR is included in version 0.42.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="scripts/migrate/transforms/imports.ts">
<violation number="1" location="scripts/migrate/transforms/imports.ts:53">
P1: The new `$store/sdk/*` rewrite patterns are over-broad (`.*`) and can rewrite unrelated imports with matching prefixes. Anchor these rules to the exact specifier (optionally with `.ts`/`.tsx`) to avoid false matches.</violation>
</file>
<file name="scripts/migrate/phase-verify.ts">
<violation number="1" location="scripts/migrate/phase-verify.ts:181">
P2: The new `$store/` verification regex misses side-effect imports (`import "$store/..."`) because it only searches for `from ...` syntax.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Comment on lines
+53
to
+57
| [/^"\$store\/sdk\/clx(?:\.tsx?)?.*"$/, `"@decocms/start/sdk/clx"`], | ||
| [/^"\$store\/sdk\/useId(?:\.tsx?)?.*"$/, `"react"`], | ||
| [/^"\$store\/sdk\/useOffer(?:\.tsx?)?.*"$/, `"@decocms/apps/commerce/sdk/useOffer"`], | ||
| [/^"\$store\/sdk\/useVariantPossiblities(?:\.tsx?)?.*"$/, `"@decocms/apps/commerce/sdk/useVariantPossibilities"`], | ||
| [/^"\$store\/sdk\/usePlatform(?:\.tsx?)?.*"$/, null], |
There was a problem hiding this comment.
P1: The new $store/sdk/* rewrite patterns are over-broad (.*) and can rewrite unrelated imports with matching prefixes. Anchor these rules to the exact specifier (optionally with .ts/.tsx) to avoid false matches.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/migrate/transforms/imports.ts, line 53:
<comment>The new `$store/sdk/*` rewrite patterns are over-broad (`.*`) and can rewrite unrelated imports with matching prefixes. Anchor these rules to the exact specifier (optionally with `.ts`/`.tsx`) to avoid false matches.</comment>
<file context>
@@ -49,6 +49,14 @@ const IMPORT_RULES: Array<[RegExp, string | null]> = [
[/^"site\/sdk\/usePlatform(?:\.tsx?)?.*"$/, null],
+ // $store/ → ~/ (common Deno import map alias for project root)
+ [/^"\$store\/sdk\/clx(?:\.tsx?)?.*"$/, `"@decocms/start/sdk/clx"`],
+ [/^"\$store\/sdk\/useId(?:\.tsx?)?.*"$/, `"react"`],
+ [/^"\$store\/sdk\/useOffer(?:\.tsx?)?.*"$/, `"@decocms/apps/commerce/sdk/useOffer"`],
</file context>
Suggested change
| [/^"\$store\/sdk\/clx(?:\.tsx?)?.*"$/, `"@decocms/start/sdk/clx"`], | |
| [/^"\$store\/sdk\/useId(?:\.tsx?)?.*"$/, `"react"`], | |
| [/^"\$store\/sdk\/useOffer(?:\.tsx?)?.*"$/, `"@decocms/apps/commerce/sdk/useOffer"`], | |
| [/^"\$store\/sdk\/useVariantPossiblities(?:\.tsx?)?.*"$/, `"@decocms/apps/commerce/sdk/useVariantPossibilities"`], | |
| [/^"\$store\/sdk\/usePlatform(?:\.tsx?)?.*"$/, null], | |
| [/^"\$store\/sdk\/clx(?:\.tsx?)?"$/, `"@decocms/start/sdk/clx"`], | |
| [/^"\$store\/sdk\/useId(?:\.tsx?)?"$/, `"react"`], | |
| [/^"\$store\/sdk\/useOffer(?:\.tsx?)?"$/, `"@decocms/apps/commerce/sdk/useOffer"`], | |
| [/^"\$store\/sdk\/useVariantPossiblities(?:\.tsx?)?"$/, `"@decocms/apps/commerce/sdk/useVariantPossibilities"`], | |
| [/^"\$store\/sdk\/usePlatform(?:\.tsx?)?"$/, null], |
| const srcDir = path.join(ctx.sourceDir, "src"); | ||
| if (!fs.existsSync(srcDir)) return true; | ||
| const bad = findFilesWithPattern(srcDir, /from\s+["']site\//); | ||
| const bad = findFilesWithPattern(srcDir, /from\s+["'](site\/|\$store\/)/); |
There was a problem hiding this comment.
P2: The new $store/ verification regex misses side-effect imports (import "$store/...") because it only searches for from ... syntax.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/migrate/phase-verify.ts, line 181:
<comment>The new `$store/` verification regex misses side-effect imports (`import "$store/..."`) because it only searches for `from ...` syntax.</comment>
<file context>
@@ -173,14 +173,14 @@ const checks: Check[] = [
const srcDir = path.join(ctx.sourceDir, "src");
if (!fs.existsSync(srcDir)) return true;
- const bad = findFilesWithPattern(srcDir, /from\s+["']site\//);
+ const bad = findFilesWithPattern(srcDir, /from\s+["'](site\/|\$store\/)/);
if (bad.length > 0) {
- console.log(` Still has site/ imports: ${bad.join(", ")}`);
</file context>
Suggested change
| const bad = findFilesWithPattern(srcDir, /from\s+["'](site\/|\$store\/)/); | |
| const bad = findFilesWithPattern(srcDir, /(?:from\s+["']|import\s+["'])(site\/|\$store\/)/); |
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
$store/alias (common in Deno import maps) →~/(Vite alias)$store/sdk/*specific rewrites matching existingsite/sdk/*rules (clx, useOffer, etc.)$store/imports alongsidesite/Tested on
deco-sites/miess-01— previously all$store/imports survived migration causing Vite "Failed to resolve import" errors at runtime.Test plan
deco-migrateon a site using$store/imports (e.g. miess-01)$store/imports remain insrc/after migration🤖 Generated with Claude Code
Summary by cubic
Fixes the migrate script to convert
$store/alias imports to~/and map$store/sdk/*to the correct packages, preventing Vite resolve errors. The verify phase now flags any remainingsite/or$store/imports.$store/sdk/*to the right targets:@decocms/start/sdk/clx,react,@decocms/apps/commerce/sdk/useOffer,@decocms/apps/commerce/sdk/useVariantPossibilities; drop deprecatedusePlatform.$store/...to~/<path>.site/or$store/imports insrc/.Written for commit aec6b96. Summary will update on new commits.