Skip to content

Commit 9091b21

Browse files
jelbournandrewseguin
authored andcommitted
build(bazel): add rule for cdk npm package (#10509)
* build(bazel): add rule for cdk npm package * Bump to rc0, remove moment from cdk rollup config * Remove TODOs
1 parent 4e1bb26 commit 9091b21

File tree

26 files changed

+153
-59
lines changed

26 files changed

+153
-59
lines changed

WORKSPACE

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
workspace(name = "angular_material")
22

33
# Add nodejs rules
4-
git_repository(
4+
http_archive(
55
name = "build_bazel_rules_nodejs",
6-
remote = "https://github.com/bazelbuild/rules_nodejs.git",
7-
commit = "0.5.1",
6+
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.5.3.zip",
7+
strip_prefix = "rules_nodejs-0.5.3",
8+
sha256 = "17a5515f59777b00cb25dbc710017a14273f825029b2ec60e0969d28914870be",
89
)
910

1011
# NOTE: this rule installs nodejs, npm, and yarn, but does NOT install
1112
# your npm dependencies. You must still run the package manager.
12-
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")
13+
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories")
14+
15+
check_bazel_version("0.9.0")
1316
node_repositories(package_json = ["//:package.json"])
1417

1518
# Add sass rules
@@ -23,10 +26,11 @@ load("@io_bazel_rules_sass//sass:sass.bzl", "sass_repositories")
2326
sass_repositories()
2427

2528
# Add TypeScript rules
26-
git_repository(
29+
http_archive(
2730
name = "build_bazel_rules_typescript",
28-
remote = "https://github.com/bazelbuild/rules_typescript.git",
29-
tag = "0.11.1",
31+
url = "https://github.com/bazelbuild/rules_typescript/archive/0.11.1.zip",
32+
strip_prefix = "rules_typescript-0.11.1",
33+
sha256 = "7406bea7954e1c906f075115dfa176551a881119f6820b126ea1eacb09f34a1a",
3034
)
3135

3236
# Setup TypeScript Bazel workspace

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"devDependencies": {
4343
"@angular-devkit/core": "^0.4.5",
4444
"@angular-devkit/schematics": "^0.4.5",
45-
"@angular/bazel": "6.0.0-beta.8",
46-
"@angular/compiler-cli": "6.0.0-beta.8",
45+
"@angular/bazel": "6.0.0-rc.0",
46+
"@angular/compiler-cli": "6.0.0-rc.0",
4747
"@angular/http": "6.0.0-beta.8",
4848
"@angular/platform-browser-dynamic": "6.0.0-beta.8",
4949
"@angular/platform-server": "6.0.0-beta.8",

components.bzl renamed to packages.bzl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
# List of all @angular/material components / subpackages.
2+
CDK_PACKAGES = [
3+
"coercion",
4+
"keycodes",
5+
"scrolling",
6+
"accordion",
7+
"observers",
8+
"a11y",
9+
"overlay",
10+
"platform",
11+
"bidi",
12+
"table",
13+
"tree",
14+
"portal",
15+
"layout",
16+
"stepper",
17+
"collections",
18+
]
19+
220
MATERIAL_PACKAGES = [
321
"autocomplete",
422
"badge",

src/cdk/BUILD.bazel

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package(default_visibility=["//visibility:public"])
22
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_config")
3+
load("@angular//:index.bzl", "ng_package")
4+
load("//:packages.bzl", "CDK_PACKAGES")
5+
load("//src/cdk:rollup_globals.bzl", "CDK_ROLLUP_GLOBALS")
36

7+
8+
# Export the CDK tsconfig so that subpackages can reference it directly.
49
exports_files(["tsconfig-build.json"])
510

11+
# Root "@angular/cdk" entry-point that does not re-export individual entry-points.
612
ts_library(
713
name = "cdk",
814
srcs = glob(["*.ts"], exclude=["**/*.spec.ts"]),
@@ -11,8 +17,11 @@ ts_library(
1117
tsconfig = ":tsconfig-build.json",
1218
)
1319

14-
ts_config(
15-
name ="tsconfig_tests",
16-
src = "tsconfig-tests.json",
17-
deps = ["tsconfig-build.json"],
20+
# Creates the @angular/cdk package published to npm.
21+
ng_package(
22+
name = "npm_package",
23+
srcs = ["package.json"],
24+
entry_point = "src/cdk/public_api.js",
25+
globals = CDK_ROLLUP_GLOBALS,
26+
deps = [":cdk"] + ["//src/cdk/%s" % p for p in CDK_PACKAGES]
1827
)

src/cdk/a11y/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ng_module(
1414
"//src/cdk/platform",
1515
"@rxjs",
1616
],
17-
tsconfig = ":tsconfig-build.json",
17+
tsconfig = "//src/cdk:tsconfig-build.json",
1818
)
1919

2020
# TODO(jelbourn): remove this when sass_library acts like a filegroup
@@ -39,7 +39,7 @@ ts_library(
3939
"//src/cdk/testing",
4040
"@rxjs",
4141
],
42-
tsconfig = ":tsconfig-build.json",
42+
tsconfig = "//src/cdk:tsconfig-build.json",
4343
)
4444

4545
ts_web_test(

src/cdk/accordion/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ng_module(
1111
"//src/cdk/coercion",
1212
"//src/cdk/collections",
1313
],
14-
tsconfig = ":tsconfig-build.json",
14+
tsconfig = "//src/cdk:tsconfig-build.json",
1515
)
1616

1717
ts_library(
@@ -22,7 +22,7 @@ ts_library(
2222
":accordion",
2323
"@rxjs",
2424
],
25-
tsconfig = ":tsconfig-build.json",
25+
tsconfig = "//src/cdk:tsconfig-build.json",
2626
)
2727

2828
ts_web_test(

src/cdk/bidi/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ng_module(
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/cdk/bidi",
1010
deps = ["@rxjs"],
11-
tsconfig = ":tsconfig-build.json",
11+
tsconfig = "//src/cdk:tsconfig-build.json",
1212
)
1313

1414
ts_library(
@@ -19,7 +19,7 @@ ts_library(
1919
":bidi",
2020
"@rxjs",
2121
],
22-
tsconfig = ":tsconfig-build.json",
22+
tsconfig = "//src/cdk:tsconfig-build.json",
2323
)
2424

2525
ts_web_test(

src/cdk/coercion/BUILD.bazel

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

5-
# Note: this will need to ng_module if any Angular-specific stuff is added to coercion.
6-
ts_library(
6+
7+
ng_module(
78
name = "coercion",
89
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
910
module_name = "@angular/cdk/coercion",
10-
deps = [],
11-
tsconfig = ":tsconfig-build.json",
11+
deps = ["@rxjs"],
12+
tsconfig = "//src/cdk:tsconfig-build.json",
1213
)
1314

1415
ts_library(

src/cdk/collections/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ng_module(
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/cdk/collections",
1010
deps = ["@rxjs"],
11-
tsconfig = ":tsconfig-build.json",
11+
tsconfig = "//src/cdk:tsconfig-build.json",
1212
)
1313

1414
ts_library(
@@ -19,7 +19,7 @@ ts_library(
1919
":collections",
2020
"@rxjs",
2121
],
22-
tsconfig = ":tsconfig-build.json",
22+
tsconfig = "//src/cdk:tsconfig-build.json",
2323
)
2424

2525
ts_web_test(

src/cdk/keycodes/BUILD.bazel

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

4-
# Note: this will need to ng_module if any Angular-specific stuff is added to coercion.
5-
ts_library(
5+
6+
ng_module(
67
name = "keycodes",
78
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
89
module_name = "@angular/cdk/keycodes",
9-
deps = [],
10-
tsconfig = ":tsconfig-build.json",
10+
deps = ["@rxjs"],
11+
tsconfig = "//src/cdk:tsconfig-build.json",
1112
)

src/cdk/layout/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ng_module(
1212
"//src/cdk/platform",
1313
"@rxjs",
1414
],
15-
tsconfig = ":tsconfig-build.json",
15+
tsconfig = "//src/cdk:tsconfig-build.json",
1616
)
1717

1818
ts_library(
@@ -24,7 +24,7 @@ ts_library(
2424
"//src/cdk/platform",
2525
"@rxjs",
2626
],
27-
tsconfig = ":tsconfig-build.json",
27+
tsconfig = "//src/cdk:tsconfig-build.json",
2828
)
2929

3030
ts_web_test(

src/cdk/observers/BUILD.bazel

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ ng_module(
77
name = "observers",
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/cdk/observers",
10-
deps = ["@rxjs", "//src/cdk/coercion"],
11-
tsconfig = ":tsconfig-build.json",
10+
deps = [
11+
"@rxjs",
12+
"//src/cdk/coercion",
13+
],
14+
tsconfig = "//src/cdk:tsconfig-build.json",
1215
)
1316

1417
ts_library(
@@ -19,7 +22,7 @@ ts_library(
1922
":observers",
2023
"@rxjs",
2124
],
22-
tsconfig = ":tsconfig-build.json",
25+
tsconfig = "//src/cdk:tsconfig-build.json",
2326
)
2427

2528
ts_web_test(

src/cdk/overlay/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ng_module(
1515
"//src/cdk/scrolling",
1616
"@rxjs",
1717
],
18-
tsconfig = ":tsconfig-build.json",
18+
tsconfig = "//src/cdk:tsconfig-build.json",
1919
)
2020

2121
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
@@ -38,7 +38,7 @@ ts_library(
3838
"//src/cdk/testing",
3939
"@rxjs",
4040
],
41-
tsconfig = ":tsconfig-build.json",
41+
tsconfig = "//src/cdk:tsconfig-build.json",
4242
)
4343

4444
ts_web_test(

src/cdk/platform/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ ng_module(
66
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
77
module_name = "@angular/cdk/platform",
88
deps = ["@rxjs"],
9-
tsconfig = ":tsconfig-build.json",
9+
tsconfig = "//src/cdk:tsconfig-build.json",
1010
)

src/cdk/portal/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ng_module(
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/cdk/portal",
1010
deps = ["@rxjs"],
11-
tsconfig = ":tsconfig-build.json",
11+
tsconfig = "//src/cdk:tsconfig-build.json",
1212
)
1313

1414
ts_library(
@@ -19,7 +19,7 @@ ts_library(
1919
":portal",
2020
"@rxjs",
2121
],
22-
tsconfig = ":tsconfig-build.json",
22+
tsconfig = "//src/cdk:tsconfig-build.json",
2323
)
2424

2525
ts_web_test(

src/cdk/rollup_globals.bzl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
load("//:packages.bzl", "CDK_PACKAGES")
2+
3+
# Base rollup globals for dependencies and the root entry-point.
4+
CDK_ROLLUP_GLOBALS = {
5+
'tslib': 'tslib',
6+
'@angular/cdk': 'ng.cdk',
7+
}
8+
9+
# Rollup globals for subpackages in the form of, e.g., {"@angular/cdk/table": "ng.cdk.table"}
10+
CDK_ROLLUP_GLOBALS.update({
11+
"@angular/cdk/%s" % p: "ng.cdk.%s" % p for p in CDK_PACKAGES
12+
})

src/cdk/scrolling/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ng_module(
1111
"//src/cdk/platform",
1212
"@rxjs",
1313
],
14-
tsconfig = ":tsconfig-build.json",
14+
tsconfig = "//src/cdk:tsconfig-build.json",
1515
)
1616

1717
ts_library(
@@ -23,7 +23,7 @@ ts_library(
2323
"//src/cdk/testing",
2424
"@rxjs",
2525
],
26-
tsconfig = ":tsconfig-build.json",
26+
tsconfig = "//src/cdk:tsconfig-build.json",
2727
)
2828

2929
ts_web_test(

src/cdk/stepper/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ ng_module(
1212
"//src/cdk/keycodes",
1313
"@rxjs",
1414
],
15-
tsconfig = ":tsconfig-build.json",
15+
tsconfig = "//src/cdk:tsconfig-build.json",
1616
)

src/cdk/stepper/step.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/cdk/stepper/stepper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class StepperSelectionEvent {
6767
moduleId: module.id,
6868
selector: 'cdk-step',
6969
exportAs: 'cdkStep',
70-
templateUrl: 'step.html',
70+
template: '<ng-template><ng-content></ng-content></ng-template>',
7171
encapsulation: ViewEncapsulation.None,
7272
changeDetection: ChangeDetectionStrategy.OnPush,
7373
})

src/cdk/table/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ng_module(
1111
"//src/cdk/collections",
1212
"@rxjs",
1313
],
14-
tsconfig = ":tsconfig-build.json",
14+
tsconfig = "//src/cdk:tsconfig-build.json",
1515
)
1616

1717
ts_library(
@@ -23,7 +23,7 @@ ts_library(
2323
"//src/cdk/collections",
2424
"@rxjs",
2525
],
26-
tsconfig = ":tsconfig-build.json",
26+
tsconfig = "//src/cdk:tsconfig-build.json",
2727
)
2828

2929
ts_web_test(

0 commit comments

Comments
 (0)