Skip to content

Commit f66f136

Browse files
committed
build: build cdk with angular from source
* Continues the long-term Bazel goal by fixing the CDK bazel build targets. Also builds the CDK targets with Angular from source. Follow up's will try to make serving, and testing possible.
1 parent f194b37 commit f66f136

File tree

30 files changed

+193
-162
lines changed

30 files changed

+193
-162
lines changed

BUILD.bazel

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
# TODO(jelbourn): figure out if these workarounds are still needed
4-
5-
# TODO: Replace with fine-grained node_modules using `npm_install` / `yarn_install`.
6-
# TODO: See https://github.com/bazelbuild/rules_nodejs/wiki#migrating-to-rules_nodejs-013
7-
alias(
8-
name = "node_modules",
9-
actual = "@npm//:node_modules",
10-
)
11-
123
# Glob pattern that matches all Angular testing bundles.
134
ANGULAR_TESTING = [
145
"node_modules/@angular/*/bundles/*-testing.umd.js",

WORKSPACE

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ workspace(name = "angular_material")
33
# Add NodeJS rules (explicitly used for sass bundle rules)
44
http_archive(
55
name = "build_bazel_rules_nodejs",
6-
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.14.2.zip",
7-
strip_prefix = "rules_nodejs-0.14.2",
8-
sha256 = "af481421c9e74f754a693a8bf5e9409484e38cf7be6f73f85879bdc7ed1b1d82",
6+
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.15.0.zip",
7+
strip_prefix = "rules_nodejs-0.15.0",
8+
sha256 = "5f5b6464ca20aa63d278caaf4736f0381eb838800d7375132057a48f09d0b837",
99
)
1010

1111
# Add TypeScript rules
1212
http_archive(
1313
name = "build_bazel_rules_typescript",
14-
url = "https://github.com/bazelbuild/rules_typescript/archive/0.19.1.zip",
15-
strip_prefix = "rules_typescript-0.19.1",
16-
sha256 = "91a03623a03a463ffd62cea3f7a384c2f298af6438d5d153fc4d69aa5665b53d",
14+
url = "https://github.com/bazelbuild/rules_typescript/archive/0.20.2.zip",
15+
strip_prefix = "rules_typescript-0.20.2",
16+
sha256 = "2879fbd7168ba5d17db22bc2f585c0d1d3a82dd5e6f8af118e8b2f74d290024e",
1717
)
1818

1919
# Fetch transient dependencies of the TypeScript bazel rules.
@@ -31,6 +31,23 @@ http_archive(
3131
load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
3232
sass_repositories()
3333

34+
# Add Angular source and Bazel rules.
35+
http_archive(
36+
name = "angular",
37+
# Temporarily locked down to the angular/angular:bazel branch. This branch includes necessary
38+
# commits that make building from source possible.
39+
# TODO(devversion): switch to release archive if workaround can be removed
40+
url = "https://github.com/angular/angular/archive/08e4489cf5a93a352954f1639da5e92112993753.zip",
41+
strip_prefix = "angular-08e4489cf5a93a352954f1639da5e92112993753",
42+
sha256 = "a59c85426048cc95f51937d0c26f4d1143b7bef730152b68ac4b79d1438e746b",
43+
)
44+
45+
# Add RxJS from the node modules.
46+
local_repository(
47+
name = "rxjs",
48+
path = "node_modules/rxjs/src",
49+
)
50+
3451
# NOTE: this rule installs nodejs, npm, and yarn, but does NOT install
3552
# your npm dependencies. You must still run the package manager.
3653
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
@@ -54,14 +71,10 @@ yarn_install(
5471
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
5572
ts_setup_workspace()
5673

57-
# Add Angular rules
58-
local_repository(
59-
name = "angular",
60-
path = "node_modules/@angular/bazel",
61-
)
74+
# Setup Angular bazel rules
75+
load("@angular//packages/bazel:package.bzl", "rules_angular_dependencies")
76+
rules_angular_dependencies()
6277

63-
# Add rxjs
64-
local_repository(
65-
name = "rxjs",
66-
path = "node_modules/rxjs/src",
67-
)
78+
# Setup Angular workspace for building (Bazel managed node modules)
79+
load("@angular//:index.bzl", "ng_setup_workspace")
80+
ng_setup_workspace()

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"devDependencies": {
4646
"@angular-devkit/core": "7.0.0-rc.1",
4747
"@angular-devkit/schematics": "7.0.0-rc.1",
48-
"@angular/bazel": "7.0.0-rc.0",
4948
"@angular/compiler-cli": "7.0.0-rc.0",
5049
"@angular/http": "7.0.0-rc.0",
5150
"@angular/platform-browser-dynamic": "7.0.0-rc.0",

src/cdk/BUILD.bazel

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
2+
33
load("@angular//:index.bzl", "ng_package")
44
load("//:packages.bzl", "CDK_TARGETS", "ROLLUP_GLOBALS", "VERSION_PLACEHOLDER_REPLACEMENTS")
5+
load("//tools:defaults.bzl", "ng_module")
56

67
# Export the CDK tsconfig so that subpackages can reference it directly.
78
exports_files(["tsconfig-build.json"])
89

910
# Root "@angular/cdk" entry-point that does not re-export individual entry-points.
10-
ts_library(
11+
ng_module(
1112
name = "cdk",
1213
srcs = glob(["*.ts"], exclude=["**/*.spec.ts"]),
1314
module_name = "@angular/cdk",
14-
deps = [],
15-
tsconfig = "//src/lib:tsconfig-build.json",
15+
deps = [
16+
"@angular//packages/core",
17+
],
18+
tsconfig = ":tsconfig-build.json",
1619
)
1720

1821
# Creates the @angular/cdk package published to npm.

src/cdk/a11y/BUILD.bazel

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
2+
33
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library")
44
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
5-
5+
load("//tools:defaults.bzl", "ng_module")
66

77
ng_module(
88
name = "a11y",
99
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
1010
module_name = "@angular/cdk/a11y",
1111
deps = [
12+
"@angular//packages/common",
13+
"@angular//packages/core",
14+
"@rxjs",
15+
"@rxjs//operators",
1216
"//src/cdk/coercion",
1317
"//src/cdk/keycodes",
1418
"//src/cdk/observers",
1519
"//src/cdk/platform",
16-
"@rxjs",
1720
],
1821
tsconfig = "//src/cdk:tsconfig-build.json",
1922
)

src/cdk/accordion/BUILD.bazel

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
3-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
42

3+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
4+
load("//tools:defaults.bzl", "ng_module")
55

66
ng_module(
77
name = "accordion",
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/cdk/accordion",
1010
deps = [
11+
"@angular//packages/core",
12+
"@rxjs",
1113
"//src/cdk/coercion",
1214
"//src/cdk/collections",
13-
"@rxjs",
1415
],
1516
tsconfig = "//src/cdk:tsconfig-build.json",
1617
)

src/cdk/bidi/BUILD.bazel

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
3-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
42

3+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
4+
load("//tools:defaults.bzl", "ng_module")
55

66
ng_module(
77
name = "bidi",
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/cdk/bidi",
10-
deps = ["@rxjs"],
10+
deps = [
11+
"@angular//packages/common",
12+
"@angular//packages/core",
13+
],
1114
tsconfig = "//src/cdk:tsconfig-build.json",
1215
)
1316

1417
ts_library(
1518
name = "bidi_test_sources",
1619
testonly = 1,
1720
srcs = glob(["**/*.spec.ts"]),
18-
deps = [
19-
":bidi",
20-
"@rxjs",
21-
],
21+
deps = [":bidi"],
2222
tsconfig = "//src/cdk:tsconfig-build.json",
2323
)
2424

src/cdk/coercion/BUILD.bazel

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
3-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
4-
load("@angular//:index.bzl", "ng_module")
52

3+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
64

7-
ng_module(
5+
ts_library(
86
name = "coercion",
97
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
108
module_name = "@angular/cdk/coercion",
11-
deps = ["@rxjs"],
9+
deps = ["@npm//tslib"],
1210
tsconfig = "//src/cdk:tsconfig-build.json",
1311
)
1412

src/cdk/collections/BUILD.bazel

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
3-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
42

3+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
4+
load("//tools:defaults.bzl", "ng_module")
55

66
ng_module(
77
name = "collections",
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/cdk/collections",
10-
deps = ["@rxjs"],
10+
deps = [
11+
"@angular//packages/core",
12+
"@rxjs"
13+
],
1114
tsconfig = "//src/cdk:tsconfig-build.json",
1215
)
1316

src/cdk/drag-drop/BUILD.bazel

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
2+
33
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
44
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary")
5-
5+
load("//tools:defaults.bzl", "ng_module")
66

77
ng_module(
88
name = "drag-drop",
99
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
1010
module_name = "@angular/cdk/drag-drop",
1111
deps = [
12+
"@angular//packages/common",
13+
"@angular//packages/core",
1214
"@rxjs",
15+
"@rxjs//operators",
1316
"//src/cdk/platform",
1417
"//src/cdk/overlay",
1518
"//src/cdk/bidi",

src/cdk/keycodes/BUILD.bazel

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
3-
load("@angular//:index.bzl", "ng_module")
42

3+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
54

6-
ng_module(
5+
ts_library(
76
name = "keycodes",
87
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
98
module_name = "@angular/cdk/keycodes",
10-
deps = ["@rxjs"],
9+
deps = ["@npm//tslib"],
1110
tsconfig = "//src/cdk:tsconfig-build.json",
1211
)

src/cdk/layout/BUILD.bazel

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
3-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
42

3+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
4+
load("//tools:defaults.bzl", "ng_module")
55

66
ng_module(
77
name = "layout",
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/cdk/layout",
1010
deps = [
11+
"@angular//packages/core",
12+
"@rxjs",
13+
"@rxjs//operators",
1114
"//src/cdk/coercion",
1215
"//src/cdk/platform",
13-
"@rxjs",
1416
],
1517
tsconfig = "//src/cdk:tsconfig-build.json",
1618
)

src/cdk/observers/BUILD.bazel

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
3-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
42

3+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
4+
load("//tools:defaults.bzl", "ng_module")
55

66
ng_module(
77
name = "observers",
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/cdk/observers",
1010
deps = [
11+
"@angular//packages/core",
1112
"@rxjs",
13+
"@rxjs//operators",
1214
"//src/cdk/coercion",
1315
],
1416
tsconfig = "//src/cdk:tsconfig-build.json",

src/cdk/overlay/BUILD.bazel

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
2+
33
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library")
44
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
5+
load("//tools:defaults.bzl", "ng_module")
56

67
ng_module(
78
name = "overlay",
89
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
910
module_name = "@angular/cdk/overlay",
1011
deps = [
12+
"@angular//packages/common",
13+
"@angular//packages/core",
14+
"@rxjs",
15+
"@rxjs//operators",
1116
"//src/cdk/bidi",
1217
"//src/cdk/coercion",
1318
"//src/cdk/keycodes",
1419
"//src/cdk/platform",
1520
"//src/cdk/portal",
1621
"//src/cdk/scrolling",
17-
"@rxjs",
1822
],
1923
tsconfig = "//src/cdk:tsconfig-build.json",
2024
)

src/cdk/platform/BUILD.bazel

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
2+
3+
load("//tools:defaults.bzl", "ng_module")
34

45
ng_module(
56
name = "platform",
67
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
78
module_name = "@angular/cdk/platform",
8-
deps = ["@rxjs"],
9+
deps = [
10+
"@angular//packages/common",
11+
"@angular//packages/core",
12+
],
913
tsconfig = "//src/cdk:tsconfig-build.json",
1014
)

src/cdk/portal/BUILD.bazel

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
3-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
42

3+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
4+
load("//tools:defaults.bzl", "ng_module")
55

66
ng_module(
77
name = "portal",
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/cdk/portal",
10-
deps = ["@rxjs"],
10+
deps = [
11+
"@angular//packages/core",
12+
],
1113
tsconfig = "//src/cdk:tsconfig-build.json",
1214
)
1315

1416
ts_library(
1517
name = "portal_test_sources",
1618
testonly = 1,
1719
srcs = glob(["**/*.spec.ts"]),
18-
deps = [
19-
":portal",
20-
"@rxjs",
21-
],
20+
deps = [":portal"],
2221
tsconfig = "//src/cdk:tsconfig-build.json",
2322
)
2423

0 commit comments

Comments
 (0)