Skip to content

Output files' filename for scripts hashes are incorrect  #22906

Closed
@JoshuaEN

Description

@JoshuaEN

🐞 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?

Yes, the previous version in which this bug was not present was: Angular 11 (per original bug report, I did not test this)

Description

Reopening #22602
If I understand correctly, per https://github.com/angular/angular-cli/blob/master/CHANGELOG.md#1322-2022-02-02, this should be fixed in 13.2.2 and higher (since the main PR [#22612] associated with ff54b49e7 closed #22602 ) . However, I see the issue in 13.2.2, 13.3.0, and 14.0.0-next.6.

🔬 Minimal Reproduction

(copied from original bug, except for updated clone link to a fork with 13.3.0)

  1. Clone https://github.com/JoshuaEN/angular-filename-hashing-bug-reproduction
  2. Run npm ci to install dependencies.
  3. Run ng build --configuration=production (with the default es2017 target in tsconfig.json).
  4. Observe the contents of the output dist/angular-filename-hashing-bug-reproduction/scripts.{revhash_1}.js file to be try{console.log()}catch(c){}.
  5. Change the compilerOptions.target to es2019 (or es2020 or es2021) from es2017 in tsconfig.json.
  6. Run ng build --configuration=production.
  7. Observe the contents of the output dist/angular-filename-hashing-bug-reproduction/scripts.{revhash_2}.js file to be try{console.log()}catch{} (different from the output from step 4).
  8. Observe that revhash_1 equals revhash_2.

🌍 Your Environment


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 13.3.0
Node: 16.14.2
Package Manager: npm 8.5.0
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1303.0
@angular-devkit/build-angular   13.3.0
@angular-devkit/core            13.3.0
@angular-devkit/schematics      13.3.0
@schematics/angular             13.3.0
rxjs                            7.4.0
typescript                      4.5.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions