Angular-cli: Sourcemaps for legacy JS scripts have absolute path, instead of relative

Created on 7 Dec 2017  Â·  7Comments  Â·  Source: angular/angular-cli

Versions

angular/cli: 1.4.9
node: 6.11.3
os: win32 x64
@angular/animations: 4.4.6
@angular/common: 4.4.6
@angular/compiler: 4.4.6
@angular/core: 4.4.6
@angular/forms: 4.4.6
@angular/http: 4.4.6
@angular/platform-browser: 4.4.6
@angular/platform-browser-dynamic: 4.4.6
@angular/router: 4.4.6
@angular/cli: 1.4.9
@angular/compiler-cli: 4.4.6
@angular/language-service: 4.4.6
typescript: 2.3.4

Repro steps

  • Add legacy js scripts to angular-cli.json scripts array
  • Build via "ng build --prod --sm

here is my angular-cli.json:
], "scripts": [ "App.js", "modules/module1.js", "modules/module2.js" .... ]

Observed behavior

Sourcemaps generated for legacy js scripts (scripts.bundle.js) contain relative path, instead js.map looks like this:

{"version":3,"sources":["C:\\Users\\ibalan\\Documents\\Projects\\myproject\\src\\App.js"}

Desired behavior

Sourcemaps should have relative paths, is there is switch or option in a config for this?

When I build with --dev - sourcemap for scripts is not created at all

devkibuild-angular medium regression bufix

Most helpful comment

I just tested on latest master and I see:

  • Absolute paths in app bundles ({"version":3,"sources":["D:/sandbox/master-project/node_modules/rxjs/_esm5/symbol/rxSubscriber.js",)
  • Odd paths for scripts: {"version":3,"sources":["src/scripts.js"],
  • Odd double paths for css bundles {"version":3,"sources":["D:/sandbox/master-project/src/D:/sandbox/master-project/styles.css"]

Something is definitely wrong with sourcemaps here.

All 7 comments

This issue should be resolved... please update to the latest version of the CLI (currently: 1.6.0).

Unfortunately, upgrading to 1.6 did not resolve the issue. I still get absolute paths.

I just tested on latest master and I see:

  • Absolute paths in app bundles ({"version":3,"sources":["D:/sandbox/master-project/node_modules/rxjs/_esm5/symbol/rxSubscriber.js",)
  • Odd paths for scripts: {"version":3,"sources":["src/scripts.js"],
  • Odd double paths for css bundles {"version":3,"sources":["D:/sandbox/master-project/src/D:/sandbox/master-project/styles.css"]

Something is definitely wrong with sourcemaps here.

Guys, any news on this?

I think this was fixed by webpack 4, as I cannot reproduce this locally with latest master. The new sourcemaps looks like this (formatted):

{
  "version": 3,
  "sources": [
    "webpack:///modules/test.js",
    "webpack:///App.js"
  ],
  "names": [],
  "mappings": "AAAA;;;ACCA",
  "file": "scripts.js",
  "sourcesContent": [
    "console.log(1);\n",
    "\nalert(1);\n"
  ],
  "sourceRoot": ""
}

Still got this error with:

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / â–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |
  | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.2.4
Node: 10.9.0
OS: win32 x64
Angular: 6.1.9
... animations, common, compiler, compiler-cli,
core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.8.4
@angular-devkit/build-angular     0.8.4
@angular-devkit/build-optimizer   0.8.4
@angular-devkit/build-webpack     0.8.4
@angular-devkit/core              0.8.4
@angular-devkit/schematics        0.8.4
@angular/cdk                      6.4.7
@angular/cli                      6.2.4
@angular/material                 6.4.7
@ngtools/webpack                  6.2.4
@schematics/angular               0.8.4
@schematics/update                0.8.4
rxjs                              6.2.2
typescript                        2.9.1
webpack                           4.20.2

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings