#Debugging steps into modified file

11 messages · Page 1 of 1 (latest)

zealous shale
#

What do I do to get vs code to step into the actual TS file instead of this? See it has the sourceMappingURL thing at the bottom and some other generated stuff at the top.

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es2020",
        "declaration": true,
        "outDir": "./dist",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "sourceMap": true
    },
    "include": [
        "src/stasis/**/*"
    ],
    "exclude": [
        "node_modules"
    ]
}
{
    "name": "test",
    "type": "node",
    "request": "launch",
    "runtimeArgs": [
        "--nolazy",
        "-r",
        "ts-node/register/transpile-only"
    ],
    "args": [
        "evaluate.ts",
        "${input:subscription}"
    ],
    "cwd": "${workspaceRoot}/src/stasis",
    "internalConsoleOptions": "openOnSessionStart",
    "skipFiles": [
        "<node_internals>/**",
        "${workspaceFolder}/node_modules/**",
    ]
}
wanton dagger
#

@zealous shale you need to generate map files

#

those source maps will then be loaded by the runtime when debugging, and will allow you to see the corresponding TS code, instead of the JS that's actually running

zealous shale
wanton dagger
#

make sure those are in the same folder as your JS code

#

or that the sourceMaps are appended to the JS, that is also an option

#

maybe there is a nodejs option you need to enable too, to load map files, not sure

zealous shale
#

Moving the class into the same directory seems to have helped. That is good to know, but is counter to my end goal. The goal is to write classes that I can export to an azure devops artifact feed so that others can instantiate my classes in their ts projects. The class pictured above is me trying to emulate that. I think what I need to do now is get my classes emitted in whatever way the artifact feed will expect, I'm guessing that is a d.ts? Then in my test I can make a new TS project which imports those d.ts files.

wanton dagger
#

@zealous shale the basic idea is:

  • you write the source code of library in JS
  • you compile your TS code to JS, using tsc
  • you emit typings (.d.ts files) at the same time, using tsc too, those files are for your TS consumers, to know the types of what they import
  • you references those JS and typings files in your package.json
    you publish the JS files, typings files, and the package.json on npm
#

also, you don't need to distribute the map files, those are only used for debugging
most libraries don't ship them, tho you could (but it would make your lib bigger)
the main reason is that your lib is supposed to be bug-free, so no need to debug that part of the application