Skip to content

Count export readers from resolved imports, not from words - #2678

Merged
max-sixty merged 4 commits into
mainfrom
count-export-readers-from-imports
Oct 12, 2026
Merged

max-sixty merged 4 commits into
mainfrom
count-export-readers-from-imports

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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. Revision in build/browser/domain.ts passed that way for weeks (#2674).

tests/js_facts.mjs gains an imports reading that resolves each read to the exporting file: named imports, re-exports, export * forwarding, TypeScript and JSDoc import("…").Name types, and namespace use, static or through import() (member reads, destructuring, .then handlers, through await, conditionals and tests). It resolves extensionless and .js-for-.ts specifiers, 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 an import() of a computed specifier reads that name in any module. The Worker's entry (worker/wrangler.toml's main) 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: accompaniedThread and accompanyThread in thread/landing.js and isAddressable in thread/model.js. Reviewing the 77 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 .github/scripts/dependency-bundles.mjs. All six are unexported or removed.

The served-path mapping tests/runtime/dom.mjs used moves to tests/served-paths.mjs, which js_facts.mjs shares.

Restoring export on isAddressable, which design.js names because it imports anchor-resolution.js's, fails the new check and passes the old one.

No user-visible behaviour changed.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 3 commits October 12, 2026 15:07
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]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import reader loses the source of a namespace that is re-exported through a local binding.

Comment thread tests/js_facts.mjs Resolved
@max-sixty
max-sixty merged commit a23847f into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the count-export-readers-from-imports branch October 12, 2026 22:39
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.

2 participants