Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Multiple assets emit different content to the same filename error for assets with persistent cache

オープン
#21,576 コメント 5 件 リアクション 8 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
typescript, webpack
領域
build-system

調査の方向性

まず、ng build と webpack 5 の永続キャッシュで問題を再現します: 異なるフォルダーに同じファイル名の SVG アセットを 2 つ用意し、その後、ビルド間でそれらの import 順序を変更します。キャッシュされたアセットと新たに訪問されたアセットがどのように出力されるかを追跡します。完了条件は、ビルドを繰り返しても同じファイル名に異なる内容が出力されたり、webpack の競合エラーが発生したりしなくなることです。

索引モデルが issue の本文から書いたものです。

説明

area: @angular-devkit/build-angular devkit/build-angular:browser freq1: low needs: investigation type: bug/fix

🐞 Bug report

Command (mark with an x)
  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc
Is this a regression?

No

Description

This issue is a continuation for the https://github.com/angular/angular-cli/issues/12186. The fix, introduced for that issue, does not correctly work when using webpack 5 persistent cache.

The problem comes from the fact that when you have multiple assets with the same name, but different folder, CLI emits the first visited asset to the root of fs(disregarding it's folder path), while emiting subsequent assets with this name to their corresponding folders.

To do that Angular CLI keeps track of the emitted(visited) files in-memory, and it does not work when part of the compilation was restored from file system cache. This makes it so that CLI does not realise that a certain svg file was previously emited to the root of the fs, which in turn may lead to the emition of a different svg file(with the same name, but different content) to the same place in the root of the fs, triggering webpack emit conflict error.

🔬 Minimal Reproduction

  1. Enable webpack 5 persistent cache feature
  2. Make sure the cache is clear
  3. Create a project with 2 different SVG assets with the same name, but place them in two different folders
  4. Import one of this images somewhere in the code of the project
  5. Run ng build. The svg is emitted to the root of fs, and is cached
  6. Change the code to import second image right before the first one
  7. Run ng build again. CLI will try to emit the second svg to the root of fs, but there is already the first svg retrieved from the cache there.
  8. You should see the webpack emit conflict error.

🔥 Exception or Error

Error: Conflict: Multiple assets emit different content to the same filename empty.svg

🌍 Your Environment


Angular CLI: 12.2.0
Node: 14.17.3
Package Manager: npm 6.14.13
OS: darwin x64

Angular: 12.2.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1202.0
@angular-devkit/build-angular   12.2.0
@angular-devkit/core            12.2.0
@angular-devkit/schematics      12.2.0
@schematics/angular             12.2.0
rxjs                            6.6.7
typescript                      4.2.4
webpack                         5.47.1
主要言語
TypeScript
スター
27k
フォーク
11.8k
平均マージ
17時間 25分
マージ済み PR(30日)
183

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

angular/angular-cli のほかの issue

angular/angular-cli の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。