angular-cli: Incorrect line numbers in sourcemaps
OS?
Windows 10
Versions.
angular-cli: 1.0.0-beta.18
node: 6.5.0
os: win32 x64
Checked a beta.17 project, does not appear to occur there. Lines seem to be correct for debugging.
Repro steps.
ng new source-map
cd source-map
ng serve
- Open
src/app/app.component.ts
and add some testing code
export class AppComponent {
title = 'app works!';
ngOnInit(){
let value = true;
if (value){
value = false;
}
}
}
- Open devtools (tested in Chrome)
ctrl+p
and openapp.component.ts
- Set breakpoint on line 12 (
let value = true
) and line 14 (value = false
) - Refresh page
- Hit breakpoint on line 12, notice call stack is outside
ngOnInit
even though breakpoint is within - Hit breakpoint on line 14, notice call stack is within
ngOnInit
butvalue = undefined
- Step and see code execute as expected, but highlighted line to be shifted by a few lines
Other useful info
Seems to shift by ~ 5 lines in my local project, not sure if it is the same shift in the repro (repro shift looks like 3?). Shift can be seen in VS Code Chrome Debugging - where line numbers are given for the mappings.
Maps 48991 (actual line in main.bundle.js
that breakpoint is set to in vscode) to 48986 (where the breakpoint actually is during runtime)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 10
- Comments: 18 (4 by maintainers)
I also confirm the line number issue in beta.18. A quick workaround for me was to update this file
node_modules/angular-cli/models/webpack-build-development.js
in my project and replacecheap-module-source-map
tosource-map
. Takes much longer to compile, but line numbers are matching on breakpoints.Indeed my change has broken sourcemaps. My initial testing seemed to indicate it was fine, but it’s not.
I’ll keep an eye out for https://github.com/webpack/webpack/issues/3165 and see where it comes out.
I have the same problem and it was killing me trying to debug some issues. @un33k’s fix worked like a charm - thanks heaps! And yeah - same here - I saw no noticable speed difference after the switch to
source-map
.I have also issues with debugging and breakpoints since beta.18. Breakpoints are jumping sometimes (click on line 15, jumps to line 19) and execution doesn’t stop at breakpoint.
I believe this may be related to use of cheap-module-source-map change from #2619 and since it is happening in Chrome, without vscode debugging, figured it warranted another issue.
It is fixed in master and does not need to be reopened. The other issue is a duplicate.