Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Commit ea4846b

Browse files
CaerusKaruAdam Plumer
authored and
Adam Plumer
committed
build: upgrade to Angular v9 and switch to Bazel
1 parent f11c8ff commit ea4846b

File tree

93 files changed

+8173
-16117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+8173
-16117
lines changed

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.bazelrc

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
###############################
2+
# Filesystem interactions #
3+
###############################
4+
5+
# Don't create bazel-* symlinks in the WORKSPACE directory.
6+
# These require .gitignore and may scare users. Also, it's a workaround for
7+
# https://github.com/bazelbuild/rules_typescript/issues/12 which affects the common case of
8+
# having `tsconfig.json` in the WORKSPACE directory. Instead, you should run
9+
# `bazel info output_base` to find out where the outputs went.
10+
build --symlink_prefix=/
11+
12+
# Performance: avoid stat'ing input files
13+
build --watchfs
14+
15+
# Turn off legacy external runfiles
16+
build --nolegacy_external_runfiles
17+
run --nolegacy_external_runfiles
18+
test --nolegacy_external_runfiles
19+
20+
# This flag is needed to so that the bazel cache is not invalidated
21+
# when running bazel via `yarn bazel`.
22+
build --incompatible_strict_action_env
23+
24+
# Do not build runfile forests by default. If an execution strategy relies on runfile
25+
# forests, the forest is created on-demand. See: https://github.com/bazelbuild/bazel/issues/6627
26+
# and https://github.com/bazelbuild/bazel/commit/03246077f948f2790a83520e7dccc2625650e6df
27+
build --nobuild_runfile_links
28+
29+
###############################
30+
# Output control #
31+
###############################
32+
33+
# A more useful default output mode for bazel query
34+
# Prints eg. "ng_module rule //foo:bar" rather than just "//foo:bar"
35+
query --output=label_kind
36+
37+
# By default, failing tests don't print any output, it goes to the log file
38+
test --test_output=errors
39+
40+
#################################
41+
# Release configuration. #
42+
# Run with "--config=release" #
43+
#################################
44+
45+
# Configures script to do version stamping.
46+
# See https://docs.bazel.build/versions/master/user-manual.html#flag--workspace_status_command
47+
build:release --workspace_status_command="node ./tools/bazel-stamp-vars.js"
48+
build:release --stamp
49+
50+
################################
51+
# View Engine / Ivy toggle #
52+
################################
53+
build:view-engine --define=angular_ivy_enabled=False
54+
build:ivy --define=angular_ivy_enabled=True
55+
56+
# Set Ivy as the default
57+
build --config=ivy
58+
59+
################################
60+
# --config=debug #
61+
################################
62+
63+
# Enable debugging tests with --config=debug
64+
test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test_strategy=exclusive --test_timeout=9999 --nocache_test_results
65+
66+
################################
67+
# Local Environment Setup #
68+
# Needs to be last statement #
69+
################################
70+
# Load any settings which are specific to the current user. Needs to be *last* statement
71+
# in this config, as the user configuration should be able to overwrite flags from this file.
72+
try-import .bazelrc.user

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0.0

.npmignore

Lines changed: 0 additions & 19 deletions
This file was deleted.

BUILD.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
load("//:rollup-globals.bzl", "ROLLUP_GLOBALS")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
exports_files([
6+
"LICENSE",
7+
])
8+
9+
genrule(
10+
name = "rollup_globals",
11+
outs = ["rollup_globals.json"],
12+
cmd = "echo '%s' > $@" % ROLLUP_GLOBALS,
13+
)

