Search code examples
angularnpmangularjs-directiveangular-clinode-modules

What is the use of "Hash: fec054139de85795" in ng serve?


Attaching the ng serve response here for reference:

Lazy Chunk Files | Names | Raw Size src_app_features_main-overview_main-overview_module_ts.js | app-features-main-overview-main-overview-module | 5.00 MB |

5 unchanged chunks

Build at: 2024-03-25T08:18:43.385Z - Hash: fec054139de85795 - Time: 1347ms

√ Compiled successfully.


Solution

  • It's the "Compilation specific hash".

    Origin of the hash

    The output-template in angular-cli:

    `Build at: ${w(new Date().toISOString())} - Hash: ${w(json.hash || '')} - Time: ${w('' + time)}ms`,
    

    uses the JSON field hash from webpack's Stats Data, Structure:

    {
      "version": "5.9.0", // Version of webpack used for the compilation
      "hash": "11593e3b3ac85436984a", // Compilation specific hash
      "time": 2469, // Compilation time in milliseconds
    

    Purpose and usage of the hash

    You can expect it to be identical for multiple builds if the build artifact is identical and different if anything in the build artifact changed.

    You can use it for everything you've to identify a specific artifact, as long as you just care about the result and not from which actual build it originated. For example if you save your artifact to an artifact store, you can use the hash in the file name. That way you can easily find the matching artifact from your build logs, if you have to.