build: Introduce Bazel build rules

So far this just compiles the core and common packages.
This commit is contained in:
Alex Eagle 2017-06-02 09:43:52 -07:00 committed by Alex Rickabaugh
parent 02d74cafba
commit 5faf520067
12 changed files with 115 additions and 32 deletions

6
.bazelrc Normal file
View File

@ -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

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
.DS_STORE
/dist/
bazel-*
node_modules
bower_components

18
BUILD Normal file
View File

@ -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",
]),
)

12
WORKSPACE Normal file
View File

@ -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")

View File

@ -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",

13
packages/common/BUILD Normal file
View File

@ -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",
)

View File

@ -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 ///<reference in the .d.ts output
"types": [],
/**
* The rest of the file is configuration that's overridden by bazel.
* It can be removed after we fully migrate.
*/
"baseUrl": ".",
"declaration": true,
"experimentalDecorators": true,
"outDir": "../../dist/packages/common",
"paths": {
"@angular/core": ["../../dist/packages/core"]
},
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"target": "es2015",
"skipLibCheck": true,
"lib": [ "es2015", "dom" ],
// don't auto-discover @types/node, it results in a ///<reference in the .d.ts output
"types": []
"inlineSources": true
},
"files": [
"public_api.ts",
"../../node_modules/zone.js/dist/zone.js.d.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/common"
}
]
}

13
packages/core/BUILD Normal file
View File

@ -0,0 +1,13 @@
package(default_visibility=["//visibility:public"])
load("@io_bazel_rules_typescript//:defs.bzl", "ts_library")
ts_library(
name = "core",
srcs = glob(["**/*.ts"], exclude=[
"test/**",
"testing/**",
]),
module_name = "@angular/core",
deps = [],
tsconfig = ":tsconfig-build.json",
)

View File

@ -16,6 +16,7 @@ import {NgModuleFactoryLoader} from './ng_module_factory_loader';
const _SEPARATOR = '#';
const FACTORY_CLASS_SUFFIX = 'NgFactory';
declare var System: any;
/**
* Configuration for SystemJsNgModuleLoader.

View File

@ -6,6 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
// Import zero symbols from zone.js. This causes the zone ambient type to be
// added to the type-checker, without emitting any runtime module load statement
import {} from 'zone.js';
// TODO(jteplitz602): Load WorkerGlobalScope from lib.webworker.d.ts file #3492
declare var WorkerGlobalScope: any /** TODO #9100 */;
// CommonJS / Node have global context exposed as "global" variable.

View File

@ -6,6 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/
// Import zero symbols from zone.js. This causes the zone ambient type to be
// added to the type-checker, without emitting any runtime module load statement
import {} from 'zone.js';
import {EventEmitter} from '../event_emitter';
/**

View File

@ -1,34 +1,40 @@
{
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/core"
},
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"stripInternal": true,
"experimentalDecorators": true,
"strictNullChecks": true,
"module": "es2015",
"moduleResolution": "node",
"target": "es2015",
"lib": ["es2015", "dom"],
"skipLibCheck": true,
// don't auto-discover @types/node, it results in a ///<reference in the .d.ts output
"types": [],
/**
* The rest of the file is configuration that's overridden by bazel.
* It can be removed after we fully migrate.
*/
"baseUrl": ".",
"experimentalDecorators": true,
"outDir": "../../dist/packages/core",
"paths": {
"rxjs/*": ["../../node_modules/rxjs/*"]
},
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"target": "es2015",
"lib": ["es2015", "dom"],
"skipLibCheck": true,
// don't auto-discover @types/node, it results in a ///<reference in the .d.ts output
"types": []
"inlineSources": true
},
"files": [
"public_api.ts",
"../../node_modules/zone.js/dist/zone.js.d.ts",
"../system.d.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/core"
}
]
}