Markus Pscheidt
Markus Pscheidt

Reputation: 7331

Angular 12 library source maps unavailable

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"
    }
  }
}

Upvotes: 3

Views: 2073

Answers (2)

Said Chleuh
Said Chleuh

Reputation: 11

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

Upvotes: 1

Markus Pscheidt
Markus Pscheidt

Reputation: 7331

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": []
}

Upvotes: 5

Related Questions