Skip to content

Commit 42185fc

Browse files
committed
build: use ts_json_schema's ts output directly
This PR changes ts_json_schema to not create a ts_library rule for the json schema, and instead let consuming ts_libraries use and compile the resulting .ts files themselves. This is needed in order to maintain the module_name of the consuming libraries on the .ts files resulting from json compilation.
1 parent 30878e1 commit 42185fc

File tree

8 files changed

+55
-71
lines changed

8 files changed

+55
-71
lines changed

packages/angular/cli/BUILD.bazel

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,35 @@ ts_library(
1818
"**/*_spec.ts",
1919
"**/*_spec_large.ts",
2020
],
21-
),
21+
) + [
22+
"//packages/angular/cli:lib/config/schema.ts",
23+
"//packages/angular/cli:commands/analytics.ts",
24+
"//packages/angular/cli:commands/add.ts",
25+
"//packages/angular/cli:commands/build.ts",
26+
"//packages/angular/cli:commands/deploy.ts",
27+
"//packages/angular/cli:commands/config.ts",
28+
"//packages/angular/cli:commands/deprecated.ts",
29+
"//packages/angular/cli:commands/doc.ts",
30+
"//packages/angular/cli:commands/e2e.ts",
31+
"//packages/angular/cli:commands/easter-egg.ts",
32+
"//packages/angular/cli:commands/generate.ts",
33+
"//packages/angular/cli:commands/help.ts",
34+
"//packages/angular/cli:commands/lint.ts",
35+
"//packages/angular/cli:commands/new.ts",
36+
"//packages/angular/cli:commands/serve.ts",
37+
"//packages/angular/cli:commands/test.ts",
38+
"//packages/angular/cli:commands/update.ts",
39+
"//packages/angular/cli:commands/version.ts",
40+
"//packages/angular/cli:commands/run.ts",
41+
"//packages/angular/cli:commands/xi18n.ts",
42+
],
2243
data = glob([
2344
"**/*.json",
2445
"**/*.md",
2546
]),
2647
module_name = "@angular/cli",
2748
# strict_checks = False,
2849
deps = [
29-
":command_schemas",
3050
"//packages/angular_devkit/architect",
3151
"//packages/angular_devkit/architect:node",
3252
"//packages/angular_devkit/core",
@@ -45,33 +65,6 @@ ts_library(
4565
],
4666
)
4767

