deferredImports: partial output never loads the block, and the Angular 22.2 named form does not compile

未關閉
#654 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
angular, rust
領域
compilers

研究方向

Start with component/decorator.rs, transform/control_flow.rs, and partial/component.rs, which the issue identifies as the parsing, trigger, and partial emit paths. Compare the array and named forms against the reproduction and the ngtsc 22.2 behavior described in the issue. The work is done when the intended array-form behavior is decided and both forms compile and emit deferred dependencies correctly in full and partial modes.

由索引模型根據 Issue 內容生成。

描述

Summary

Two problems with @Component.deferredImports:

  1. With the array form, partial compilation emits no deferBlockDependencies and no dependencies. After linking, the block is ɵɵdefer(1, 0), and the deferred component never loads or renders.
  2. The Angular 22.2 named form (deferredImports: {blk: [ChildCmp]} with @defer (name blk)) does not compile at all. It fails with Unrecognized trigger.

Found while re-checking #623.

Reproduction

// (i) array form. ngtsc 22.2 rejects it in full and partial mode.
@Component({
  selector: 'app',
  // @ts-ignore
  deferredImports: [ChildCmp],
  template: '@defer { <child-cmp /> }',
})
export class App {}

// (ii) named form, Angular 22.2
@Component({
  selector: 'app',
  deferredImports: {blk: [ChildCmp]},
  template: '@defer (name blk) { <child-cmp /> }',
})
export class App {}

ChildCmp is imported from ./child.

ngtsc 22.2.3 oxc (main 5780233)
(i) full error: 'deferredImports' must be an object mapping block names to dependency arrays. accepted. The deps fn is inline, but import {ChildCmp} is kept, so the code is not split
(i) partial same error no deferBlockDependencies. After linking: ɵɵdefer(1, 0), and <child-cmp> never renders
(ii) full const App_Defer_1_DepsFn = () => [import("./child").then(m => m.ChildCmp)], and the import is removed Unrecognized trigger. The source is returned untouched
(ii) partial deferBlockDependencies: [() => [import("./child")…]] and ngDeclareClassMetadataAsync Unrecognized trigger

Where

  • The object form is not parsed: component/decorator.rs (extract_identifier_array).
  • name is rejected as a trigger: transform/control_flow.rs.
  • Partial emit skips deferBlockDependencies: partial/component.rs.

One question is a product call: should oxc keep accepting the array form, which ngtsc 22.2 rejects?

主要語言
Rust
星號
245
分支
26
平均合併
22 小時 27 分鐘
30 天內合併 PR
106

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

voidzero-dev/oxc-angular-compiler 的其他 Issue

查看 voidzero-dev/oxc-angular-compiler 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。