Skip to content

build: build cdk with angular from source #13541

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 2 commits into from
Oct 11, 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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
- run: sudo cp ./.circleci/bazel.rc /etc/bazel.bazelrc

# TODO(jelbourn): Update this command to run all tests if the Bazel issues have been fixed.
- run: bazel build src/cdk:npm_package
- run: bazel test src/{cdk,lib}/schematics:unit_tests

- save_cache:
Expand Down
9 changes: 0 additions & 9 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
package(default_visibility = ["//visibility:public"])

# TODO(jelbourn): figure out if these workarounds are still needed

# TODO: Replace with fine-grained node_modules using `npm_install` / `yarn_install`.
# TODO: See https://github.com/bazelbuild/rules_nodejs/wiki#migrating-to-rules_nodejs-013
alias(
name = "node_modules",
actual = "@npm//:node_modules",
)

# Glob pattern that matches all Angular testing bundles.
ANGULAR_TESTING = [
"node_modules/@angular/*/bundles/*-testing.umd.js",
Expand Down
49 changes: 33 additions & 16 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ workspace(name = "angular_material")
# Add NodeJS rules (explicitly used for sass bundle rules)
http_archive(
name = "build_bazel_rules_nodejs",
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.14.2.zip",
strip_prefix = "rules_nodejs-0.14.2",
sha256 = "af481421c9e74f754a693a8bf5e9409484e38cf7be6f73f85879bdc7ed1b1d82",
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.15.0.zip",
strip_prefix = "rules_nodejs-0.15.0",
sha256 = "5f5b6464ca20aa63d278caaf4736f0381eb838800d7375132057a48f09d0b837",
)

# Add TypeScript rules
http_archive(
name = "build_bazel_rules_typescript",
url = "https://github.com/bazelbuild/rules_typescript/archive/0.19.1.zip",
strip_prefix = "rules_typescript-0.19.1",
sha256 = "91a03623a03a463ffd62cea3f7a384c2f298af6438d5d153fc4d69aa5665b53d",
url = "https://github.com/bazelbuild/rules_typescript/archive/0.20.2.zip",
strip_prefix = "rules_typescript-0.20.2",
sha256 = "2879fbd7168ba5d17db22bc2f585c0d1d3a82dd5e6f8af118e8b2f74d290024e",
)

# Fetch transient dependencies of the TypeScript bazel rules.
Expand All @@ -31,6 +31,27 @@ http_archive(
load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
sass_repositories()

# Add Angular source and Bazel rules.
http_archive(
name = "angular",
# Temporarily locked down to the angular/angular:bazel branch. This branch includes necessary
# commits that make building from source possible.
Copy link
Member

Choose a reason for hiding this comment

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

Is there an issue somewhere tracking this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not that I know of. I think it's just a WIP branch that includes the new design with rules_angular_dependencies.

Copy link
Member

Choose a reason for hiding this comment

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

@alexeagle what's the status of the changes on that branch making it to angular master?

# TODO(devversion): switch to release archive if workaround can be removed
url = "https://github.com/angular/angular/archive/08e4489cf5a93a352954f1639da5e92112993753.zip",
strip_prefix = "angular-08e4489cf5a93a352954f1639da5e92112993753",
sha256 = "a59c85426048cc95f51937d0c26f4d1143b7bef730152b68ac4b79d1438e746b",
)

# Add RxJS as repository because those are needed in order to build Angular from source.
# Also we cannot refer to the RxJS version from the node modules because self-managed
# node modules are not guaranteed to be installed.
http_archive(
name = "rxjs",
url = "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz",
strip_prefix = "package/src",
sha256 = "72b0b4e517f43358f554c125e40e39f67688cd2738a8998b4a266981ed32f403",
)

# 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", "yarn_install")
Expand All @@ -54,14 +75,10 @@ yarn_install(
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
ts_setup_workspace()

# Add Angular rules
local_repository(
name = "angular",
path = "node_modules/@angular/bazel",
)
# Setup Angular bazel rules
load("@angular//packages/bazel:package.bzl", "rules_angular_dependencies")
rules_angular_dependencies()

# Add rxjs
local_repository(
name = "rxjs",
path = "node_modules/rxjs/src",
)
# Setup Angular workspace for building (Bazel managed node modules)
load("@angular//:index.bzl", "ng_setup_workspace")
ng_setup_workspace()
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"devDependencies": {
"@angular-devkit/core": "7.0.0-rc.1",
"@angular-devkit/schematics": "7.0.0-rc.1",
"@angular/bazel": "7.0.0-rc.0",
"@angular/compiler-cli": "7.0.0-rc.0",
"@angular/http": "7.0.0-rc.0",
"@angular/platform-browser-dynamic": "7.0.0-rc.0",
Expand Down
11 changes: 7 additions & 4 deletions src/cdk/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,18 +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", "CDK_TARGETS", "ROLLUP_GLOBALS", "VERSION_PLACEHOLDER_REPLACEMENTS")
load("//tools:defaults.bzl", "ng_module")

# 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(
ng_module(
name = "cdk",
srcs = glob(["*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk",
deps = [],
tsconfig = "//src/lib:tsconfig-build.json",
deps = [
"@angular//packages/core",
],
tsconfig = ":tsconfig-build.json",
)

# Creates the @angular/cdk package published to npm.
Expand Down
9 changes: 6 additions & 3 deletions src/cdk/a11y/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")

load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")

load("//tools:defaults.bzl", "ng_module")

ng_module(
name = "a11y",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/a11y",
deps = [
"@angular//packages/common",
"@angular//packages/core",
"@rxjs",
"@rxjs//operators",
"//src/cdk/coercion",
"//src/cdk/keycodes",
"//src/cdk/observers",
"//src/cdk/platform",
"@rxjs",
],
tsconfig = "//src/cdk:tsconfig-build.json",
)
Expand Down
7 changes: 4 additions & 3 deletions src/cdk/accordion/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")

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

ng_module(
name = "accordion",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/accordion",
deps = [
"@angular//packages/core",
"@rxjs",
"//src/cdk/coercion",
"//src/cdk/collections",
"@rxjs",
],
tsconfig = "//src/cdk:tsconfig-build.json",
)
Expand Down
14 changes: 7 additions & 7 deletions src/cdk/bidi/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")

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

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

ts_library(
name = "bidi_test_sources",
testonly = 1,
srcs = glob(["**/*.spec.ts"]),
deps = [
":bidi",
"@rxjs",
],
deps = [":bidi"],
tsconfig = "//src/cdk:tsconfig-build.json",
)

Expand Down
8 changes: 3 additions & 5 deletions src/cdk/coercion/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
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")

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

ng_module(
ts_library(
Copy link
Member

Choose a reason for hiding this comment

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

I believe that the ng_package rule only worked with this being an ng_module, but maybe that is moot now since we can't package the library without ivy anyway

Copy link
Member Author

Choose a reason for hiding this comment

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

Just checked locally, and seems to work as expected.

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

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

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

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

Expand Down
7 changes: 5 additions & 2 deletions src/cdk/drag-drop/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary")

load("//tools:defaults.bzl", "ng_module")

ng_module(
name = "drag-drop",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/drag-drop",
deps = [
"@angular//packages/common",
"@angular//packages/core",
"@rxjs",
"@rxjs//operators",
"//src/cdk/platform",
"//src/cdk/overlay",
"//src/cdk/bidi",
Expand Down
7 changes: 3 additions & 4 deletions src/cdk/keycodes/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("@angular//:index.bzl", "ng_module")

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

ng_module(
ts_library(
name = "keycodes",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/keycodes",
deps = ["@rxjs"],
deps = ["@npm//tslib"],
tsconfig = "//src/cdk:tsconfig-build.json",
)
8 changes: 5 additions & 3 deletions src/cdk/layout/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")

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

ng_module(
name = "layout",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/layout",
deps = [
"@angular//packages/core",
"@rxjs",
"@rxjs//operators",
"//src/cdk/coercion",
"//src/cdk/platform",
"@rxjs",
],
tsconfig = "//src/cdk:tsconfig-build.json",
)
Expand Down
6 changes: 4 additions & 2 deletions src/cdk/observers/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")

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

ng_module(
name = "observers",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/observers",
deps = [
"@angular//packages/core",
"@rxjs",
"@rxjs//operators",
"//src/cdk/coercion",
],
tsconfig = "//src/cdk:tsconfig-build.json",
Expand Down
8 changes: 6 additions & 2 deletions src/cdk/overlay/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")

load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
load("//tools:defaults.bzl", "ng_module")

ng_module(
name = "overlay",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/overlay",
deps = [
"@angular//packages/common",
"@angular//packages/core",
"@rxjs",
"@rxjs//operators",
"//src/cdk/bidi",
"//src/cdk/coercion",
"//src/cdk/keycodes",
"//src/cdk/platform",
"//src/cdk/portal",
"//src/cdk/scrolling",
"@rxjs",
],
tsconfig = "//src/cdk:tsconfig-build.json",
)
Expand Down
8 changes: 6 additions & 2 deletions src/cdk/platform/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")

load("//tools:defaults.bzl", "ng_module")

ng_module(
name = "platform",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/platform",
deps = ["@rxjs"],
deps = [
"@angular//packages/common",
"@angular//packages/core",
],
tsconfig = "//src/cdk:tsconfig-build.json",
)
13 changes: 6 additions & 7 deletions src/cdk/portal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")

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

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

ts_library(
name = "portal_test_sources",
testonly = 1,
srcs = glob(["**/*.spec.ts"]),
deps = [
":portal",
"@rxjs",
],
deps = [":portal"],
tsconfig = "//src/cdk:tsconfig-build.json",
)

Expand Down
Loading