Repository navigation
feat(compiler): evaluate decorator metadata imported from other files - #553
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Brooooooklyn
force-pushed
the
feat/issue-518-cross-file-metadata
branch
from
October 6, 2026 18:26
b941407 to
669b769
Compare
Brooooooklyn
force-pushed
the
feat/issue-518-cross-file-metadata
branch
from
October 6, 2026 18:43
669b769 to
b42f67a
Compare
Fixes #518. Decorator metadata referencing exported consts in other files errored with "depends on 'X', which is imported from another module" even though ngtsc resolves these through its program-wide checker: // meta.ts: export const INPUTS = ['x']; import { INPUTS } from './meta'; @directive({ inputs: INPUTS }) class A {} A new `resolve_imported_values` transform option (napi `resolveImportedValues`, on in the vite plugin and the compare harness) extends the existing cross-file analysis: `CrossFileAnalyzer` now evaluates exported `const` initializers through a resolver-aware `StringConsts`, following `export {}`, `export *`, and cross-file const chains, bounded and cycle-safe. Files read for resolution land in `TransformResult.dependencies` and are registered with Vite's watcher so metadata edits re-transform dependents in dev. Anything unresolvable — packages, `export declare`, functions, dynamic initializers — keeps the existing diagnostic unchanged. The vite plugin's transform call now passes `resolveImportedValues` plus `baseDir`/`tsconfigPath`, and consumes `result.dependencies` (previously dropped) so files read for value resolution are watched. Also: `cargo test` in CI now runs `--all-features` — feature-gated tests (cross_file_elision's whole suite) never ran before.
Brooooooklyn
force-pushed
the
feat/issue-518-cross-file-metadata
branch
from
October 7, 2026 03:44
b42f67a to
4c4f0c4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #518.
What
Decorator metadata that references values exported from other files errored with
"depends on 'X', which is imported from another module"— e.g.ngtsc evaluates these through its program-wide checker. This adds an opt-in
resolve_imported_values/ napiresolveImportedValuesoption (gated on the existingcross_file_elisionfeature, which the vite plugin and compare builds already compile) that resolves exportedconstvalues Rust-side.How
directive/evaluator.rs: an ownedStaticValue(scalars, arrays, objects — no references) plus anImportValueResolvertrait. The evaluator consults it for named imports andns.Xmember access;Nonekeeps today's opaque-reference diagnostic.component/cross_file_elision.rs:CrossFileAnalyzeris nowRc<Inner>soanalyze_filecan hand outRc<dyn ImportValueResolver>(CrossFileResolver).resolve_export_valueskips node_modules, followsexport {}/export *chains (depth-capped, cycle-safe — circularexport *visited-set added; the hop specifier is now carried as the resolved absolute path so nested-dir barrels resolve correctly), and evaluates const initializers with a resolver-backedStringConstsso[...OTHER_IMPORTED, 'b']chains across files.TransformResult.dependencies; the vite plugin now consumesresult.dependencies(previously dropped) and registers them with the watcher — an elidedimport { INPUTS }has no JS edge, so metadata edits would otherwise go stale.Unresolvable values (packages,
export declare, functions, dynamic initializers, objects containing them) keep the existing diagnostic verbatim.Verification
cargo test --workspace --all-features: all green (1177 lib tests; 49 cross_file_elision unit tests incl. 11 new; 9 new tempdir end-to-end tests covering inputs arrays,@Inputoption objects, namespace imports, re-export/star chains, dependency reporting, and every fallback path).resolveImportedValues: true): 100% pass in every category vs Angular 22.2.1.cargo testnow runs--all-features— feature-gated tests previously never ran.Known limitation (matches today's error path): imported values containing non-literal members (e.g.
{transform: booleanAttribute}) stay opaque and keep the diagnostic.