48-
ts_library(
49-
name = "command_schemas",
50-
srcs = [],
51-
deps = [
52-
":add_schema",
53-
":analytics_schema",
54-
":build_schema",
55-
":cli_schema",
56-
":config_schema",
57-
":deploy_schema",
58-
":deprecated_schema",
59-
":doc_schema",
60-
":e2e_schema",
61-
":easter_egg_schema",
62-
":generate_schema",
63-
":help_schema",
64-
":lint_schema",
65-
":new_schema",
66-
":run_schema",
67-
":serve_schema",
68-
":test_schema",
69-
":update_schema",
70-
":version_schema",
71-
":xi18n_schema",
72-
],
73-
)
74-
7568
ts_json_schema(
7669
name = "cli_schema",
7770
src = "lib/config/schema.json",

packages/angular/pwa/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ ts_library(
2424
"**/*_spec.ts",
2525
"**/*_spec_large.ts",
2626
],
27-
),
27+
) + [
28+
"//packages/angular/pwa:pwa/schema.ts",
29+
],
2830
deps = [
29-
":pwa_schema",
3031
"//packages/angular_devkit/core",
3132
"//packages/angular_devkit/schematics",
3233
"@npm//@types/node",

packages/angular_devkit/architect/BUILD.bazel

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ ts_library(
4949
# strict_checks = False,
5050
deps = [
5151
":architect",
52-
":builder_builders_schema",
53-
":builder_input_schema",
54-
":builder_output_schema",
5552
"//packages/angular_devkit/core",
5653
"//packages/angular_devkit/core:node",
5754
"@npm//@types/node",
@@ -67,15 +64,17 @@ ts_library(
6764
"**/*_spec.ts",
6865
"**/*_spec_large.ts",
6966
],
70-
),
67+
) + [
68+
"//packages/angular_devkit/architect:src/input-schema.ts",
69+
"//packages/angular_devkit/architect:src/output-schema.ts",
70+
"//packages/angular_devkit/architect:src/builders-schema.ts",
71+
"//packages/angular_devkit/architect:src/progress-schema.ts",
72+
],
7173
# strict_checks = False,
7274
data = glob(["**/*.json"]),
7375
module_name = "@angular-devkit/architect",
7476
module_root = "src/index.d.ts",
7577
deps = [
76-
":builder_input_schema",
77-
":builder_output_schema",
78-
":progress_schema",
7978
"//packages/angular_devkit/core",
8079
"//packages/angular_devkit/core:node",
8180
"@npm//@types/node",

packages/angular_devkit/build_webpack/BUILD.bazel

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ ts_library(
3030
"src/test-utils.ts",
3131
"src/**/*_spec.ts",
3232
],
33-
),
33+
) + [
34+
"//packages/angular_devkit/build_webpack:src/webpack/schema.ts",
35+
"//packages/angular_devkit/build_webpack:src/webpack-dev-server/schema.ts",
36+
],
3437
data = glob(
3538
include = [
3639
"package.json",
@@ -42,8 +45,6 @@ ts_library(
4245
module_name = "@angular-devkit/build-webpack",
4346
module_root = "src/index.d.ts",
4447
deps = [
45-
":webpack_schema",
46-
":webpack_dev_server_schema",
4748
"//packages/angular_devkit/architect",
4849
"//packages/angular_devkit/core",
4950
"@npm//@types/node",

packages/schematics/angular/BUILD.bazel

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ load("//tools:ts_json_schema.bzl", "ts_json_schema")
1212
package(default_visibility = ["//visibility:public"])
1313

1414
# Create a list of Tuple("path/file.json", "path_file") to be used as rules
15-
ALL_SCHEMA_TARGETS_PAIR = [
15+
ALL_SCHEMA_TARGETS = [
1616
(
1717
x,
1818
x.replace("/", "_").replace("-", "_").replace(".json", ""),
@@ -26,11 +26,9 @@ ALL_SCHEMA_TARGETS_PAIR = [
2626
name = name,
2727
src = src,
2828
)
29-
for (src, name) in ALL_SCHEMA_TARGETS_PAIR
29+
for (src, name) in ALL_SCHEMA_TARGETS
3030
]
3131

32-
ALL_SCHEMA_DEPS = [":" + name for (_, name) in ALL_SCHEMA_TARGETS_PAIR]
33-
3432
ts_library(
3533
name = "angular",
3634
srcs = glob(
@@ -45,10 +43,13 @@ ts_library(
4543
# Exclude test helpers.
4644
"utility/test/**/*.ts",
4745
],
48-
),
46+
) + [
47+
"//packages/schematics/angular:" + src.replace(".json", ".ts")
48+
for (src, _) in ALL_SCHEMA_TARGETS
49+
],
4950
module_name = "@schematics/angular",
5051
# strict_checks = False,
51-
deps = ALL_SCHEMA_DEPS + [
52+
deps = [
5253
"//packages/angular_devkit/core",
5354
"//packages/angular_devkit/schematics",
5455
"//packages/angular_devkit/schematics:tasks",
@@ -87,7 +88,7 @@ ts_library(
8788
),
8889
# @external_begin
8990
tsconfig = "//:tsconfig-test.json",
90-
deps = ALL_SCHEMA_DEPS + [
91+
deps = [
9192
":angular",
9293
"//packages/angular_devkit/core",
9394
"//packages/angular_devkit/core:node_testing",

packages/schematics/schematics/BUILD.bazel

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ ts_library(
2222
"blank/project-files/**",
2323
"blank/schematic-files/**",
2424
],
25-
),
25+
) + [
26+
"//packages/schematics/schematics:blank/schema.ts",
27+
"//packages/schematics/schematics:schematic/schema.ts",
28+
],
2629
deps = [
27-
":blank_schema",
28-
":schematic_schema",
2930
"//packages/angular_devkit/core",
3031
"//packages/angular_devkit/schematics",
3132
"//packages/angular_devkit/schematics:tasks",

packages/schematics/update/BUILD.bazel

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ ts_library(
2020
"**/*_spec_large.ts",
2121
"**/*_benchmark.ts",
2222
],
23-
),
23+
) + [
24+
"//packages/schematics/update:update/schema.ts",
25+
"//packages/schematics/update:migrate/schema.ts",
26+
],
2427
deps = [
25-
":migrate_schema",
26-
":update_schema",
2728
"//packages/angular_devkit/core",
2829
"//packages/angular_devkit/schematics",
2930
"//packages/angular_devkit/schematics:tasks",

tools/ts_json_schema.bzl

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ _ts_json_schema_interface = rule(
4646
)
4747
# @external_end
4848

49-
# Generates a library that contains the interface for a JSON Schema file. Takes a single `src`
50-
# argument as input, an optional data field for reference files, and produces a ts_library()
51-
# rule containing the typescript interface.
49+
# Generates a TS file that contains the interface for a JSON Schema file. Takes a single `src`
50+
# argument as input, an optional data field for reference files, and produces a
51+
# _ts_json_schema_interface() rule containing the typescript interface.
5252
# The file produced will have the same name, with the extension replaced from `.json` to `.ts`.
5353
# Any filename collision will be an error thrown by Bazel.
5454
def ts_json_schema(name, src, data = []):
@@ -61,17 +61,4 @@ def ts_json_schema(name, src, data = []):
6161
out = out,
6262
data = data,
6363
)
64-
# @external_end
65-
66-
ts_library(
67-
name = name,
68-
deps = [
69-
"@npm//@types/node",
70-
],
71-
# Remove these to empty the rule, since those files are also compiled elsewhere.
72-
# @external_begin
73-
srcs = [
74-
out,
75-
],
76-
# @external_end
77-
)
64+
# @external_end

0 commit comments

Comments
 (0)