Skip to content

Conversation

@harunaOseni
Copy link
Contributor

Summary

Implements dynamic debug path resolution for TypeScript/Jest tests. The debugger now automatically resolves localRoot/remoteRoot based on the Bazel execution environment, eliminating the need for manual sourceMapPathOverrides configuration.

Changes

  • Add BazelInfoService to query Bazel execution_root, output_base, and platform
  • Add TypeScriptLanguageTools.constructDebugRemoteRoot() to build runfiles path dynamically
  • Fix race condition: await prepareDebugInfo() before test execution
  • Filter invalid test sources (node_modules, bazel-out) from BSP results
  • Support nested package paths (e.g., @//src/path/to/pkg:target)

Testing

  • Tested with simple TypeScript/Jest project (root package targets)
  • Tested with go-code monorepo (nested package targets)
  • Breakpoints work out of the box without manual configuration

…results

When the BSP server returns source items, filter out invalid paths that
should not be treated as test sources:
- node_modules paths (dependencies, not actual test files)
- bazel-out paths (compiled JS files, not source TS files)

This ensures that jest_test targets with complex dependency structures
are correctly handled, and the source inference fallback is triggered
when needed.

Added TypeScriptLanguageTools.isValidTestSource() static method to
centralize the validation logic.
- Add BazelInfoService to query execution_root, output_base, and platform
- Add TypeScriptLanguageTools.constructDebugRemoteRoot() to build runfiles path
- Fix race condition: await prepareDebugInfo() before test execution
- Dynamically inject localRoot/remoteRoot into debug config at runtime

This eliminates the need for manual sourceMapPathOverrides configuration
in launch.json. The debugger now automatically resolves paths based on
the Bazel execution environment and target being debugged.
Handle targets in nested packages (e.g., @//src/path/to/pkg:target) by
extracting and including the package path in the runfiles directory.

Previously only root package targets (@//:target) worked correctly.
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.

1 participant