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

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

未关闭
#21,576 5 条评论 8 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

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

调研方向

首先使用 ng build 和 webpack 5 持久缓存重现该问题:在不同文件夹中使用两个文件名相同的 SVG 资源,然后在不同构建之间更改它们的导入顺序。跟踪缓存资源和新访问资源的输出方式。完成标准是,重复构建不再向同一文件名输出不同内容,也不再引发 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 分钟
30 天内合并 PR
183

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

angular/angular-cli 的其他 Issue

查看 angular/angular-cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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