Repository navigation
fix(browser): derive source-map imports from syntax nodes - #588
Conversation
Signed-off-by: Rudy Celekli <[email protected]>
…sed sources Discarding a source's edges whenever it had parse errors cost more than it protected. parseJavaScriptSource only enabled jsx and typescript, so a decorated TypeScript source did not parse at all and contributed no edges at all, even for the imports Babel could otherwise have read. That is the common shape for the bundles this boundary inspects. "decorators-legacy" is enabled instead of "decorators" because the standard form still rejects parameter decorators such as constructor(@Inject() private s: S), which is the Angular and Nest dependency-injection shape. import x = require("m") parses cleanly but is a TSImportEqualsDeclaration rather than a call expression, so it contributed no edge. It is now read as a require dependency. It is only legal at module top level and always refers to the host loader, so it needs no unbound-require check; the local-alias form imports an entity name and still declares nothing. A source whose syntax could not be recovered now yields status "partial" with a limitation naming the affected sources, instead of an included item whose empty edge list was indistinguishable from a source that genuinely imports nothing. Edges that did parse are retained and the caller is told the list is a subset, which matches how the static and semantic analysers already report recovered syntax. The source-map item status union gains "partial" and the coverage rollup now counts it as retained, so a collection of only-partial items reports partial rather than unavailable.
|
Pushed The problem was the parse gate. 1. Decorated TypeScript never parsed at all. Worth knowing if you enable it yourself:
2. 3. An empty edge list could not be told apart from a source REA could not read. This is the part I would most want you to reconsider, because it is a contract change rather than a local fix. Every one of these reported
So a source now reports If you would rather keep the discard, the alternative I would accept is surfacing only the limitation without retaining recovered edges, but I would still want the status to change, because One consequence to be aware of: your existing case Verification was scoped — I ran |
# Conflicts: # docs/product-catalog.json # docs/verification/managed-conformance-manifest.json # skills/reverse-engineer-anything/SKILL.md # src/generatedMcpToolCatalog.ts
…odes Resolve the generated-file conflicts by taking main's generated output and regenerating from the merged source contracts, rather than merging generated text by hand.
|
Thanks, @rudycelekli, for your work on “fix(browser): derive source-map imports from syntax nodes.” I appreciate your contribution to REA. |
* fix(browser): derive source-map imports from syntax nodes Signed-off-by: Rudy Celekli <[email protected]> * fix(browser): recover source-map dependencies from decorated and aliased sources Discarding a source's edges whenever it had parse errors cost more than it protected. parseJavaScriptSource only enabled jsx and typescript, so a decorated TypeScript source did not parse at all and contributed no edges at all, even for the imports Babel could otherwise have read. That is the common shape for the bundles this boundary inspects. "decorators-legacy" is enabled instead of "decorators" because the standard form still rejects parameter decorators such as constructor(@Inject() private s: S), which is the Angular and Nest dependency-injection shape. import x = require("m") parses cleanly but is a TSImportEqualsDeclaration rather than a call expression, so it contributed no edge. It is now read as a require dependency. It is only legal at module top level and always refers to the host loader, so it needs no unbound-require check; the local-alias form imports an entity name and still declares nothing. A source whose syntax could not be recovered now yields status "partial" with a limitation naming the affected sources, instead of an included item whose empty edge list was indistinguishable from a source that genuinely imports nothing. Edges that did parse are retained and the caller is told the list is a subset, which matches how the static and semantic analysers already report recovered syntax. The source-map item status union gains "partial" and the coverage rollup now counts it as retained, so a collection of only-partial items reports partial rather than unavailable. * Merge main into fix(browser): derive source-map imports from syntax nodes Resolve the generated-file conflicts by taking main's generated output and regenerating from the merged source contracts, rather than merging generated text by hand. --------- Signed-off-by: Rudy Celekli <[email protected]> Co-authored-by: morluto <[email protected]>
Summary
Parse original source map source contents as inert JavaScript/TypeScript AST. Retain literal import/export/dynamic import syntax; require edges use existing lexical IR to exclude shadowed bindings. Comments, string/template contents and malformed parser-recovered source cannot invent dependency edges. Source map artifact remains included if original source syntax cannot be parsed, but its module edge list is empty. Type-only source relationships remain syntactic; this does not claim imports actually executed.
No tracking issue: this is a focused correctness regression found through production-seam reproduction.
Problem and expected behavior
Derived module edges exclude comments, quoted content, parser recovery, and bound require calls; source paths and source-map identities remain retained.
Change and scope
The change stays in the owning adapter/application stage and corrects existing behavior without adding tools or broadening provider coverage.
Contract and boundary impact
Evidence and regression coverage
Seventeen focused source-map tests pass; the former regex invented dependencies from comments and string contents. Valid quote/template and malformed-source controls are covered.
Tests exercise production parsing, filesystem, HTTP, or browser seams, without module mocks. Evidence above is executed; unverified platform/provider coverage is stated explicitly.
Validation performed
All required local gates passed on the signed commit:
npm run check:prnpm run check:cinpm run verify:packagenpm pack --dry-runDevelopment runtime: Node.js 24.18.0 and npm 11.16.0. Upstream CI is separate from these local results.
Compatibility, safety, and release
No migration or package dependency changes. Real Hopper/Ghidra verification was not run; this patch does not change those providers. Remaining proof limits are stated above. The final diff contains source and tests only.
Prepared with AI assistance.