Skip to content

feat: narrow outFiles to workspace dependencies in npm/yarn monorepos - #2398

Open
Aparajith (Aparajith24) wants to merge 1 commit into
microsoft:mainfrom
Aparajith24:fix/outfiles
Open

feat: narrow outFiles to workspace dependencies in npm/yarn monorepos#2398
Aparajith (Aparajith24) wants to merge 1 commit into
microsoft:mainfrom
Aparajith24:fix/outfiles

Conversation

@Aparajith24

Copy link
Copy Markdown

In an npm/yarn workspaces monorepo, outFiles was previously left to fall back to scanning the entire opened folder for sourcemaps. This happened because the widen-only logic in guessOutFiles only kicks in when the debugged program lives outside the opened workspace folder, but in a monorepo, the folder VS Code has open typically is the repo root, so the program is always "inside" it and the widen logic never narrows anything. The result: debugging one package in a large monorepo scanned every other unrelated package's compiled output too, making it slow to hit breakpoints.

This adds a narrower path: when the opened workspace folder itself has a "workspaces" field in its "package.json" (npm/yarn workspaces), we:

  1. Find the specific package being debugged (nearest package.json walking up from the entry file).
  2. Read the workspace's package list from the workspaces glob patterns (e.g. packages/*).
  3. Walk that package's dependencies/devDependencies/peerDependencies to find which of them are other packages in the same workspace*.
  4. Set outFiles to just the debugged package plus those workspace-local dependencies, instead of the whole repo.

This only applies when outFiles isn't already set by the user (same guard the existing widen-only logic uses), so anyone with a manually configured outFiles is unaffected. Projects without a workspaces field are also completely unaffected, this is additive, not a change to existing behavior.

Closes #1730

  In a monorepo using npm/yarn `workspaces`, outFiles previously fell
  back
  to scanning the entire opened folder for sourcemaps, since the
  debugged
  program already lives inside it. Detect a `workspaces` root and narrow
  outFiles to the debugged package plus its workspace-local dependencies
  instead.

  Fixes microsoft#1730
@Aparajith24

Copy link
Copy Markdown
Author

oyeappu (Aparajith (@Aparajith24)) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

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

Successfully merging this pull request may close these issues.

Using dependency graph to reduce file scanning

1 participant