Skip to content

Commit 66999dd

Browse files
alan-agius4mmalerba
authored andcommitted
build: enable breakpoints in source files (angular#64220)
This commit revamps the debugging setup and enabling developers to set breakpoints directly in the source TypeScript files. Key changes include: - Updated `launch.json` with source map path overrides to correctly map compiled output back to the original source code. - Switched from `external` to `linked` sourcemaps in the Bazel build configuration for better debugging support. - Consolidated the recommended VSCode settings into the main `launch.json` and `tasks.json`, removing the separate `recommended-*.json` files. - Updated the debugging documentation to reflect the new, simplified workflow. These changes significantly improve the developer experience for contributors working on the language service, making it much easier to debug and troubleshoot issues. This applies to both the framework packages and vscode-ng-langugage-service. PR Close angular#64220
1 parent 90d3b7f commit 66999dd

File tree

13 files changed

+75
-221
lines changed

13 files changed

+75
-221
lines changed

.vscode/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ To use the recommended configurations follow the steps below:
88

99
- install the recommended extensions in `.vscode/extensions.json`
1010
- copy (or link) `.vscode/recommended-settings.json` to `.vscode/settings.json`
11-
- copy (or link) `.vscode/recommended-launch.json` to `.vscode/launch.json`
12-
- copy (or link) `.vscode/recommended-tasks.json` to `.vscode/tasks.json`
1311
- restart the editor
1412

1513
If you already have your custom workspace settings, you should instead manually merge the file contents.

.vscode/launch.json

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
"--disable-extensions",
1212
"--extensionDevelopmentPath=${workspaceFolder}/vscode-ng-language-service"
1313
],
14-
"outFiles": [
15-
"${workspaceFolder}/dist/bin/vscode-ng-language-service/client/index.js",
16-
"${workspaceFolder}/dist/bin/vscode-ng-language-service/server/index.js"
17-
],
18-
"preLaunchTask": "vsce: watch bundles"
14+
"preLaunchTask": "VSCE: watch bundles"
1915
},
2016
{
2117
"type": "extensionHost",
@@ -26,23 +22,63 @@
2622
"--disable-extensions",
2723
"--extensionDevelopmentPath=${workspaceFolder}/dist/bin/vscode-ng-language-service/npm/vscode-ng-language-service/vsix_sandbox"
2824
],
29-
"sourceMaps": false,
30-
"preLaunchTask": "vsce: package"
25+
"preLaunchTask": "VSCE: package"
3126
},
3227
{
28+
"name": "VSCE: Attach to Server",
3329
"type": "node",
3430
"request": "attach",
35-
"name": "VSCE: Attach to Server",
3631
"port": 6009,
3732
"restart": true,
33+
"sourceMaps": true,
34+
"skipFiles": ["<node_internals>/**"],
35+
"sourceMapPathOverrides": {
36+
"?:*/bin/*": "${workspaceFolder}/*"
37+
},
38+
"resolveSourceMapLocations": ["!**/node_modules/**"]
39+
},
40+
{
41+
"name": "DEBUG: Attach to bazel test",
42+
"type": "node",
43+
"request": "attach",
44+
"port": 9229,
45+
"restart": true,
46+
"timeout": 600000,
47+
"sourceMaps": true,
3848
"skipFiles": ["<node_internals>/**"],
39-
"outFiles": ["${workspaceFolder}/dist/bin/vscode-ng-language-service/server/index.js"]
49+
"sourceMapPathOverrides": {
50+
"?:*/bin/*": "${workspaceFolder}/*"
51+
},
52+
"resolveSourceMapLocations": ["!**/node_modules/**"]
53+
},
54+
{
55+
"name": "DEBUG: Run bazel test (Custom Target)",
56+
"type": "node",
57+
"request": "launch",
58+
"restart": true,
59+
"timeout": 600000,
60+
"runtimeExecutable": "pnpm",
61+
"runtimeArgs": ["bazel", "test", "${input:bazelTarget}", "--config=debug"],
62+
"console": "integratedTerminal",
63+
"cwd": "${workspaceFolder}"
4064
}
4165
],
4266
"compounds": [
4367
{
44-
"name": "VSCE: Dev Client + Server",
68+
"name": "VSCE: Dev Client + Attach to Server",
4569
"configurations": ["VSCE: Launch Dev Client", "VSCE: Attach to Server"]
70+
},
71+
{
72+
"name": "DEBUG: Run bazel test (Custom Target) + Attach",
73+
"configurations": ["DEBUG: Attach to bazel test", "DEBUG: Run bazel test (Custom Target)"]
74+
}
75+
],
76+
"inputs": [
77+
{
78+
"id": "bazelTarget",
79+
"type": "promptString",
80+
"description": "Enter the Bazel test target (e.g., //path/to/my:unit_test)",
81+
"default": "//packages/..."
4682
}
4783
]
4884
}

