angular-builders icon indicating copy to clipboard operation
angular-builders copied to clipboard

Persistent cache error - from pack: TypeError: Cannot read property 'map' of undefined

Open KhoaSydney opened this issue 4 years ago • 3 comments

Describe the Bug

Restoring failed for persistent caching

Minimal Reproduction

Angular CLI 12.1.1, image

Angular-Builders/Custom-Webpack 12.1.1.beta

First build ran successfully. I can see the cache folders for angular-webpack and babel-webpack and cache files created. Second build, there are lot of warning (from pack: TypeError: Cannot read property of 'map' of undefined). If I replace the custom-webpack with @angular-devkit/build-angular, persistent cache works. I also noted the first build take much longer (22minutes) when using @angular-builders/custom-webpack compare to @angular-devkit/build-angular (10mins)

The error come from here : image

The same issue also happens when I use @Angular-builder/custom-webpack 12.1.0

image

Eventually, the build completed but it doesnt look like there is any cache restore happens as seen from the capture above angular.json "architect": { "build": { "builder": "@angular-builders/custom-webpack:browser", //"builder": "@angular-devkit/build-angular:browser", "options": { "customWebpackConfig": { "path": "./webpack.config.js", "mergeRules": { "output": "replace", "entry": "replace" }, "replaceDuplicatePlugins": true }, "outputPath": "./dev-build", "index": "", "main": "app/silverlight/silverlight.bootstrap.ts", "polyfills": "app/polyfills.ts", "tsConfig": "./tsconfig.json", "inlineStyleLanguage": "scss"

      },
       "configurations": {
        "production": {
          "customWebpackConfig": {
            "path": "./webpack.config.production.js",
            "mergeRules": {
              "output": "replace",
              "entry": "replace"
            },
            "replaceDuplicatePlugins": true
          },
          "fileReplacements": [
            {
              "replace": "./app/environments/environment.ts",
              "with": "./app/environments/environment.prod.ts"
            }
          ],
          "optimization": {
            "scripts": true,
            "styles": {
              "minify": true,
              "inlineCritical": true
            },
            "fonts": true
          },
          "sourceMap": {
            "hidden": false,
            "styles": false
          },
          "outputHashing": "all",
          "namedChunks": false,
          "extractLicenses": false,
          "vendorChunk": true,
          "buildOptimizer": true,
          "aot": true,
          "assets": []
        },
        "development": {
          "buildOptimizer": false,
          "optimization": false,
          "vendorChunk": true,
          "extractLicenses": false,
          "sourceMap": true,
          "namedChunks": false
        },

      "defaultConfiguration": "development"
    },,
    "serve": {
      //"builder": "@angular-devkit/build-angular:dev-server",
      "builder": "@angular-builders/custom-webpack:dev-server",
      "options": {
        "port": 9090,
        "proxyConfig": "app/proxy.config.js",
        "servePath": "dev-build/"
      },
      "configurations": {
        "production": {
          "browserTarget": "app:build:production"
        },
        "development": {
          "browserTarget": "app:build:development"
        }
      },
      "defaultConfiguration": "development"
    },

  }

Expected Behavior

Persistent cache restore cache item successfully. The build time should reduce as the result of Persistent caching working

KhoaSydney avatar Jul 08 '21 04:07 KhoaSydney

Is there a possibility your custom webpack config affects the build? What if you use custom-webpack builder but the custom config is empty?

just-jeb avatar Jul 11 '21 13:07 just-jeb

@just-jeb I commented out my custom webpack config module.exports = {} and it still doesnt work (take a long time with persistent cache turn on). I think this must be related to custom webpack. I also came across a comment here where the user said the custom webpack causes performance issue https://github.com/angular/angular-cli/issues/20792#issuecomment-872179937

KhoaSydney avatar Jul 13 '21 07:07 KhoaSydney

Hey, thanks for checking it out for me. I can't think of anything that would cause the custom-webpack multiply the build time.
Any chance you can try clean install (with removing the package-lock.json) like they did here? If it still doesn't help I'm gonna need a reproduction.
Thank you.

just-jeb avatar Jul 18 '21 09:07 just-jeb