angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Debugging not working well in Webpack Branch

Open masaanli opened this issue 10 years ago • 35 comments

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Windows 10
  2. Versions. Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here: Beta 10 (webpack / master branch)
  3. Repro steps. Was this an app that wasn't created using the CLI? What change did you

    do on your code? etc.

  4. The log given by the failure. Normally this include a stack trace and some

    more information.

5. Mention any other details that might be useful.


Thanks! We'll be in touch soon.

The debugging isnt working anymore in firefox, chrome or edge.

When I put a breakpoint nothing happens. When I put a debugger command, it's debugging at strange lines. not where I put the debugger command.

masaanli avatar Aug 02 '16 16:08 masaanli

Some issue on Chrome dev tools side, AFAIK

sirajc avatar Aug 02 '16 19:08 sirajc

@sirajc It's also not working in Firefox for me. It isn't very easy to work with now hehe;) With beta 10 from NPM (SystemJS) It was working previous week ;)

masaanli avatar Aug 03 '16 04:08 masaanli

I've noticed this actually. If I place a breakpoint inside a mapped TS file, the breakpoint will move up the file about 10-20 lines above and obviously not work. It seems the maps aren't quite correctly generated

intellix avatar Aug 03 '16 08:08 intellix

I believe this is a Typescript-mapping problem only. Mapping onto Javascript files (e.g. node dependencies) work fine.

jmc265 avatar Aug 04 '16 12:08 jmc265

@thelarkinn Can you have a look please

sirajc avatar Aug 04 '16 17:08 sirajc

I have also noticed that console errors point to lines far from where the actual error occurred

iamyojimbo avatar Aug 07 '16 01:08 iamyojimbo

Tried to update to the latest Angular CLI Beta 11 Webpack, (NPM) but not worked.

masaanli avatar Aug 08 '16 16:08 masaanli

Actually, for me it's sometimes not working properly even before upgrading to webpack (using PhpStorm)

Namek avatar Aug 09 '16 11:08 Namek

@Namek Do you mean the Webpack Branch or just the Masterbranch where Webpack is inside?

masaanli avatar Aug 09 '16 11:08 masaanli

I just looked again at this issue and to be more specific; I'm having the same problem on Firefox and Internet Explorer.

@TheLarkInn got some progress on this one?

masaanli avatar Aug 09 '16 11:08 masaanli

Yesterday I didn't even touch anything related to webpack in this project. Maybe my webstorm is broken.

Namek avatar Aug 09 '16 14:08 Namek

Actually the problem is being caused by the sourcemap-istanbul-instrumenter-loader which was setup to always instruments the typescript app code in the webpack-build-test.js. Would be better to have a task specific for coverage where the instrumentation would take place. The test tasks will run without instrumentation so we could debug it.

abner avatar Aug 11 '16 00:08 abner

We did just cut a new release on the webpack tag this morning with improved coverage settings. Would you mind just double checking if mappings work on prod and dev.

TheLarkInn avatar Aug 11 '16 04:08 TheLarkInn

@TheLarkInn going to check it today!

masaanli avatar Aug 11 '16 05:08 masaanli

The issue isn't the coverage itself. Coverage is OK in master branch. The problem is the instrumented code, when you debug the tests on karma http://localhost:9876/debug.html. All the application code will look like this:

image

If i just comment out this part of node_modules/angular-cli/addon/ng2/models/webpack-build-test.jswebpack-build-test.js:

    //   postLoaders: [
    //     {
    //       test: /\.(js|ts)$/, loader: 'sourcemap-istanbul-instrumenter-loader',
    //       exclude: [
    //         /\.(e2e|spec)\.ts$/,
    //         /node_modules/
    //       ],
    //       query: { 'force-sourcemap': true }
    //     }
    //   ]
    // },

And run karma again, so i will be capable of debug the code:

image

But obviouslly i won't have any coverage data :

image

My proposal is to have two different tasks:

  • ng test which will allow run the tests without coverage allowing to debug the application source code;
  • ng test-coverage, which will run tests and generate the coverage reports;

I would try make this changes and submit a merge request.

abner avatar Aug 11 '16 09:08 abner

Maybe the Karma fixed the problem?

But my problem was debugging of just the Source Codes. like app.component.ts etc. etc.

This evening im gonna test it.

masaanli avatar Aug 11 '16 10:08 masaanli

So in test you actually get the sourcemaps for your spec files. So set a breakpoint and you will see those correctly.

TheLarkInn avatar Aug 11 '16 13:08 TheLarkInn

We're still investigating sourcemaps on prod and dev modes though.

TheLarkInn avatar Aug 11 '16 13:08 TheLarkInn

@TheLarkInn Nice to hear that, hopefully we find a quick solution for it! :) Now only can console.log hehe

masaanli avatar Aug 11 '16 15:08 masaanli

So we will have to change these to source-map for now which is ok. This comes with the expense of webpack generating accurate sourcemaps that chrome and firefox won't flake out on (which we [as in the webpack org] is looking into). This comes at the expense of a slightly slower dev env build. But since this is in memory-fs when being ng serve'd it may not even be noticeable.

TheLarkInn avatar Aug 12 '16 05:08 TheLarkInn