Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#21,576 5 bình luận 8 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript, webpack
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện vấn đề với ng build và persistent cache của webpack 5: sử dụng hai SVG asset có cùng tên tệp trong các thư mục khác nhau, sau đó thay đổi thứ tự import của chúng giữa các build. Theo dõi cách các asset đã được cache và các asset mới được truy cập được phát ra. Hoàn tất khi các build lặp lại không còn phát ra nội dung khác nhau vào cùng một tên tệp hoặc tạo ra lỗi xung đột của webpack.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
TypeScript
Star
27k
Fork
11.8k
Merge trung bình
17 giờ 25 phút
Pull request đã merge (30 ngày)
183

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của angular/angular-cli

Tất cả issue của angular/angular-cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.