diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
index 1e9b57e0e8..9f7fa8c52a 100644
--- a/.bazelci/presubmit.yml
+++ b/.bazelci/presubmit.yml
@@ -60,7 +60,7 @@ tasks:
build_targets:
- "//..."
test_flags:
- - "--test_tag_filters=examples"
+ - "--test_tag_filters=examples,-no-bazelci-ubuntu"
- "--local_resources=792,1.0,1.0"
# test_args will be passed to the nested bazel process
- "--test_arg=--local_resources=13288,7.0,1.0"
@@ -72,16 +72,6 @@ tasks:
# TODO(gregmagolan): make node_repositories acccept different archives for different platforms
- "//examples:examples_vendored_node"
- "//examples:examples_vendored_node_and_yarn"
- # ubuntu1604_angular_bazel_example:
- # name: ubuntu1604_angular_bazel_example
- # platform: ubuntu1604
- # bazel-in-bazel angular_bazel_example fails on ubuntu as the bazelci
- # ubuntu docker image is missing shares libs required for the versions
- # of chrome and firefox fetched by rules_webtesting. On circleci
- # we have the same issue but we can work around it using apt-get.
- # on bazelci apt-get fails with permission denied and there is no sudo
- # command to switch to root.
- # TODO(gregmagolan): figure out how to install the shared libs on bazelci
ubuntu1804:
name: ubuntu1804
platform: ubuntu1804
@@ -155,7 +145,7 @@ tasks:
build_targets:
- "//..."
test_flags:
- - "--test_tag_filters=examples"
+ - "--test_tag_filters=examples,-no-bazelci-ubuntu"
- "--local_resources=792,1.0,1.0"
# test_args will be passed to the nested bazel process
- "--test_arg=--local_resources=13288,7.0,1.0"
@@ -167,16 +157,6 @@ tasks:
# TODO(gregmagolan): make node_repositories acccept different archives for different platforms
- "//examples:examples_vendored_node"
- "//examples:examples_vendored_node_and_yarn"
- # ubuntu1804_angular_bazel_example:
- # name: ubuntu1804_angular_bazel_example
- # platform: ubuntu1804
- # bazel-in-bazel angular_bazel_example fails on ubuntu as the bazelci
- # ubuntu docker image is missing shares libs required for the versions
- # of chrome and firefox fetched by rules_webtesting. On circleci
- # we have the same issue but we can work around it using apt-get.
- # on bazelci apt-get fails with permission denied and there is no sudo
- # command to switch to root.
- # TODO(gregmagolan): figure out how to install the shared libs on bazelci
macos:
name: macos
platform: macos
@@ -246,30 +226,6 @@ tasks:
- "--test_arg=--test_tag_filters=-no-bazelci,-no-bazelci-mac,-manual"
test_targets:
- "//..."
- macos_angular_bazel_example:
- name: macos_angular_bazel_example
- platform: macos
- # We need to reduce the memory & CPU usage of the top-level
- # bazel process for bazel-in-bazel tests to not deplete the
- # system memory completely.
- # - startup JVM memory reduced
- # - top-level bazel process should use as little memory as possible and only 1 core
- # - nested bazel process should use a limited number of cores
- shell_commands:
- - echo 'startup --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1536m' >> .bazelrc
- build_targets:
- # Split up the build & test as test takes a long time and has very
- # little output so running build first makes CI output friendlier.
- # The build step can also use up more memory which may be required
- # to build the release package with this configuration.
- - "//e2e:e2e_angular_bazel_example"
- test_flags:
- - "--local_resources=792,1.0,1.0"
- # test_args will be passed to the nested bazel process
- - "--test_arg=--local_resources=14336,4.0,1.0"
- - "--test_arg=--test_tag_filters=-no-bazelci,-manual"
- test_targets:
- - "//e2e:e2e_angular_bazel_example"
macos_cross_compile:
name: macos_cross_compile
platform: macos
@@ -328,19 +284,6 @@ tasks:
- "--test_arg=--local_resources=13288,1.0,1.0"
test_targets:
- "//..."
- # windows_angular_bazel_example:
- # name: windows_angular_bazel_example
- # platform: windows
- # bazel-in-bazel angular_bazel_example fails on Windows on bazelci cloning a git repo:
- # ```
- # ERROR: no such package '@io_bazel_rules_k8s//k8s': Traceback (most recent call last):
- # File "D:/b/ftxm343s/execroot/build_bazel_rules_nodejs/_tmp/3726d3573001cb4068a18af89eb255de/_bazel_b/ktluxf26/external/bazel_tools/tools/build_defs/repo/git.bzl", line 163
- # _clone_or_update(ctx)
- # File "D:/b/ftxm343s/execroot/build_bazel_rules_nodejs/_tmp/3726d3573001cb4068a18af89eb255de/_bazel_b/ktluxf26/external/bazel_tools/tools/build_defs/repo/git.bzl", line 36, in _clone_or_update
- # git_repo(ctx, directory)
- # ```
- # This is most likely due to a memory issue with this large bazel-in-bazel test.
- # TODO(gregmagolan): figure out what is broken with the above
windows_cross_compile:
name: windows_cross_compile
platform: windows
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 488cb52057..c1021db2f7 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -224,33 +224,6 @@ jobs:
command: bazel test --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,7.0,1.0 //examples:examples_vendored_node //examples:examples_vendored_node_and_yarn
no_output_timeout: 20m
- test_e2e_angular_bazel_example:
- <<: *job_defaults
- resource_class: xlarge
- # We need to reduce the memory & CPU usage of the top-level
- # bazel process for this large bazel-in-bazel test to not
- # deplete the system memory completely.
- # - startup JVM memory reduced
- # - top-level bazel process should use as little memory as possible and only 1 core
- # - nested bazel process should have its memory & core optimally capped as well
- steps:
- - *attach_workspace
- - *init_environment
- - run:
- name: Tune top-level bazel JVM memory usage
- command: echo 'startup --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1280m' >> .bazelrc
- - *init_bazel
- - *hide_node_and_yarn_local_binaries
-
- # Split up the build & test as test takes a long time and has very
- # little output so running build first makes CI output friendlier.
- # The build step can also use up more memory which may be required
- # to build the release package with this configuration.
- - run: bazel build //e2e:e2e_angular_bazel_example
- - run:
- command: bazel test --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,7.0,1.0 --test_arg=--test_tag_filters=-no-circleci,-manual //e2e:e2e_angular_bazel_example
- no_output_timeout: 20m
-
test_legacy_runfiles:
<<: *job_defaults
steps:
@@ -284,6 +257,3 @@ workflows:
- test_examples:
requires:
- setup
- - test_e2e_angular_bazel_example:
- requires:
- - setup
diff --git a/e2e/BUILD.bazel b/e2e/BUILD.bazel
index e174878c0f..afe85304b1 100644
--- a/e2e/BUILD.bazel
+++ b/e2e/BUILD.bazel
@@ -175,23 +175,6 @@ e2e_integration_test(
},
)
-e2e_integration_test(
- name = "e2e_angular_bazel_example",
- size = "enormous",
- timeout = "eternal",
- # to reduce the chance of depleting all available system memory locally
- # and on CI, limit the Bazel JVM memory usage for the nested bazel process
- bazelrc_append = "startup --host_jvm_args=-Xms256m --host_jvm_args=-Xmx2g",
- npm_packages = {
- "//packages/karma:npm_package": "@bazel/karma",
- "//packages/protractor:npm_package": "@bazel/protractor",
- "//packages/typescript:npm_package": "@bazel/typescript",
- },
- # TODO(gregmagolan): why is this tagged manual?
- tags = ["manual"],
- workspace_files = "@e2e_angular_bazel_example//:bazel_integration_test_files",
-)
-
load(":index.bzl", "ALL_E2E")
# Ensure that all e2e directories have a test target
diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel
index 4854babfa8..ad8a0e942c 100644
--- a/examples/BUILD.bazel
+++ b/examples/BUILD.bazel
@@ -14,6 +14,36 @@
load(":test.bzl", "example_integration_test")
+example_integration_test(
+ name = "examples_angular",
+ npm_packages = {
+ "//packages/karma:npm_package": "@bazel/karma",
+ "//packages/protractor:npm_package": "@bazel/protractor",
+ "//packages/typescript:npm_package": "@bazel/typescript",
+ },
+ tags = [
+ # bazel-in-bazel angular_bazel_example fails on ubuntu as the bazelci
+ # ubuntu docker image is missing shares libs required for the versions
+ # of chrome and firefox fetched by rules_webtesting. On circleci
+ # we have the same issue but we can work around it using apt-get.
+ # on bazelci apt-get fails with permission denied and there is no sudo
+ # command to switch to root.
+ # TODO(gregmagolan): figure out how to install the shared libs on bazelci
+ "no-bazelci-ubuntu",
+ # bazel-in-bazel angular_bazel_example fails on Windows on bazelci cloning a git repo:
+ # ```
+ # ERROR: no such package '@io_bazel_rules_k8s//k8s': Traceback (most recent call last):
+ # File "D:/b/ftxm343s/execroot/build_bazel_rules_nodejs/_tmp/3726d3573001cb4068a18af89eb255de/_bazel_b/ktluxf26/external/bazel_tools/tools/build_defs/repo/git.bzl", line 163
+ # _clone_or_update(ctx)
+ # File "D:/b/ftxm343s/execroot/build_bazel_rules_nodejs/_tmp/3726d3573001cb4068a18af89eb255de/_bazel_b/ktluxf26/external/bazel_tools/tools/build_defs/repo/git.bzl", line 36, in _clone_or_update
+ # git_repo(ctx, directory)
+ # ```
+ # This is most likely due to a memory issue with this large bazel-in-bazel test.
+ # TODO(gregmagolan): figure out what is broken with the above
+ "no-bazelci-windows",
+ ],
+)
+
example_integration_test(
name = "examples_app",
npm_packages = {
diff --git a/examples/angular/.bazelrc b/examples/angular/.bazelrc
new file mode 100644
index 0000000000..3431057af6
--- /dev/null
+++ b/examples/angular/.bazelrc
@@ -0,0 +1 @@
+import %workspace%/../../common.bazelrc
diff --git a/examples/angular/BUILD.bazel b/examples/angular/BUILD.bazel
new file mode 100644
index 0000000000..19ff32de5a
--- /dev/null
+++ b/examples/angular/BUILD.bazel
@@ -0,0 +1,37 @@
+load("@k8s_deploy//:defaults.bzl", "k8s_deploy")
+
+package(default_visibility = ["//:__subpackages__"])
+
+# ts_library and ng_module use the `//:tsconfig.json` target
+# by default. This alias allows omitting explicit tsconfig
+# attribute.
+alias(
+ name = "tsconfig.json",
+ actual = "//src:tsconfig.json",
+)
+
+k8s_deploy(
+ name = "deploy",
+ images = {
+ "gcr.io/internal-200822/src:nodejs_image": "//src:image",
+ },
+ template = ":deployment.yaml",
+)
+
+# For testing from the root workspace of this repository with bazel_integration_test.
+filegroup(
+ name = "all_files",
+ srcs = glob(
+ include = ["**/*"],
+ exclude = [
+ "bazel-out/**/*",
+ "dist/**/*",
+ "node_modules/**/*",
+ ],
+ ) + [
+ "//e2e:all_files",
+ "//src:all_files",
+ "//tools:all_files",
+ ],
+ visibility = ["//visibility:public"],
+)
diff --git a/examples/angular/WORKSPACE b/examples/angular/WORKSPACE
new file mode 100644
index 0000000000..a117cea255
--- /dev/null
+++ b/examples/angular/WORKSPACE
@@ -0,0 +1,146 @@
+# The WORKSPACE file tells Bazel that this directory is a "workspace", which is like a project root.
+# The content of this file specifies all the external dependencies Bazel needs to perform a build.
+
+####################################
+# ESModule imports (and TypeScript imports) can be absolute starting with the workspace name.
+# The name of the workspace should match the npm package where we publish, so that these
+# imports also make sense when referencing the published package.
+workspace(
+ name = "angular_bazel_example",
+ managed_directories = {"@npm": ["node_modules"]},
+)
+
+# These rules are built-into Bazel but we need to load them first to download more rules
+load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+# Fetch rules_nodejs so we can install our npm dependencies
+http_archive(
+ name = "build_bazel_rules_nodejs",
+ sha256 = "0d9660cf0894f1fe1e9840818553e0080fbce0851169812d77a70bdb9981c946",
+ urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.37.0/rules_nodejs-0.37.0.tar.gz"],
+)
+
+# Fetch sass rules for compiling sass files
+http_archive(
+ name = "io_bazel_rules_sass",
+ sha256 = "4f05239080175a3f4efa8982d2b7775892d656bb47e8cf56914d5f9441fb5ea6",
+ strip_prefix = "rules_sass-86ca977cf2a8ed481859f83a286e164d07335116",
+ url = "https://github.com/bazelbuild/rules_sass/archive/86ca977cf2a8ed481859f83a286e164d07335116.zip",
+)
+
+# Check the bazel version and download npm dependencies
+load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "yarn_install")
+
+# Bazel version must be at least the following version because:
+# - 0.27.0 Adds managed directories support
+check_bazel_version(
+ message = """
+You no longer need to install Bazel on your machine.
+Angular has a dependency on the @bazel/bazel package which supplies it.
+Try running `yarn bazel` instead.
+ (If you did run that, check that you've got a fresh `yarn install`)
+
+""",
+ minimum_bazel_version = "0.27.0",
+)
+
+# Setup the Node.js toolchain & install our npm dependencies into @npm
+yarn_install(
+ name = "npm",
+ package_json = "//:package.json",
+ yarn_lock = "//:yarn.lock",
+)
+
+# Install all bazel dependencies of our npm packages
+load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
+
+install_bazel_dependencies()
+
+# Load npm_bazel_protractor dependencies
+load("@npm_bazel_protractor//:package.bzl", "npm_bazel_protractor_dependencies")
+
+npm_bazel_protractor_dependencies()
+
+# Load npm_bazel_karma dependencies
+load("@npm_bazel_karma//:package.bzl", "rules_karma_dependencies")
+
+rules_karma_dependencies()
+
+# Setup the rules_webtesting toolchain
+load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
+
+web_test_repositories()
+
+# Temporary work-around for https://github.com/angular/angular/issues/28681
+# TODO(gregmagolan): go back to @io_bazel_rules_webtesting browser_repositories
+load("@npm_bazel_karma//:browser_repositories.bzl", "browser_repositories")
+
+browser_repositories()
+
+# Setup the rules_typescript tooolchain
+load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace")
+
+ts_setup_workspace()
+
+# Setup the rules_sass toolchain
+load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
+
+sass_repositories()
+
+################################
+# Support for Remote Execution #
+################################
+
+http_archive(
+ name = "bazel_toolchains",
+ sha256 = "88e818f9f03628eef609c8429c210ecf265ffe46c2af095f36c7ef8b1855fef5",
+ strip_prefix = "bazel-toolchains-92dd8a7",
+ urls = [
+ "https://github.com/bazelbuild/bazel-toolchains/archive/92dd8a7.zip",
+ ],
+)
+
+####################################################
+# Support creating Docker images for our node apps #
+####################################################
+
+http_archive(
+ name = "io_bazel_rules_docker",
+ sha256 = "aed1c249d4ec8f703edddf35cbe9dfaca0b5f5ea6e4cd9e83e99f3b0d1136c3d",
+ strip_prefix = "rules_docker-0.7.0",
+ urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.7.0.tar.gz"],
+)
+
+load("@io_bazel_rules_docker//nodejs:image.bzl", nodejs_image_repos = "repositories")
+
+nodejs_image_repos()
+
+####################################################
+# Kubernetes setup, for deployment to Google Cloud #
+####################################################
+
+git_repository(
+ name = "io_bazel_rules_k8s",
+ commit = "36ae5b534cc51ab0815c9bc723760469a9f7175c",
+ remote = "https://github.com/bazelbuild/rules_k8s.git",
+ shallow_since = "1545317854 -0500",
+)
+
+load("@io_bazel_rules_k8s//k8s:k8s.bzl", "k8s_defaults", "k8s_repositories")
+
+k8s_repositories()
+
+k8s_defaults(
+ # This creates a rule called "k8s_deploy" that we can call later
+ name = "k8s_deploy",
+ # This is the name of the cluster as it appears in:
+ # kubectl config view --minify -o=jsonpath='{.contexts[0].context.cluster}'
+ cluster = "_".join([
+ "gke",
+ "internal-200822",
+ "us-west1-a",
+ "angular-bazel-example",
+ ]),
+ kind = "deployment",
+)
diff --git a/examples/angular/angular-metadata.tsconfig.json b/examples/angular/angular-metadata.tsconfig.json
new file mode 100644
index 0000000000..89431c3e44
--- /dev/null
+++ b/examples/angular/angular-metadata.tsconfig.json
@@ -0,0 +1,39 @@
+// WORKAROUND https://github.com/angular/angular/issues/18810
+//
+// This file is required to run ngc on 3rd party libraries such as @ngrx,
+// to write files like node_modules/@ngrx/store/store.ngsummary.json.
+//
+{
+ "compilerOptions": {
+ "lib": [
+ "dom",
+ "es2015"
+ ],
+ "experimentalDecorators": true,
+ "types": [],
+ "module": "amd",
+ "moduleResolution": "node"
+ },
+ "angularCompilerOptions": {
+ "enableSummariesForJit": true
+ },
+ "include": [
+ "node_modules/@angular/**/*",
+ "node_modules/@ngrx/**/*"
+ ],
+ "exclude": [
+ "node_modules/@ngrx/store/migrations/**",
+ "node_modules/@ngrx/store/schematics/**",
+ "node_modules/@ngrx/store/schematics-core/**",
+ "node_modules/@angular/cdk/schematics/**",
+ "node_modules/@angular/cdk/typings/schematics/**",
+ "node_modules/@angular/material/schematics/**",
+ "node_modules/@angular/material/typings/schematics/**",
+ "node_modules/@angular/common/upgrade*",
+ "node_modules/@angular/router/upgrade*",
+ "node_modules/@angular/bazel/**",
+ "node_modules/@angular/compiler-cli/**",
+ "node_modules/@angular/**/testing/**"
+
+ ]
+}
diff --git a/examples/angular/deployment.yaml b/examples/angular/deployment.yaml
new file mode 100644
index 0000000000..1fbf2c6f71
--- /dev/null
+++ b/examples/angular/deployment.yaml
@@ -0,0 +1,19 @@
+# Configuration for deployment to kubernetes
+
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+ name: angular-bazel-example-prod
+spec:
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ app: angular-bazel-example-prod
+ spec:
+ containers:
+ - name: angular-bazel-example
+ image: gcr.io/internal-200822/src:nodejs_image
+ imagePullPolicy: Always
+ ports:
+ - containerPort: 8080
diff --git a/examples/angular/e2e/BUILD.bazel b/examples/angular/e2e/BUILD.bazel
new file mode 100644
index 0000000000..c0ccfb79e5
--- /dev/null
+++ b/examples/angular/e2e/BUILD.bazel
@@ -0,0 +1,35 @@
+load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite")
+load("@npm_bazel_typescript//:defs.bzl", "ts_library")
+
+ts_library(
+ name = "e2e",
+ testonly = 1,
+ srcs = glob(["src/*.ts"]),
+ tsconfig = "//src:tsconfig-test",
+ deps = [
+ "@npm//@types/jasmine",
+ "@npm//jasmine",
+ "@npm//protractor",
+ ],
+)
+
+protractor_web_test_suite(
+ name = "prodserver_test",
+ on_prepare = ":protractor.on-prepare.js",
+ server = "//src:prodserver",
+ deps = [":e2e"],
+)
+
+protractor_web_test_suite(
+ name = "devserver_test",
+ on_prepare = ":protractor.on-prepare.js",
+ server = "//src:devserver",
+ deps = [":e2e"],
+)
+
+# For testing from the root workspace of this repository with bazel_integration_test.
+filegroup(
+ name = "all_files",
+ srcs = glob(["**/*"]),
+ visibility = ["//visibility:public"],
+)
diff --git a/examples/angular/e2e/protractor.on-prepare.js b/examples/angular/e2e/protractor.on-prepare.js
new file mode 100644
index 0000000000..813592154c
--- /dev/null
+++ b/examples/angular/e2e/protractor.on-prepare.js
@@ -0,0 +1,26 @@
+// The function exported from this file is used by the protractor_web_test_suite.
+// It is passed to the `onPrepare` configuration setting in protractor and executed
+// before running tests.
+//
+// If the function returns a promise, as it does here, protractor will wait
+// for the promise to resolve before running tests.
+
+const protractorUtils = require('@bazel/protractor/protractor-utils');
+const protractor = require('protractor');
+const path = require('path');
+
+module.exports = function(config) {
+ // In this example, `@bazel/protractor/protractor-utils` is used to run
+ // the server. protractorUtils.runServer() runs the server on a randomly
+ // selected port (given a port flag to pass to the server as an argument).
+ // The port used is returned in serverSpec and the protractor serverUrl
+ // is the configured.
+ const isProdserver = path.basename(config.server, path.extname(config.server)) === 'prodserver';
+ return protractorUtils
+ .runServer(config.workspace, config.server, isProdserver ? '-p' : '-port', [])
+ .then(serverSpec => {
+ // Example app is hosted under `/example` in the prodserver and under `/` in devserver
+ const serverUrl = `http://localhost:${serverSpec.port}` + (isProdserver ? '/example' : '');
+ protractor.browser.baseUrl = serverUrl;
+ });
+};
diff --git a/examples/angular/e2e/src/app.e2e-spec.ts b/examples/angular/e2e/src/app.e2e-spec.ts
new file mode 100644
index 0000000000..3de22628e0
--- /dev/null
+++ b/examples/angular/e2e/src/app.e2e-spec.ts
@@ -0,0 +1,16 @@
+import {AppPage} from './app.po';
+
+describe('angular example application', () => {
+ let page: AppPage;
+
+ beforeEach(() => {
+ page = new AppPage();
+ });
+
+ it('should display: Hello World!', async () => {
+ await page.navigateTo();
+ expect(await page.getParagraphText()).toEqual(`Hello Adolph Blain...`);
+ await page.typeInInput('!');
+ expect(await page.getParagraphText()).toEqual(`Hello Adolph Blain...!`);
+ });
+});
diff --git a/examples/angular/e2e/src/app.po.ts b/examples/angular/e2e/src/app.po.ts
new file mode 100644
index 0000000000..73033fc89a
--- /dev/null
+++ b/examples/angular/e2e/src/app.po.ts
@@ -0,0 +1,22 @@
+import {browser, by, element} from 'protractor';
+
+export class AppPage {
+ async navigateTo() {
+ await browser.get(browser.baseUrl + '/hello');
+ return browser.waitForAngular();
+ }
+
+ async waitForElement(el, timeout = 10000) {
+ await browser.wait(() => el.isPresent(), timeout);
+ await browser.wait(() => el.isDisplayed(), timeout);
+ return el;
+ }
+
+ async getParagraphText() {
+ return (await this.waitForElement(element(by.css('div#greeting')))).getText();
+ }
+
+ async typeInInput(s: string) {
+ return (await this.waitForElement(element(by.css('input')))).sendKeys(s);
+ }
+}
diff --git a/examples/angular/package.json b/examples/angular/package.json
new file mode 100644
index 0000000000..1ac9988459
--- /dev/null
+++ b/examples/angular/package.json
@@ -0,0 +1,65 @@
+{
+ "name": "angular-bazel-example",
+ "private": true,
+ "description": "Demo of building Angular apps with Bazel",
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=10.9.0 <11.0.0",
+ "yarn": ">=1.9.2 <2.0.0"
+ },
+ "dependencies": {
+ "@angular/animations": "8.2.6",
+ "@angular/cdk": "8.2.0",
+ "@angular/common": "8.2.6",
+ "@angular/core": "8.2.6",
+ "@angular/forms": "8.2.6",
+ "@angular/material": "8.2.0",
+ "@angular/platform-browser": "8.2.6",
+ "@angular/platform-browser-dynamic": "8.2.6",
+ "@angular/router": "8.2.6",
+ "@ngrx/store": "8.0.1",
+ "date-fns": "1.30.1",
+ "rxjs": "6.5.2",
+ "systemjs": "0.21.6",
+ "tslib": "1.10.0",
+ "zone.js": "0.10.2"
+ },
+ "devDependencies": {
+ "@angular/bazel": "8.2.6",
+ "@angular/cli": "8.3.4",
+ "@angular/compiler": "8.2.6",
+ "@angular/compiler-cli": "8.2.6",
+ "@bazel/bazel": "^0.29.0",
+ "@bazel/benchmark-runner": "0.1.0",
+ "@bazel/buildifier": "0.28.0",
+ "@bazel/ibazel": "0.10.3",
+ "@bazel/karma": "~0.37.0",
+ "@bazel/protractor": "~0.37.0",
+ "@bazel/typescript": "~0.37.0",
+ "@types/jasmine": "3.4.0",
+ "@types/node": "6.14.6",
+ "clang-format": "1.2.4",
+ "core-js": "2.6.9",
+ "firebase-tools": "7.1.0",
+ "husky": "3.0.4",
+ "ts-morph": "3.1.0",
+ "typescript": "3.4.5"
+ },
+ "scripts": {
+ "build": "bazel build //src:bundle",
+ "serve": "ibazel run //src:devserver",
+ "deploy": "ng build && firebase deploy",
+ "serve-prod": "bazel run //src:prodserver",
+ "e2e": "bazel test //e2e:all",
+ "test": "bazel test //src/...",
+ "benchmark": "ibazel-benchmark-runner //src:devserver src/app/hello-world/hello-world.component.ts --url=http://localhost:5432",
+ "postinstall": "ngc -p angular-metadata.tsconfig.json",
+ "bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-actions,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,out-of-order-load,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unsorted-dict-items,unused-variable",
+ "bazel:lint": "yarn bazel:format --lint=warn",
+ "bazel:lint-fix": "yarn bazel:format --lint=fix",
+ "format": "git-clang-format",
+ "precommit": "check-clang-format \"yarn format\"",
+ "generate": "node tools/generator/index.js",
+ "generate:clean": "node tools/generator/index.js --clean"
+ }
+}
diff --git a/examples/angular/src/BUILD.bazel b/examples/angular/src/BUILD.bazel
new file mode 100644
index 0000000000..7b7788cf99
--- /dev/null
+++ b/examples/angular/src/BUILD.bazel
@@ -0,0 +1,206 @@
+load("@build_bazel_rules_nodejs//:defs.bzl", "history_server", "rollup_bundle")
+load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
+load("@io_bazel_rules_docker//container:container.bzl", "container_image")
+load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")
+load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
+load("@npm_angular_bazel//:index.bzl", "ng_module")
+load("@npm_bazel_typescript//:defs.bzl", "ts_config", "ts_devserver", "ts_library")
+
+package(default_visibility = ["//:__subpackages__"])
+
+ts_config(
+ name = "tsconfig-test",
+ src = "tsconfig-test.json",
+ deps = [":tsconfig.json"],
+)
+
+# Run the sass compiler to output "styles.css"
+# TODO(alexeagle): demonstrate the sass_library rule too
+sass_binary(
+ name = "styles",
+ src = "styles.scss",
+)
+
+# We don't import from these, but the generated ngfactory code will
+NG_FACTORY_ADDED_IMPORTS = [
+ "@npm//@angular/animations",
+ "@npm//@angular/cdk",
+ "@npm//@angular/material",
+ "@npm//@angular/forms",
+]
+
+ts_library(
+ name = "initialize_testbed",
+ testonly = 1,
+ srcs = [
+ "initialize_testbed.ts",
+ ],
+ deps = [
+ "@npm//@angular/core",
+ "@npm//@angular/platform-browser-dynamic",
+ "@npm//@types",
+ ],
+)
+
+ng_module(
+ name = "src",
+ srcs = [
+ "main.dev.ts",
+ "main.prod.ts",
+ ],
+ tsconfig = ":tsconfig.json",
+ deps = NG_FACTORY_ADDED_IMPORTS + [
+ "//src/app",
+ "@npm//@angular/core",
+ "@npm//@angular/platform-browser",
+ "@npm//@angular/router",
+ "@npm//@ngrx/store",
+ ],
+)
+
+filegroup(
+ name = "rxjs_umd_modules",
+ srcs = [
+ ":rxjs_shims.js",
+ "@npm//:node_modules/rxjs/bundles/rxjs.umd.js",
+ ],
+)
+
+# Files that we serve in both development and production
+_ASSETS = [
+ # This label references an output of the "styles" sass_binary above.
+ ":styles.css",
+
+ # Directly reference a file that came from @angular/material npm package
+ "@npm//:node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
+
+ # We load zone.js outside the bundle. That's because it's a "pollyfill"
+ # which speculates that such features might be available in a browser.
+ # Also it's tricky to configure dead code elimination to understand that
+ # zone.js is used, given that we don't have any import statement that
+ # imports from it.
+ "@npm//:node_modules/zone.js/dist/zone.min.js",
+]
+
+# This devserver is written in Go and is super-fast.
+# It doesn't run any bundler or code splitter. Instead, it concatenates
+# named UMD and named AMD JavaScript code on-the-fly in-memory.
+# This scales really well for massive codebases.
+ts_devserver(
+ name = "devserver",
+ # Serve these files but don't inject tags for them into the index file
+ # This might be because we only want to lazy-load these scripts on-demand,
+ # or because they aren't compatible with Require.js so we must use a runtime
+ # loader to load them.
+ data = [
+ "//src/assets",
+ ],
+ # Start from the development version of the main
+ entry_module = "angular_bazel_example/src/main.dev",
+ #
+
+