Skip to content

Commit a1bf58e

Browse files
devversionAndrewKushnir
authored andcommitted
build: migrate symbol-extractor to ts_project (#61156)
Migrates the symbol-extractor code to `ts_project`. PR Close #61156
1 parent 032b802 commit a1bf58e

File tree

13 files changed

+67
-74
lines changed

13 files changed

+67
-74
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ setup_dependencies_2()
258258

259259
git_repository(
260260
name = "rules_angular",
261-
commit = "f47fe935fecac02f02fe1337274207f00146a765",
261+
commit = "e35da7371d02d0c8d165c518d532d66be7afb8a6",
262262
remote = "https://github.com/devversion/rules_angular.git",
263263
)
264264

packages/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ ts_config(
3535
)
3636

3737
rules_js_tsconfig(
38-
name = "build-tsconfig",
38+
name = "tsconfig_build",
3939
src = "tsconfig-build.json",
4040
deps = [
4141
"//:node_modules/tslib",
4242
],
4343
)
4444

4545
rules_js_tsconfig(
46-
name = "test-tsconfig",
46+
name = "tsconfig_test",
4747
src = "tsconfig-test.json",
4848
deps = [
49-
":build-tsconfig",
49+
":tsconfig_build",
5050
"//:node_modules/@types/jasmine",
5151
],
5252
)

tools/BUILD.bazel

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config")
12
load("//tools:defaults.bzl", "ts_config")
23

34
package(default_visibility = ["//visibility:public"])
@@ -13,6 +14,21 @@ ts_config(
1314
deps = ["tsconfig.json"],
1415
)
1516

17+
rules_js_tsconfig(
18+
name = "tsconfig_build",
19+
src = "tsconfig.json",
20+
deps = ["//:node_modules/@types/node"],
21+
)
22+
23+
rules_js_tsconfig(
24+
name = "tsconfig_test",
25+
src = "tsconfig-test.json",
26+
deps = [
27+
":tsconfig_build",
28+
"//:node_modules/@types/jasmine",
29+
],
30+
)
31+
1632
platform(
1733
name = "rbe_ubuntu1604-angular",
1834
parents = ["@rbe_ubuntu1604_angular//config:platform"],

tools/bazel/ts_project_interop.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def ts_project(
106106
tsconfig = None,
107107
testonly = False,
108108
visibility = None,
109-
ignore_strict_deps = False,
109+
# TODO: Enable this for all `ts_project` targets at end of migration.
110+
ignore_strict_deps = True,
110111
enable_runtime_rnjs_interop = True,
111112
rule_impl = _ts_project,
112113
**kwargs):

tools/defaults2.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def ts_project(
1111
module_name = kwargs.pop("module_name", compute_module_name(testonly))
1212

1313
if tsconfig == None and native.package_name().startswith("packages"):
14-
tsconfig = "//packages:test-tsconfig" if testonly else "//packages:build-tsconfig"
14+
tsconfig = "//packages:tsconfig_test" if testonly else "//packages:tsconfig_build"
1515

1616
_ts_project(
1717
name,
@@ -31,7 +31,7 @@ def ng_project(
3131
module_name = kwargs.pop("module_name", compute_module_name(testonly))
3232

3333
if tsconfig == None and native.package_name().startswith("packages"):
34-
tsconfig = "//packages:test-tsconfig" if testonly else "//packages:build-tsconfig"
34+
tsconfig = "//packages:tsconfig_test" if testonly else "//packages:tsconfig_build"
3535
_ts_project(
3636
name,
3737
source_map = source_map,

tools/symbol-extractor/BUILD.bazel

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
1+
load("//tools:defaults.bzl", "jasmine_node_test")
2+
load("//tools:defaults2.bzl", "ts_project")
23

34
package(default_visibility = ["//visibility:public"])
45

5-
ts_library(
6+
ts_project(
67
name = "lib",
78
testonly = True,
89
srcs = glob(
@@ -12,25 +13,26 @@ ts_library(
1213
"**/*_spec",
1314
],
1415
),
16+
tsconfig = "//tools:tsconfig_build",
1517
deps = [
16-
"//packages:types",
17-
"@npm//@bazel/runfiles",
18-
"@npm//typescript",
18+
"//:node_modules/@bazel/runfiles",
19+
"//:node_modules/@types/jasmine",
20+
"//:node_modules/typescript",
1921
],
2022
)
2123

22-
ts_library(
24+
ts_project(
2325
name = "test_lib",
2426
testonly = 1,
2527
srcs = glob(
2628
["**/*_spec.ts"],
2729
exclude = ["symbol_extractor_spec/**"],
2830
),
31+
tsconfig = "//tools:tsconfig_test",
2932
deps = [
30-
":lib",
31-
"//packages:types",
32-
"@npm//@bazel/runfiles",
33-
"@npm//typescript",
33+
":lib_rjs",
34+
"//:node_modules/@bazel/runfiles",
35+
"//:node_modules/typescript",
3436
],
3537
)
3638

tools/symbol-extractor/index.bzl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.dev/license
55

6-
load("//tools:defaults.bzl", "nodejs_binary", "nodejs_test")
6+
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_test")
77

88
"""
99
This test verifies that a set of top level symbols from a javascript file match a gold file.
@@ -13,27 +13,26 @@ def js_expected_symbol_test(name, src, golden, data = [], **kwargs):
1313
"""This test verifies that a set of top level symbols from a javascript file match a gold file.
1414
"""
1515
all_data = data + [
16-
Label("//tools/symbol-extractor:lib"),
17-
Label("@npm//typescript"),
16+
Label("//tools/symbol-extractor:lib_rjs"),
1817
src,
1918
golden,
2019
]
21-
entry_point = "//tools/symbol-extractor:cli.ts"
20+
entry_point = "//tools/symbol-extractor:cli.js"
2221

23-
nodejs_test(
22+
js_test(
2423
name = name,
2524
data = all_data,
2625
entry_point = entry_point,
2726
tags = kwargs.pop("tags", []) + ["symbol_extractor"],
28-
templated_args = ["$(rootpath %s)" % src, "$(rootpath %s)" % golden],
27+
fixed_args = ["$(rootpath %s)" % src, "$(rootpath %s)" % golden],
2928
**kwargs
3029
)
3130

32-
nodejs_binary(
31+
js_binary(
3332
name = name + ".accept",
3433
testonly = True,
3534
data = all_data,
3635
entry_point = entry_point,
37-
templated_args = ["$(rootpath %s)" % src, "$(rootpath %s)" % golden, "--accept"],
36+
fixed_args = ["$(rootpath %s)" % src, "$(rootpath %s)" % golden, "--accept"],
3837
**kwargs
3938
)

tools/symbol-extractor/symbol_extractor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9+
/// <reference types="jasmine" />
10+
911
import ts from 'typescript';
1012

1113
export class SymbolExtractor {

tools/symbol-extractor/symbol_extractor_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('scenarios', () => {
4949
it('should properly capture classes in TypeScript ES2015 class output', () => {
5050
const jsFileContent = fs.readFileSync(
5151
runfiles.resolve(
52-
'angular/tools/symbol-extractor/symbol_extractor_spec/es2015_class_output.mjs',
52+
'angular/tools/symbol-extractor/symbol_extractor_spec/es2015_class_output.js',
5353
),
5454
'utf8',
5555
);

tools/symbol-extractor/symbol_extractor_spec/BUILD.bazel

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
load("//tools:defaults.bzl", "ts_library")
1+
load("//tools:defaults2.bzl", "ts_project")
22

33
package(default_visibility = ["//visibility:public"])
44

5-
ts_library(
6-
name = "es2015_class_output_lib",
7-
srcs = ["es2015_class_output.ts"],
8-
)
9-
10-
filegroup(
5+
ts_project(
116
name = "es2015_class_output",
12-
srcs = [":es2015_class_output_lib"],
13-
output_group = "es6_sources",
7+
srcs = ["es2015_class_output.ts"],
8+
tsconfig = "tsconfig.json",
149
)
1510

1611
filegroup(

0 commit comments

Comments
 (0)