GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Multiple assets emit different content to the same filename error for assets with persistent cache · Issue #21576 · angular/angular-cli

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

New issue
Copy link
New issue
Copy link
Open
Open
Multiple assets emit different content to the same filename error for assets with persistent cache#21576
Copy link
Labels
area: @angular-devkit/build-angulardevkit/build-angular:browserfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyneeds: investigationRequires some digging to determine if action is neededRequires some digging to determine if action is neededtype: bug/fix
Milestone
needsTriage

Description

@pshurygin
pshurygin
opened on Aug 14, 2021
Issue body actions

🐞 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 #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
Reacted by Yuriy Grunin, Nikita Balakirev, Dmitrii Gniteev, Andrey Piskunov, Aleksandr Prikhodko, Konstantin Zhandov, Dmitrii Usanov and Maksim Popov

Activity

  1. alan-agius4
    added
    needs: repro stepsWe cannot reproduce the issue with the information givenWe cannot reproduce the issue with the information given
    on Aug 14, 2021
  2. alan-agius4 commented on Aug 14, 2021

    @alan-agius4
    alan-agius4
    on Aug 14, 2021
    Collaborator
    More actions

    Hi @pshurygin, I tried to replicate this locally, but I am not managing to replicate the issue.

    Screenshot 2021-08-14 at 12 49 35

    Can you setup a minimal repro please?

    You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

    This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

  3. pshurygin commented on Aug 14, 2021

    @pshurygin
    pshurygin
    on Aug 14, 2021
    Author
    More actions

    @alan-agius4 Are you using actually different images for that? If so, I guess one might also need to have import of the second asset from a different(lazy loaded) chunk, as this is how we have it in our repo. I will try to make a minimal reproduction repo for that.

  4. alan-agius4 commented on Aug 14, 2021

    @alan-agius4
    alan-agius4
    on Aug 14, 2021
    Collaborator
    More actions

    Yes, the 2 images are different.

  5. pshurygin commented on Aug 14, 2021

    @pshurygin
    pshurygin
    on Aug 14, 2021
    Author
    More actions

    @alan-agius4 Yes, you need your second asset to be in a different bundle. I've also didn't mention that you have to run build in development mode, otherwise file names are hashed. Here is the reproduction repo

    1. Comment out contents of child.component.scss
    2. run NG_PERSISTENT_BUILD_CACHE=1 ng build --configuration development
    3. Uncomment contents of child.component.scss
    4. run NG_PERSISTENT_BUILD_CACHE=1 ng build --configuration development again
  6. alan-agius4
    added
    freq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarely
    needs: investigationRequires some digging to determine if action is neededRequires some digging to determine if action is needed
    type: bug/fix
    area: @angular-devkit/build-angular
    and removed
    needs: repro stepsWe cannot reproduce the issue with the information givenWe cannot reproduce the issue with the information given
    on Aug 16, 2021
  7. ngbot
    added this to the needsTriage milestone on Aug 16, 2021
  8. alan-agius4
    added
    devkit/build-angular:browser
    on Aug 16, 2021
  9. hschmidtchen commented on Mar 27, 2023

    @hschmidtchen
    hschmidtchen
    on Mar 27, 2023
    More actions

    Hi @alan-agius4,
    I would like to provide a data point that this issue still persists.
    This thread helped me to solve a similar issue which was caused by two independent third-party dependencies adding equally named static assets to the build (fonts).
    Luckily, one of the dependencies could be replaced but if that was not the case, we would have been forced to disable angular caching for local development.

    Reacted by Giorgi Cheishvili
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @angular-devkit/build-angulardevkit/build-angular:browserfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyneeds: investigationRequires some digging to determine if action is neededRequires some digging to determine if action is neededtype: bug/fix

    Type

    No type

    Projects

    No projects

      Milestone

      • needsTriageNo due date

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.