mirror of
https://github.com/angular/angular.git
synced 2026-11-22 22:55:25 -05:00
Previously, `QueryEngine` invoked `AnalysisHost::resolve` directly on every syntactic dependency scan, cross-file constant evaluation, export-map walk, and NgModule scope traversal without an engine-level cache. For asynchronous bundler hosts, repeating identical `(importer, specifier, kind, type_only, attributes)` lookups across queries and rebuilds would generate redundant cross-boundary round-trips. In addition, failed module resolutions only recorded `UNRESOLVED_IMPORTS_FILE_ID` during the Stage-1 static dependency scan of `.ts` sources. That scan does not resolve the specifiers of `.d.ts` files, so a failed lookup made from one, such as a re-export to a missing target, was untracked and not re-run when the target was later created. Deleting a resolved file also left importers holding stale cached dependency edges. Introduce `ResolutionCache` on `QueryEngine` to memoize completed module resolution outcomes per importer `FileId` and request key while maintaining both a target-to-importer reverse index and an unresolved-importer index. Route query-time module lookups through `QueryContext::resolve_request`, `resolve_from_id`, and `resolve_from_path` so every resolution records the importer dependency and every failed lookup—including negative cache hits— records `UNRESOLVED_IMPORTS_FILE_ID`. Classify pure re-exports in `analyze_file_syntax` with `ImportKind::ReExport` so syntactic dependency discovery shares cached resolutions with cross-file evaluation and export-map queries. On `invalidate_file_id`, drop only the edited importer's cached resolutions so edits to a leaf module preserve cached resolutions across its importers. On `FileUpdateType::Deleted`, evict queries derived from importers that had resolved to the deleted target while keeping their `ParseFile` results cached. On `invalidate_module_resolution`, stop serving every cached resolution and re-run importers with previously unresolved specifiers. The superseded entries are kept as stale rather than dropped, so the reverse index still covers importers whose queries stay cached and that therefore do not resolve again, and a lookup that the host answers after the change is not memoized. When a host resolution changes a module's `IdKind`, also evict the importers whose cached resolutions report the previous kind. The resolution that changed the kind is not memoized, so the query re-run that follows asks the host again.
Rust-based Compiler Preprocessor
Caution
Prototype — External Contributions Not Accepted
The Rust-based compiler preprocessor code in this directory is an early-stage prototype under active development by the Angular team.
We are not accepting issues, bug reports, feature requests, or pull requests for this package from external contributors at this time. Any issues or PRs opened for this code will be closed.
Overview
This directory contains a native AST analysis preprocessor and typecheck block (TCB) generation pipeline designed for high-performance Angular compilation and developer tooling integration. It combines Rust-based AST analysis (ng-analyze) using oxc with a TypeScript-based typechecking coordination layer.