build: build material-examples with bazel (#13932)

This includes a `genrule` to create the generated `ExampleModule`
This commit is contained in:
Paul Gschwendtner
2018-11-02 22:38:34 +01:00
committed by Jeremy Elbourn
parent 150c964c32
commit c64503e0bf
10 changed files with 334 additions and 240 deletions
+5
View File
@@ -24,5 +24,10 @@
"lib": ["es2015", "dom"],
"skipLibCheck": true,
"types": ["tslib"]
},
"bazelOptions": {
// Note: We can remove this once we fully switched away from Gulp. Currently we still set
// some options here just in favor of the standard tsconfig's which extending this one.
"suppressTsconfigOverrideWarnings": true
}
}
+51
View File
@@ -0,0 +1,51 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_package")
load("//:packages.bzl", "CDK_TARGETS", "MATERIAL_TARGETS", "ROLLUP_GLOBALS")
load("//tools:defaults.bzl", "ng_module")
ng_module(
name = "examples",
srcs = glob(["**/*.ts"]) + [":example-module"],
module_name = "@angular/material-examples",
assets = glob(["**/*.html", "**/*.css"]),
deps = [
"@angular//packages/common",
"@angular//packages/core",
"@angular//packages/forms",
"@npm//moment",
"//src/material-moment-adapter",
] + CDK_TARGETS + MATERIAL_TARGETS,
# Specify the tsconfig that is also used by Gulp. We need to explicitly use this tsconfig
# because in order to import Moment with TypeScript, some specific options need to be set.
tsconfig = ":tsconfig-build.json",
)
ng_package(
name = "npm_package",
srcs = ["package.json"],
entry_point = "src/material-examples/public_api.js",
globals = ROLLUP_GLOBALS,
deps = [":examples"],
# TODO(devversion): re-enable once we have set up the proper compiler for the ng_package
tags = ["manual"],
)
genrule(
name = "example-module",
srcs = glob(["**/*.ts"]),
outs = ["example-module.ts"],
cmd = """
# As a workaround for https://github.com/bazelbuild/rules_nodejs/issues/404, we pass the
# data to the Bazel entry-point through environment variables.
export _SOURCE_FILES="$(SRCS)"
export _OUTPUT_FILE="$@"
export _BASE_DIR="$$(dirname $(location //src/material-examples:index.ts))"
# Run the bazel entry-point for generating the example module.
./$(location //tools/example-module:bazel-bin)
""",
tools = ["//tools/example-module:bazel-bin"],
output_to_bindir = True,
)
+1 -1
View File
@@ -18,7 +18,7 @@
// Unset options inherited from tsconfig-build
"annotateForClosureCompiler": false,
"flatModuleOutFile": null,
"flatModuleId": null,
"flatModuleId": null
},
"include": [
"**/*.spec.ts",