Skip to content

Commit 6eff8c6

Browse files
committed
Migrate to Bazel
1 parent cd98641 commit 6eff8c6

29 files changed

+441
-10
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: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Enable debugging tests with --config=debug
2+
test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test_strategy=exclusive --test_timeout=9999 --nocache_test_results
3+
4+
###############################
5+
# Filesystem interactions #
6+
###############################
7+
8+
# Turn off legacy external runfiles
9+
build --nolegacy_external_runfiles
10+
run --nolegacy_external_runfiles
11+
test --nolegacy_external_runfiles
12+
13+
# Turn on --incompatible_strict_action_env which was on by default
14+
# in Bazel 0.21.0 but turned off again in 0.22.0. Follow
15+
# https://github.com/bazelbuild/bazel/issues/7026 for more details.
16+
# This flag is needed to so that the bazel cache is not invalidated
17+
# when running bazel via `yarn bazel`.
18+
# See https://github.com/angular/angular/issues/27514.
19+
build --incompatible_strict_action_env
20+
run --incompatible_strict_action_env
21+
test --incompatible_strict_action_env
22+
23+
# Do not build runfile trees by default. If an execution strategy relies on runfile
24+
# symlink teee, the tree is created on-demand. See: https://github.com/bazelbuild/bazel/issues/6627
25+
# and https://github.com/bazelbuild/bazel/commit/03246077f948f2790a83520e7dccc2625650e6df
26+
build --nobuild_runfile_links
27+
28+
build --enable_runfiles
29+
30+
###############################
31+
# Output #
32+
###############################
33+
34+
# A more useful default output mode for bazel query
35+
# Prints eg. "ng_module rule //foo:bar" rather than just "//foo:bar"
36+
query --output=label_kind
37+
38+
# By default, failing tests don't print any output, it goes to the log file
39+
test --test_output=errors
40+
41+
####################################################
42+
# User bazel configuration
43+
# NOTE: This needs to be the *last* entry in the config.
44+
####################################################
45+
46+
# Load any settings which are specific to the current user. Needs to be *last* statement
47+
# in this config, as the user configuration should be able to overwrite flags from this file.
48+
try-import .bazelrc.user

.bazelversion

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

BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
2+
load("@npm//:defs.bzl", "npm_link_all_packages")
3+
4+
npm_link_all_packages(name = "node_modules")
5+
6+
ts_config(
7+
name = "tsconfig",
8+
src = "tsconfig.json",
9+
visibility = ["//visibility:public"]
10+
)

WORKSPACE

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
3+
http_archive(
4+
name = "aspect_rules_js",
5+
sha256 = "f2b36aac9d3368e402c9083c884ad9b26ca6fa21e83b53c12482d6cb2e949451",
6+
strip_prefix = "rules_js-1.0.0-rc.4",
7+
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.0.0-rc.4.tar.gz",
8+
)
9+
10+
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
11+
12+
rules_js_dependencies()
13+
14+
http_archive(
15+
name = "aspect_rules_ts",
16+
sha256 = "bfaad966d3293595b2b1a44b33a12967ee138e414d6c27b7a2656b43ca19ee51",
17+
strip_prefix = "rules_ts-0.12.0",
18+
url = "https://github.com/aspect-build/rules_ts/archive/refs/tags/v0.12.0.tar.gz",
19+
)
20+
21+
load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
22+
23+
rules_ts_dependencies(ts_version_from = "//:package.json",)
24+
25+
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
26+
27+
nodejs_register_toolchains(
28+
name = "nodejs",
29+
node_version = DEFAULT_NODE_VERSION,
30+
)
31+
32+
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
33+
34+
npm_translate_lock(
35+
name = "npm",
36+
yarn_lock = "//:yarn.lock",
37+
package_json = "//:package.json",
38+
verify_node_modules_ignored = "//:.bazelignore",
39+
)
40+
41+
load("@npm//:repositories.bzl", "npm_repositories")
42+
43+
npm_repositories()

bazel-bin

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/private/var/tmp/_bazel_greg/8339ba048fbba58dc1c31a82c5eb13a4/execroot/__main__/bazel-out/darwin-fastbuild/bin

bazel-out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/private/var/tmp/_bazel_greg/8339ba048fbba58dc1c31a82c5eb13a4/execroot/__main__/bazel-out

bazel-testlogs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/private/var/tmp/_bazel_greg/8339ba048fbba58dc1c31a82c5eb13a4/execroot/__main__/bazel-out/darwin-fastbuild/testlogs

bazel-vscode-ng-language-service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/private/var/tmp/_bazel_greg/8339ba048fbba58dc1c31a82c5eb13a4/execroot/__main__

client/BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
2+
3+
ts_config(
4+
name = "tsconfig",
5+
src = "tsconfig.json",
6+
deps = [
7+
"//:tsconfig",
8+
"//common:tsconfig",
9+
],
10+
visibility = ["//client:__subpackages__"]
11+
)

client/src/BUILD.bazel

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
2+
3+
4+
ts_project(
5+
name = "src",
6+
srcs = glob(["*.ts"]),
7+
composite = True,
8+
declaration = True,
9+
source_map = True,
10+
# TODO: re-enable workers once issue is fixed
11+
supports_workers = False,
12+
tsconfig = "//client:tsconfig",
13+
deps = [
14+
"//:node_modules/@types/node",
15+
"//:node_modules/@types/vscode",
16+
"//:node_modules/typescript",
17+
"//:node_modules/vscode-languageclient",
18+
"//common",
19+
],
20+
visibility = [
21+
"//client:__subpackages__",
22+
],
23+
)

client/src/client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import * as path from 'path';
1111
import * as vscode from 'vscode';
1212
import * as lsp from 'vscode-languageclient/node';
1313

14-
import {OpenOutputChannel, ProjectLoadingFinish, ProjectLoadingStart, SuggestStrictMode, SuggestStrictModeParams} from '../common/notifications';
15-
import {GetComponentsWithTemplateFile, GetTcbRequest, GetTemplateLocationForComponent, IsInAngularProject, RunNgccRequest} from '../common/requests';
16-
import {resolve, Version} from '../common/resolver';
14+
import {OpenOutputChannel, ProjectLoadingFinish, ProjectLoadingStart, SuggestStrictMode, SuggestStrictModeParams} from '../../common/notifications';
15+
import {GetComponentsWithTemplateFile, GetTcbRequest, GetTemplateLocationForComponent, IsInAngularProject, RunNgccRequest} from '../../common/requests';
16+
import {resolve, Version} from '../../common/resolver';
1717

1818
import {isInsideComponentDecorator, isInsideInlineTemplateRegion, isInsideStringLiteral} from './embedded_support';
1919

client/src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import * as vscode from 'vscode';
1010

11-
import {ServerOptions} from '../common/initialize';
11+
import {ServerOptions} from '../../common/initialize';
1212

1313
import {AngularLanguageClient} from './client';
1414
import {ANGULAR_SCHEME, TcbContentProvider} from './providers';

client/src/tests/BUILD.bazel

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
2+
3+
ts_config(
4+
name = "tsconfig",
5+
src = "tsconfig.json",
6+
deps = [
7+
"//:tsconfig",
8+
"//client:tsconfig",
9+
],
10+
)
11+
12+
ts_project(
13+
name = "tests",
14+
srcs = glob(["*.ts"]),
15+
declaration = True,
16+
source_map = True,
17+
# TODO: re-enable workers once issue is fixed
18+
supports_workers = False,
19+
tsconfig = ":tsconfig",
20+
deps = [
21+
"//client/src",
22+
"//:node_modules/@types/vscode",
23+
"//:node_modules/@types/jasmine",
24+
"//:node_modules/vscode-languageserver-textdocument",
25+
],
26+
)

common/BUILD.bazel

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
2+
3+
ts_config(
4+
name = "tsconfig",
5+
src = "tsconfig.json",
6+
visibility = [
7+
"//client:__subpackages__",
8+
"//common:__subpackages__",
9+
"//server:__subpackages__",
10+
"//integration:__subpackages__",
11+
],
12+
deps = ["//:tsconfig"],
13+
)
14+
15+
ts_project(
16+
name = "common",
17+
srcs = glob(["*.ts"]),
18+
composite = True,
19+
declaration = True,
20+
source_map = True,
21+
# TODO: re-enable workers once issue is fixed
22+
supports_workers = False,
23+
tsconfig = ":tsconfig",
24+
visibility = [
25+
"//client:__subpackages__",
26+
"//common:__subpackages__",
27+
"//server:__subpackages__",
28+
"//integration:__subpackages__",
29+
],
30+
deps = [
31+
"//:node_modules/@types/node",
32+
"//:node_modules/vscode-jsonrpc",
33+
"//:node_modules/vscode-languageserver-protocol",
34+
],
35+
)

common/tests/BUILD.bazel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
2+
3+
ts_config(
4+
name = "tsconfig",
5+
src = "tsconfig.json",
6+
deps = [
7+
"//:tsconfig",
8+
"//common:tsconfig",
9+
],
10+
)
11+
12+
ts_project(
13+
name = "tests",
14+
srcs = glob(["*.ts"]),
15+
declaration = True,
16+
source_map = True,
17+
# TODO: re-enable workers once issue is fixed
18+
supports_workers = False,
19+
tsconfig = ":tsconfig",
20+
deps = [
21+
"//common",
22+
"//:node_modules/@types/jasmine",
23+
],
24+
)

integration/BUILD.bazel

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
2+
3+
ts_config(
4+
name = "tsconfig",
5+
src = "tsconfig.json",
6+
deps = [
7+
"//:tsconfig",
8+
"//server:tsconfig",
9+
],
10+
visibility = ["//integration:__subpackages__"]
11+
)
12+
13+
ts_project(
14+
name = "integration",
15+
srcs = glob([
16+
"*.ts",
17+
# NB: there is an import cycle between lsp/*.ts and test_constants.ts so they cannot be
18+
# broken up into separate ts_project targets
19+
"lsp/*.ts",
20+
]),
21+
declaration = True,
22+
source_map = True,
23+
# TODO: re-enable workers once issue is fixed
24+
supports_workers = False,
25+
tsconfig = ":tsconfig",
26+
deps = [
27+
"//:node_modules/@types/jasmine",
28+
"//:node_modules/@types/node",
29+
"//:node_modules/vscode-jsonrpc",
30+
"//:node_modules/vscode-languageserver-protocol",
31+
"//:node_modules/vscode-uri",
32+
"//common",
33+
],
34+
visibility = [
35+
"//integration:__subpackages__",
36+
],
37+
)

integration/e2e/BUILD.bazel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
2+
3+
ts_project(
4+
name = "e2e",
5+
srcs = glob(["*.ts"]),
6+
declaration = True,
7+
source_map = True,
8+
# TODO: re-enable workers once issue is fixed
9+
supports_workers = False,
10+
tsconfig = "//integration:tsconfig",
11+
deps = [
12+
"//:node_modules/@types/jasmine",
13+
"//:node_modules/@types/node",
14+
"//:node_modules/@types/vscode",
15+
"//:node_modules/vscode-test",
16+
"//integration",
17+
],
18+
visibility = [
19+
"//integration:__subpackages__",
20+
],
21+
)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@
233233
"esbuild": "0.14.39",
234234
"jasmine": "3.99.0",
235235
"prettier": "2.6.2",
236+
"rxjs": "6.6.7",
236237
"ts-node": "^10.8.1",
237238
"tslint": "6.1.3",
238239
"tslint-eslint-rules": "5.4.0",

server/BUILD.bazel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
2+
3+
ts_config(
4+
name = "tsconfig",
5+
src = "tsconfig.json",
6+
deps = [
7+
"//:tsconfig",
8+
"//common:tsconfig",
9+
],
10+
visibility = [
11+
"//server:__subpackages__",
12+
"//integration:__subpackages__",
13+
]
14+
)
15+
16+
ts_config(
17+
name = "tsconfig_banner",
18+
src = "banner.tsconfig.json",
19+
deps = [
20+
"//:tsconfig",
21+
"//common:tsconfig",
22+
],
23+
visibility = ["//server:__subpackages__"]
24+
)

0 commit comments

Comments
 (0)