Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source maps from packages in node_modules don't work in the debugger #45196

Open
DetachHead opened this issue Oct 27, 2022 · 3 comments
Open

Comments

@DetachHead
Copy link

Version

v18.10.0

Platform

Microsoft Windows NT 10.0.19044.0 x64

Subsystem

No response

What steps will reproduce the bug?

  1. create a .ts file that imports from a package that includes the source code and source maps, for example:
    // main.ts
    import { exactly } from '@detachhead/ts-helpers/dist/utilityFunctions/misc'
    exactly(1 as number, 2 as number)
  2. compile it with typescript: tsc main.ts --sourcemap
  3. in vscode, set a breakpoint on the exactly function call
  4. run it with the nodejs debug console in vscode: node main.js
  5. when the breakpoint is reached, hit F11 to step into the function

How often does it reproduce? Is there a required condition?

every time

What is the expected behavior?

steps into the source code located at ./node_modules/@detachhead/ts-helpers/src/utilityFunctions/misc.ts, as the @detachhead/ts-helpers package includes its source code and source maps

What do you see instead?

stepped into compiled .js file
image

Additional information

debugging in webstorm produces a slightly different result. instead of stepping into the .js file when pressing "step into", it just steps over instead

@Trott
Copy link
Member

Trott commented Oct 27, 2022

@nodejs/tooling (Maybe there's a better team to ping? I basically looked at the teams that @bcoe is on and picked the one that seemed the most plausibly related to source maps.)

@bcoe
Copy link
Contributor

bcoe commented Nov 3, 2022

This might be a good opportunity for a contribution from someone who uses vscode and Node.js, I'm unlikely to have any time to dig into this.

@DetachHead
Copy link
Author

a workaround is to create a launch config to run your script, specifying the node_modules directory in resolveSourceMapLocations:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch TypeScript",
            "type": "node",
            "request": "launch",
            "program": "dist/main.js",
            "outFiles": ["${workspaceFolder}/dist/**/*.js"],
            "resolveSourceMapLocations": [
                "${workspaceFolder}/dist/**/*",
                "${workspaceFolder}/node_modules/**/*"
            ]
        }
    ]
}

however having to create launch configs is inconvenient. i'm not sure anymore whether this a node or vscode issue, so let me know if you think i should raise it there instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants