Skip to content

build(bazel): add rules for moment adapter and experimental packages #10689

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 1 commit into from
Apr 3, 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
27 changes: 26 additions & 1 deletion packages.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# List of all @angular/material components / subpackages.
# List of all components / subpackages.

CDK_PACKAGES = [
"coercion",
"keycodes",
Expand All @@ -18,6 +19,8 @@ CDK_PACKAGES = [
"collections",
]

CDK_TARGETS = ["//src/cdk"] + ["//src/cdk/%s" % p for p in CDK_PACKAGES]

MATERIAL_PACKAGES = [
"autocomplete",
"badge",
Expand Down Expand Up @@ -55,3 +58,25 @@ MATERIAL_PACKAGES = [
"tooltip",
"tree",
]

MATERIAL_TARGETS = ["//src/lib:material"] + ["//src/lib/%s" % p for p in MATERIAL_PACKAGES]

# Base rollup globals for everything in the repo.
ROLLUP_GLOBALS = {
'tslib': 'tslib',
'moment': 'moment',
'@angular/cdk': 'ng.cdk',
'@angular/cdk-experimental': 'ng.cdkExperimental',
'@angular/material': 'ng.material',
'@angular/material-experimental': 'ng.materialExperimental',
}

# Rollup globals for cdk subpackages in the form of, e.g., {"@angular/cdk/table": "ng.cdk.table"}
ROLLUP_GLOBALS.update({
"@angular/cdk/%s" % p: "ng.cdk.%s" % p for p in CDK_PACKAGES
})

# Rollup globals for material subpackages, e.g., {"@angular/material/list": "ng.material.list"}
ROLLUP_GLOBALS.update({
"@angular/material/%s" % p: "ng.material.%s" % p for p in MATERIAL_PACKAGES
})
21 changes: 21 additions & 0 deletions src/cdk-experimental/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module", "ng_package")
load("//:packages.bzl", "CDK_TARGETS", "ROLLUP_GLOBALS")


ng_module(
name = "cdk-experimental",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk-experimental",
deps = CDK_TARGETS,
assets = glob(["**/*.css", "**/*.html"]),
tsconfig = "//src/lib:tsconfig-build.json",
)

ng_package(
name = "npm_package",
srcs = ["package.json"],
entry_point = "src/cdk-experimental/public_api.js",
globals = ROLLUP_GLOBALS,
deps = [":cdk-experimental"],
)
8 changes: 3 additions & 5 deletions src/cdk/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("@angular//:index.bzl", "ng_package")
load("//:packages.bzl", "CDK_PACKAGES")
load("//src/cdk:rollup_globals.bzl", "CDK_ROLLUP_GLOBALS")

load("//:packages.bzl", "CDK_TARGETS", "ROLLUP_GLOBALS")

# Export the CDK tsconfig so that subpackages can reference it directly.
exports_files(["tsconfig-build.json"])
Expand All @@ -22,6 +20,6 @@ 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]
globals = ROLLUP_GLOBALS,
deps = CDK_TARGETS,
)
12 changes: 0 additions & 12 deletions src/cdk/rollup_globals.bzl

This file was deleted.

10 changes: 4 additions & 6 deletions src/lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("@angular//:index.bzl", "ng_package", "ng_module")
load("//tools:sass_bundle.bzl", "sass_bundle")
load("//:packages.bzl", "MATERIAL_PACKAGES")
load("//src/lib:rollup_globals.bzl", "MATERIAL_ROLLUP_GLOBALS")
load("//:packages.bzl", "MATERIAL_PACKAGES", "MATERIAL_TARGETS", "ROLLUP_GLOBALS")


# Export the root material tsconfig so that subpackages can reference it directly.
Expand Down Expand Up @@ -41,7 +41,7 @@ sass_bundle(
# ],
# entry_point = "src/lib/public_api.js",
# entry_point_name = "material",
# globals = MATERIAL_ROLLUP_GLOBALS,
# globals = ROLLUP_GLOBALS,
# data = [
# ":theming_bundle",
# "//src/lib/prebuilt-themes:indigo-pink",
Expand All @@ -50,7 +50,5 @@ sass_bundle(
# "//src/lib/prebuilt-themes:purple-green",
# ],
# packages = ["//src/lib/schematics:npm_package"],
# deps = [
# ":material",
# ] + ["//src/lib/%s" % p for p in MATERIAL_PACKAGES],
# deps = MATERIAL_TARGETS
#)
12 changes: 0 additions & 12 deletions src/lib/rollup_globals.bzl

This file was deleted.

22 changes: 22 additions & 0 deletions src/material-experimental/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module", "ng_package")
load("//:packages.bzl", "CDK_TARGETS", "ROLLUP_GLOBALS")


ng_module(
name = "material-experimental",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/material-experimental",
deps = [
"//src/lib:material",
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be MATERIAL_TARGETS + CDK_TARGETS?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's intentional; this prevents this package from using both styles of @angular/material imports

] + CDK_TARGETS,
tsconfig = "//src/lib:tsconfig-build.json",
)

ng_package(
name = "npm_package",
srcs = ["package.json"],
entry_point = "src/material-experimental/public_api.js",
globals = ROLLUP_GLOBALS,
deps = [":material-experimental"],
)
21 changes: 21 additions & 0 deletions src/material-moment-adapter/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("@angular//:index.bzl", "ng_package")
load("//:packages.bzl", "ROLLUP_GLOBALS")


ts_library(
name = "material-moment-adapter",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/material-moment-adapter",
deps = ["//src/lib:material"],
tsconfig = "//src/material-moment-adapter:tsconfig-build.json",
)

ng_package(
name = "npm_package",
srcs = ["package.json"],
entry_point = "src/material-moment-adapter/public_api.js",
globals = ROLLUP_GLOBALS,
deps = [":material-moment-adapter"],
)