From 5faf520067265e07c240d5233328d6a55509aba4 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 2 Jun 2017 09:43:52 -0700 Subject: [PATCH] build: Introduce Bazel build rules So far this just compiles the core and common packages. --- .bazelrc | 6 +++ .gitignore | 1 + BUILD | 18 +++++++++ WORKSPACE | 12 ++++++ package.json | 2 +- packages/common/BUILD | 13 +++++++ packages/common/tsconfig-build.json | 38 +++++++++++-------- packages/core/BUILD | 13 +++++++ .../system_js_ng_module_factory_loader.ts | 1 + packages/core/src/util.ts | 4 ++ packages/core/src/zone/ng_zone.ts | 3 ++ packages/core/tsconfig-build.json | 36 ++++++++++-------- 12 files changed, 115 insertions(+), 32 deletions(-) create mode 100644 .bazelrc create mode 100644 BUILD create mode 100644 WORKSPACE create mode 100644 packages/common/BUILD create mode 100644 packages/core/BUILD diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000000..7b35f14ca3 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,6 @@ +# Disable sandboxing because it's too slow. +# https://github.com/bazelbuild/bazel/issues/2424 +build --spawn_strategy=standalone + +# Performance: avoid stat'ing input files +build --watchfs diff --git a/.gitignore b/.gitignore index 6899818c96..d37159c39e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_STORE /dist/ +bazel-* node_modules bower_components diff --git a/BUILD b/BUILD new file mode 100644 index 0000000000..11438eec58 --- /dev/null +++ b/BUILD @@ -0,0 +1,18 @@ +package(default_visibility = ["//visibility:public"]) +exports_files(["tsconfig.json"]) + +# This rule belongs in node_modules/BUILD +# It's here as a workaround for +# https://github.com/bazelbuild/bazel/issues/374#issuecomment-296217940 +filegroup( + name = "node_modules", + srcs = glob([ + # Performance workaround: list individual files + # This won't scale in the general case. + # TODO(alexeagle): figure out what to do + "node_modules/typescript/lib/**", + "node_modules/zone.js/**/*.d.ts", + "node_modules/rxjs/**/*.d.ts", + "node_modules/@types/**/*.d.ts", + ]), +) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000000..7257bff005 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,12 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +git_repository( + name = "io_bazel_rules_typescript", + remote = "https://github.com/bazelbuild/rules_typescript.git", + tag = "0.0.3", +) + +load("@io_bazel_rules_typescript//:defs.bzl", "node_repositories", "yarn_install") + +node_repositories() +yarn_install(package_json = "//:package.json") diff --git a/package.json b/package.json index c199905e1b..033d1abb2f 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "engines": { "node": ">=6.9.5 <7.0.0", "npm": ">=3.10.7 <4.0.0", - "yarn": ">=0.21.3 <0.22.0" + "yarn": ">=0.21.3 <1.0.0" }, "repository": { "type": "git", diff --git a/packages/common/BUILD b/packages/common/BUILD new file mode 100644 index 0000000000..857abc0b1e --- /dev/null +++ b/packages/common/BUILD @@ -0,0 +1,13 @@ +package(default_visibility=["//visibility:public"]) +load("@io_bazel_rules_typescript//:defs.bzl", "ts_library") + +ts_library( + name = "common", + srcs = glob(["**/*.ts"], exclude=[ + "test/**", + "testing/**", + ]), + module_name = "@angular/common", + deps = ["//packages/core"], + tsconfig = ":tsconfig-build.json", +) diff --git a/packages/common/tsconfig-build.json b/packages/common/tsconfig-build.json index 873effbeb7..4060df709f 100644 --- a/packages/common/tsconfig-build.json +++ b/packages/common/tsconfig-build.json @@ -1,35 +1,41 @@ { + "angularCompilerOptions": { + "annotateForClosureCompiler": true, + "strictMetadataEmit": true, + "flatModuleOutFile": "index.js", + "flatModuleId": "@angular/common" + }, + "compilerOptions": { - "baseUrl": ".", - "declaration": true, "stripInternal": true, - "experimentalDecorators": true, "strictNullChecks": true, "noImplicitAny": true, "noFallthroughCasesInSwitch": true, "module": "es2015", "moduleResolution": "node", + "target": "es2015", + "skipLibCheck": true, + "lib": [ "es2015", "dom" ], + // don't auto-discover @types/node, it results in a ///