angular / angular/angular-cli

Esbuild Web Worker Type Safety and Redundant tsconfig.worker.json

未关闭
#30,676 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
angular/build:application area: @angular/build freq1: low severity1: confusing type: bug/fix
主要语言
TypeScript
星标
27k
派生
11.8k
平均合并
14 小时 23 分钟
30 天内合并 PR
162

描述

### Command

build

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

When using esbuild as the bundler for Angular projects, the support for web workers appears misleading in terms of type safety:

- In the previous webpack-based build setup, web workers had proper TypeScript type checking at build time.

- Currently, esbuild does not type-check web workers during build time. This is not documented or clearly communicated, leading to a false sense of correctness.

- Additionally, creating a project with a web worker generates a `tsconfig.worker.json`, which seems redundant because esbuild doesn't use it for type-checking. Also `builder` contains the `webWorkerTsConfig` option in the schema, as I understand it, this doesn't affect anything. This can confuse developers into thinking their web worker code is properly validated.

**Expected Behavior**

Either esbuild-based builder should perform type checking on web worker files, or there should be clear documentation and/or warnings that type-checking is not performed on workers.

**Current Behavior**

- No build-time type checking for worker code.

- Misleading tsconfig.worker.json is generated, giving false confidence in type safety.

### Minimal Reproduction

1. Generate a new Angular project with esbuild (Angular CLI 18+).
2. Add a web worker via ng generate web-worker.
3. Introduce a type error in the worker file.
4. Run ng build – no type error is reported.

### Exception or Error

```text

```

### Your Environment

```text
Any version with esbuild bundler.
```

### Anything else relevant?

_No response_

贡献指南

打开贡献指南

调研方向

首先复现所描述的 Angular CLI esbuild 工作流:生成一个 web worker,添加一个类型错误,然后运行 ng build。检查生成的 tsconfig.worker.json 以及 builder schema 中的 webWorkerTsConfig 选项。当 worker 的类型检查行为得到修正或得到明确记录,并且误导性的配置得到处理时,即视为完成。

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

评估

技术栈
angular, typescript
领域
build-system, cli
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。