Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 0676c11

Browse files
authored
feat: Use Bazel for builds (#2152)
BREAKING CHANGES: Components can no longer be imported through `@angular-mdc/web`. Use the individual secondary entry-points, such as `@angular-mdc/web/button` Also, we no longer have a direct depedency on `tslib`. Instead it is now listed a `peerDependency`. Users not using the Angular CLI will need to manually install `tslib` via; ``` yarn add tslib # or npm install tslib --save ``` closes #2151 closes #2153
1 parent 63979c8 commit 0676c11

File tree

306 files changed

+9255
-5050
lines changed

Some content is hidden

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

306 files changed

+9255
-5050
lines changed

.bazelignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.bazelrc

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
###############################
25+
# Output control #
26+
###############################
27+
28+
# A more useful default output mode for bazel query
29+
# Prints eg. "ng_module rule //foo:bar" rather than just "//foo:bar"
30+
query --output=label_kind
31+
32+
# By default, failing tests don't print any output, it goes to the log file
33+
test --test_output=errors
34+
35+
#################################
36+
# Release configuration. #
37+
# Run with "--config=release" #
38+
#################################
39+
40+
# Configures script to do version stamping.
41+
# See https://docs.bazel.build/versions/master/user-manual.html#flag--workspace_status_command
42+
build:release --workspace_status_command="node ./tools/bazel-stamp-vars.js"
43+
build:release --stamp
44+
45+
################################
46+
# View Engine / Ivy toggle #
47+
################################
48+
build:view-engine --define=angular_ivy_enabled=False
49+
build:ivy --define=angular_ivy_enabled=True
50+
51+
# Set Ivy as the default
52+
build --config=ivy
53+
54+
################################
55+
# --config=debug #
56+
################################
57+
58+
# Enable debugging tests with --config=debug
59+
test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test_strategy=exclusive --test_timeout=9999 --nocache_test_results
60+
61+
################################
62+
# Local Environment Setup #
63+
# Needs to be last statement #
64+
################################
65+
# Load any settings which are specific to the current user. Needs to be *last* statement
66+
# in this config, as the user configuration should be able to overwrite flags from this file.
67+
try-import .bazelrc.user
68+
69+
# TODO: check if we can enable these deprecations.
70+
build --incompatible_new_actions_api=false
71+
build --incompatible_no_support_tools_in_action_inputs=false

.bazelversion

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.2.0

.gitattributes

-2
This file was deleted.

.github/workflows/build-deploy-docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
yarn
3636
3737
- name: Build angular-mdc-web
38-
run: yarn run build:release
38+
run: sudo yarn run build
3939

4040
- name: Build documentation
4141
run: |

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
with:
2626
node-version: 13
2727
- run: yarn
28-
- run: yarn build
28+
- run: sudo yarn build
2929
unit-test:
3030
runs-on: ubuntu-latest
3131
steps:

.gitignore

+12-9
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
/dist
55
/tmp
66
/out-tsc
7+
/bazel-out
8+
/demos/node_modules
9+
/demos/dist
710

811
# dependencies
912
/node_modules
10-
/demos/node_modules
11-
/demos/dist
1213

1314
# IDEs and editors
1415
/.idea
@@ -20,18 +21,20 @@
2021
*.sublime-workspace
2122

2223
# IDE - VSCode
23-
.vscode/*
24+
/.idea
25+
/.vscode/launch.json
26+
/*.iml
2427

2528
# misc
29+
.DS_Store
2630
/.sass-cache
2731
/connect.lock
28-
/coverage
2932
/libpeerconnection.log
3033
npm-debug.log
34+
yarn-debug.log
3135
yarn-error.log
3236
testem.log
33-
/typings
34-
35-
# System Files
36-
.DS_Store
37-
Thumbs.db
37+
/.chrome
38+
/.git
39+
/.firebase
40+
/.bazelrc.user

BUILD.bazel

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
load("//:rollup-globals.bzl", "ROLLUP_GLOBALS")
4+
load("//packages:config.bzl", "MDC_ENTRYPOINTS")
5+
6+
exports_files([
7+
"LICENSE",
8+
"README.md",
9+
])
10+
11+
genrule(
12+
name = "rollup_globals",
13+
outs = ["rollup_globals.json"],
14+
cmd = "echo '%s' > $@" % ROLLUP_GLOBALS,
15+
)
16+
17+
entryPoints = ["web/%s" % e for e in MDC_ENTRYPOINTS]
18+
19+
genrule(
20+
name = "entry_points_manifest",
21+
outs = ["entry_points_manifest.json"],
22+
cmd = "echo '%s' > $@" % entryPoints,
23+
)

WORKSPACE

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
workspace(
2+
name = "angular_mdc",
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 = "2eca5b934dee47b5ff304f502ae187c40ec4e33e12bcbce872a2eeb786e23269",
12+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.4.1/rules_nodejs-1.4.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.
18+
check_bazel_version("2.2.0")
19+
20+
node_repositories(
21+
node_repositories = {
22+
"13.10.1-darwin_amd64": ("node-v13.10.1-darwin-x64.tar.gz", "node-v13.10.1-darwin-x64", "a6a66fdc79e70267fc191f10ee045793240974e1268fdea6c2d28afbc1d635e8"),
23+
"13.10.1-linux_amd64": ("node-v13.10.1-linux-x64.tar.xz", "node-v13.10.1-linux-x64", "69d69165282d88f321e751f03ee5d3370db65e5ca4c587af24994b12f31d4827"),
24+
"13.10.1-windows_amd64": ("node-v13.10.1-win-x64.zip", "node-v13.10.1-win-x64", "f9d0aac273a44dbd52dd8cdb3d6c684b68b860d128af58d77a0c08f39f51f229"),
25+
},
26+
node_urls = ["https://nodejs.org/dist/v{version}/{filename}"],
27+
node_version = "13.10.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()

angular-tsconfig.json

+31
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+
}

build-config.js

-41
This file was deleted.

demos/angular.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"index": "src/index.html",
2222
"main": "src/main.ts",
2323
"polyfills": "src/polyfills.ts",
24-
"tsConfig": "tsconfig.app.json",
24+
"tsConfig": "tsconfig.json",
2525
"assets": [
2626
"src/favicon.png",
2727
"src/assets"
@@ -50,7 +50,7 @@
5050
"extractCss": true,
5151
"namedChunks": false,
5252
"aot": true,
53-
"extractLicenses": true,
53+
"extractLicenses": true,
5454
"vendorChunk": false,
5555
"buildOptimizer": true,
5656
"budgets": [
@@ -100,4 +100,4 @@
100100
}
101101
},
102102
"defaultProject": "angular-mdc-demos"
103-
}
103+
}

demos/package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88
},
99
"private": true,
1010
"dependencies": {
11-
"@angular/common": "^9.0.5",
12-
"@angular/compiler": "^9.0.5",
13-
"@angular/core": "^9.0.5",
14-
"@angular/forms": "^9.0.5",
15-
"@angular/platform-browser": "^9.0.5",
16-
"@angular/platform-browser-dynamic": "^9.0.5",
17-
"@angular/router": "^9.0.5",
11+
"@angular/common": "^9.0.7",
12+
"@angular/compiler": "^9.0.7",
13+
"@angular/core": "^9.0.7",
14+
"@angular/forms": "^9.0.7",
15+
"@angular/platform-browser": "^9.0.7",
16+
"@angular/platform-browser-dynamic": "^9.0.7",
17+
"@angular/router": "^9.0.7",
1818
"rxjs": "~6.5.3",
1919
"tslib": "^1.11.1",
2020
"zone.js": "~0.10.2"
2121
},
2222
"devDependencies": {
23-
"@angular-devkit/build-angular": "^0.900.5",
24-
"@angular/cli": "^9.0.5",
25-
"@angular/compiler-cli": "^9.0.5",
26-
"@types/node": "^13.7.7",
23+
"@angular-devkit/build-angular": "^0.900.7",
24+
"@angular/cli": "^9.0.7",
25+
"@angular/compiler-cli": "^9.0.7",
26+
"@types/node": "^13.9.2",
2727
"highlight.js": "^9.18.1",
2828
"ngx-highlightjs": "^4.0.2",
29-
"ts-node": "^8.5.4",
29+
"ts-node": "^8.6.2",
3030
"tslint": "~5.20.1",
3131
"typescript": "~3.7.4"
3232
}

demos/src/app/app-routing.module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ const routes: Routes = [
2626
{path: 'theme-docs', loadChildren: () => import('./components/theme-docs/theme.module').then(m => m.ThemeModule)},
2727
{
2828
path: 'data-table-demo', loadChildren: () =>
29-
import('./components/data-table-demo/data-table.module').then(m => m.DataTableModule)
29+
import('./components/data-table/module').then(m => m.DataTableModule)
3030
},
3131
{path: 'dialog-demo', loadChildren: () => import('./components/dialog/module').then(m => m.DialogModule)},
32-
{path: 'drawer-demo', loadChildren: () => import('./components/drawer-demo/drawer.module').then(m => m.DrawerModule)},
32+
{path: 'drawer-demo', loadChildren: () => import('./components/drawer/module').then(m => m.DrawerModule)},
3333
{
3434
path: 'elevation-demo', loadChildren: () =>
3535
import('./components/elevation-demo/elevation.module').then(m => m.ElevationModule)
@@ -54,7 +54,7 @@ const routes: Routes = [
5454
path: 'linear-progress-demo', loadChildren: () =>
5555
import('./components/linear-progress/module').then(m => m.LinearProgressModule)
5656
},
57-
{path: 'list-demo', loadChildren: () => import('./components/list-demo/list.module').then(m => m.ListModule)},
57+
{path: 'list-demo', loadChildren: () => import('./components/list/module').then(m => m.ListModule)},
5858
{path: 'menu-demo', loadChildren: () => import('./components/menu/module').then(m => m.MenuModule)},
5959
{
6060
path: 'menu-surface-demo', loadChildren: () =>

demos/src/app/app.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {Router, NavigationEnd} from '@angular/router';
33

44
import {environment} from '../environments/environment';
55

6-
import {MdcDrawer, MdcTopAppBar} from '@angular-mdc/web';
6+
import {MdcDrawer} from '@angular-mdc/web/drawer';
7+
import {MdcTopAppBar} from '@angular-mdc/web/top-app-bar';
78

89
const SMALL_WIDTH_BREAKPOINT = 1240;
910

0 commit comments

Comments
 (0)