Skip to content

fix(linker): link declarations wherever they sit, like Babel's linker - #620

Merged
Brooooooklyn merged 4 commits into
mainfrom
fix/link-every-call
Oct 23, 2026
Merged

Brooooooklyn merged 4 commits into
mainfrom
fix/link-every-call

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Replaces #605, which conflicts with main and sits on an org fork I can't push to. It keeps #605's commit (author: Damian Kaczmarek) and adds a fix on top.

Problem

Babel's linker (@angular/compiler-cli/linker/babel) links every ɵɵngDeclare* call it meets. This linker used a hand-written walker that only went into the statements and expressions it listed, so declarations elsewhere stayed unlinked, and their ngImport: i0 kept all of @angular/core in the bundle. Deepkit's runtime types hit this: static __type = [() => i0.ɵɵngDeclareComponent(...)] (+130 KB minified in an app using @deepkit/desktop-ui).

Fix

leftover ɵɵngDeclare calls Babel main #605 this PR
[() => D], { m() { return D } } (Deepkit) 0 1 0 0
(() => { class X { static ɵfac = D } … })(), (function(){…}).call(this) 0 1 1 0
f(...[D]), new X(...[D]) 0 1 1 0
if (D), for (x = D;;), while, switch, throw, yield, c ? : 0 1 1 0
extends f(D), [D]() {}, { [D]: v } 0 1 1 0
tag`${D}`, a?.b(D), (x = D) => {}, import(D) 0 1 1 0

Factory at the start of a statement (D = ɵɵngDeclareFactory(…)):

D.name;  // #605: function X_Factory(…) {…}.name;   -> SyntaxError
         // now:  ;(function X_Factory(…) {…}).name;
export default D + "";  // #605 exported the function; now the string, as with Babel

Checks

Not covered (Babel links these, this linker does not yet): a declaration nested inside another declaration's arguments, and the string-key callee i0["ɵɵngDeclare…"]().

Co-authored-by: Damian Kaczmarek rush@rushbase.net

🤖 Generated with Claude Code

Rush and others added 2 commits October 23, 2026 16:40
…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).
The hand-written walker only went into the statements and expressions it
listed, so declarations in an IIFE callee, a spread argument, a statement
head, a computed key, a superclass, a tagged template, an optional call or
a default value stayed unlinked. An oxc Visit now reaches every call.

A linked factory that starts a longer statement, such as
`ɵɵngDeclareFactory(…).name;`, gets parentheses (and a `;` before them),
like Babel's output, so it is not read as a function declaration.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@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-23T08:58:17.571754Z fc3309c 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.

@Brooooooklyn

Copy link
Copy Markdown
Member Author

@codex review

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

@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: 20f0e0a57a

ℹ️ 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
… list

In the bare body of `if`, `else`, a loop or a label, the `;` became the
body itself, so the rest of the statement ran unconditionally.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Brooooooklyn

Copy link
Copy Markdown
Member Author

@codex review

@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: 7420e133ee

ℹ️ 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 Outdated
Decorators are now visited, and `@function X_Factory(…) {…}` does not parse.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Brooooooklyn

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: fc3309c2d3

ℹ️ 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".

@Brooooooklyn
Brooooooklyn merged commit 61fb8a4 into main Oct 23, 2026
10 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/link-every-call branch October 23, 2026 09:14
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