WebWorkers problem in Angular related to Vite `optimizeDeps`
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript, vite
- 領域
- build-system, tooling
調査の方向性
リンクされている cornerstonejs/angular-cornerstone3d の再現をクローンし、npm i に続けて npm run start を実行します。Angular のセットアップを、動作している Vite の例と比較します。Angular CLI による Vite optimizeDeps、キャッシュ、モジュールワーカーの処理を調査し、警告が解消されていること、ワーカーが正しいパスを使用していること、npm run build が成功することを確認します。
索引モデルが issue の本文から書いたものです。
説明
Command
serve
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
We have a library that utilizes web workers. It employs the new Worker interface:
const instance = new Worker(
new URL('./decodeImageFrameWorker.js', import.meta.url),
{ type: 'module' }
);
We have successfully consumed the lib in various scenarios, whether based on Webpack or Vite. See the examples below:
- https://github.com/cornerstonejs/vite-react-cornerstone3d
- https://github.com/cornerstonejs/vue-cornerstone3d
- https://github.com/cornerstonejs/nextjs-cornerstone3d
When integrating into a Vite-based framework, a warning appears regarding one of the dependencies. This is a known issue in Vite, specifically with esbuild. To resolve this, we should add the library to optimizeDeps in the Vite config - recommended by vite maintainers, which works well.
I attempted to integrate a poc of the same library in Angular and encountered a similar warning. I tried customizing Vite but faced a limitation, as there is no way to override optimizeDeps in Angular, as noted here.
In some threads, I see that setting
"cli": {
"cache": {
"enabled": false
}
}
removes the warning above, but then the worker is requested from an incorrect path.
I also have tried the following
"development": {
"buildTarget": "angular-vite-6:build:development",
"prebundle": false
}
still no success
Minimal Reproduction
This is basically minimal repo for reproduction
commands to run
npm i
npm run start
Exception or Error
With the cache enabled, the Vite warning appears, and disabling the cache loads the worker from the wrong path.
Your Environment
Angular CLI: 19.0.2
Node: 18.19.1
Package Manager: npm 10.2.4
OS: darwin arm64
Angular: 19.0.1
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1900.2
@angular-devkit/build-angular 19.0.2
@angular-devkit/core 19.0.2
@angular-devkit/schematics 19.0.2
@angular/cli 19.0.2
@schematics/angular 19.0.2
rxjs 7.8.1
typescript 5.6.3
zone.js 0.15.0
Anything else relevant?
I want to emphasize that other Vite-based implementations for Vue, React, and Quasar work, so it's only Angular that's not working.
In addition, the npm run build also does not work and tries to load the worker from a wrong path (Again the build with vite, and webpack works)
- 主要言語
- TypeScript
- スター
- 27k
- フォーク
- 11.8k
- 平均マージ
- 16時間 35分
- マージ済み PR(30日)
- 176
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
angular/angular-cli のほかの issue
-
area: @angular/build gemini-triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
angular/angular-cli#33055 · コメント 1 件 · リアクション 3 件 ·
-
area: @angular/build gemini-triaged
難易度 4/5 3〜5日 初心者へのやさしさ 72/100
angular/angular-cli#34137 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 担当者 1 名 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 担当者 1 名 ·
angular/angular-cli の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
linagora/twake-calendar-frontend#1377 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
EclipseFdn/open-vsx.org#13385 · コメント 1 件 ·
-
front-end UI/UX
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
S: triage
難易度 1/5 1時間未満 初心者へのやさしさ 85/100