Skip to content

Commit

Permalink
build: Introduce Bazel build rules
Browse files Browse the repository at this point in the history
So far this just compiles the core and common packages.
  • Loading branch information
alexeagle authored and alxhub committed Jun 5, 2017
1 parent 02d74ca commit 5faf520
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 32 deletions.
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_STORE

/dist/
bazel-*
node_modules
bower_components

Expand Down
18 changes: 18 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -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 changes: 12 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions packages/common/BUILD
Original file line number Diff line number Diff line change
@@ -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",
)
38 changes: 22 additions & 16 deletions packages/common/tsconfig-build.json
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions packages/core/BUILD
Original file line number Diff line number Diff line change
@@ -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",
)
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/zone/ng_zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
36 changes: 21 additions & 15 deletions packages/core/tsconfig-build.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

0 comments on commit 5faf520

Please sign in to comment.