Repository navigation
fix(sync): a barrel whose re-export points elsewhere re-links the files importing through it - #2985
Open
danusha2345 wants to merge 1 commit into
Open
danusha2345 wants to merge 1 commit into
danusha2345 wants to merge 1 commit into
Conversation
…es importing through it `c.ts` imports `foo` through `index.ts`, which re-exports it from `a.ts`. When the barrel's clause is changed to `b.ts`, the barrel declares nothing of `foo` and `c.ts` did not change, so no definition delta, added file or failed reference named `c.ts`'s binding: it stayed on `a.ts` until a full re-index, and an `export *` moved the same way, in a full or a scoped sync (colbymchenry#2978). An import node is named by the module it names, so the orchestrator samples the `file\0module` pairs of a changed file's import nodes before the store replaces them, as it samples the definition pairs, and reports the ES modules whose set of imported modules changed when they pass bindings on now or lost an import: `reExportsChangedFilePaths`. For those, the sync re-opens what their importers bind through them, up through the modules that pass them on in turn, with the failures parked under them, and the edges into the members of what the bindings pointed at, which a value typed by a binding reached by their own names (reopenReferencesThroughRetargetedModules, built on the importer walk the removed-files pass uses). It runs after the name-matched-import pass, which reads the bindings a name match took before they go back. The sweep binds them against the barrel as it is now. A module given re-exports is read the same way; one whose body alone changed reports nothing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes #2978.
What happened
c.tsimportsfoothroughindex.ts, which re-exports it froma.ts. When the barrel's clause is changed tob.tsand the tree is synced,barkeeps callinga.ts:foo; a fresh index givesb.ts:foo. The barrel declares nothing offoo, so the definition delta (CG-33) has nothing to rebind; no file was added for the walks below a barrel (#2665) or the added-files pass; the binding never failed, so the retries (#1240, #2744) never see it; and the name-matched-import pass (#2744's other half) reads only bindings a name match took.export *moves the same way, and a scoped sync of the barrel alone too.The change
sync()samples a changed file'sfile\0moduleimport pairs before the store replaces them, as it samples the definition pairs, and returnsreExportsChangedFilePaths: the ES modules whose set of imported modules changed and that pass bindings on now (export … from) or lost an import. A body-only edit, or an import edit in a file that re-exports nothing, reports nothing.reopenReferencesThroughRetargetedModulesin module-importers.ts): the edges each importer makes through the names it binds from the module, up through the modules that pass them on in turn (a second barrel over the first), with the failures parked under them, and the edges into the members of what the bindings pointed at, which a value typed by a binding reached by their own names (w.run()withw: Widget). It is the importer walk the removed-files pass uses, without the exclusion of edges into the file itself, and it runs after the name-matched-import pass (fix(sync): a name imported through a barrel links when an edit gives the barrel its re-export #2744), which reads the bindings a name match took before they go back. The sweep then binds them against the barrel as it is now.Tests
__tests__/sync-barrel-retarget.test.ts(7 tests), each comparing the synced graph with a full index of the final tree:export *retargeted; a scoped sync of the barrel alone;new Widget(); w.run()) reaches the members of the new target;6 of 7 fail on
main(the control passes); all 7 pass here.Full suite on
main01e0ac3 with the native kernel (CODEGRAPH_KERNEL_EXPECT=1): 9,278 passed, 55 skipped, 0 failed;tsc --noEmitclean.🤖 Generated with Claude Code