Skip to content

Commit d4cccb7

Browse files
committed
build: migrate schematics to ts_project
Migrates all schematics code to `ts_project` and simplifies complexity/confusion around devmode,prodmode ESM and CommonJS.
1 parent 1f17456 commit d4cccb7

File tree

41 files changed

+411
-375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+411
-375
lines changed

.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This file should be checked into version control along with the pnpm-lock.yaml file.
44
.npmrc=-1406867100
55
package.json=-370577278
6-
pnpm-lock.yaml=-1162470554
7-
pnpm-workspace.yaml=1711114604
6+
pnpm-lock.yaml=1107477480
7+
pnpm-workspace.yaml=14857322
88
src/cdk/package.json=-908433069
99
yarn.lock=-987404687

WORKSPACE

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ yarn_install(
116116
"//:tools/postinstall/patches/@angular+build-tooling+0.0.0-1ebf18a3a60b182a3dbad12e9a149fd93af5c29b.patch",
117117
"//:tools/postinstall/patches/@bazel+concatjs+5.8.1.patch",
118118
"//:tools/postinstall/patches/tsec+0.2.2.patch",
119+
"//src/cdk:package.json",
119120
],
120121
# Currently disabled due to:
121122
# 1. Missing Windows support currently.

pnpm-lock.yaml

+9-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
packages:
22
- .
3+
- src/cdk

src/cdk/schematics/BUILD.bazel

+64-51
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,73 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
2-
load("//tools:defaults.bzl", "jasmine_node_test", "pkg_npm", "ts_library")
2+
load("//tools:defaults.bzl", "jasmine_node_test")
3+
load("//tools:defaults2.bzl", "npm_package", "ts_project")
4+
load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config")
35

46
package(default_visibility = ["//visibility:public"])
57

68
copy_to_bin(
79
name = "schematics_assets",
8-
srcs = glob([
9-
"**/files/**/*",
10-
"**/*.json",
11-
]),
10+
srcs = glob(
11+
[
12+
"**/files/**/*",
13+
"**/*.json",
14+
],
15+
exclude = [
16+
"tsconfig.json",
17+
"tsconfig-test.json",
18+
"package.json",
19+
],
20+
),
21+
)
22+
23+
copy_to_bin(
24+
name = "package_json",
25+
srcs = ["package.json"],
1226
)
1327

14-
ts_library(
28+
rules_js_tsconfig(
29+
name = "tsconfig",
30+
src = "tsconfig.json",
31+
)
32+
33+
ts_project(
1534
name = "schematics",
1635
srcs = glob(
1736
["**/*.ts"],
1837
exclude = [
19-
"**/files/**/*.ts",
38+
"**/files/**/*",
2039
"**/*.spec.ts",
2140
"testing/**/*.ts",
2241
],
2342
),
24-
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
25-
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
26-
devmode_module = "commonjs",
27-
prodmode_module = "commonjs",
28-
tsconfig = ":tsconfig.json",
29-
deps = [
43+
interop_deps = [
3044
"//src/cdk/schematics/update-tool",
31-
"@npm//@schematics/angular",
32-
"@npm//@angular-devkit/core",
33-
"@npm//@angular-devkit/schematics",
34-
# TODO(devversion): Only include jasmine for test sources (See: tsconfig types).
35-
"@npm//@types/jasmine",
36-
"@npm//@types/glob",
37-
"@npm//@types/node",
38-
"@npm//glob",
39-
"@npm//parse5",
40-
"@npm//typescript",
4145
],
42-
)
43-
44-
# This package is intended to be combined into the main @angular/cdk package as a dep.
45-
pkg_npm(
46-
name = "npm_package",
47-
srcs = ["package.json"],
46+
tsconfig = "tsconfig.json",
4847
deps = [
49-
":schematics",
50-
":schematics_assets",
48+
"//:node_modules/@angular-devkit/core",
49+
"//:node_modules/@angular-devkit/schematics",
50+
"//:node_modules/@schematics/angular",
51+
"//:node_modules/@types/glob",
52+
"//:node_modules/@types/node",
53+
"//:node_modules/glob",
54+
"//:node_modules/parse5",
55+
"//:node_modules/typescript",
5156
],
5257
)
5358

54-
### Testing rules
55-
56-
jasmine_node_test(
57-
name = "unit_tests",
58-
srcs = [":unit_test_sources"],
59-
data = [
59+
# This package is intended to be combined into the main @angular/cdk package as a dep.
60+
npm_package(
61+
name = "npm_package",
62+
srcs = [
63+
"package.json",
6064
":schematics_assets",
65+
":schematics_rjs",
6166
],
67+
package = "@angular/cdk/schematics",
6268
)
6369

64-
ts_library(
70+
ts_project(
6571
name = "unit_test_sources",
6672
testonly = True,
6773
srcs = glob(
@@ -71,21 +77,28 @@ ts_library(
7177
"**/files/**/*.spec.ts",
7278
],
7379
),
74-
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
75-
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
76-
devmode_module = "commonjs",
77-
prodmode_module = "commonjs",
78-
tsconfig = ":tsconfig.json",
79-
deps = [
80-
":schematics",
80+
extends = "tsconfig.json",
81+
interop_deps = [
8182
"//src/cdk/schematics/testing",
8283
"//src/cdk/schematics/update-tool",
8384
"//src/cdk/testing/private",
84-
"@npm//@angular-devkit/schematics",
85-
"@npm//@bazel/runfiles",
86-
"@npm//@schematics/angular",
87-
"@npm//@types/jasmine",
88-
"@npm//@types/node",
89-
"@npm//typescript",
85+
],
86+
tsconfig = "tsconfig-test.json",
87+
deps = [
88+
":schematics_rjs",
89+
"//:node_modules/@angular-devkit/schematics",
90+
"//:node_modules/@bazel/runfiles",
91+
"//:node_modules/@schematics/angular",
92+
"//:node_modules/@types/jasmine",
93+
"//:node_modules/@types/node",
94+
"//:node_modules/typescript",
95+
],
96+
)
97+
98+
jasmine_node_test(
99+
name = "unit_tests",
100+
srcs = [":unit_test_sources"],
101+
data = [
102+
":schematics_assets",
90103
],
91104
)
+18-17
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
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 = "testing",
77
testonly = True,
88
srcs = glob(["**/*.ts"]),
9-
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
10-
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
11-
devmode_module = "commonjs",
12-
prodmode_module = "commonjs",
9+
# Needed to ensure these files are picked up as CommonJS, as otherwise
10+
# the higher-level `package.json` from `src/package.json` is `type: module`.
11+
data = ["//src/cdk/schematics:package_json"],
12+
extends = "//src/cdk/schematics:tsconfig",
1313
tsconfig = "tsconfig.json",
1414
deps = [
15-
"@npm//@angular-devkit/core",
16-
"@npm//@angular-devkit/schematics",
17-
"@npm//@bazel/runfiles",
18-
"@npm//@schematics/angular",
19-
"@npm//@types/fs-extra",
20-
"@npm//@types/glob",
21-
"@npm//@types/jasmine",
22-
"@npm//@types/node",
23-
"@npm//fs-extra",
24-
"@npm//jsonc-parser",
25-
"@npm//rxjs",
15+
"//:node_modules/@angular-devkit/core",
16+
"//:node_modules/@angular-devkit/schematics",
17+
"//:node_modules/@bazel/runfiles",
18+
"//:node_modules/@schematics/angular",
19+
"//:node_modules/@types/fs-extra",
20+
"//:node_modules/@types/glob",
21+
"//:node_modules/@types/jasmine",
22+
"//:node_modules/@types/node",
23+
"//:node_modules/fs-extra",
24+
"//:node_modules/glob",
25+
"//:node_modules/jsonc-parser",
26+
"//:node_modules/rxjs",
2627
],
2728
)
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2+
"extends": "../tsconfig.json",
23
"compilerOptions": {
34
"strict": true,
45
"lib": ["es2015"],
56
"types": ["node", "jasmine", "glob"]
6-
}
7+
},
8+
"exclude": []
79
}

src/cdk/schematics/tsconfig-test.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"types": ["jasmine", "node"]
5+
},
6+
"exclude": []
7+
}

src/cdk/schematics/tsconfig.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"lib": ["es2017"],
55
"module": "commonjs",
66
"moduleResolution": "node",
7-
"outDir": "../../../dist/packages/cdk/schematics",
8-
"noEmitOnError": false,
7+
"rootDir": ".",
98
"strictNullChecks": true,
109
"noPropertyAccessFromIndexSignature": true,
10+
"strict": true,
1111
"useUnknownInCatchVariables": true,
1212
"noImplicitOverride": true,
1313
"noImplicitReturns": true,
@@ -22,8 +22,5 @@
2222
"target": "es2015",
2323
"types": ["jasmine", "node"]
2424
},
25-
"exclude": ["**/files/**/*", "**/*.spec.ts", "ng-update/test-cases/**/*", "testing/**/*.ts"],
26-
"bazelOptions": {
27-
"suppressTsconfigOverrideWarnings": true
28-
}
25+
"exclude": ["**/files/**/*", "**/*.spec.ts", "ng-update/test-cases/**/*", "testing/**/*.ts"]
2926
}
+5-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +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 = "update-tool",
77
srcs = glob(["**/*.ts"]),
8-
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
9-
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
10-
devmode_module = "commonjs",
11-
prodmode_module = "commonjs",
8+
extends = "//src/cdk/schematics:tsconfig",
129
tsconfig = ":tsconfig.json",
1310
deps = [
14-
"@npm//@types/node",
15-
"@npm//typescript",
11+
"//:node_modules/@types/node",
12+
"//:node_modules/typescript",
1613
],
1714
)
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2+
"extends": "../tsconfig.json",
23
"compilerOptions": {
34
"strict": true,
45
"lib": ["es2015"],
56
"types": ["node", "glob"]
6-
}
7+
},
8+
"exclude": []
79
}
+17-10
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
2-
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
2+
load("//tools:defaults.bzl", "pkg_npm")
3+
load("//tools:defaults2.bzl", "ts_project")
4+
load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config")
35

