Skip to content
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

build(bazel): fix bazel types reference directive resolves #25774

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# If you change the `docker_image` version, also change the `cache_key` suffix and the version of
# `com_github_bazelbuild_buildtools` in the `/WORKSPACE` file.
var_1: &docker_image angular/ngcontainer:0.4.0
var_2: &cache_key v2-angular-{{ .Branch }}-{{ checksum "yarn.lock" }}-0.4.0
var_2: &cache_key v2-angular-{{ .Branch }}-{{ checksum "yarn.lock" }}-bust1-0.4.0

# Define common ENV vars
var_3: &define_env_vars
Expand Down
41 changes: 20 additions & 21 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,29 @@ http_archive(
)

http_archive(
name = "bazel_skylib",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/0.3.1.zip"],
strip_prefix = "bazel-skylib-0.3.1",
sha256 = "95518adafc9a2b656667bbf517a952e54ce7f350779d0dd95133db4eb5c27fb1",
)

http_archive(
name = "io_bazel_rules_webtesting",
url = "https://github.com/bazelbuild/rules_webtesting/archive/0.2.1.zip",
strip_prefix = "rules_webtesting-0.2.1",
sha256 = "7d490aadff9b5262e5251fa69427ab2ffd1548422467cb9f9e1d110e2c36f0fa",
name = "build_bazel_rules_typescript",
url = "https://github.com/bazelbuild/rules_typescript/archive/0.16.2.zip",
strip_prefix = "rules_typescript-0.16.2",
sha256 = "31601b777840fbf600dbd1893ade0d1de37166e7ba52b90735b107cfb67e38c7",
)
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
rules_typescript_dependencies()

http_archive(
name = "build_bazel_rules_typescript",
url = "https://github.com/bazelbuild/rules_typescript/archive/0.16.0.zip",
strip_prefix = "rules_typescript-0.16.0",
sha256 = "e65c5639a42e2f6d3f9d2bda62487d6b42734830dda45be1620c3e2b1115070c",
name = "bazel_toolchains",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/5124557861ebf4c0b67f98180bff1f8551e0b421.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/5124557861ebf4c0b67f98180bff1f8551e0b421.tar.gz",
],
strip_prefix = "bazel-toolchains-5124557861ebf4c0b67f98180bff1f8551e0b421",
sha256 = "c3b08805602cd1d2b67ebe96407c1e8c6ed3d4ce55236ae2efe2f1948f38168d",
)

http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.10.3/rules_go-0.10.3.tar.gz",
sha256 = "feba3278c13cde8d67e341a837f69a029f698d7a27ddbb2a202be7a10b22142a",
name = "io_bazel_rules_sass",
url = "https://github.com/bazelbuild/rules_sass/archive/1.11.0.zip",
strip_prefix = "rules_sass-1.11.0",
sha256 = "dbe9fb97d5a7833b2a733eebc78c9c1e3880f676ac8af16e58ccf2139cbcad03",
)

