Skip to content

Commit c87c83f

Browse files
Alex Eaglealexeagle
authored andcommitted
feat(angular): introduce an Angular CLI builder
This replaces the one being removed in angular/angular#37190
1 parent f9f3dea commit c87c83f

File tree

15 files changed

+338
-0
lines changed

15 files changed

+338
-0
lines changed

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist
33
bazel-out
44
e2e/symlinked_node_modules_yarn/node_modules
55
e2e/symlinked_node_modules_npm/node_modules/
6+
packages/angular/node_modules

.github/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ generate_codeowners(
77
# do not sort
88
owners = [
99
"//:OWNERS",
10+
"//packages/angular:OWNERS",
1011
"//packages/labs:OWNERS",
1112
"//packages/rollup:OWNERS",
1213
"//examples:OWNERS.examples_nestjs",

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Don't edit it directly
33

44
* @gregmagolan @soldair @alexeagle
5+
/packages/angular/** @alan-agius4 @alexeagle
56
/packages/labs/** @mrmeku @alexeagle
67
/packages/rollup/** @jbedard @alexeagle
78
/examples/nestjs/** @zachgrayio @zMotivat0r @rayman1104 @siberex @alexeagle

WORKSPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ npm_install(
8383
package_lock_json = "//packages/node-patches:package-lock.json",
8484
)
8585

86+
npm_install(
87+
name = "angular_deps",
88+
package_json = "//packages/angular:package.json",
89+
package_lock_json = "//packages/angular:package-lock.json",
90+
)
91+
8692
# Install all Bazel dependencies needed for npm packages that supply Bazel rules
8793
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
8894

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
'scope-enum': [
66
2, 'always',
77
[
8+
'angular',
89
'builtin',
910
'create',
1011
'examples',

packages/angular/BUILD.bazel

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
load("@build_bazel_rules_nodejs//:tools/defaults.bzl", "codeowners", "pkg_npm")
2+
load("//packages/typescript:index.bzl", "ts_project")
3+
4+
codeowners(
5+
teams = ["@alan-agius4"],
6+
)
7+
8+
ts_project(
9+
tsc = "@angular_deps//typescript/bin:tsc",
10+
deps = ["@angular_deps//:node_modules"],
11+
)
12+
13+
pkg_npm(
14+
name = "npm_package",
15+
srcs = [
16+
"README.md",
17+
"package.json",
18+
"src/builders/builders.json",
19+
"src/builders/schema.d.ts",
20+
"src/builders/schema.json",
21+
],
22+
deps = ["tsconfig"],
23+
)

packages/angular/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Angular support for Bazel
2+
3+
This package is a replacement for parts of the deprecated @angular/bazel package previously maintained by the Angular team.
4+
5+
Currently, this only provides an Angular CLI Builder, which can execute Bazel when triggered by `ng build`, `ng test`, etc.
6+
See https://angular.io/guide/cli-builder for more info about Builders.
7+
8+
This builder assumes you have already created Bazel configurations (WORKSPACE and BUILD files).
9+
There is presently no tooling to generate these automatically that's supported by either Angular team or rules_nodejs maintainers.
10+
See the `@bazel/create` package for a quickstart to creating a Bazel workspace, or look at examples in rules_nodejs.
11+
12+
To use it, you would just install this package (it doesn't hook into `ng add` because it has no schematics):
13+
14+
```sh
15+
$ npm install --save-dev @bazel/angular
16+
```
17+
18+
Then edit your `angular.json` to invoke Bazel. For example, to have `ng build` do `bazel build //:all` you would edit the `architect` block to have:
19+
20+
```json
21+
"architect": {
22+
"build": {
23+
"builder": "@bazel/angular:build",
24+
"options": {
25+
"targetLabel": "//:all",
26+
"bazelCommand": "build"
27+
}
28+
}
29+
```

packages/angular/package-lock.json

Lines changed: 121 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/angular/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "@bazel/angular",
3+
"description": "Run Bazel under the Angular CLI",
4+
"license": "Apache-2.0",
5+
"version": "0.0.0-PLACEHOLDER",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/bazelbuild/rules_nodejs.git",
9+
"directory": "packages/angular"
10+
},
11+
"bugs": {
12+
"url": "https://github.com/bazelbuild/rules_nodejs/issues"
13+
},
14+
"keywords": [
15+
"angular",
16+
"bazel"
17+
],
18+
"builders": "./src/builders/builders.json",
19+
"dependencies": {
20+
"@bazel/bazelisk": "^1.4.0",
21+
"@bazel/ibazel": "^0.13.1",
22+
"@angular-devkit/architect": "^0.901.7"
23+
},
24+
"devDependencies": {
25+
"@angular-devkit/core": "^9.1.7",
26+
"@types/node": "^14.0.5",
27+
"typescript": "^3.9.3"
28+
}
29+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"builders": {
3+
"build": {
4+
"implementation": "./index",
5+
"schema": "./schema.json",
6+
"description": "Executes Bazel on a target."
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)