Removes the experimental "selectorless" template syntax (`<MyComp>` / `@Dir(...)`)
which was never shipped. This deletes:
- compiler: lexer/parser support for component and directive tokens, the
html `Component`/`Directive` nodes and the R3 `Component`/`Directive`
(`TmplAstComponent`/`TmplAstDirective`) nodes together with their visitor
methods and the `directives` field on elements/templates, the
`selectorlessEnabled`/`enableSelectorless` parse options, direct pipe
references (`BindingPipeType`), selectorless reference validation, the
selectorless paths in the binder (`referencedDirectiveExists`),
type-check ops, indexer, i18n and template pipeline.
- compiler-cli: the `_enableSelectorless` option, selectorless component
analysis and `SelectorlessScope`, deferred selectorless dependencies,
selectorless template symbols, out-of-band diagnostics and the related
error codes (2024, 2025, 2026, 8018), the linker option, and the
preprocessor/ng-analyze selectorless analysis.
- language-service: selectorless definitions, quick info, references and
rename.
- the selectorless runtime and compiler tests.
`SelectorlessMatcher` is kept since it is used to match foreign components
(`foreignImports`) by tag name.
`HybridCompiler` wrote `<tsconfig>.ngdiag.json` itself from `prepareChunk` and `prepareChunkSync`,
which tied it to a `tsconfigPath` and to the Node filesystem, or to a `virtualFiles` overlay
standing in for it. Now that the analyzer no longer requires a tsconfig, hosts that embed the
compiler without one have nowhere to write such a file, and whether and where diagnostics are
persisted is a decision for the build driver rather than for the compiler.
`tsconfigPath` and `virtualFiles` are therefore removed from `HybridCompilerOptions`, together
with `writeDiagnosticsFile` and `writeDiagnosticsFileSync`, and `hybrid_compiler.ts` no longer
imports `node:fs`. In their place, `HybridCompiler.getDiagnostics()` returns the collected
per-file diagnostics in the deterministic order the `.ngdiag.json` already used and leaves out
diagnostics anchored on `.d.ts` files unless `includeDeclarationFiles` is set, making it the
single place that filters and orders them; `serializeDiagnostics` now only formats that output.
The `.ngdiag.json` write moves into `run` in `ngp.ts`, gated on a new optional
`RunOptions.tsconfigPath`. The write that preceded the processing of each chunk is dropped as
redundant, while `run` still writes after every chunk and once more at the end so that option
diagnostics reach the file even when the analyzer produces no chunks.
Without a tsconfig there is also nothing to resolve relative paths against, so `rootDir` and
`rootDirs` on `HybridCompilerOptions` must now be absolute; relative `rootDirs` used to be
resolved against `rootDir` or `dirname(tsconfigPath)`. This matters because
`getProjectRelativePath`, which produces the `ɵsetClassDebugInfo` paths and HMR IDs, uses
`path.posix.relative` and would silently resolve a relative root against the process cwd. Both
options are normalized to forward slashes; `rootDir` previously was not, which would have broken
that computation for backslash paths on Windows. `main.ts` resolves relative `rootDirs` against
the tsconfig directory, matching TypeScript and the analyzer, and the test helpers do the same.
Fixes that referencing a non-class from a declaration file in an `NgModule` (e.g. passing `NgModule` itself into `imports`) produced a diagnostic pointing to the `.d.ts` file. There were two problems:
1. The evaluator was resolving a type reference to anything it could find, whereas ngtsc only resolves it if the target is a class. As a result, `declare const NgModule: NgModuleDecorator` was resolving to the interface instead of the variable.
2. ngtsc keeps diagnostics on `.d.ts` files, but they're never reported if the build only asks for the diagnostics of the compilation unit's source files, which is what the `.ngdiag.json` consumers do. We now omit them when serializing, but still keep them around so that `getDiagnostics`-style consumers can see them.
An earlier change ported over the compiler option diagnostics from ngtsc, but it mixed them in with the other diagnostics. This ended up breaking internally in two ways:
1. Internally we don't report the compiler option diagnostics, because they're tracked separately.
2. ngtsc has some logic that skips extended template checks, template semantic checks and source file validations if there are any config diagnostics.
Forward angularCompilerOptions.i18nPreserveWhitespaceForLegacyExtraction into
templateParseOptions.preserveSignificantWhitespace (defaulting to true) across
the CLI entry point, test utilities, and NGP test driver so legacy i18n
whitespace collapsing matches ngtsc.
- Port `ngp.test.ts` to `test/ngp_spec.ts` to test the `main.ts` CLI entrypoint under Bazel.
- Fix the inverted `fs.access(ngAnalyzeDir)` fallback in `main.ts`: when `alxhub/ng-hybrid-preprocessor` commit `c707e178` converted `if (!fs.existsSync(ngAnalyzeDir))` to async `fs.access(ngAnalyzeDir)`, it placed `ngAnalyzeDir = path.resolve(__dirname, '../../ng-analyze')` inside the `try` block instead of the `catch` block, overwriting a valid `./ng-analyze` directory with `../../ng-analyze` whenever `./ng-analyze` existed.
- Port `scripts/check-sidecar-isolation.mjs` to `test/sidecar_isolation_spec.ts` to guard against static imports of `analyzer_loader`, `analyzer_napi`, `analyzer_wasm`, or `wasm_host_fs` from sidecar-mode entrypoints.
- Port `scripts/typecheck-goldens.ts` to `test/typecheck_goldens_spec.ts` with a dedicated sharded `//packages/compiler-cli/preprocessor/test:typecheck_goldens_test` Bazel target to verify emitted TypeScript across all golden test cases.
- Add Bazel (`dist/bin/packages/compiler-cli/preprocessor/ng-analyze/ng_analyze_wasm/ng_analyze_wasm.js`) and bundled (`../ng-analyze/ng_analyze_wasm/ng_analyze_wasm.js`) WASM binding candidates to `wasmCandidates()` in `analyzer_loader.ts` so `createAnalyzer(..., {backend: 'wasm'})` and `main.ts --wasm` locate the Bazel-built WASM binary without requiring an explicit `wasmBinding` path.
- Wire `options.sidecar` in `test/utils.ts` (`runPipeline`) to spawn `SidecarAnalyzer` (`ng_analyze_bin`) so `t4_tri_modal_parity_audit` in `test/resource_resolution_spec.ts` compares WASM vs. Sidecar output rather than comparing WASM against itself.
- Deduplicate `refName` and `refToExpression` in `processor.ts` by importing them from `compiler-utils.ts`.
- Remove unused `_workspaceName` and `_rootDirs` parameters from `prepareTcbTargets` in `tcb.ts` and its call sites.
- Remove unused imports, interfaces (`ImportViaMetadata`), fields (`FileAnalysis.typeOnlyExports`), variables (`IGNORE_MARKER_REGEX`, `currentTcbUri`, `GOLDEN_ROOT`), and helper functions (`collectGoldenCases()`, `flatten()`).
- Fix outdated comments, typos, and Vitest/standalone repo references.
`<link rel="stylesheet">` URLs in a component template were resolved relative to the component file in TypeScript and read directly from disk, bypassing the analyzer's resource resolution. Stylesheets that only exist under a secondary `rootDirs` entry were therefore reported as a false NG2008, even though the same URL works in the decorator's `styleUrls`.
The NG2008 was also anchored on the `templateUrl` string-literal span, so a `templateUrl` written as a template literal produced a diagnostic without a location, which crashed `tsc` when it tried to format it.
Template-linked stylesheets now go through a new `Analyzer.readResource` API backed by the same `ResourceResolver` as `templateUrl`/`styleUrls`, and NG2008 is anchored on the full `templateUrl` expression like in ngtsc.
Port three commits that landed in ng-hybrid-preprocessor after the initial
monorepo integration snapshot (1f279a05):
1. Scope evaluator cycle guards to the current resolution path (ng-hybrid-preprocessor#607):
Cross-file evaluation previously used a flat `visited: HashSet<String>`
that never removed keys upon returning from a resolution step. Consequently,
any static method call or static member reached along multiple sibling,
non-cyclic paths (such as `X.forRoot()` imported both directly and through
a spread constant) resolved only on the first occurrence and turned every
subsequent occurrence into `Dynamic(ImportCycle)`. Since a single dynamic
entry invalidates an `@NgModule.imports` array, modules with diamond
`ModuleWithProviders` imports silently lost their compilation scope.
Replace the flat set with a path-scoped stack (`ResolutionState.in_progress`)
and Tarjan-style low-link memoization (`ResolutionState.completed`) so
sibling occurrences resolve independently without exponential re-evaluation
on deep diamond chains, while genuine cycles (`A.m() -> B.n() -> A.m()`)
are still cut as `ImportCycle`.
2. Drop every stale `HybridCompiler.fileCache` entry on file updates (ng-hybrid-preprocessor#614):
`HybridCompiler.fileCache` is keyed by `AnalysisResult.filePath` (the
query engine's interned `FileId` path, which is case-folded on
case-insensitive platforms), whereas `update_file_content_core` and
`invalidate_files_core` previously returned only `fs.canonicalize()`
spellings of the directly edited files. This left stale TCB and bound-target
entries in `fileCache` both when paths contained uppercase segments on
macOS/Windows and when an edit invalidated a transitive dependent outside
the `tsconfig.json` entrypoints (such as a file opened on demand by the
language service).
Route invalidations through `Analyzer::evict_file` to collect every
transitively evicted per-file `QueryKey` (including `QueryKey::ProgramFiles`)
and emit its `engine.lookup_path` wire spelling, and avoid caching empty
`FileAnalysis` entries under raw caller paths when `getMetadataForFile`
returns `null`.
3. Audit comments, normalize Angular permalinks, and refine TODOs (ng-hybrid-preprocessor#702):
Tighten docstrings and inline comments across the Rust analyzer, TypeScript
preprocessor, language service, and test suites; normalize upstream ngtsc
reference permalinks; document non-obvious evaluator and compiler pipeline
invariants; and standardize `TODO(...)` tags.