Skip to content

JS --related follows export { a as b } from and namespace re-exports to their importers - #317

Open
calvin-archastro wants to merge 1 commit into
mainfrom
factory/tsk_1aGmlpT2Nh8HncWI0LFfUl-dc89170e-1699-4d3c-8b46-
Open

calvin-archastro wants to merge 1 commit into
mainfrom
factory/tsk_1aGmlpT2Nh8HncWI0LFfUl-dc89170e-1699-4d3c-8b46-

Conversation

@calvin-archastro

@calvin-archastro calvin-archastro commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review on ArchCode

Epic: Aster bug bash fixes
Task: JS --related follows export { a as b } from and namespace re-exports to their importers

Problem and author intent

--related missed JS/TS importers that reached a changed export only through a renaming source re-export or a re-exported namespace. Reported against aster 0.30.1 (GitHub issue 240): with export { orig as renamed } from "./orig.js", import * as o from "./orig.js"; export { o }, and a direct importer, editing orig planned only test/direct.test.js. Without that direct test, the rename barrel was selected and the namespace barrel still was not. export { default as X } from failed the same way. Same-name export { orig } from, export * as oo from, and import { orig }; export { orig as renamed2 } already worked.

Before, Walker::export treated an export with a module source as a unit edge only (reexports) and dropped specifier names and aliases. Symbol matching is by imported name, so a test of renamed or o does not match a change to orig. The unit edge is not enough once a named direct importer exists, because that suppresses the users(unit) fallback. Local export { a as b } already created a Const definition of b whose refs held a. A bare local export { o } created nothing, and the namespace import alone was not a unit edge, so importers of that binding never matched.

Intent is to add the missing name edges without changing same-name or star re-exports, and without touching dynamic imports.

What changed

Source export { name as alias } from spec, including default as X, now also records a Const definition of the alias. refs holds the source name (orig or default) and uses holds the module spec. reexports is unchanged. A same-name source re-export still adds no alias definition.

Local export { … } clauses are walked through a shared export_specifiers helper. Each specifier is stored as an Exported (local, exported, span) and resolved after imports are bound. If that local name is a namespace import (imported is none), the file gains a reexports edge for the namespace spec. An existing alias definition gets uses; a bare export { o } (which previously created no definition) gets a Const definition of the name importers use, with refs containing that name and uses containing the spec. Export-before-import is covered because resolution happens after binding. export * as stays reexport-only.

Scope

  • src/related/js.rs — export fact extraction and binding resolution
  • tests/related.rs — selection regression
  • Diff evidence for these paths is complete in this payload: 10 hunks, +296/−18, 0 omitted hunks, paths, or patch bytes
  • Dynamic import handling is unchanged

Risk assessment

Medium. Selection widens only for importers of renaming re-exports and of re-exported namespaces. Namespace matching is an accepted over-approximation: any changed export of the namespace module selects importers of the namespace binding, even if the test never names that export. Barrel files are common, so affected-test sets can grow; this change does not include a large barrel fixture. Same-name and export * edges are intentionally unchanged.

User impact

aster --related on JS/TS projects selects tests that import through export { a as b } from, export { default as X } from, and import * as o; export { o } (including a rename of that namespace). Direct importers are still selected. Tests of unrelated modules are not selected by these edges.

Testing

The diff adds, but does not prove execution of:

  • source_reexports_that_rename_are_definitions_of_the_alias and a_reexported_namespace_is_a_definition_of_that_binding in src/related/js.rs (alias defs, default as X, same-name and star re-exports stay definition-free, namespace re-export including export-before-import)
  • js_renamed_and_namespace_reexports_reach_their_importers in tests/related.rs (issue layout with direct/rename/namespace tests, the no-direct variant, default as X, and an unrelated export selecting the namespace importer but not another module)

Pipeline checks format, lint, test, fix, reformat, verify-lint, verify-test, and commit are reported succeeded with exit 0. Check excerpts are truncated and do not name these functions, so that success is not evidence the new tests ran. Author-reported cargo test --lib related::, cargo test --test related, clippy, and fmt are advisory only and are not confirmed here.

Follow-ups and known issues

  • Dynamic import selection (issue 239) remains out of scope.
  • Namespace over-selection of unnamed exports is accepted, not fixed.
  • No measurement here of selection size on a large barrel.

@calvin-archastro
calvin-archastro requested a review from a team November 1, 2026 04:20
@calvin-archastro

calvin-archastro commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

ArchDev is watching this pull request. State: watching (cycle 2 of 2 for head 3a9aa51).

when trigger decision result
2026-11-01T16:42:50.973Z merge conflict enqueue job_5110faeec72161ac68c47096 failed Pipeline step finalize-conflict failed: command exited with code 1
2026-11-01T17:01:23.574Z verify head enqueue job_9e8b199d64a671cb2bbdd8e2 no change

Paused by the no-autofix label or a draft; never resolves reviewer threads. Jobs: job_5110faeec72161ac68c47096, job_9e8b199d64a671cb2bbdd8e2.

@calvin-archastro
calvin-archastro force-pushed the factory/tsk_1aGmlpT2Nh8HncWI0LFfUl-dc89170e-1699-4d3c-8b46- branch from 8dfed37 to 3a9aa51 Compare November 1, 2026 16:50

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant