Skip to content

Commit a309c1b

Browse files
committed
build: migrate all ts_library targets in tools/
Migrates all `ts_library` targets in `tools/` to use the `rules_js` `ts_project` rule.
1 parent daf0d2f commit a309c1b

File tree

20 files changed

+100
-141
lines changed

20 files changed

+100
-141
lines changed

Diff for: .aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Input hashes for repository rule npm_translate_lock(name = "npm2", pnpm_lock = "@//:pnpm-lock.yaml").
33
# This file should be checked into version control along with the pnpm-lock.yaml file.
44
.npmrc=-2023857461
5-
package.json=-713547691
5+
package.json=1433234131
66
pnpm-lock.yaml=-26661838
77
pnpm-workspace.yaml=1711114604
88
yarn.lock=824621907

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"integration-tests:size-test": "bazel test //integration/size-test/...",
4848
"test-linker-aot": "bazel test --partial_compilation --test_tag_filters=partial-compilation-integration,-firefox --build_tests_only -- //integration/... //src/...",
4949
"test-linker-jit": "bazel test --partial_compilation --test_tag_filters=partial-compilation-integration,-firefox --build_tests_only --//tools:force_partial_jit_compilation=True -- //integration/... //src/...",
50-
"check-tooling-setup": "yarn tsc --project tools/tsconfig.json && yarn tsc --project scripts/tsconfig.json && yarn tsc --project .ng-dev/tsconfig.json",
50+
"check-tooling-setup": "yarn tsc --project tools/tsconfig.json --noEmit && yarn tsc --project scripts/tsconfig.json --noEmit && yarn tsc --project .ng-dev/tsconfig.json --noEmit",
5151
"tsc": "node ./node_modules/typescript/bin/tsc",
5252
"ci-push-deploy-docs-app": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/docs-deploy/deploy-ci-push.mts",
5353
"ci-docs-monitor-test": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/docs-deploy/monitoring/ci-test.mts",

Diff for: tools/BUILD.bazel

+16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
2+
load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config")
23

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

