Skip to content

Commit 59e8fa0

Browse files
committed
build: improve source map configuration for better debugging
This commit refactors the jasmine_test rule in tools/defaults.bzl to use the centralized version from @devinfra//bazel/jasmine:jasmine.bzl. This simplifies the rule by removing manual source-map-support handling. Source map generation has been standardized across the project by enabling the sourceMap option in the root tsconfig.json and removing conflicting inline source map settings from test-specific configurations. These changes significantly improve the developer experience by enabling breakpoints to be set directly within TypeScript source files when debugging tests in editors like VSCode. Additionally, the exclusion rules for .vscode/tasks.json and .vscode/launch.json have been removed from .gitignore, aligning with the standard practice of not tracking user-specific editor configurations.
1 parent 61d328b commit 59e8fa0

File tree

6 files changed

+6
-21
lines changed

6 files changed

+6
-21
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ jsconfig.json
3333
# https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore
3434
.vscode/
3535
!.vscode/settings.json
36-
!.vscode/tasks.json
37-
!.vscode/launch.json
3836
!.vscode/extensions.json
3937
**/*.code-workspace
4038

packages/schematics/angular/workspace/index_spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ describe('Workspace Schematic', () => {
2323

2424
it('should create all files of a workspace', async () => {
2525
const options = { ...defaultOptions };
26-
2726
const tree = await schematicRunner.runSchematic('workspace', options);
2827
const files = tree.files;
2928
expect(files).toEqual(

tools/defaults.bzl

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
2-
load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test")
32
load("@aspect_rules_js//js:defs.bzl", _js_binary = "js_binary")
3+
load("@devinfra//bazel/jasmine:jasmine.bzl", _jasmine_test = "jasmine_test")
44
load("@devinfra//bazel/ts_project:index.bzl", "strict_deps_test")
55
load("@rules_angular//src/ng_package:index.bzl", _ng_package = "ng_package")
66
load("@rules_angular//src/ts_project:index.bzl", _ts_project = "ts_project")
@@ -12,6 +12,7 @@ def ts_project(
1212
deps = [],
1313
tsconfig = None,
1414
testonly = False,
15+
source_map = True,
1516
visibility = None,
1617
**kwargs):
1718
if tsconfig == None:
@@ -21,6 +22,7 @@ def ts_project(
2122
name = name,
2223
testonly = testonly,
2324
declaration = True,
25+
source_map = source_map,
2426
tsconfig = tsconfig,
2527
visibility = visibility,
2628
deps = deps,
@@ -54,21 +56,15 @@ def ng_package(deps = [], **kwargs):
5456
**kwargs
5557
)
5658

57-
def jasmine_test(data = [], args = [], **kwargs):
58-
# Create relative path to root, from current package dir. Necessary as
59-
# we change the `chdir` below to the package directory.
60-
relative_to_root = "/".join([".."] * len(native.package_name().split("/")))
61-
59+
def jasmine_test(args = [], tsconfig = "//:test-tsconfig", **kwargs):
6260
_jasmine_test(
6361
node_modules = "//:node_modules",
62+
tsconfig = tsconfig,
6463
chdir = native.package_name(),
6564
args = [
66-
"--require=%s/node_modules/source-map-support/register.js" % relative_to_root,
67-
# Escape so that the `js_binary` launcher triggers Bash expansion.
6865
"'**/*+(.|_)spec.js'",
6966
"'**/*+(.|_)spec.mjs'",
7067
"'**/*+(.|_)spec.cjs'",
7168
] + args,
72-
data = data + ["//:node_modules/source-map-support"],
7369
**kwargs
7470
)

tsconfig-test-esm.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
{
77
"extends": "./tsconfig-build-esm.json",
88
"compilerOptions": {
9-
"sourceMap": false,
10-
"inlineSourceMap": true,
11-
"inlineSources": true,
129
"types": ["node", "jasmine"]
1310
}
1411
}

tsconfig-test.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"inlineSourceMap": true,
5-
"sourceRoot": ".",
6-
// Inline sources are necessary for our tests to show the proper sources, since we are using
7-
// Istanbul (not Constantinople) as well, and applying both source maps to get the original
8-
// source in devtools.
9-
"inlineSources": true,
104
"types": ["node", "jasmine"]
115
}
126
}

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"noImplicitOverride": true,
1111
"isolatedModules": true,
1212
"skipLibCheck": true,
13+
"sourceMap": true,
1314
"strict": true,
1415
"target": "es2023",
1516
"lib": ["es2023"],

0 commit comments

Comments
 (0)