angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.54k stars 3k forks source link

Sourcemaps for angular-ui-router bower components and npm modules are broken #3465

Closed aeisenberg closed 7 years ago

aeisenberg commented 7 years ago

My version of UI-Router is: 1.0.3

Bug Report

Current Behavior:

Cannot set breakpoints in any ui-router files in Chrome Dev Tools. Cannot step through any ui-router files in Chrome Dev Tools.

Steps to reproduce:

  1. Create a project that imports ui-router 1.0.3
  2. Open a page from that project in chrome
  3. Open debugger.
  4. Open bower_components/angular-ui-router/release/angular-ui-router.js (or any other file in the ui-router project)
  5. Set a breakpoint.
  6. BUG: Chrome navigates you a non-existant typescript file (though breakpoint is set)
  7. Run program to that point
  8. BUG: Chrome stops the debugger at the appropriate line in the program, but opens a blank typescript file.

There are other problems related to this bug, including the inability to run karma tests that rely on sourcemaps.

Analysis

The sourcemaps appear to be broken. Open up the file releases/angular-ui-router.js.map and you can see that it references a bunch of sources, like this:

"sources":["../src/angular.ts","../node_modules/@uirouter/core/src/common/hof.ts","../node_modules/@uirouter/core/src/common/glob.ts","...

None of these files exist in the bower component.

The solution I would suggest would be to ensure that typescript files are included in the bower component.

aeisenberg commented 7 years ago

Hmmm...I am now taking a look at the npm packages in the @uirouter namespace. They don't appear to have typescript sources either. So, I would guess that things are broken for these packages as well.

aeisenberg commented 7 years ago

And looking a bit deeper into the source maps, I see entries like the following: /Users/cthielen/projects/uirouter/angularjs/node_modules/@uirouter/core/src/common/predicates.ts.

So, it looks like there are two problems here and the problems are most likely present in both the bower and the npm versions of the package:

  1. source map source files (ie- the *.ts files) do not exist in the package
  2. source map source paths reference fully qualified paths

I am updating the title of this report accordingly.

aeisenberg commented 7 years ago

I can submit a PR for this. It is easy enough to ensure that *.ts files are included in npm and bower builds, but I am not sure how rollup generates its sourcemaps. So, I don't know how to fix full paths in sources files.

If someone could give me a pointer, I would submit a fix for this. Thanks.

aeisenberg commented 7 years ago

I think the PRs I submitted above are enough to fix this issue.