Skip to content

chore(lr-5e24): static ESM import-resolution check for lib/public/#227

Merged
akuehner merged 1 commit into
mainfrom
chore/lr-5e24-esm-import-check
Jun 11, 2026
Merged

chore(lr-5e24): static ESM import-resolution check for lib/public/#227
akuehner merged 1 commit into
mainfrom
chore/lr-5e24-esm-import-check

Conversation

@akuehner

Copy link
Copy Markdown
Member

Summary

  • Adds test/esm-import-check.test.js — a static analysis pass that walks every .js file in lib/public/, extracts named imports from relative specifiers, and verifies each imported name is actually exported by the target module.
  • Catches the failure class from lr-8657 / PR fix(lr-8657): repoint stale pending-navigate imports — fixes console stuck on 'Reconnecting' #223: stale named imports pointing to a file where the export has moved or been renamed. All 276 existing tests pass; the new check is test #277, running in under 2ms with zero new dependencies.

What is checked

  • Every relative import path resolves to an existing file.
  • Every named symbol in import { a, b } actually appears as an export in the target file.

What is intentionally skipped

  • Bare specifiers (node:test, ws, etc.) — no local file to check.
  • Default imports — no stable name to verify.
  • export * from chains — accepted without deep-following to avoid false-positives on unbounded re-export graphs.

Test plan

  • npm test: 277/277 pass, 0 failures
  • New test runs in under 2ms (measured: 1.84ms)
  • No new npm dependencies

Regression proof

A stale import { getPendingNavigate } from ./filebrowser.js (after the export moved to pending-navigate.js) would produce:
MISSING EXPORT app.js imports { getPendingNavigate } from ./modules/filebrowser.js — not exported by modules/filebrowser.js

Task: lr-5e24

Adds test/esm-import-check.test.js — a static analysis pass that walks
every .js file in lib/public/, extracts named imports from relative
specifiers, and verifies that each imported name is actually exported by
the target module.

Catches the failure class from lr-8657 / PR #223: stale named imports
that point to a file where the export has moved or been renamed. All
276 existing unit tests pass; the new check adds test #277 and runs in
under 2 ms.

Constraints honoured:
- Static only: no dynamic require/import, no browser code execution.
- Skips bare specifiers (node:*, ws, …).
- Skips export * chains to avoid false-positives on unbounded re-exports.
- Zero new npm dependencies.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@akuehner akuehner merged commit e353632 into main Jun 11, 2026
1 check passed
@akuehner akuehner deleted the chore/lr-5e24-esm-import-check branch June 11, 2026 14:48
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