19

Starting with Angular 7.2, the vendorSourceMap option is deprecated:

> ng serve --vendor-source-map

Option "vendorSourceMap" is deprecated.

Official documentation of ng serve says vendorSourceMap is deprecated, but gives no alternative way of resolving library sources:

--vendorSourceMap=true|false

Deprecated

Resolve vendor packages sourcemaps.

Default: false

What is the correct, non-deprecated way, then to resolve vendor source maps in Angular 7.2?

Stephane
  • 11,836
  • 25
  • 112
  • 175
Markus Pscheidt
  • 6,853
  • 5
  • 55
  • 76
  • 1
    According to [this](https://github.com/angular/angular-cli/blob/32a096f3f084fd58719d9009be4ff1d6666b6565/packages/angular_devkit/build_angular/src/angular-cli-files/models/build-options.ts#L29), `--sourceMap` will be used in the future. Looks like they are moving away from the flag being a Boolean to allowing more options. Maybe try something like `--sourceMap=vendor`(?) – R. Richards Apr 15 '19 at 16:28

2 Answers2

52

The correct angular.json options are

"serve": {
  "builder": "@angular-devkit/build-angular:dev-server",
  "options": {
    "sourceMap": {
      "scripts": true,
      "styles": true,
      "vendor": true
    },
...

Verified on 10.0.*. (Updated verfied version from 7.2.15 > 10.0.*)

Btw, the documentation is really poor on this matter, and I could not find a blog post or resource with an example.

Liam
  • 27,717
  • 28
  • 128
  • 190
LppEdd
  • 20,274
  • 11
  • 84
  • 139
  • Not that this explains much, but at least it lists the options... https://angular.io/guide/workspace-config#optimization-and-source-map-configuration – Christian Oct 19 '20 at 22:27
  • Any idea how to set the sourceMap configuration from the command line `--sourceMap=` to have scripts be true and vendor be false? – Thomas Jahncke Mar 19 '21 at 13:35
  • @ThomasJahncke never tried. Honestly the quicker way is to debug the serve script and see where those options go. – LppEdd Mar 19 '21 at 13:37
  • @LppEdd thank you for your reply. FWIW, I am using ng build --watch instead of serve, but that is a different topic. I wasn't able to get the `angular.json` config to work with that setup so I thought I would try the command line. How do you debug the serve / build script? – Thomas Jahncke Mar 19 '21 at 14:12
  • @ThomasJahncke you need to check if the JSON "build" configuration supports the above settings first. It might not. It's a bit difficult for me to answer because I don't work anymore on Angular (or frontend stuff) since February 2020. I'll check if I still have a project tho – LppEdd Mar 19 '21 at 14:18
  • @ThomasJahncke as far as I remember you'll find the NG scripts under the angular NPM libraries, probably angular-devkit – LppEdd Mar 19 '21 at 14:19
0

In version 12 this option is not allowed , so you can debug your library by modifying angular.json : and make verbose option equals to true

"serve": {
          "builder": "@angular-devkit/build-angular:dev-server",

          "configurations": {
            "production": {
              "browserTarget": "testAdmin:build:production"
            },
            "development": {
              "browserTarget": "testAdmin:build:development",
              "verbose": true <--- **modify this // or add this option**
            }
          },
          "defaultConfiguration": "development"
        },
Lama Sonmez
  • 93
  • 1
  • 16