46
package(default_visibility = ["//visibility:public"])
57

68
copy_to_bin(
79
name = "schematics_assets",
8-
srcs = glob(["**/*.json"]),
10+
srcs = glob(
11+
["**/*.json"],
12+
exclude = ["tsconfig.json"],
13+
),
14+
)
15+
16+
rules_js_tsconfig(
17+
name = "tsconfig",
18+
src = "tsconfig.json",
919
)
1020

11-
ts_library(
21+
ts_project(
1222
name = "schematics",
1323
srcs = glob(
1424
["**/*.ts"],
1525
exclude = ["**/*.spec.ts"],
1626
),
17-
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
18-
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
19-
devmode_module = "commonjs",
20-
prodmode_module = "commonjs",
27+
tsconfig = ":tsconfig",
2128
deps = [
22-
"@npm//@angular-devkit/schematics",
23-
"@npm//@types/node",
29+
"//:node_modules/@angular-devkit/schematics",
30+
"//:node_modules/@types/node",
2431
],
2532
)
2633

@@ -30,6 +37,6 @@ pkg_npm(
3037
deps = [
3138
":schematics",
3239
":schematics_assets",
33-
"//src/google-maps/schematics/ng-update:ng_update_index",
40+
"//src/google-maps/schematics/ng-update",
3441
],
3542
)

src/google-maps/schematics/migration.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"migration-v20": {
44
"version": "20.0.0-0",
55
"description": "Updates the Angular Google Maps package to v20",
6-
"factory": "./ng-update/index_bundled#updateToV20"
6+
"factory": "./ng-update/index#updateToV20"
77
}
88
}
99
}

0 commit comments

Comments
 (0)