WORKSPACE

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
workspace(
2+
name = "preboot",
3+
managed_directories = {"@npm": ["node_modules"]},
4+
)
5+
6+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
7+
8+
# Add NodeJS rules
9+
http_archive(
10+
name = "build_bazel_rules_nodejs",
11+
sha256 = "d14076339deb08e5460c221fae5c5e9605d2ef4848eee1f0c81c9ffdc1ab31c1",
12+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.6.1/rules_nodejs-1.6.1.tar.gz"],
13+
)
14+
15+
load("@build_bazel_rules_nodejs//:index.bzl", "check_bazel_version", "node_repositories", "yarn_install")
16+
17+
# The minimum bazel version to use with this repo is v3.1.0.
18+
check_bazel_version("3.0.0")
19+
20+
node_repositories(
21+
node_repositories = {
22+
"12.9.1-darwin_amd64": ("node-v12.9.1-darwin-x64.tar.gz", "node-v12.9.1-darwin-x64", "9aaf29d30056e2233fd15dfac56eec12e8342d91bb6c13d54fb5e599383dddb9"),
23+
"12.9.1-linux_amd64": ("node-v12.9.1-linux-x64.tar.xz", "node-v12.9.1-linux-x64", "680a1263c9f5f91adadcada549f0a9c29f1b26d09658d2b501c334c3f63719e5"),
24+
"12.9.1-windows_amd64": ("node-v12.9.1-win-x64.zip", "node-v12.9.1-win-x64", "6a4e54bda091bd02dbd8ff1b9f6671e036297da012a53891e3834d4bf4bed297"),
25+
},
26+
node_urls = ["https://nodejs.org/dist/v{version}/{filename}"],
27+
node_version = "12.9.1",
28+
# We do not need to define a specific yarn version as bazel will respect the .yarnrc file
29+
# and run the version of yarn defined at the set-path value.
30+
# Since bazel runs yarn from the working directory of the package.json, and our .yarnrc
31+
# file is in the same directory, it correctly discovers and respects it. Additionally,
32+
# it ensures that the yarn environment variable to detect if yarn has already followed
33+
# the set-path value is reset.
34+
)
35+
36+
yarn_install(
37+
name = "npm",
38+
# Redirects Yarn `stdout` output to `stderr`. This ensures that stdout is not accidentally
39+
# polluted when Bazel runs Yarn. Workaround until the upstream fix is available:
40+
# https://github.com/bazelbuild/bazel/pull/10611.
41+
args = ["1>&2"],
42+
# We add the postinstall patches file, and ngcc main fields update script here so
43+
# that Yarn will rerun whenever one of these files has been modified.
44+
data = [
45+
"//:tools/postinstall/apply-patches.js",
46+
"//:tools/postinstall/update-ngcc-main-fields.js",
47+
],
48+
package_json = "//:package.json",
49+
quiet = False,
50+
yarn_lock = "//:yarn.lock",
51+
)
52+
53+
# Install all bazel dependencies of the @ngdeps npm packages
54+
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
55+
56+
install_bazel_dependencies()
57+
58+
# Setup TypeScript Bazel workspace
59+
load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")
60+
61+
ts_setup_workspace()
62+
63+
# Fetch transitive dependencies which are needed to use the karma rules.
64+
load("@npm_bazel_karma//:package.bzl", "npm_bazel_karma_dependencies")
65+
66+
npm_bazel_karma_dependencies()
67+
68+
# Setup web testing. We need to setup a browser because the web testing rules for TypeScript need
69+
# a reference to a registered browser (ideally that's a hermetic version of a browser)
70+
load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
71+
72+
web_test_repositories()
73+
74+
load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl", "browser_repositories")
75+
76+
browser_repositories(
77+
chromium = True,
78+
firefox = True,
79+
)

angular-tsconfig.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Workaround for https://github.com/angular/angular/issues/18810
2+
// This file is required because when using the Angular NPM packages and building
3+
// with AOT compilation, NGC needs the "ngsummary.json" files.
4+
{
5+
"angularCompilerOptions": {
6+
// In snapshot builds the compiler-cli will now use ngtsc by default. In
7+
// order to be able to build the summary files, we need to use ngc.
8+
"enableIvy": false
9+
},
10+
"compilerOptions": {
11+
"module": "umd",
12+
"moduleResolution": "node",
13+
"lib": [
14+
"dom",
15+
"es2015"
16+
],
17+
"experimentalDecorators": true,
18+
"types": []
19+
},
20+
"include": [
21+
"node_modules/@angular/**/*"
22+
],
23+
"exclude": [
24+
"node_modules/@angular/**/schematics/**",
25+
"node_modules/@angular/**/testing/**",
26+
"node_modules/@angular/bazel/**",
27+
"node_modules/@angular/common/upgrade*",
28+
"node_modules/@angular/compiler-cli/**",
29+
"node_modules/@angular/router/upgrade*"
30+
]
31+
}

bs-config.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)