3

After upgrading to Angular 12, the source maps of a custom Angular library component are not available for debugging anymore.

Here is part of angular.json from the Angular application module, which consumes the library:

"projects": {
  "myapp": {
    "build": {
      "configurations": {
        "development": {
          "optimization": false,
          "sourceMap": true,
          "namedChunks": true,
          "extractLicenses": false,
          "vendorChunk": true,
          "buildOptimizer": false,
          "budgets": []
        }
      }
    },
    "serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "options": {
        "browserTarget": "myapp:build"
      },
      "configurations": {
        "production": {
          "browserTarget": "myapp:build:production"
        },
        "development": {
          "browserTarget": "myapp:build:development"
        }
      },
      "defaultConfiguration": "development"
    }
  }
}

2 Answers 2

5

Simply setting sourceMap: "true" is not sufficient in this case.

In order to make library sources available, use the following instead and set sourceMap.vendor to true:

"development": {
  "optimization": false,
  "sourceMap": {
    "scripts": true,
    "styles": true,
    "vendor": true
  },
  "namedChunks": true,
  "extractLicenses": false,
  "vendorChunk": true,
  "buildOptimizer": false,
  "budgets": []
}
Sign up to request clarification or add additional context in comments.

Comments

1

I resolved this problem in angular 14 by putting sourceMap true in angular.jsoin and tsconfig.json and : In chrome : Inspect -> Parameters -> Preferences -> source -> Enable javascript sourceMap

maybe can help

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.