angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.98k forks source link

file hash different when building with and without sourcemaps when buildOptimizer set to true #17237

Open fasidOnGit opened 4 years ago

fasidOnGit commented 4 years ago

🐞 Bug report

Command (mark with an x)

Description

The difference in bundle hash when "buildOptimizer": true and hence the bundle itself.

I am building the application with and without sourcemaps (2 times), here is the snippet of the configurations

"configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "6mb"
                }
              ]
            },
            "srcmap": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": {
                "hidden": true,
                "scripts": true,
                "styles": true
              },
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "6mb"
                }
              ]
            }
          }

Notice that, I have two configurations production and srcmap with "buildOptimizer": true the only difference is the sourcemap. where

If I run, ng build --prod and ng build --configuration=srcmap I get bundles with difference in their hashes.

According to the following issue, the above said bug shouldn't be happening because I am already using hidden sourcemap

related to https://github.com/angular/angular-cli/issues/8981

When I change to buildOptimizer: false in both production and srcmap then I run the build for both and then I get similar bundles.

angelnikolov commented 4 years ago

Maybe related https://github.com/angular/angular-cli/issues/8981#issuecomment-356658544