Repository navigation
fix(browser): retain optional source-map requires - #2886
Conversation
Carry the require callee from dependency extraction into lexical scope validation so optional calls remain visible without admitting shadowed loaders. Fixes morluto#2883
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
TL;DR: This PR merged on 2026-10-13 at 16:57 UTC as f104500 (#2886), so this is a record test. On Linux with real headless Chromium, f104500 keeps the ResultsThe merge holds the same two files as the PR head 1319c19, byte for byte. Its diff matches I served the exact map from issue #2883 on a loopback page, with the same SHA-256 as the issue. I opened it in Chromium 154.0.8037.57 (BSD-3-Clause) and ran the issue's
A second page had one original file per form. A direct fetcher call and the CLI agreed on every form. Shadowed, computed, member and template forms stay out in both builds. The full table is folded below.
Not run
Thanks, JFSAS, for the clear issue, the small fix and the real-browser repro. Forms, before and after
Test setup
CommandsSame change as the PR head:
Builds, one tree per commit, with Node 24 first on PATH:
Tests, with HOME and TMPDIR set to folders in the job dir. Each ran on
Here Direct fetcher call, on both trees, with
CLI, with two static loopback servers (ports 39101 and 39102) and one headless Chromium on CDP port 39103:
Here FixturesThe first page is the issue's own layout:
The new test fails on 69bd81f because 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Thanks for catching optional |
Summary
Fixes #2883. A source-map original containing
require?.("./dep.cjs")now produces the same literal dependency candidate as the ordinary call. Locally shadowed and computed calls remain excluded.Problem and expected behavior
On
3e7c6302, a fetched map containing ordinary and optional calls reportsincludedbut retains only the ordinary dependency. Real Chrome runs through compiled CLI and stdio MCP reproduce that omission. After this change both dependencies are retained with their existing resolved URLs and unchanged source-map bytes/digest.Change and scope
The source-map adapter accepts
OptionalCallExpressionand returns its callee together with the dependency. The consumer validates that retained callee through the existing lexical reference analysis, rather than independently checking the AST call kind. This keeps optional calls subject to the same shadowing gate and leaves TypeScript import-equals declarations on their existing path.Ordinary static-analysis correctness fix; maintainer scope decision: not applicable. #2842 changes literal reading in the adjacent extractor and addresses a separate trigger; the two fixes may need a small hunk reconciliation when merging.
Contract and boundary impact
WebSourceMapFetcher.Expected effects:
Evidence and regression coverage
A real loopback HTTP boundary test covers ordinary and optional literal calls, a shadowed optional call, a computed argument, resolved URLs and retained map/original evidence. It failed before the producer fix and passes afterward.
The same map (SHA-256
d9d6a38307044d56516840ff08aef4a583f37a188fd228ebdd21e2db69ef82c1) was served to Chrome 155.0.8059.40 and inspected by both public interfaces on macOS arm64:3e7c6302./normal.cjs./normal.cjs,./optional.cjsThe shadowed call is absent in both builds. REA does not execute the original CommonJS text, and the edges do not establish runtime execution. Windows/Linux and other browsers were not run.
Validation performed
Node 24.18.0 / npm 11.16.0:
npm run test:focused -- tests/boundary/browser/optionalSourceMapRequire.test.ts tests/boundary/browser/webSourceMapFetcher.test.ts tests/boundary/browser/webSourceMapNestedCoordinates.test.ts tests/boundary/browser/webSourceMapHttpStatus.test.ts tests/boundary/browser/webSourceMapResponseCleanup.test.ts: 104/104 passed. The strengthened final regression was rerun and passed.npm run build:cached,npm run check:fast,npm run knip,npm run verify:architecture-guards,npm run verify:test-discovery: passed. The pre-push hook also passedcheck:faston the committed version.npm run check: blocked by existing formatting errors in unchangedsrc/domain/functionComparison.test.tsandsrc/ida/IdaOperationRunner.ts. Formatting for both changed files passed. The separate fast checks, knip and architecture guards above completed successfully.Compatibility, safety, and release
No breaking schema or installation change. No native decompiler claim; browser validation is limited to the macOS/Chrome configuration stated above. No original-source execution or additional network access is introduced.
Before merge
Prepared with AI assistance; all reported executions were run locally.