Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

fix(aot): a user binding named `i0` collides with the injected `import * as i0 from '@angular/core'`

已关闭
#509 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
angular, rust, typescript
领域
compilers

调研方向

Start with crates/oxc_angular_compiler/src/component/namespace_registry.rs and compare its alias selection with the JIT handling from #504. Trace the hard-coded i0 uses in class_metadata/compiler.rs and component/transform.rs, including the HMR dependency and emitted import. Done means each file chooses one free namespace alias and the repros no longer produce duplicate bindings or refer to the user's i0.

由索引模型根据 Issue 内容生成。

描述

bug

In AOT output, OXC always adds import * as i0 from '@angular/core' and refers to it as i0. If the file already has a top-level i0, the output declares it twice (a SyntaxError), and the Ivy code may use the user's i0. ngtsc picks a free name (i0_1). #504 fixed this for the JIT path by choosing a free name. AOT still uses a fixed name.

Repro A

import {Component} from '@angular/core';
const i0 = 1;
@Component({selector: 'c', template: '<div>{{v}}</div>'})
export class C { v = i0; }

Repro B

import {Component} from '@angular/core';
import * as i0 from './other';
@Component({selector: 'c', template: '<div>{{v}}</div>'})
export class C { v = i0.x; }

OXC (main and #504 tip)

import {Component} from '@angular/core';
import * as i0 from '@angular/core';
const i0 = 1;                      // duplicate declaration
export class C { v = i0;
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({...
import * as i0 from './other';
import * as i0 from '@angular/core';   // duplicate import binding

ngtsc 22.1.7

import * as i0_1 from "@angular/core";
const i0 = 1;
export class C {
    v = i0;
    static ɵcmp = /*@__PURE__*/ i0_1.ɵɵdefineComponent({ ... i0_1.ɵɵtext(1); ...

(B: import * as i0 from './other'; import * as i0_1 from "@angular/core";)

Where

i0 is hard-coded in several places:

  • crates/oxc_angular_compiler/src/component/namespace_registry.rs (@angular/core → i0; the iN names for other modules have the same problem)
  • class_metadata/compiler.rs (ReadVarExpr { name: "i0" })
  • component/transform.rs (HMR namespace dependency, and the emitted import)

On main?

Yes. #504 only fixes the JIT path (JIT_ANGULAR_CORE_NS, commit 5128879).

Direction

Pick the namespace alias once per file, avoiding top-level bindings (as #504 does for JIT and as ngtsc's ImportManager does), and pass it to every place that emits the namespace.

主要语言
Rust
星标
232
派生
21
平均合并
1 天 16 小时
30 天内合并 PR
62

环境准备

这个项目没有提供开发容器、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 摘要。