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

Top level folder gets truncated when JS Project is not the root folder #894

Closed
jasonwilliams opened this issue Dec 14, 2020 · 3 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@jasonwilliams
Copy link
Contributor

jasonwilliams commented Dec 14, 2020

Describe the bug
When the JavaScript project is not at the top level the debugger doesn't match the paths well.

To Reproduce
Steps to reproduce the behavior:

  1. Checkout https://github.com/jasonwilliams/nextjs9-typescript-server-vscode-example/tree/monorepo (monorepo branch)
  2. Set a breakpoint on line 9 in webapp/pages/index.tsx (on const alfa)
  3. run docker-compose up inside of webapp
  4. Once that's running start the debugger (launch server (Docker))
  5. It won't bind, run "Create diagnostic information..."
  6. You should see the matcher has truncated the "webapp" folder

Screenshot
In this screenshot webapp is lost (on the second bullet point), causing the matcher not to find the file
image

VS Code Version: 1.53
Debugger Version Nightly (v2020.12.917)

@jasonwilliams jasonwilliams added the bug Issue identified by VS Code Team member as probable bug label Dec 14, 2020
@jasonwilliams jasonwilliams changed the title Top level folder gets truncated when working in a monorepo Top level folder gets truncated when JS Project is not the root folder Dec 14, 2020
@connor4312
Copy link
Member

Thanks for the issue. This is because the sourceMapPathOverrides are applied to the webpack:/// path. The relevant default here is 'webpack://?:*/*': ${cwd}/*`, so the debugger reports that is applied:

"SourceMap: mapping webpack:///./pages/index.tsx => e:\Downloads\nextjs9-typescript-server-vscode-example/./pages/index.tsx, via sourceMapPathOverrides entry - /^webpack:\/\/.?\/(.?)$/i"

This bypasses the localRoot/remoteRoot. The solution here is to set the "cwd": "${workspaceFolder}/webapp".

I think it would make sense to default the cwd to the localRoot, if the former is unset and the latter is.

@connor4312 connor4312 added this to the December 2020 milestone Dec 15, 2020
@jasonwilliams
Copy link
Contributor Author

Thanks @connor4312 !
Out of interest, what is cwd usually based off? Where the node executable runs? Or where the script first fired from?

@connor4312
Copy link
Member

Generally the workspace folder:

export function guessWorkingDirectory(program?: string, folder?: vscode.WorkspaceFolder): string {

@RMacfarlane RMacfarlane added the verified Verification succeeded label Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants