Skip to content

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

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

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).
@Brooooooklyn

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T07:30:34.167811Z f3e67f3 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f3e67f34b2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/oxc_angular_compiler/src/linker/mod.rs
Comment thread crates/oxc_angular_compiler/src/linker/mod.rs
Comment thread crates/oxc_angular_compiler/src/linker/mod.rs
@Brooooooklyn

Copy link
Copy Markdown
Member

Thanks @Rush! This conflicts with main and I can't push to the org fork, so I carried it over to #620: your commit is kept as is (you stay its author), then I resolved the conflict and added a fix on top that makes the linker visit every call like Babel's, plus parentheses for a factory that starts a statement (Codex's findings here). Closing in favor of #620.

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.

2 participants