Skip to content

Commit 150c964

Browse files
gregmagolanjelbourn
authored andcommittedNov 2, 2018
fix: bazel support for downstream apps (#13836)
1 parent 94c60d6 commit 150c964

22 files changed

+4321
-154
lines changed
 

‎WORKSPACE

+13-6
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ http_archive(
1717
# Add Angular source and Bazel rules.
1818
http_archive(
1919
name = "angular",
20-
url = "https://github.com/angular/angular/archive/7.0.1.zip",
21-
strip_prefix = "angular-7.0.1",
20+
url = "https://github.com/angular/angular/archive/7.0.2.zip",
21+
strip_prefix = "angular-7.0.2",
2222
)
2323

2424
# Add RxJS as repository because those are needed in order to build Angular from source.
2525
# Also we cannot refer to the RxJS version from the node modules because self-managed
2626
# node modules are not guaranteed to be installed.
27+
# TODO(gmagolan): remove this once rxjs ships with an named UMD bundle and we
28+
# are no longer building it from source.
2729
http_archive(
2830
name = "rxjs",
2931
url = "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz",
@@ -72,12 +74,14 @@ node_repositories(
7274
yarn_version = "1.9.4",
7375
)
7476

75-
# Use Bazel managed node modules. See more below:
76-
# https://github.com/bazelbuild/rules_nodejs#bazel-managed-vs-self-managed-dependencies
77+
# @npm is temporarily needed to build @rxjs from source since its ts_library
78+
# targets will depend on an @npm workspace by default.
79+
# TODO(gmagolan): remove this once rxjs ships with an named UMD bundle and we
80+
# are no longer building it from source.
7781
yarn_install(
7882
name = "npm",
79-
package_json = "//:package.json",
80-
yarn_lock = "//:yarn.lock",
83+
package_json = "//tools:npm/package.json",
84+
yarn_lock = "//tools:npm/yarn.lock",
8185
)
8286

8387
# Setup TypeScript Bazel workspace
@@ -88,6 +92,9 @@ ts_setup_workspace()
8892
load("@angular//:index.bzl", "ng_setup_workspace")
8993
ng_setup_workspace()
9094

95+
load("@angular_material//:index.bzl", "angular_material_setup_workspace")
96+
angular_material_setup_workspace()
97+
9198
# Setup Go toolchain (required for Bazel web testing rules)
9299
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
93100
go_rules_dependencies()

‎index.bzl

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright Google LLC All Rights Reserved.
2+
#
3+
# Use of this source code is governed by an MIT-style license that can be
4+
# found in the LICENSE file at https://angular.io/license
5+
"""Public API surface is re-exported here.
6+
7+
This API is exported for users building Angular Material from source in
8+
downstream projects.
9+
"""
10+
11+
load("//tools:angular_material_setup_workspace.bzl",
12+
_angular_material_setup_workspace = "angular_material_setup_workspace")
13+
14+
angular_material_setup_workspace = _angular_material_setup_workspace

‎package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
"version": "7.0.2",
3030
"requiredAngularVersion": ">=7.0.0",
3131
"dependencies": {
32-
"@angular/animations": "^7.0.0",
33-
"@angular/common": "^7.0.0",
34-
"@angular/compiler": "^7.0.0",
35-
"@angular/core": "^7.0.0",
36-
"@angular/elements": "^7.0.0",
37-
"@angular/forms": "^7.0.0",
38-
"@angular/platform-browser": "^7.0.0",
32+
"@angular/animations": "^7.0.2",
33+
"@angular/common": "^7.0.2",
34+
"@angular/compiler": "^7.0.2",
35+
"@angular/core": "^7.0.2",
36+
"@angular/elements": "^7.0.2",
37+
"@angular/forms": "^7.0.2",
38+
"@angular/platform-browser": "^7.0.2",
3939
"@webcomponents/custom-elements": "^1.1.0",
4040
"core-js": "^2.4.1",
4141
"rxjs": "^6.3.3",
@@ -47,13 +47,13 @@
4747
"devDependencies": {
4848
"@angular-devkit/core": "^7.0.1",
4949
"@angular-devkit/schematics": "^7.0.1",
50-
"@angular/bazel": "7.0.1",
51-
"@angular/compiler-cli": "^7.0.0",
52-
"@angular/http": "^7.0.0",
53-
"@angular/platform-browser-dynamic": "^7.0.0",
54-
"@angular/platform-server": "^7.0.0",
55-
"@angular/router": "^7.0.0",
56-
"@angular/upgrade": "^7.0.0",
50+
"@angular/bazel": "^7.0.2",
51+
"@angular/compiler-cli": "^7.0.2",
52+
"@angular/http": "^7.0.2",
53+
"@angular/platform-browser-dynamic": "^7.0.2",
54+
"@angular/platform-server": "^7.0.2",
55+
"@angular/router": "^7.0.2",
56+
"@angular/upgrade": "^7.0.2",
5757
"@bazel/ibazel": "0.6.0",
5858
"@bazel/karma": "0.20.3",
5959
"@bazel/typescript": "0.20.3",

‎src/cdk/coercion/BUILD.bazel

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ ts_library(
66
name = "coercion",
77
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
88
module_name = "@angular/cdk/coercion",
9-
deps = ["@npm//tslib"],
9+
deps = ["@matdeps//tslib"],
1010
)
1111

1212
ts_library(
1313
name = "coercion_test_sources",
1414
srcs = glob(["**/*.spec.ts"]),
1515
deps = [
16-
"@npm//@types/jasmine",
16+
"@matdeps//@types/jasmine",
1717
":coercion"
1818
],
1919
testonly = 1,

‎src/cdk/collections/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ts_library(
1616
name = "collections_test_sources",
1717
srcs = glob(["**/*.spec.ts"]),
1818
deps = [
19-
"@npm//@types/jasmine",
19+
"@matdeps//@types/jasmine",
2020
":collections"
2121
],
2222
testonly = 1,

‎src/cdk/keycodes/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ ts_library(
66
name = "keycodes",
77
module_name = "@angular/cdk/keycodes",
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
9-
deps = ["@npm//tslib"],
9+
deps = ["@matdeps//tslib"],
1010
)

‎src/cdk/schematics/BUILD.bazel

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
43
load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
54
load("//:packages.bzl", "VERSION_PLACEHOLDER_REPLACEMENTS")
6-
load("//tools:defaults.bzl", "jasmine_node_test")
5+
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
76

87
# TODO(devversion): remove when https://github.com/bazelbuild/rules_nodejs/issues/352 is fixed
98
exports_files(["#bazel_workaround.txt"])
@@ -24,15 +23,15 @@ ts_library(
2423
]),
2524
tsconfig = ":tsconfig.json",
2625
deps = [
27-
"@npm//@schematics/angular",
28-
"@npm//@angular-devkit/schematics",
26+
"@matdeps//@schematics/angular",
27+
"@matdeps//@angular-devkit/schematics",
2928
# TODO(devversion): Only include jasmine for test sources (See: tsconfig types).
30-
"@npm//@types/jasmine",
31-
"@npm//@types/node",
32-
"@npm//glob",
33-
"@npm//parse5",
34-
"@npm//tslint",
35-
"@npm//typescript"
29+
"@matdeps//@types/jasmine",
30+
"@matdeps//@types/node",
31+
"@matdeps//glob",
32+
"@matdeps//parse5",
33+
"@matdeps//tslint",
34+
"@matdeps//typescript"
3635
],
3736
)
3837

@@ -57,13 +56,13 @@ ts_library(
5756
srcs = glob(["**/*.spec.ts"], exclude = ["**/files/**/*.spec.ts"]),
5857
deps = [
5958
"//src/cdk/schematics/testing",
60-
"@npm//@schematics/angular",
61-
"@npm//@angular-devkit/schematics",
62-
"@npm//@types/jasmine",
63-
"@npm//@types/node",
64-
"@npm//mock-fs",
65-
"@npm//tslint",
66-
"@npm//typescript",
59+
"@matdeps//@schematics/angular",
60+
"@matdeps//@angular-devkit/schematics",
61+
"@matdeps//@types/jasmine",
62+
"@matdeps//@types/node",
63+
"@matdeps//mock-fs",
64+
"@matdeps//tslint",
65+
"@matdeps//typescript",
6766
":schematics",
6867
],
6968
tsconfig = ":tsconfig.json",

‎src/cdk/schematics/testing/BUILD.bazel

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ ts_library(
77
module_name = "@angular/cdk/schematics/testing",
88
srcs = glob(["**/*.ts"]),
99
deps = [
10-
"@npm//@angular-devkit/core",
11-
"@npm//@angular-devkit/schematics",
12-
"@npm//@schematics/angular",
13-
"@npm//@types/node",
14-
"@npm//@types/fs-extra",
15-
"@npm//fs-extra",
16-
"@npm//rxjs",
10+
"@matdeps//@angular-devkit/core",
11+
"@matdeps//@angular-devkit/schematics",
12+
"@matdeps//@schematics/angular",
13+
"@matdeps//@types/node",
14+
"@matdeps//@types/fs-extra",
15+
"@matdeps//fs-extra",
16+
"@matdeps//rxjs",
1717
],
1818
)

‎src/lib/form-field/BUILD.bazel

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ng_module(
1010
assets = [
1111
":form-field.css",
1212
":form-field-fill.css",
13+
":form-field-input.css",
1314
":form-field-legacy.css",
1415
":form-field-outline.css",
1516
":form-field-standard.css",
16-
"//src/lib/input:input.css"
1717
] + glob(["**/*.html"]),
1818
deps = [
1919
"@angular//packages/animations",
@@ -49,6 +49,12 @@ sass_binary(
4949
deps = ["//src/lib/core:core_scss_lib"],
5050
)
5151

52+
sass_binary(
53+
name = "form_field_input_scss",
54+
src = "form-field-input.scss",
55+
deps = ["//src/lib/core:core_scss_lib"],
56+
)
57+
5258
sass_binary(
5359
name = "form_field_legacy_scss",
5460
src = "form-field-legacy.scss",
File renamed without changes.

‎src/lib/form-field/form-field.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,16 @@ export const MAT_FORM_FIELD_DEFAULT_OPTIONS =
9999
selector: 'mat-form-field',
100100
exportAs: 'matFormField',
101101
templateUrl: 'form-field.html',
102-
// MatInput is a directive and can't have styles, so we need to include its styles here.
103-
// The MatInput styles are fairly minimal so it shouldn't be a big deal for people who
104-
// aren't using MatInput.
102+
// MatInput is a directive and can't have styles, so we need to include its styles here
103+
// in form-field-input.css. The MatInput styles are fairly minimal so it shouldn't be a
104+
// big deal for people who aren't using MatInput.
105105
styleUrls: [
106106
'form-field.css',
107107
'form-field-fill.css',
108+
'form-field-input.css',
108109
'form-field-legacy.css',
109110
'form-field-outline.css',
110111
'form-field-standard.css',
111-
'../input/input.css',
112112
],
113113
animations: [matFormFieldAnimations.transitionMessages],
114114
host: {

‎src/lib/input/BUILD.bazel

+1-9
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ ng_module(
77
name = "input",
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/material/input",
10-
assets = [
11-
":input.css",
12-
] + glob(["**/*.html"]),
10+
assets = glob(["**/*.html"]),
1311
deps = [
1412
"@angular//packages/common",
1513
"@angular//packages/core",
@@ -29,12 +27,6 @@ filegroup(
2927
srcs = glob(["**/_*.scss"]),
3028
)
3129

32-
sass_binary(
33-
name = "input_scss",
34-
src = "input.scss",
35-
deps = ["//src/lib/core:core_scss_lib"],
36-
)
37-
3830
sass_library(
3931
name = "theme",
4032
srcs = glob(["**/*-theme.scss"]),

‎src/lib/schematics/BUILD.bazel

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
43
load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
54
load("//:packages.bzl", "VERSION_PLACEHOLDER_REPLACEMENTS")
6-
load("//tools:defaults.bzl", "jasmine_node_test")
5+
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
76

87
filegroup(
98
name = "schematics_assets",
@@ -20,13 +19,13 @@ ts_library(
2019
]),
2120
deps = [
2221
"//src/cdk/schematics",
23-
"@npm//@angular-devkit/schematics",
24-
"@npm//@schematics/angular",
22+
"@matdeps//@angular-devkit/schematics",
23+
"@matdeps//@schematics/angular",
2524
# TODO(devversion): Only include jasmine for test sources (See: tsconfig types).
26-
"@npm//@types/jasmine",
27-
"@npm//@types/node",
28-
"@npm//tslint",
29-
"@npm//typescript",
25+
"@matdeps//@types/jasmine",
26+
"@matdeps//@types/node",
27+
"@matdeps//tslint",
28+
"@matdeps//typescript",
3029
],
3130
tsconfig = ":tsconfig.json",
3231
)
@@ -54,10 +53,10 @@ ts_library(
5453
":schematics",
5554
"//src/cdk/schematics",
5655
"//src/cdk/schematics/testing",
57-
"@npm//@schematics/angular",
58-
"@npm//@angular-devkit/schematics",
59-
"@npm//@types/jasmine",
60-
"@npm//@types/node",
56+
"@matdeps//@schematics/angular",
57+
"@matdeps//@angular-devkit/schematics",
58+
"@matdeps//@types/jasmine",
59+
"@matdeps//@types/node",
6160
],
6261
tsconfig = ":tsconfig.json",
6362
testonly = True,

‎src/material-moment-adapter/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ng_module(
1010
module_name = "@angular/material-moment-adapter",
1111
deps = [
1212
"@angular//packages/core",
13-
"@npm//moment",
13+
"@matdeps//moment",
1414
"//src/lib/core"
1515
],
1616
# Explicitly specify the tsconfig that is also used by Gulp. We need to explicitly use this

‎test/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ts_library(
99
deps = [
1010
"@angular//packages/core/testing",
1111
"@angular//packages/platform-browser-dynamic/testing",
12-
"@npm//@types/jasmine",
12+
"@matdeps//@types/jasmine",
1313
],
1414
# This file *must* end with "spec" in order for ts_web_test to load it.
1515
srcs = ["angular-test-init-spec.ts"],

‎tools/BUILD.bazel

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
2+
load("//tools:defaults.bzl", "ts_library")
33
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
44

55

66
ts_library(
77
name = "sass_bundle_lib",
88
srcs = ["sass_bundle.ts"],
99
deps = [
10-
"@npm//@types/node",
11-
"@npm//scss-bundle",
10+
"@matdeps//@types/node",
11+
"@matdeps//scss-bundle",
1212
],
1313
tsconfig = "bazel-tools-tsconfig.json",
1414
)
@@ -17,7 +17,7 @@ ts_library(
1717
nodejs_binary(
1818
name = "sass_bundle",
1919
data = [
20-
"@npm//scss-bundle",
20+
"@matdeps//scss-bundle",
2121
":sass_bundle_lib",
2222
],
2323
entry_point = "angular_material/tools/sass_bundle.js",
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright Google LLC All Rights Reserved.
2+
#
3+
# Use of this source code is governed by an MIT-style license that can be
4+
# found in the LICENSE file at https://angular.io/license
5+
"""Install Angular Material source dependencies"""
6+
7+
load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")
8+
9+
def angular_material_setup_workspace():
10+
"""This repository rule should be called from your WORKSPACE file.
11+
12+
It creates some additional Bazel external repositories that are used internally
13+
to build Angular Material
14+
"""
15+
# Use Bazel managed node modules. See more below:
16+
# https://github.com/bazelbuild/rules_nodejs#bazel-managed-vs-self-managed-dependencies
17+
# Note: The repository_rule name is `@matdeps` so it does not conflict with the `@npm` repository
18+
# name downstream when building Angular Material from source. In the future when Angular + Bazel
19+
# users can build using the @angular/material npm bundles (depends on Ivy) this can be changed
20+
# to `@npm`.
21+
yarn_install(
22+
name = "matdeps",
23+
package_json = "@angular_material//:package.json",
24+
yarn_lock = "@angular_material//:yarn.lock",
25+
)

0 commit comments

Comments
 (0)
Please sign in to comment.