Skip to content

fix(linker): link declarations nested in arrays, objects and other expressions - #605

Open
Rush wants to merge 1 commit into
voidzero-dev:mainfrom
encharm:fix/link-nested-declarations
Open

Rush wants to merge 1 commit into
voidzero-dev:mainfrom
encharm:fix/link-nested-declarations

Conversation

@Rush

@Rush Rush commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Babel's linker (@angular/compiler-cli/linker/babel) links every ɵɵngDeclare* call it meets. This linker walked only some expression kinds and left declarations unlinked inside array and object literals, new arguments, static and computed member expressions, unary and binary expressions, template literals and await.

That matters for libraries compiled with Deepkit's runtime types, which record each static initializer as a function in a static __type = [...] array:

static __type = [() => i0.ɵɵngDeclareComponent({ minVersion: '14.0.0', ngImport: i0, ... }), ...];

Every class then carried an unlinked copy of its declarations, and their ngImport: i0 kept all of @angular/core in the bundle (+130 KB minified in an app using @deepkit/desktop-ui).

walk_expression now descends into those expression kinds. test_link_declarations_nested_in_arrays_and_objects (tests/linker_test.rs) links declarations in each position and fails without the change.

…pressions

Babel's linker links every ɵɵngDeclare* call; this one walked only some expression kinds and missed
declarations inside array and object literals, `new` arguments, member and binary expressions,
templates and awaits. A library compiled with Deepkit's runtime types records each static initializer
as a function in a `static __type = [...]` array, so every class carried an unlinked copy of its
declarations, whose `ngImport: i0` kept all of @angular/core in the bundle (+130 KB minified in an app
using @deepkit/desktop-ui).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant