Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

@defer doesn't lazy-load an imports entry written as forwardRef(() => X)

Đã đóng
#632 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@edbzn đang làm issue này rồi.

Từ ngày 25/10/2026.

  • #640 của @edbzn — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust, typescript
Lĩnh vực
compilers

Hướng nghiên cứu

Start in compile_component_full and inspect the implicit-deferral gate and identifier matching for @Component.imports; compare how ngtsc resolves forwardRef through forwardRefResolver. Run the ngtsc defer_spec.ts case “should lazy-load dependency referenced with a fowardRef” against oxc with cross-file analysis enabled and resolveImportedValues: true. Done means the generated output uses a defer dependency function with a dynamic import and no static CmpA import; an open pull request (#640) is already linked.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

A standalone component listed in @Component.imports through forwardRef(() => X) and used only inside @defer is not lazy-loaded: the static import stays and ɵɵdefer gets no dependency function, so the component ships in the main chunk. A plain imports: [X] entry is deferred correctly (#313). Found by running Angular's ngtsc spec defer_spec.ts: "should lazy-load dependency referenced with a fowrardRef" against oxc (cross-file analysis on, resolveImportedValues: true).

Reproduction

// cmp-a.ts
import {Component} from '@angular/core';
@Component({selector: 'cmp-a', template: 'CmpA!'})
export class CmpA {}

// test.ts
import {Component, forwardRef} from '@angular/core';
import {CmpA} from './cmp-a';

@Component({
  selector: 'test-cmp',
  imports: [forwardRef(() => CmpA)],
  template: `@defer { <cmp-a /> }`,
})
export class TestCmp {}
Actual
import { CmpA } from './cmp-a';
...
i0.ɵɵdefer(1, 0);
...
dependencies: i0.ɵɵgetComponentDepsFactory(TestCmp, [forwardRef(() => CmpA)])
Expected (ngc)
const TestCmp_Defer_1_DepsFn = () => [import("./cmp-a").then(m => m.CmpA)];
...
i0.ɵɵdefer(1, 0, TestCmp_Defer_1_DepsFn);

and no import { CmpA }.

Cause

The implicit-deferral gate in compile_component_full only runs when every imports entry is a bare identifier, and the identifier list it matches against skips forwardRef(...) entries; ngtsc resolves them through forwardRefResolver first.

Ngôn ngữ chính
Rust
Star
244
Fork
26
Merge trung bình
23 giờ 41 phút
Pull request đã merge (30 ngày)
106

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của voidzero-dev/oxc-angular-compiler

Tất cả issue của voidzero-dev/oxc-angular-compiler

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.