6+
rules_js_tsconfig(
7+
name = "tsconfig",
8+
src = "tsconfig.json",
9+
deps = ["//:node_modules/@types/node"],
10+
)
11+
12+
rules_js_tsconfig(
13+
name = "tsconfig-test",
14+
src = "tsconfig-test.json",
15+
deps = [
16+
":tsconfig",
17+
"//:node_modules/@types/jasmine",
18+
],
19+
)
20+
521
# Bazel config setting that matches if the partial compilation flag
622
# for `@angular/bazel` is set to `True`.
723
config_setting(

Diff for: tools/dgeni/BUILD.bazel

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2-
load("//tools:defaults.bzl", "ts_library")
2+
load("//tools:defaults2.bzl", "ts_project")
33

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

@@ -16,18 +16,15 @@ nodejs_binary(
1616
templated_args = ["--bazel_patch_module_resolver"],
1717
)
1818

19-
ts_library(
19+
ts_project(
2020
name = "sources",
2121
srcs = glob(["**/*.ts"]),
22-
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
23-
devmode_module = "commonjs",
24-
tsconfig = ":tsconfig.json",
22+
tsconfig = "//tools:tsconfig",
2523
deps = [
26-
"//tools/highlight-files:sources",
27-
"@npm//@types/node",
28-
"@npm//dgeni",
29-
"@npm//dgeni-packages",
30-
"@npm//highlight.js",
31-
"@npm//typescript",
24+
"//:node_modules/dgeni",
25+
"//:node_modules/dgeni-packages",
26+
"//:node_modules/highlight.js",
27+
"//:node_modules/typescript",
28+
"//tools/highlight-files:sources_rjs",
3229
],
3330
)

Diff for: tools/example-module/BUILD.bazel

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2-
load("//tools:defaults.bzl", "ts_library")
2+
load("//tools:defaults2.bzl", "ts_project")
33

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

6-
ts_library(
6+
ts_project(
77
name = "example-module-lib",
88
srcs = glob(["**/*.ts"]),
9-
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
10-
devmode_module = "commonjs",
11-
tsconfig = ":tsconfig.json",
9+
tsconfig = "//tools:tsconfig",
1210
deps = [
13-
"@npm//@types/node",
14-
"@npm//typescript",
11+
"//:node_modules/typescript",
1512
],
1613
)
1714

Diff for: tools/extract-tokens/BUILD.bazel

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2-
load("//tools:defaults.bzl", "ts_library")
2+
load("//tools:defaults2.bzl", "ts_project")
33

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

6-
ts_library(
6+
ts_project(
77
name = "extract_tokens_lib",
88
srcs = glob(["**/*.ts"]),
9-
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
10-
devmode_module = "commonjs",
11-
tsconfig = ":tsconfig.json",
9+
tsconfig = "//tools:tsconfig",
1210
deps = [
13-
"//tools/highlight-files:sources",
14-
"@npm//@types/node",
15-
"@npm//sass",
11+
"//:node_modules/sass",
12+
"//tools/highlight-files:sources_rjs",
1613
],
1714
)
1815

Diff for: tools/highlight-files/BUILD.bazel

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2-
load("//tools:defaults.bzl", "ts_library")
2+
load("//tools:defaults2.bzl", "ts_project")
33

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

6-
ts_library(
6+
ts_project(
77
name = "sources",
88
srcs = glob(["**/*.ts"]),
9-
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
10-
devmode_module = "commonjs",
11-
tsconfig = ":tsconfig.json",
9+
tsconfig = "//tools:tsconfig",
1210
deps = [
13-
"//tools/region-parser",
14-
"@npm//@types/fs-extra",
15-
"@npm//@types/node",
16-
"@npm//fs-extra",
11+
"//:node_modules/@types/fs-extra",
12+
"//:node_modules/fs-extra",
13+
"//tools/region-parser:region-parser_rjs",
1714
],
1815
)
1916

Diff for: tools/markdown-to-html/BUILD.bazel

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2-
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
2+
load("//tools:defaults.bzl", "jasmine_node_test")
3+
load("//tools:defaults2.bzl", "ts_project")
34

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

6-
ts_library(
7+
ts_project(
78
name = "transform-markdown",
89
srcs = glob(
910
["**/*.ts"],
1011
exclude = [
1112
"*.spec.ts",
1213
],
1314
),
14-
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
15-
devmode_module = "commonjs",
16-
tsconfig = ":tsconfig.json",
15+
tsconfig = "//tools:tsconfig",
1716
deps = [
18-
"//tools/highlight-files:sources",
19-
"@npm//@types/marked",
20-
"@npm//@types/node",
21-
"@npm//marked",
17+
"//:node_modules/@types/marked",
18+
"//:node_modules/marked",
19+
"//tools/highlight-files:sources_rjs",
2220
],
2321
)
2422

@@ -33,16 +31,16 @@ nodejs_binary(
3331
templated_args = ["--bazel_patch_module_resolver"],
3432
)
3533

36-
ts_library(
34+
ts_project(
3735
name = "unit_test_lib",
3836
testonly = True,
3937
srcs = glob(
4038
["*.spec.ts"],
4139
),
42-
tsconfig = ":tsconfig.json",
40+
tsconfig = "//tools:tsconfig-test",
4341
visibility = ["//visibility:private"],
4442
deps = [
45-
":transform-markdown",
43+
":transform-markdown_rjs",
4644
"@npm//@types/jasmine",
4745
"@npm//@types/node",
4846
"@npm//marked",

Diff for: tools/markdown-to-html/docs-marked-renderer.spec.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ describe('DocsMarkdownRenderer', () => {
77
});
88

99
it('generates regular headings for h1 and h2', () => {
10-
expect(renderer.heading('a', 1, 'ignored')).toEqual('<h1>a</h1>');
11-
expect(renderer.heading('b', 2, 'ignored')).toEqual('<h2>b</h2>');
10+
expect(renderer.heading('a', 1, 'ignored')).toBe('<h1>a</h1>');
11+
expect(renderer.heading('b', 2, 'ignored')).toContain('<h2 ');
1212
});
1313

1414
it('creates header link for h3 and h4 headings', () => {
@@ -74,23 +74,28 @@ describe('DocsMarkdownRenderer', () => {
7474
const result = renderer.html(`<!-- example(
7575
{
7676
"example": "exampleName",
77-
"file": "example-html.html",
77+
"file": "example-html.html"
7878
}
7979
) -->`);
8080
expectEqualIgnoreLeadingWhitespace(
8181
result,
8282
`<div material-docs-example="exampleName"
83-
file="example-html.html"></div>`,
83+
file="example-html.html"
84+
></div>`,
8485
);
8586
});
8687

8788
it('generates html using new API with no file and no region', () => {
8889
const result = renderer.html(`<!-- example(
8990
{
90-
"example": "exampleName",
91+
"example": "exampleName"
9192
}
9293
) -->`);
93-
expectEqualIgnoreLeadingWhitespace(result, `<div material-docs-example="exampleName"></div>`);
94+
expectEqualIgnoreLeadingWhitespace(
95+
result,
96+
`<div material-docs-example="exampleName"
97+
></div>`,
98+
);
9499
});
95100

96101
it('generates html using old API', () => {

Diff for: tools/markdown-to-html/docs-marked-renderer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Renderer, Slugger} from 'marked';
22
import {basename, extname} from 'path';
33

44
/** Regular expression that matches example comments. */
5-
const exampleCommentRegex = /<!--\s*example\(([^)]+)\)\s*-->/g;
5+
const exampleCommentRegex = /<!--\s*example\(\s*([^)]+)\)\s*-->/g;
66

77
/**
88
* Custom renderer for marked that will be used to transform markdown files to HTML
@@ -80,7 +80,7 @@ export class DocsMarkdownRenderer extends Renderer {
8080
html = html.replace(exampleCommentRegex, (_match: string, content: string) => {
8181
// using [\s\S]* because .* does not match line breaks
8282
if (content.match(/\{[\s\S]*\}/g)) {
83-
const {example, file, region} = JSON.parse(content) as {
83+
const {example, file, region} = JSON.parse(content.trim()) as {
8484
example: string;
8585
file: string;
8686
region: string;

Diff for: tools/markdown-to-html/tsconfig.json

-14
This file was deleted.

Diff for: tools/package-docs-content/BUILD.bazel

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2-
load("//tools:defaults.bzl", "ts_library")
2+
load("//tools:defaults2.bzl", "ts_project")
33

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

@@ -15,14 +15,11 @@ nodejs_binary(
1515
templated_args = ["--bazel_patch_module_resolver"],
1616
)
1717

18-
ts_library(
18+
ts_project(
1919
name = "sources",
2020
srcs = glob(["**/*.ts"]),
21-
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
22-
devmode_module = "commonjs",
23-
tsconfig = ":tsconfig.json",
21+
tsconfig = "//tools:tsconfig",
2422
deps = [
25-
"@npm//@types/fs-extra",
26-
"@npm//@types/node",
23+
"//:node_modules/@types/fs-extra",
2724
],
2825
)

Diff for: tools/package-docs-content/tsconfig.json

-13
This file was deleted.

Diff for: tools/postcss/BUILD.bazel

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
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(
5+
ts_project(
66
name = "postcss",
77
srcs = [
88
"compare-nodes.ts",
99
],
10-
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
11-
devmode_module = "commonjs",
10+
tsconfig = "//tools:tsconfig",
1211
deps = [
13-
"@npm//postcss",
12+
"//:node_modules/postcss",
1413
],
1514
)

Diff for: tools/region-parser/BUILD.bazel

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
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(
5+
ts_project(
66
name = "region-parser",
77
srcs = glob(["**/*.ts"]),
8-
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
9-
devmode_module = "commonjs",
10-
tsconfig = ":tsconfig.json",
11-
deps = [
12-
"@npm//@types/node",
13-
],
8+
tsconfig = "//tools:tsconfig",
149
)

Diff for: tools/region-parser/tsconfig.json

-13
This file was deleted.

Diff for: tools/sass/BUILD.bazel

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2-
load("//tools:defaults.bzl", "ts_library")
2+
load("//tools:defaults2.bzl", "ts_project")
33

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

6-
ts_library(
6+
ts_project(
77
name = "sass_lib",
88
srcs = [
99
"compiler-main.ts",
1010
"local-sass-importer.ts",
1111
],
12-
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
13-
devmode_module = "commonjs",
12+
tsconfig = "//tools:tsconfig",
1413
deps = [
15-
"@npm//@bazel/worker",
16-
"@npm//@types/node",
17-
"@npm//@types/yargs",
18-
"@npm//sass",
19-
"@npm//yargs",
14+
"//:node_modules/@bazel/worker",
15+
"//:node_modules/@types/node",
16+
"//:node_modules/@types/yargs",
17+
"//:node_modules/sass",
18+
"//:node_modules/yargs",
2019
],
2120
)
2221

0 commit comments

Comments
 (0)