Skip to content

Typescript Nodejs Debug #636

Closed
Closed

Description

@mfrancis107

Is there a way to use the Typescript compiler and debug with breakpoints on the Typescript file?

I've tried getting it to work but can't seem to find a way.

If there is a way I think it should be documented better.

Activity

  1. guybedford commented on Jul 30, 2015

    @guybedford
    Member

    Yes, source maps are not currently supported for TypeScript compilation.

  2. mhegazy commented on Aug 13, 2015

    @mhegazy

    @mfrancis107 and @guybedford is this related to systemjs builder? can you provide more details about your scenario?

  3. guybedford commented on Aug 13, 2015

    @guybedford
    Member

    @mhegazy thanks so much for checking in here! This is actually both for the in-browser transpilation and for SystemJS builder as well. In-browser transpilation is at https://github.com/ModuleLoader/es6-module-loader/blob/master/src/transpiler.js#L68, and while it shows source maps, they don't provide full debugging in Chrome back to the original source, which we have for the other transpilers.

    The builder transpilation is at https://github.com/systemjs/builder/blob/master/compilers/esm.js#L94, and also doesn't have source map support, which would be provided by just returning a source map object at https://github.com/systemjs/builder/blob/master/compilers/esm.js#L105.

    Any tips or ideas would be really great to hear here.

  4. guybedford commented on Aug 13, 2015

    @guybedford
    Member

    To see the in-browser transpilation, open for example https://github.com/systemjs/systemjs/blob/master/test/test-typescript.html, and see that the original ES6 is not present in comparison to others. Looking at the original source it seems like the reason is that the source map looks like:

    {"version":3,"file":"es6-circular1.js","sourceRoot":"","sources":["es6-circular1.js"],"names":["p"],"mappings":";;QACW,CAAC,EACD,CAAC;IACZ;QACEA,EAAEA,CAACA,CAACA,CAACA,CAACA;YACJA,eAAAA,CAACA,GAAGA,oBAACA,CAAAA,CAACA;QACRA,IAAIA;YACFA,eAAAA,CAACA,GAAGA,oBAACA,CAAAA,CAACA;IACVA,CAACA;IALD,iBAKC,CAAA;;;;;;;YACD,CAAC,EAAE,CAAC"}

    Where the sources and file name are the same. The point is that for in-browser transpilation we have to change the name of the transpiled source to source.js!transpiled so it can have a separate representation in the debugger, but the load.address argument provided to transpile at https://github.com/ModuleLoader/es6-module-loader/blob/master/src/transpiler.js#L78 becomes both the sources and file value.

  5. mhegazy commented on Aug 13, 2015

    @mhegazy

    thanks @guybedford for the explanation. I have created microsoft/TypeScript#4301 to track this issue.

    also feel free to ping @vladima or myself if you see other issues with the TypeScript/SystemJs interaction in the future. thanks again !

  6. vladima commented on Aug 13, 2015

    @vladima
    Contributor

    @guybedford I've tried to make a simple scenario to repro this issue and it seems to work for me. What I've done:

    • add simple ts file with content
    export class X { 
    
        method() {
            alert(1); // 1
        }
    }
    • added an html page
    <html>
    <head>
        <script src="node_modules/typescript/lib/typescript.js"></script>
        <script src="node_modules/systemjs/dist/system.src.js"></script>
    </head>
    <body>
        <script>
            System.transpiler = "typescript";
            System.import("m1.ts").then(function (m) {
                var x = new m.X();
                x.method(); // 2 
            });
        </script>
    </body>
    </html>
    • Putting breakpoint in original code at line // 1 works fine
    • Setting breakpoint in html at line // 2 and stepping into original code works fine.

    In both cases I was stepping into original TypeScript code (not in transpiled JavaScript).
    Can you please give more information about the scenario that does not work (or ideally a small repro) so I can make sure that the problem is fixed on TypeScript side?

  7. guybedford commented on Aug 17, 2015

    @guybedford
    Member

    @vladima my apologies you're actually completely right here - this is working completely fine, it was actually just an issue with my tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions