Decide: two `@Component` on one class — ngtsc compiles the first with no error; OXC's HMR text scan pairs the second
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- angular, rust, typescript
- 領域
- build-system, tooling
調査の方向性
Start with the two-decorator reproduction and compare ngtsc and OXC output and runtime behavior. Read crates/oxc_angular_compiler/src/component/transform.rs, napi/angular-compiler/vite-plugin/utils/decorator-fields.ts, and napi/angular-compiler/vite-plugin/index.ts; done requires an agreed option and matching compiler metadata and HMR behavior.
索引モデルが issue の本文から書いたものです。
説明
import {Component} from '@angular/core';
@Component({selector: 'a-cmp', template: 'first'})
@Component({selector: 'b-cmp', template: 'second'})
export class C {}
ngtsc 22.1.7 gives no diagnostic. It compiles the first @Component and leaves the second as a runtime decorator. At runtime that second decorator replaces ɵcmp with a JIT getter, so the module crashes on load without @angular/compiler. Same with OXC's output. So the input is broken under both compilers, and there is no ngtsc error for OXC to copy.
OXC still differs from ngtsc in two small ways. Opening this to decide whether either is worth fixing.
Compile output
OXC (#504 tip and main, same output):
@Component({selector: 'b-cmp', template: 'second'})
export class C {
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({type:C,selectors:[["a-cmp"]], ... i0.ɵɵtext(0,"first") ...});
}
... i0.ɵsetClassMetadata(C,[{type:Component,args:[{selector:"a-cmp",template:"first"}]}],null,null)
ngtsc 22.1.7:
let C = class C {
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: C, selectors: [["a-cmp"]], ... i0.ɵɵtext(0, "first") ... });
};
C = __decorate([
Component({ selector: 'b-cmp', template: 'second' })
], C);
... i0.ɵsetClassMetadata(C, [{
type: Component,
args: [{ selector: 'a-cmp', template: 'first' }]
}, {
type: Component,
args: [{ selector: 'b-cmp', template: 'second' }]
}], null, null)
Both compile the first decorator and keep the second. Difference 1: ngtsc's setClassMetadata lists both decorators, OXC's lists only the compiled one.
Runtime (node, @angular/core 22.1.7, no @angular/compiler), both outputs:
Error: The component 'C' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.
HMR (Vite plugin)
Rust reports componentDecorators = {"c.ts@C": "Component"}, and templateUpdates["c.ts@C"] is the template of the first decorator (ɵɵtext(0,"first")).
stripComponentMetadata empties the template: / styles: of the decorator locateComponentDecorators pairs with C. Pass 2 of that scan looks for class X only between one decorator's ) and the next decorator's @, so the first @Component pairs with no class and the second one gets C. Difference 2: the plugin empties the decorator the compiler did not take:
pairs: [["C","({selector: 'b-cmp', template: 'second'})"]]
edit first (compiled) -> stripped forms differ => full reload
edit second (not compiled) -> stripped forms equal => HMR event, but the update holds the first template, so nothing changes
(Checked by running the real decorator-fields.ts functions and a copy of stripComponentMetadata with oxnode. Same pairing on main, where the scan only looks for the literal @Component(.)
Where
crates/oxc_angular_compiler/src/component/transform.rs:find_component_decoratortakes the first match (same as ngtsc);component_decoratorsreports only its callee text, not its position.napi/angular-compiler/vite-plugin/utils/decorator-fields.ts:locateComponentDecorators, pass 2 (bounded class-name scan).napi/angular-compiler/vite-plugin/index.ts:stripComponentMetadatakeys the decorators by class name, so two same-spelled decorators on one class can't be told apart.
On main?
Yes (both differences). componentDecorators itself is only on the #504 stack (d1fa6c4).
Options
- Leave as is: the input already crashes at runtime with ngtsc too.
- Report the compiled decorator's span (not only its spelling) in
componentDecorators, so the plugin empties exactly that one. - List every class decorator in
setClassMetadata, like ngtsc. - Add a warning for a second Angular class decorator of the same kind (ngtsc has none, so this would go beyond ngtsc).
- 主要言語
- Rust
- スター
- 232
- フォーク
- 21
- 平均マージ
- 2日 14時間
- マージ済み PR(30日)
- 30
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
voidzero-dev/oxc-angular-compiler のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
voidzero-dev/oxc-angular-compiler#511 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
voidzero-dev/oxc-angular-compiler#522 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
voidzero-dev/oxc-angular-compiler#520 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
voidzero-dev/oxc-angular-compiler#519 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
voidzero-dev/oxc-angular-compiler#518 ·
メンテナーはふだん 1 日以内に返信
voidzero-dev/oxc-angular-compiler の issue をすべて見る
似ている issue
-
review-drift
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
oxidecomputer/hansei#14 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
rubys/roundhouse#444 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
install: root SSH tmpfiles.d drop-in is labeled etc_runtime_t instead of etc_t対応中かも @andrewdunndev が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信