Skip to content

build(bazel): add rule for cdk npm package #10509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
workspace(name = "angular_material")

# Add nodejs rules
git_repository(
http_archive(
name = "build_bazel_rules_nodejs",
remote = "https://github.com/bazelbuild/rules_nodejs.git",
commit = "0.5.1",
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.5.3.zip",
strip_prefix = "rules_nodejs-0.5.3",
sha256 = "17a5515f59777b00cb25dbc710017a14273f825029b2ec60e0969d28914870be",
)

# NOTE: this rule installs nodejs, npm, and yarn, but does NOT install
# your npm dependencies. You must still run the package manager.
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories")

check_bazel_version("0.9.0")
node_repositories(package_json = ["//:package.json"])

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

# Add TypeScript rules
git_repository(
http_archive(
name = "build_bazel_rules_typescript",
remote = "https://github.com/bazelbuild/rules_typescript.git",
tag = "0.11.1",
url = "https://github.com/bazelbuild/rules_typescript/archive/0.11.1.zip",
strip_prefix = "rules_typescript-0.11.1",
sha256 = "7406bea7954e1c906f075115dfa176551a881119f6820b126ea1eacb09f34a1a",
)

# Setup TypeScript Bazel workspace
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"devDependencies": {
"@angular-devkit/core": "^0.4.5",
"@angular-devkit/schematics": "^0.4.5",
"@angular/bazel": "6.0.0-beta.8",
"@angular/compiler-cli": "6.0.0-beta.8",
"@angular/bazel": "6.0.0-rc.0",
"@angular/compiler-cli": "6.0.0-rc.0",
"@angular/http": "6.0.0-beta.8",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you want to update all the @angular/* in lock-step?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't update the rest due to rxjs 6.0, which we don't have working yet

"@angular/platform-browser-dynamic": "6.0.0-beta.8",
"@angular/platform-server": "6.0.0-beta.8",
Expand Down
18 changes: 18 additions & 0 deletions components.bzl → packages.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
# List of all @angular/material components / subpackages.
CDK_PACKAGES = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to try a bit harder to glob these, so adding a new subdirectory will automatically do the right thing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions? glob can only be used where a list of files is expected, and I don't want to repeat the glob in multiple places. AFAICT, there aren't any skylark APIs that deal with the file system.

"coercion",
"keycodes",
"scrolling",
"accordion",
"observers",
"a11y",
"overlay",
"platform",
"bidi",
"table",
"tree",
"portal",
"layout",
"stepper",
"collections",
]

MATERIAL_PACKAGES = [
"autocomplete",
"badge",
Expand Down
17 changes: 13 additions & 4 deletions src/cdk/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_config")
load("@angular//:index.bzl", "ng_package")
load("//:packages.bzl", "CDK_PACKAGES")
load("//src/cdk:rollup_globals.bzl", "CDK_ROLLUP_GLOBALS")


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

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

ts_config(
name ="tsconfig_tests",
src = "tsconfig-tests.json",
deps = ["tsconfig-build.json"],
# Creates the @angular/cdk package published to npm.
ng_package(
name = "npm_package",
srcs = ["package.json"],
entry_point = "src/cdk/public_api.js",
globals = CDK_ROLLUP_GLOBALS,
deps = [":cdk"] + ["//src/cdk/%s" % p for p in CDK_PACKAGES]
)
4 changes: 2 additions & 2 deletions src/cdk/a11y/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ng_module(
"//src/cdk/platform",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

# TODO(jelbourn): remove this when sass_library acts like a filegroup
Expand All @@ -39,7 +39,7 @@ ts_library(
"//src/cdk/testing",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_web_test(
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/accordion/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ng_module(
"//src/cdk/coercion",
"//src/cdk/collections",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_library(
Expand All @@ -22,7 +22,7 @@ ts_library(
":accordion",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_web_test(
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/bidi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ng_module(
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/bidi",
deps = ["@rxjs"],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_library(
Expand All @@ -19,7 +19,7 @@ ts_library(
":bidi",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_web_test(
Expand Down
9 changes: 5 additions & 4 deletions src/cdk/coercion/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
load("@angular//:index.bzl", "ng_module")

# Note: this will need to ng_module if any Angular-specific stuff is added to coercion.
ts_library(

ng_module(
name = "coercion",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/coercion",
deps = [],
tsconfig = ":tsconfig-build.json",
deps = ["@rxjs"],
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_library(
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/collections/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ng_module(
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/collections",
deps = ["@rxjs"],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_library(
Expand All @@ -19,7 +19,7 @@ ts_library(
":collections",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_web_test(
Expand Down
9 changes: 5 additions & 4 deletions src/cdk/keycodes/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("@angular//:index.bzl", "ng_module")

# Note: this will need to ng_module if any Angular-specific stuff is added to coercion.
ts_library(

ng_module(
name = "keycodes",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/keycodes",
deps = [],
tsconfig = ":tsconfig-build.json",
deps = ["@rxjs"],
tsconfig = "//src/cdk:tsconfig-build.json",
)
4 changes: 2 additions & 2 deletions src/cdk/layout/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ng_module(
"//src/cdk/platform",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_library(
Expand All @@ -24,7 +24,7 @@ ts_library(
"//src/cdk/platform",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_web_test(
Expand Down
9 changes: 6 additions & 3 deletions src/cdk/observers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ ng_module(
name = "observers",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/observers",
deps = ["@rxjs", "//src/cdk/coercion"],
tsconfig = ":tsconfig-build.json",
deps = [
"@rxjs",
"//src/cdk/coercion",
],
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_library(
Expand All @@ -19,7 +22,7 @@ ts_library(
":observers",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_web_test(
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/overlay/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ng_module(
"//src/cdk/scrolling",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

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

ts_web_test(
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/platform/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ ng_module(
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/platform",
deps = ["@rxjs"],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)
4 changes: 2 additions & 2 deletions src/cdk/portal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ng_module(
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/portal",
deps = ["@rxjs"],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_library(
Expand All @@ -19,7 +19,7 @@ ts_library(
":portal",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_web_test(
Expand Down
12 changes: 12 additions & 0 deletions src/cdk/rollup_globals.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("//:packages.bzl", "CDK_PACKAGES")

# Base rollup globals for dependencies and the root entry-point.
CDK_ROLLUP_GLOBALS = {
'tslib': 'tslib',
'@angular/cdk': 'ng.cdk',
}

# Rollup globals for subpackages in the form of, e.g., {"@angular/cdk/table": "ng.cdk.table"}
CDK_ROLLUP_GLOBALS.update({
"@angular/cdk/%s" % p: "ng.cdk.%s" % p for p in CDK_PACKAGES
})
4 changes: 2 additions & 2 deletions src/cdk/scrolling/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ng_module(
"//src/cdk/platform",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_library(
Expand All @@ -23,7 +23,7 @@ ts_library(
"//src/cdk/testing",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_web_test(
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/stepper/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ ng_module(
"//src/cdk/keycodes",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)
1 change: 0 additions & 1 deletion src/cdk/stepper/step.html

This file was deleted.

2 changes: 1 addition & 1 deletion src/cdk/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class StepperSelectionEvent {
moduleId: module.id,
selector: 'cdk-step',
exportAs: 'cdkStep',
templateUrl: 'step.html',
template: '<ng-template><ng-content></ng-content></ng-template>',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wasn't necessary, right? the resource inlining has landed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't necessary, just cleaned it up incidentally since the template was trivial.

encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/table/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ng_module(
"//src/cdk/collections",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_library(
Expand All @@ -23,7 +23,7 @@ ts_library(
"//src/cdk/collections",
"@rxjs",
],
tsconfig = ":tsconfig-build.json",
tsconfig = "//src/cdk:tsconfig-build.json",
)

ts_web_test(
Expand Down
Loading