# This commit matches the version of buildifier in angular/ngcontainer
Expand Down Expand Up @@ -72,9 +71,9 @@ http_archive(

http_archive(
name = "org_brotli",
url = "https://github.com/google/brotli/archive/f9b8c02673c576a3e807edbf3a9328e9e7af6d7c.zip",
strip_prefix = "brotli-f9b8c02673c576a3e807edbf3a9328e9e7af6d7c",
sha256 = "8a517806d2b7c8505ba5c53934e7d7c70d341b68ffd268e9044d35b564a48828",
url = "https://github.com/google/brotli/archive/v1.0.5.zip",
strip_prefix = "brotli-1.0.5",
sha256 = "774b893a0700b0692a76e2e5b7e7610dbbe330ffbe3fe864b4b52ca718061d5a",
)

#
Expand Down
55 changes: 23 additions & 32 deletions integration/bazel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,33 @@ exports_files([
"protractor.conf.js",
])

# ts_library and ng_module use the `//:tsconfig.json` target
# by default. This alias allows omitting explicit tsconfig
# attribute.
alias(
name = "tsconfig.json",
actual = "//src:tsconfig.json",
)

filegroup(
name = "node_modules",
srcs = glob(
["node_modules/**/*"],
[
# Include only .js, .json & .d.ts files to reduce the number of
# files in the //:node_modules filegroup
"node_modules/**/*.js",
"node_modules/**/*.json",
"node_modules/**/*.d.ts",
# All the files in the http-server package are necesssary
"node_modules/http-server/**",
# All the files in the protractor package are necesssary
"node_modules/protractor/**",
# Also include all files in node_modules/.bin
"node_modules/.bin/*",
],
exclude = [
# Exclude rxjs because we build it from sources using the label @rxjs//:rxjs
"node_modules/rxjs/**",

# Exclude directories that commonly contain filenames which are
# illegal bazel labels
# e.g. node_modules/adm-zip/test/assets/attributes_test/New folder/hidden.txt
"node_modules/**/test/**",
# e.g. node_modules/xpath/docs/function resolvers.md
"node_modules/**/docs/**",
# Exclude files with spaces which are illegal bazel labels
"node_modules/**/* *",
],
),
)

ANGULAR_TESTING = [
"node_modules/@angular/*/bundles/*-testing.umd.js",
# We use AOT, so the compiler and the dynamic platform-browser should be
# visible only in tests
"node_modules/@angular/compiler/bundles/*.umd.js",
"node_modules/@angular/platform-browser-dynamic/bundles/*.umd.js",
]

filegroup(
name = "angular_bundles",
srcs = glob(
["node_modules/@angular/*/bundles/*.umd.js"],
exclude = ANGULAR_TESTING,
),
)

filegroup(
name = "angular_test_bundles",
testonly = 1,
srcs = glob(ANGULAR_TESTING),
)
43 changes: 8 additions & 35 deletions integration/bazel/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,18 @@ workspace(name = "bazel_integration_test")
# Download Bazel toolchain dependencies as needed by build actions
#

http_archive(
name = "build_bazel_rules_nodejs",
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/0.11.4.zip"],
strip_prefix = "rules_nodejs-0.11.4",
sha256 = "c31c4ead696944a50fad2b3ee9dfbbeffe31a8dcca0b21b9bf5b3e6c6b069801",
)

http_archive(
name = "bazel_skylib",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/0.3.1.zip"],
strip_prefix = "bazel-skylib-0.3.1",
sha256 = "95518adafc9a2b656667bbf517a952e54ce7f350779d0dd95133db4eb5c27fb1",
)

http_archive(
name = "io_bazel_rules_webtesting",
url = "https://github.com/bazelbuild/rules_webtesting/archive/0.2.1.zip",
strip_prefix = "rules_webtesting-0.2.1",
sha256 = "7d490aadff9b5262e5251fa69427ab2ffd1548422467cb9f9e1d110e2c36f0fa",
)

http_archive(
local_repository(
name = "build_bazel_rules_typescript",
url = "https://github.com/bazelbuild/rules_typescript/archive/0.16.0.zip",
strip_prefix = "rules_typescript-0.16.0",
sha256 = "e65c5639a42e2f6d3f9d2bda62487d6b42734830dda45be1620c3e2b1115070c",
)

http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.11.0/rules_go-0.11.0.tar.gz",
sha256 = "f70c35a8c779bb92f7521ecb5a1c6604e9c3edd431e50b6376d7497abc8ad3c1",
path = "node_modules/@bazel/typescript",
)
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
rules_typescript_dependencies()

http_archive(
name = "io_bazel_rules_sass",
url = "https://github.com/bazelbuild/rules_sass/archive/0.1.0.zip",
strip_prefix = "rules_sass-0.1.0",
sha256 = "b243c4d64f054c174051785862ab079050d90b37a1cef7da93821c6981cb9ad4",
url = "https://github.com/bazelbuild/rules_sass/archive/1.11.0.zip",
strip_prefix = "rules_sass-1.11.0",
sha256 = "dbe9fb97d5a7833b2a733eebc78c9c1e3880f676ac8af16e58ccf2139cbcad03",
)

#
Expand All @@ -51,7 +24,7 @@ http_archive(

local_repository(
name = "angular",
path = "node_modules/@angular/bazel",
path = "../..",
)

local_repository(
Expand Down
22 changes: 0 additions & 22 deletions integration/bazel/angular.tsconfig.json

This file was deleted.

16 changes: 5 additions & 11 deletions integration/bazel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@
"version": "0.0.0",
"license": "MIT",
"dependencies": {
"@angular/animations": "file:../../dist/packages-dist/animations",
"@angular/common": "file:../../dist/packages-dist/common",
"@angular/compiler": "file:../../dist/packages-dist/compiler",
"@angular/core": "file:../../dist/packages-dist/core",
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
"@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic",
"reflect-metadata": "file:../../node_modules/reflect-metadata",
"rxjs": "file:../../node_modules/rxjs",
"tslib": "file:../../node_modules/tslib",
"zone.js": "file:../../node_modules/zone.js"
},
"devDependencies": {
"@angular/bazel": "file:../../dist/packages-dist/bazel",
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
"@types/jasmine": "2.8.7",
"@bazel/typescript": "0.16.2",
"@types/jasmine": "file:../../node_modules/@types/jasmine",
"@types/source-map": "0.5.1",
"http-server": "0.11.1",
"protractor": "file:../../node_modules/protractor",
"tsutils": "file:../../node_modules/tsutils",
"tsickle": "file:../../node_modules/tsickle",
"typescript": "file:../../node_modules/typescript"
},
"scripts": {
"postinstall": "ngc -p angular.tsconfig.json",
"test": "bazel build ... --noshow_progress && bazel test ..."
}
}
11 changes: 8 additions & 3 deletions integration/bazel/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@ exports_files(["tsconfig.json"])
ng_module(
name = "src",
srcs = glob(["*.ts"]),
tsconfig = ":tsconfig.json",
deps = ["//src/hello-world"],
deps = [
"//src/hello-world",
"@angular//packages/common/http",
"@angular//packages/core",
"@angular//packages/platform-browser",
],
)

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

ts_devserver(
name = "devserver",
additional_root_paths = [
"bazel_integration_test/node_modules/tslib",
"bazel_integration_test/node_modules/zone.js/dist",
],
entry_module = "bazel_integration_test/src/main",
scripts = ["//:angular_bundles"],
serving_path = "/bundle.min.js",
static_files = [
"//:node_modules/tslib/tslib.js",
"//:node_modules/zone.js/dist/zone.min.js",
"index.html",
],
Expand Down
24 changes: 15 additions & 9 deletions integration/bazel/src/hello-world/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ ng_module(
exclude = ["*.spec.ts"],
),
assets = [":hello-world-styles"],
tsconfig = "//src:tsconfig.json",
# FIXME(alexeagle): the rxjs dep should come from Angular, but if we use the
# npm distro of angular there is no ts_library rule to propagate the dep.
deps = ["@rxjs"],
deps = [
"@angular//packages/core",
],
)

ng_package(
Expand All @@ -32,20 +31,27 @@ ts_library(
name = "test_lib",
testonly = 1,
srcs = glob(["*.spec.ts"]),
tsconfig = "//src:tsconfig.json",
deps = [":hello-world"],
deps = [
":hello-world",
"@angular//packages/core",
"@angular//packages/core/testing",
"@angular//packages/platform-browser",
"@angular//packages/platform-browser-dynamic/testing",
],
)

ts_web_test_suite(
name = "test",
bootstrap = ["//:node_modules/zone.js/dist/zone-testing-bundle.js"],
srcs = ["//:node_modules/tslib/tslib.js"],
bootstrap = [
"//:node_modules/zone.js/dist/zone-testing-bundle.js",
"//:node_modules/reflect-metadata/Reflect.js",
],
browsers = [
"@io_bazel_rules_webtesting//browsers:chromium-local",
"@io_bazel_rules_webtesting//browsers:firefox-local",
],
deps = [
":test_lib",
"//:angular_bundles",
"//:angular_test_bundles",
],
)
6 changes: 3 additions & 3 deletions integration/bazel/test/e2e/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ ts_library(
testonly = 1,
srcs = ["on-prepare.ts"],
tsconfig = ":tsconfig.json",
deps = ["@angular//src/protractor/utils"],
deps = ["@angular//packages/bazel/src/protractor/utils"],
)

protractor_web_test_suite(
name = "devserver_test",
configuration = "//:protractor.conf.js",
data = ["@angular//src/protractor/utils"],
data = ["@angular//packages/bazel/src/protractor/utils"],
on_prepare = ":ts_on_prepare",
server = "//src:devserver",
deps = [":e2e"],
Expand All @@ -28,7 +28,7 @@ protractor_web_test_suite(
protractor_web_test_suite(
name = "prodserver_test",
configuration = "//:protractor.conf.js",
data = ["@angular//src/protractor/utils"],
data = ["@angular//packages/bazel/src/protractor/utils"],
on_prepare = ":ts_on_prepare",
server = "//src:prodserver",
deps = [":e2e"],
Expand Down
3 changes: 3 additions & 0 deletions integration/bazel/tools/bazel.rc
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ test --test_output=errors
# Workaround https://github.com/bazelbuild/bazel/issues/3645
# Limit Bazel to consuming 3072K of RAM
build --local_resources=3072,2.0,1.0

# Use the Angular 6 compiler
build --define=compile=legacy