Repository navigation
fix(sync): an import moves to an added file that outranks the one it found - #2529
Merged
Merged
Conversation
…found An import written without an extension that resolved to one file, `./button` to `button.vue` while `button.ts` was missing, kept that edge and what it binds when `button.ts` was added beside it, though the resolver now finds `button.ts` first: sync only retried imports that had failed. A fresh index links the added file. When a sync adds a file, the module edges into the files an import of the same name finds instead (`dir/name.*` under another extension, the folder's own `dir/name/index.*` or `dir/name/__init__.py`) whose specifier now resolves to the added file go back to the sweep, and their importers join the added module's importers with that statement, so the names it binds are re-resolved too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
An import written without an extension that resolved to one file kept that edge, and what it binds, when a file the resolver finds first was added beside it. A fresh index of the same tree links the added file.
In vbenjs/vue-vben-admin,
packages/@core/ui-kit/shadcn-ui/src/components/button/holds bothbutton.tsandbutton.vue. Withbutton.tsheld out,check-button-group.vue'simport … from './button'resolves tobutton.vue. Oncebutton.tsis back, the resolver finds it first:.tscomes before.vueinEXTENSION_RESOLUTION.vue. But sync only retries imports that failed, and this one had resolved.Script imports have had this gap since #2263 (a module path resolves to its file). #2528 made it show for components: these were the only residue lines that PR added in its A/B (4 lines in vben's every-7th restore and added-late scenarios).
Fix
src/resolution/module-importers.ts, on the add side, givenReferenceResolver.resolveModuleFile(from #2528):QueryBuilder.getModuleImportsNamed):dir/name.*under another extension, or the folder's own entrydir/name/index.*ordir/name/__init__.py. Those whose specifier now resolves to the added file go back to the sweep.Removal needed nothing new: the edge into a deleted file is resurrected and re-resolved as before.
No schema change and no extraction change. Fresh indexes are untouched.
Validation
Tests.
__tests__/sync-module-importers.test.tshas a new case, "file outranking the one an import resolved to":button.vueexportssizeOfandonlyVue;button.tsexports a default,buttonClassandsizeOf.group.vueimports all of them through'./button', andpanel.tsimports the default.Results:
onlyVue.Fresh-index A/B: all 9 repos byte-identical (a sync-only change).
Sync A/B. Each arm's synced graph is compared with its own fresh index. Barrels are every 2nd
index.*; the rest are every 7th source file, deleted, restored and added late.check-button-group.vueandicon-button.vuenow linkbutton.ts, as the fresh index does.Cost. One indexed range query per added file. Sync times are within run-to-run noise in every scenario, for example vben's every-7th added late at 6.46 s on main and 6.48 s with this PR.
Overlap
🤖 Generated with Claude Code