Skip to content

Commit 520493d

Browse files
committed
feat(typescript): wire up use_angular_plugin attribute
Add tests and switch away from `ng_module` in the angular example
1 parent 6a50217 commit 520493d

22 files changed

Lines changed: 534 additions & 201 deletions

File tree

examples/angular/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load("@k8s_deploy//:defaults.bzl", "k8s_deploy")
22

33
package(default_visibility = ["//:__subpackages__"])
44

5-
# ts_library and ng_module use the `//:tsconfig.json` target
5+
# ts_library uses the `//:tsconfig.json` target
66
# by default. This alias allows omitting explicit tsconfig
77
# attribute.
88
alias(

examples/angular/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This example is deployed at https://bazel.angular.io/example
1616
This example is a monorepo, meant to show many different features and integrations that we expect are generally useful for enterprise use cases.
1717

1818
- **Angular CLI**: you can use the `ng` command to run build, serve, test, and e2e
19-
- **Angular Libraries**: to maximize build incrementality, each Angular module is compiled as a separate step. This lets us re-use Angular libraries without having to publish them as npm packages. See `src/todos` for a typical `NgModule` compiled as a library for use in the application, using the `ng_module` rule in the `BUILD.bazel` file.
19+
- **Angular Libraries**: to maximize build incrementality, each Angular module is compiled as a separate step. This lets us re-use Angular libraries without having to publish them as npm packages. See `src/todos` for a typical `NgModule` compiled as a library for use in the application, using the `ts_library` rule in the `BUILD.bazel` file.
2020
- **TypeScript Libraries**: see `src/lib` for a trivial example of a pure-TS library that's consumed in the application, using the `ts_library` rule in the `BUILD.bazel` file.
2121
- **Sass**: we use Sass for all styling. Angular components import Sass files, and these are built by Bazel as independent processes calling the modern Sass compiler (written in Dart).
2222
- **Material design**: see `src/material` where we collect the material modules we use.

examples/angular/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
"yarn": ">=1.9.2 <2.0.0"
99
},
1010
"dependencies": {
11-
"@angular/animations": "9.0.0",
11+
"@angular/animations": "9.1.0",
1212
"@angular/cdk": "9.0.0",
13-
"@angular/common": "9.0.0",
14-
"@angular/core": "9.0.0",
15-
"@angular/forms": "9.0.0",
13+
"@angular/common": "9.1.0",
14+
"@angular/core": "9.1.0",
15+
"@angular/forms": "9.1.0",
1616
"@angular/material": "9.0.0",
17-
"@angular/platform-browser": "9.0.0",
18-
"@angular/platform-browser-dynamic": "9.0.0",
19-
"@angular/platform-server": "^9.0.0",
20-
"@angular/router": "9.0.0",
17+
"@angular/platform-browser": "9.1.0",
18+
"@angular/platform-browser-dynamic": "9.1.0",
19+
"@angular/platform-server": "^9.1.0",
20+
"@angular/router": "9.1.0",
2121
"@ngrx/store": "9.0.0-beta.0",
2222
"@nguniversal/express-engine": "^9.0.0",
2323
"date-fns": "1.30.1",
@@ -29,8 +29,8 @@
2929
"devDependencies": {
3030
"@angular/bazel": "9.0.0",
3131
"@angular/cli": "9.0.0",
32-
"@angular/compiler": "9.0.0",
33-
"@angular/compiler-cli": "9.0.0",
32+
"@angular/compiler": "9.1.0",
33+
"@angular/compiler-cli": "9.1.0",
3434
"@babel/cli": "^7.6.0",
3535
"@babel/core": "^7.6.0",
3636
"@babel/preset-env": "^7.6.0",

examples/angular/src/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
55
load("@npm//@babel/cli:index.bzl", "babel")
66
load("@npm//history-server:index.bzl", "history_server")
77
load("@npm//html-insert-assets:index.bzl", "html_insert_assets")
8-
load("@npm_angular_bazel//:index.bzl", "ng_module")
98
load("@npm_bazel_rollup//:index.bzl", "rollup_bundle")
109
load("@npm_bazel_terser//:index.bzl", "terser_minified")
1110
load("@npm_bazel_typescript//:index.bzl", "ts_config", "ts_devserver", "ts_library")
@@ -44,13 +43,14 @@ ts_library(
4443
],
4544
)
4645

47-
ng_module(
46+
ts_library(
4847
name = "src",
4948
srcs = [
5049
"main.dev.ts",
5150
"main.prod.ts",
5251
],
5352
tsconfig = ":tsconfig.json",
53+
use_angular_plugin = True,
5454
deps = [
5555
"//src/app",
5656
"@npm//@angular/core",
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
load("@npm_angular_bazel//:index.bzl", "ng_module")
1+
load("@npm_bazel_typescript//:index.bzl", "ts_library")
22

33
package(default_visibility = ["//:__subpackages__"])
44

5-
ng_module(
5+
ts_library(
66
name = "app",
77
srcs = glob(
88
include = ["*.ts"],
99
exclude = ["app.server.module.ts"],
1010
),
11-
assets = ["app.component.html"],
11+
angular_assets = ["app.component.html"],
1212
tsconfig = "//src:tsconfig.json",
13+
use_angular_plugin = True,
1314
deps = [
1415
"//src/app/hello-world",
1516
"//src/app/home",
1617
"//src/app/todos",
18+
"//src/app/todos/reducers",
1719
"//src/shared/material",
1820
"@npm//@angular/core",
1921
"@npm//@angular/platform-browser",
@@ -22,12 +24,14 @@ ng_module(
2224
],
2325
)
2426

25-
ng_module(
27+
ts_library(
2628
name = "app_server",
2729
srcs = ["app.server.module.ts"],
2830
tsconfig = "//src:tsconfig-server",
31+
use_angular_plugin = True,
2932
deps = [
3033
":app",
34+
"@npm//@angular/core",
3135
"@npm//@angular/platform-server",
3236
],
3337
)

examples/angular/src/app/hello-world/BUILD.bazel

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
2-
load("@npm_angular_bazel//:index.bzl", "ng_module")
32
load("@npm_bazel_karma//:index.bzl", "karma_web_test_suite")
43
load("@npm_bazel_typescript//:index.bzl", "ts_library")
54

@@ -10,20 +9,23 @@ sass_binary(
109
src = "hello-world.component.scss",
1110
)
1211

13-
ng_module(
12+
ts_library(
1413
name = "hello-world",
1514
srcs = [
1615
"hello-world.component.ts",
1716
"hello-world.module.ts",
1817
],
19-
assets = [
18+
angular_assets = [
2019
":hello-world.component.html",
2120
":hello-world-styles",
2221
],
2322
tsconfig = "//src:tsconfig.json",
23+
use_angular_plugin = True,
2424
deps = [
2525
"//src/lib/shorten",
2626
"//src/shared/material",
27+
"@npm//@angular/core",
28+
"@npm//@angular/forms",
2729
"@npm//@angular/router",
2830
"@npm//date-fns",
2931
],

examples/angular/src/app/home/BUILD.bazel

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
load("@npm_angular_bazel//:index.bzl", "ng_module")
1+
load("@npm_bazel_typescript//:index.bzl", "ts_library")
22

33
package(default_visibility = ["//:__subpackages__"])
44

5-
ng_module(
5+
ts_library(
66
name = "home",
77
srcs = ["home.ts"],
8-
assets = ["home.html"],
8+
angular_assets = ["home.html"],
99
tsconfig = "//src:tsconfig.json",
10+
use_angular_plugin = True,
1011
deps = [
1112
"@npm//@angular/core",
1213
"@npm//@angular/router",

examples/angular/src/app/todos/BUILD.bazel

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
2-
load("@npm_angular_bazel//:index.bzl", "ng_module")
2+
load("@npm_bazel_typescript//:index.bzl", "ts_library")
33

44
package(default_visibility = ["//:__subpackages__"])
55

@@ -8,17 +8,18 @@ sass_binary(
88
src = "todos.component.scss",
99
)
1010

11-
ng_module(
11+
ts_library(
1212
name = "todos",
1313
srcs = [
1414
"todos.component.ts",
1515
"todos.module.ts",
1616
],
17-
assets = [
17+
angular_assets = [
1818
"todos.component.html",
1919
":todos-styles",
2020
],
2121
tsconfig = "//src:tsconfig.json",
22+
use_angular_plugin = True,
2223
deps = [
2324
"//src/app/todos/reducers",
2425
"//src/shared/material",

examples/angular/src/shared/material/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
load("@npm_angular_bazel//:index.bzl", "ng_module")
1+
load("@npm_bazel_typescript//:index.bzl", "ts_library")
22

33
package(default_visibility = ["//:__subpackages__"])
44

5-
ng_module(
5+
ts_library(
66
name = "material",
77
srcs = glob(["*.ts"]),
88
tsconfig = "//src:tsconfig.json",
9+
use_angular_plugin = True,
910
deps = [
1011
"@npm//@angular/core",
1112
"@npm//@angular/material",

0 commit comments

Comments
 (0)