Repository navigation
Count export readers from resolved imports, not from words - #2678
Merged
Merged
Conversation
The unused-export check counted an export as read wherever its name appeared as
a word in any tracked file, so an export used only in its own module passed
whenever an unrelated file happened to share the word (`Revision` in
`build/browser/domain.ts` did for weeks). `tests/js_facts.mjs` gains an
`imports` reading: each module's named imports, re-exports, `export *`
forwarding, TypeScript and JSDoc `import("…").Name` types, and namespace use,
static or through `import()` (member reads, destructuring, `.then` handlers),
each resolved to the exporting file, served `/runtime/…` paths and the
browser framework's committed bundle included. The word search remains only
for readers that are not JavaScript: Python tests, pages and prose.
The stricter check flagged three exports nothing reads: `accompaniedThread`
and `accompanyThread` in `thread/landing.js` and `isAddressable` in
`thread/model.js`. Reviewing the exports that only the word search still
passes found three more that only share a word with a reader: the `SAY_BOX`
re-export in `thread/landing.js` (tests read `thread/selectors.js`'s),
`offerElement` in `widget-elements.js`, and `generated` in
`dependency-bundles.mjs`. All six are unexported or removed. The served path
mapping `tests/runtime/dom.mjs` used moves to `tests/served-paths.mjs`,
shared with `js_facts.mjs`. No user-visible behaviour changed.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
reviewed
Oct 12, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The import reader loses the source of a namespace that is re-exported through a local binding.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 12, 2026
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.
The unused-export check (
tests/model/test_unused_exports.py) counted an export as read wherever its name appeared as a word in any tracked file, so an export used only in its own module passed whenever an unrelated file shared the word.Revisioninbuild/browser/domain.tspassed that way for weeks (#2674).tests/js_facts.mjsgains animportsreading that resolves each read to the exporting file: named imports, re-exports,export *forwarding, TypeScript and JSDocimport("…").Nametypes, and namespace use, static or throughimport()(member reads, destructuring,.thenhandlers, throughawait, conditionals and tests). It resolves extensionless and.js-for-.tsspecifiers, the served/runtime/,/vendor/,/widgets/and/checks/paths, and a committed bundle compiled from one module of this tree (vendor/browser-runtime.js) to that module. Vendored bundles' own imports now count as readers, since what a bundle left external is what it reads. A name taken from animport()of a computed specifier reads that name in any module. The Worker's entry (worker/wrangler.toml'smain) counts as read whole, since the Workers runtime reads its exports by name (ContainerProxy). The word search remains only for readers that are not JavaScript: Python tests, pages and prose. The docstring names each of these readers.The stricter check flagged three exports nothing reads:
accompaniedThreadandaccompanyThreadinthread/landing.jsandisAddressableinthread/model.js. Reviewing the 77 exports that only the word search still passes found three more that only share a word with a reader: theSAY_BOXre-export inthread/landing.js(tests readthread/selectors.js's),offerElementinwidget-elements.js, andgeneratedin.github/scripts/dependency-bundles.mjs. All six are unexported or removed.The served-path mapping
tests/runtime/dom.mjsused moves totests/served-paths.mjs, whichjs_facts.mjsshares.Restoring
exportonisAddressable, whichdesign.jsnames because it importsanchor-resolution.js's, fails the new check and passes the old one.No user-visible behaviour changed.