build: upgrade bazel rules to latest (#20768)

Add enough BUILD files to make it possible to
`bazel build packages/core/test`

Also re-format BUILD.bazel files with Buildifier.
Add a CI lint check that they stay formatted.

PR Close #20768
This commit is contained in:
Alex Eagle
2017-12-06 06:56:49 -08:00
committed by Jason Aden
parent 672733608b
commit 9dd60a5fb0
61 changed files with 757 additions and 131 deletions

View File

@ -9,7 +9,6 @@
"typescript": ">=2.4.2 <2.6"
},
"dependencies": {
"@bazel/typescript": "0.3.2",
"@types/node": "6.0.84"
},
"repository": {

View File

@ -4,41 +4,42 @@ load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
ts_library(
name = "ngc_lib",
srcs = [
"index.ts",
"extract_i18n.ts",
"index.ts",
],
module_name = "@angular/bazel",
tsconfig = ":tsconfig.json",
visibility = ["//test/ngc-wrapped:__subpackages__"],
deps = [
# BEGIN-INTERNAL
# Only needed when compiling within the Angular repo.
# Users will get this dependency from node_modules.
"@//packages/compiler-cli",
# END-INTERNAL
"@build_bazel_rules_typescript//internal/tsc_wrapped"
"@build_bazel_rules_typescript//internal/tsc_wrapped",
],
tsconfig = ":tsconfig.json",
visibility = ["//test/ngc-wrapped:__subpackages__"],
)
nodejs_binary(
name = "ngc-wrapped",
data = [
":ngc_lib",
"@build_bazel_rules_typescript//internal:worker_protocol.proto",
],
# Entry point assumes the user is outside this WORKSPACE,
# and references our rules with @angular//src/ngc-wrapped
entry_point = "angular/src/ngc-wrapped/index.js",
data = [
":ngc_lib",
"@build_bazel_rules_typescript//internal:worker_protocol.proto"
],
node_modules = "@build_bazel_rules_typescript_deps//:node_modules",
visibility = ["//visibility:public"],
)
nodejs_binary(
name = "xi18n",
# Entry point assumes the user is outside this WORKSPACE,
# and references our rules with @angular//src/ngc-wrapped
entry_point = "angular/src/ngc-wrapped/index.js/extract_i18n.js",
data = [
":ngc_lib",
],
# Entry point assumes the user is outside this WORKSPACE,
# and references our rules with @angular//src/ngc-wrapped
entry_point = "angular/src/ngc-wrapped/index.js/extract_i18n.js",
visibility = ["//visibility:public"],
)

View File

@ -8,32 +8,32 @@ ts_library(
"test_support.ts",
"tsconfig_template.ts",
],
tsconfig = ":tsconfig.json",
deps = [
# BEGIN-INTERNAL
# Only needed when compiling within the Angular repo.
# Users will get this dependency from node_modules.
"@//packages/compiler-cli",
# END-INTERNAL
"//src/ngc-wrapped:ngc_lib"
"//src/ngc-wrapped:ngc_lib",
],
tsconfig = ":tsconfig.json",
)
# We need a filegroup so that we can refer
# .d.ts files (by default, jasmine_node_test would get the .js files).
filegroup(
name = "angular_core",
srcs = ["@//packages/core"]
srcs = ["@//packages/core"],
)
jasmine_node_test(
name = "ngc_test",
size = "small",
srcs = [":ngc_test_lib"],
data = [
"@build_bazel_rules_typescript//internal:worker_protocol.proto",
":angular_core",
"//test/ngc-wrapped/empty:empty_tsconfig.json",
"//test/ngc-wrapped/empty:tsconfig.json",
"@build_bazel_rules_typescript//internal:worker_protocol.proto",
],
size="small",
)

View File

@ -1,10 +1,10 @@
load("@angular//:index.bzl", "ng_module")
package(default_visibility=["//test:__subpackages__"])
package(default_visibility = ["//test:__subpackages__"])
ng_module(
name = "empty",
srcs = ["empty.ts"],
deps = ["@//packages/core"],
tsconfig = ":tsconfig.json",
deps = ["@//packages/core"],
)

View File

@ -40,7 +40,7 @@ export function setup(
bazelBin?: string,
tsconfig?: string,
} = {}): TestSupport {
const runfilesPath = process.env['RUNFILES'];
const runfilesPath = process.env['TEST_SRCDIR'];
const basePath = makeTempDir(runfilesPath);
@ -150,7 +150,7 @@ function makeTempDir(baseDir): string {
}
export function listFilesRecursive(dir: string, fileList: string[] = []) {
fs.readdirSync(dir).map(file => {
fs.readdirSync(dir).forEach(file => {
if (fs.statSync(path.join(dir, file)).isDirectory()) {
listFilesRecursive(path.join(dir, file), fileList);
} else {

View File

@ -68,6 +68,9 @@ export function createTsConfig(options: TsConfigOptions) {
// Because we ask for :empty_tsconfig.json, we get the ES6 version which
// expects to write externs, yet that doesn't work under this fixture.
'tsickleExternsPath': '',
// we don't copy the node_modules into our tmp dir, so we should look in
// the original workspace directory for it
'nodeModulesPrefix': '../angular_src/node_modules',
},
'files': options.files,
'angularCompilerOptions': {