build(cdk): add bazel ng_module rules (#8370)

Part of #8369
This commit is contained in:
Jeremy Elbourn
2017-11-15 11:47:56 -08:00
committed by GitHub
parent 262c23b840
commit cf39a419ff
24 changed files with 6147 additions and 2682 deletions
+35
View File
@@ -0,0 +1,35 @@
package(default_visibility = ["//visibility:public"])
# TODO(jelbourn): figure out if these workarounds are still needed
# 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",
# Performance workaround: list individual files
# Reduces the number of files as inputs to nodejs_binary:
# bazel query "deps(:node_modules)" | wc -l
# This won't scale in the general case.
# TODO(alexeagle): figure out what to do
srcs = glob(["/".join(["node_modules", pkg, "**", ext]) for pkg in [
"@angular",
"jasmine",
"typescript",
"tslib",
"zone.js",
"rxjs",
"@types",
"tsickle",
"hammerjs",
"protobufjs",
"bytebuffer",
"reflect-metadata",
"minimist",
"moment",
] for ext in [
"*.js",
"*.json",
"*.d.ts",
]]),
)
+36
View File
@@ -0,0 +1,36 @@
workspace(name = "angular_material_src")
# Add nodejs rules
git_repository(
name = "build_bazel_rules_nodejs",
remote = "https://github.com/bazelbuild/rules_nodejs.git",
# TODO(jelbourn): use the correct tag here.
commit = "31d36ff2acdf630d1e331f38006cf1a5d303d338",
)
# NOTE: this rule installs nodejs, npm, and yarn, but does NOT install
# your npm dependencies. You must still run the package manager.
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")
node_repositories(package_json = ["//:package.json"])
# Add sass rules
git_repository(
name = "io_bazel_rules_sass",
remote = "https://github.com/bazelbuild/rules_sass.git",
tag = "0.0.2",
)
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_repositories")
sass_repositories()
# Add TypeScript rules
local_repository(
name = "build_bazel_rules_typescript",
path = "node_modules/@bazel/typescript",
)
# Add Angular rules
local_repository(
name = "angular",
path = "node_modules/@angular/bazel",
)
+20
View File
@@ -0,0 +1,20 @@
// WORKAROUND https://github.com/angular/angular/issues/18810
// This file is required to run ngc on angular libraries, to write files like
// node_modules/@angular/core/core.ngsummary.json
{
"compilerOptions": {
"lib": [
"dom",
"es2015"
],
"experimentalDecorators": true,
"types": []
},
"include": [
"node_modules/@angular/**/*"
],
"exclude": [
"node_modules/@angular/bazel/**",
"node_modules/@angular/compiler-cli/**"
]
}
+5817 -2676
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -8,6 +8,7 @@
"url": "https://github.com/angular/material2.git"
},
"scripts": {
"postinstall": "ngc -p angular.tsconfig.json",
"build": "gulp :publish:build-releases",
"demo-app": "gulp serve:devapp",
"test": "gulp test",
@@ -39,11 +40,15 @@
"zone.js": "^0.8.12"
},
"devDependencies": {
"@angular/bazel": "^5.0.1",
"@angular/compiler-cli": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/platform-server": "^5.0.0",
"@angular/router": "^5.0.0",
"@angular/upgrade": "^5.0.1",
"@bazel/ibazel": "0.0.1",
"@bazel/typescript": "^0.3.1",
"@google-cloud/storage": "^1.1.1",
"@types/chalk": "^0.4.31",
"@types/fs-extra": "^4.0.3",
+11
View File
@@ -0,0 +1,11 @@
package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
ts_library(
name = "cdk",
srcs = glob(["*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk",
deps = [],
tsconfig = ":tsconfig-build.json",
)
+14
View File
@@ -0,0 +1,14 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "a11y",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/a11y",
deps = [
"//src/cdk/coercion",
"//src/cdk/keycodes",
"//src/cdk/platform",
],
tsconfig = ":tsconfig-build.json",
)
+6 -6
View File
@@ -6,14 +6,14 @@
* found in the LICENSE file at https://angular.io/license
*/
import {NgModule} from '@angular/core';
import {FocusTrapDeprecatedDirective, CdkTrapFocus, FocusTrapFactory} from './focus-trap';
import {LIVE_ANNOUNCER_PROVIDER} from './live-announcer';
import {InteractivityChecker} from './interactivity-checker';
import {CommonModule} from '@angular/common';
import {PlatformModule} from '@angular/cdk/platform';
import {AriaDescriber, ARIA_DESCRIBER_PROVIDER} from './aria-describer';
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {ARIA_DESCRIBER_PROVIDER, AriaDescriber} from './aria-describer';
import {CdkMonitorFocus, FOCUS_MONITOR_PROVIDER} from './focus-monitor';
import {CdkTrapFocus, FocusTrapDeprecatedDirective, FocusTrapFactory} from './focus-trap';
import {InteractivityChecker} from './interactivity-checker';
import {LIVE_ANNOUNCER_PROVIDER} from './live-announcer';
@NgModule({
imports: [CommonModule, PlatformModule],
+13
View File
@@ -0,0 +1,13 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "accordion",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/accordion",
deps = [
"//src/cdk/coercion",
"//src/cdk/collections",
],
tsconfig = ":tsconfig-build.json",
)
+10
View File
@@ -0,0 +1,10 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "bidi",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/bidi",
deps = [],
tsconfig = ":tsconfig-build.json",
)
+11
View File
@@ -0,0 +1,11 @@
package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
# Note: this will need to ng_module if any Angular-specific stuff is added to coercion.
ts_library(
name = "coercion",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/coercion",
deps = [],
tsconfig = ":tsconfig-build.json",
)
+10
View File
@@ -0,0 +1,10 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "collections",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/collections",
deps = [],
tsconfig = ":tsconfig-build.json",
)
+11
View File
@@ -0,0 +1,11 @@
package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
# Note: this will need to ng_module if any Angular-specific stuff is added to coercion.
ts_library(
name = "keycodes",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/keycodes",
deps = [],
tsconfig = ":tsconfig-build.json",
)
+13
View File
@@ -0,0 +1,13 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "layout",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/layout",
deps = [
"//src/cdk/coercion",
"//src/cdk/platform",
],
tsconfig = ":tsconfig-build.json",
)
+10
View File
@@ -0,0 +1,10 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "observers",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/observers",
deps = [],
tsconfig = ":tsconfig-build.json",
)
+17
View File
@@ -0,0 +1,17 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "overlay",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/overlay",
deps = [
"//src/cdk/bidi",
"//src/cdk/coercion",
"//src/cdk/keycodes",
"//src/cdk/platform",
"//src/cdk/portal",
"//src/cdk/scrolling",
],
tsconfig = ":tsconfig-build.json",
)
+10
View File
@@ -0,0 +1,10 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "platform",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/platform",
deps = [],
tsconfig = ":tsconfig-build.json",
)
+10
View File
@@ -0,0 +1,10 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "portal",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/portal",
deps = [],
tsconfig = ":tsconfig-build.json",
)
+12
View File
@@ -0,0 +1,12 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "scrolling",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/scrolling",
deps = [
"//src/cdk/platform",
],
tsconfig = ":tsconfig-build.json",
)
+14
View File
@@ -0,0 +1,14 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "stepper",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/stepper",
deps = [
"//src/cdk/bidi",
"//src/cdk/coercion",
"//src/cdk/keycodes",
],
tsconfig = ":tsconfig-build.json",
)
+1
View File
@@ -0,0 +1 @@
declare var module: {id: string};
+12
View File
@@ -0,0 +1,12 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "table",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/table",
deps = [
"//src/cdk/collections",
],
tsconfig = ":tsconfig-build.json",
)
+1
View File
@@ -0,0 +1 @@
declare var module: {id: string};
+48
View File
@@ -0,0 +1,48 @@
###############################
# Directory structure #
###############################
# Don't create bazel-* symlinks in the WORKSPACE directory.
# These require .gitignore and may scare users.
# Also, it's a workaround for https://github.com/bazelbuild/rules_typescript/issues/12
# which affects the common case of having `tsconfig.json` in the WORKSPACE directory.
#
# Instead, you should run `bazel info bazel-bin` to find out where the outputs went.
build --symlink_prefix=/
# Another good choice is to create a dist/ directory. Then you can use
# build --symlink_prefix=dist/
# to get folders like dist/bin
# But be aware, this will still create a bazel-out symlink in your project directory.
# You may still need to exclude that, eg. from the editor's search path.
###############################
# Output #
###############################
# A more useful default output mode for bazel query
# Prints eg. "ng_module rule //foo:bar" rather than just "//foo:bar"
query --output=label_kind
# Don't print every dependency in :node_modules, for example
query --noimplicit_deps
# By default, failing tests don't print any output, it goes to the log file
test --test_output=errors
# Show which actions are run under workers,
# and print all the actions running in parallel.
# Helps to demonstrate that bazel uses all the cores on the machine.
build --experimental_ui
test --experimental_ui
###############################
# Typescript / Angular / Sass #
###############################
# Make TypeScript and Angular compilation fast, by keeping a few copies of the compiler
# running as daemons, and cache SourceFile AST's to reduce parse time.
build --strategy=TypeScriptCompile=worker --strategy=AngularTemplateCompile=worker
# Workaround rules_sass still using old 'set' constructor
# This is an error in bazel >= 0.6 unless this flag is set
build --incompatible_disallow_set_constructor=false