.vscode/recommended-launch.json

Lines changed: 0 additions & 75 deletions
This file was deleted.

.vscode/recommended-settings.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,5 @@
2121
".history": true
2222
},
2323
"git.ignoreLimitWarning": true,
24-
"gitlens.advanced.blame.customArguments": [
25-
"--ignore-revs-file .git-blame-ignore-revs"
26-
]
24+
"gitlens.advanced.blame.customArguments": ["--ignore-revs-file .git-blame-ignore-revs"]
2725
}

.vscode/recommended-tasks.json

Lines changed: 0 additions & 109 deletions
This file was deleted.

.vscode/tasks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"tasks": [
44
{
55
"type": "shell",
6-
"label": "vsce: watch bundles",
6+
"label": "VSCE: watch bundles",
77
"command": "pnpm --filter=ng-template run watch",
88
"isBackground": true,
99
"group": {
@@ -25,7 +25,7 @@
2525
},
2626
{
2727
"type": "shell",
28-
"label": "vsce: package",
28+
"label": "VSCE: package",
2929
"command": "pnpm --filter=ng-template run package"
3030
}
3131
]

contributing-docs/building-with-bazel.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,28 @@ First time setup:
9797
- Add the following to the `configurations` array:
9898

9999
```json
100-
{
101-
"type": "node",
102-
"request": "attach",
103-
"name": "Attach to Remote",
104-
"port": 9229
105-
}
100+
{
101+
"name": "Attach to Process",
102+
"type": "node",
103+
"request": "attach",
104+
"port": 9229,
105+
"restart": true,
106+
"timeout": 600000,
107+
"sourceMaps": true,
108+
"skipFiles": ["<node_internals>/**"],
109+
"sourceMapPathOverrides": {
110+
"?:*/bin/*": "${workspaceFolder}/*"
111+
},
112+
"resolveSourceMapLocations": ["!**/node_modules/**"]
113+
}
106114
```
107115

108-
**Setting breakpoints directly in your code files may not work in VSCode**. This is because the
109-
files you're actually debugging are built files that exist in a `./private/...` folder.
110-
The easiest way to debug a test for now is to add a `debugger` statement in the code
111-
and launch the bazel corresponding test (`pnpm bazel test <target> --config=debug`).
116+
The easiest way to debug a test for now is to add a `debugger` statement or add a break point
117+
in the code and launch the bazel corresponding test (`pnpm bazel test <target> --config=debug`).
112118

113119
Bazel will wait on a connection. Go to the debug view (by clicking on the sidebar or
114120
Apple+Shift+D on Mac) and click on the green play icon next to the configuration name
115-
(ie `Attach to Remote`).
121+
(ie `Attach to Process`).
116122

117123
### Debugging a Karma Test
118124

vscode-ng-language-service/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ expand_template_rule(
2626
"0.0.0-PLACEHOLDER": "{{BUILD_SCM_VERSION}}",
2727
},
2828
substitutions = {
29-
"../dist/bin/vscode-ng-language-service/client/index": "./index",
29+
"../dist/bin/vscode-ng-language-service/client/src/extension.js": "./index",
3030
},
3131
template = "package.json",
3232
)

vscode-ng-language-service/client/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ esbuild(
2929
# Do not enable minification. It seems to break the extension on Windows (with WSL). See #1198.
3030
minify = False,
3131
platform = "node",
32-
sourcemap = "external",
32+
sourcemap = "linked",
3333
visibility = ["//vscode-ng-language-service:__pkg__"],
3434
deps = [
3535
"//:node_modules/source-map-support",

vscode-ng-language-service/client/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export class AngularLanguageClient implements vscode.Disposable {
313313
// do not lazily evaluate the code so all breakpoints are respected
314314
'--nolazy',
315315
// If debugging port is changed, update .vscode/launch.json as well
316-
'--inspect=6009',
316+
'--inspect-brk=6009',
317317
],
318318
env: {
319319
NG_DEBUG: true,

0 commit comments

Comments
 (0)