Decide: `@Injectable` imported under an alias — ngtsc emits no `ɵfac`, OXC does
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- angular, rust, typescript
- 領域
- compilers
調査の方向性
Compare the alias case in the issue with ngtsc’s needsFactory logic in packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts. Review the OXC output and decide whether to preserve its working factory or match ngtsc; if keeping OXC’s behavior, record the difference in napi/angular-compiler/e2e/compare/fixtures/known-differences.ts. Done means the behavior decision is reflected in the fixture list.
索引モデルが issue の本文から書いたものです。
説明
With #504, OXC finds Angular class decorators by their @angular/core import, so an aliased @Injectable is now compiled. ngtsc 22.1.7 compiles it differently. It looks like an ngtsc bug. This issue records the difference and asks whether we keep OXC's output.
Repro
import {Injectable as X} from '@angular/core';
@X({providedIn: 'root'})
export class S {}
ngtsc 22.1.7
export class S {
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: S, factory: S.ɵfac, providedIn: 'root' });
}
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
No ɵfac and no setClassMetadata. ɵprov.factory points at S.ɵfac, which doesn't exist, so injecting S fails at runtime.
Cause, in packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts:
needsFactory:
meta.decorators === null ||
decorators.every((current) => !isAngularCore(current) || current.name === 'Injectable'),
current.name is the name as written (X), so an aliased import gives needsFactory = false. setClassMetadata is only emitted inside if (analysis.needsFactory), so it is dropped too.
OXC (#504 tip)
export class S {
static ɵfac = /*@__PURE__*/ (() =>{
let ɵS_BaseFactory;
return function S_Factory(__ngFactoryType__) {
return (ɵS_BaseFactory || (ɵS_BaseFactory = i0.ɵɵgetInheritedFactory(S)))((__ngFactoryType__ || S));
};
})();
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({token:S,factory:S.ɵfac,providedIn:"root"});
}
// + ɵsetClassMetadata(S,[{type:X,args:[{providedIn:"root"}]}],null,null)
static ɵfac: i0.ɵɵFactoryDeclaration<S, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<S>;
On main the aliased decorator is not recognized at all, so the class is left as written (@X({providedIn: 'root'}) export class S {}).
Decision needed
- Keep OXC's output (a working factory). This is a known difference from ngtsc. Add it to
napi/angular-compiler/e2e/compare/fixtures/known-differences.ts. - Or copy ngtsc's output exactly. That gives a broken
ɵprov.
Recommendation: keep it, record the difference, and maybe report it upstream.
Note: the ɵgetInheritedFactory form and InjectableDeclaration<S> vs <any> also show up for a plain @Injectable() class with no constructor, on main too. Not specific to the alias.
- 主要言語
- Rust
- スター
- 232
- フォーク
- 21
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 62
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
voidzero-dev/oxc-angular-compiler のほかの issue
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
voidzero-dev/oxc-angular-compiler#505 ·
メンテナーはふだん 1 日以内に返信
-
bug rust
難易度 4/5 3〜5日 初心者へのやさしさ 56/100
voidzero-dev/oxc-angular-compiler#313 ·
メンテナーはふだん 1 日以内に返信
-
Support useDefineForClassFields: false (Class Field Lowering)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
voidzero-dev/oxc-angular-compiler#73 · コメント 11 件 ·
メンテナーはふだん 1 日以内に返信
-
Angular 21.2.0 + @oxc-angular/vite 0.0.7 SSR runtime parity regressions (RouterLinkActive, Forms DI, Apollo DI) require app-level shims再び着手できるかも @Brooooooklyn が 219 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
voidzero-dev/oxc-angular-compiler#61 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Angular 21.2.0 + @oxc-angular/vite 0.0.7 SSR: AngularNodeAppEngine is unusable (missing app-engine manifest)再び着手できるかも @Brooooooklyn が 219 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
voidzero-dev/oxc-angular-compiler#60 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
voidzero-dev/oxc-angular-compiler の issue をすべて見る
似ている issue
-
[Feature]: [P3] engine-rs: the package source hash should ignore line endings and untracked filesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
maniator/verticopolis#880 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 3 日以内に返信
-
defect
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信