Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 6ab8b99

Browse files
authored
Fine grained deps (#214)
update to fine-grained deps
1 parent b9b3ba7 commit 6ab8b99

File tree

13 files changed

+2482
-263
lines changed

13 files changed

+2482
-263
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# We use a docker image as the basis for our build, so that all the toolchains we use
55
# are already installed and the build can start running right away. It also guarantees
66
# the environment is portable and reproducible on your local machine.
7-
var_1: &docker_image angular/ngcontainer:0.3.3
7+
var_1: &docker_image angular/ngcontainer:0.6.0
88

99
# CircleCI lets us pick the key for storing one or more caches, to speed up subsequent builds.
1010
# We can use this to avoid re-fetching our dependencies from npm on every build.
@@ -13,7 +13,7 @@ var_1: &docker_image angular/ngcontainer:0.3.3
1313
# - the branch we are on, which really shouldn't be needed since the yarn lock file should be hermetic
1414
# - the docker image tag, working around an issue we saw where changing docker images causes permission
1515
# errors when restoring the cache, like when the user we run as changes
16-
var_2: &cache_key angular-{{ .Branch }}-{{ checksum "yarn.lock" }}-0.3.3
16+
var_2: &cache_key angular-{{ .Branch }}-{{ checksum "yarn.lock" }}-0.6.0
1717

1818
# Each job will inherit these defaults
1919
anchor_1: &job_defaults

BUILD.bazel

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,3 @@ alias(
1212
name = "tsconfig.json",
1313
actual = "//src:tsconfig.json",
1414
)
15-
16-
# This export allows targets in other packages to reference files that live
17-
# in this package.
18-
exports_files([
19-
# Let devserver and testing targets reference systemjs & zone.js distros
20-
"node_modules/systemjs/dist/system.js",
21-
"node_modules/zone.js/dist/zone.min.js",
22-
"node_modules/zone.js/dist/zone-testing-bundle.js",
23-
])
24-
25-
filegroup(
26-
name = "node_modules",
27-
srcs = glob(
28-
[
29-
# Include only .js, .json & .d.ts files to reduce the number of
30-
# files in the //:node_modules filegroup
31-
"node_modules/**/*.js",
32-
"node_modules/**/*.json",
33-
"node_modules/**/*.d.ts",
34-
# All the files in the protractor package are necesssary
35-
"node_modules/protractor/**",
36-
# Also include all files in node_modules/.bin
37-
"node_modules/.bin/*",
38-
],
39-
exclude = [
40-
# Files under test & docs may contain file names that
41-
# are not legal Bazel labels (e.g.,
42-
# node_modules/ecstatic/test/public/中文/檔案.html)
43-
"node_modules/**/test/**",
44-
"node_modules/**/docs/**",
45-
# Files with spaces in the name are not legal Bazel labels
46-
"node_modules/**/* */**",
47-
"node_modules/**/* *",
48-
],
49-
) + ["@build_bazel_rules_typescript//:node_modules"],
50-
# "@build_bazel_rules_typescript//:node_modules" is incluced
51-
# in `//:node_modules` so that npm dependencies that are hoisted to
52-
# node_modules/@bazel/typescript/node_modules because of conflicting
53-
# versions can be resolved correctly
54-
)

README.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,7 @@ Follow https://github.com/angular/angular/issues/19058 for updates.
1515

1616
## Installation
1717

18-
Install Bazel from the distribution, see [install] instructions.
19-
On Mac, if you have Homebrew installed you can
20-
21-
```bash
22-
brew tap bazelbuild/tap
23-
brew tap-pin bazelbuild/tap
24-
brew install bazel
25-
```
26-
27-
Bazel will install a hermetic version of Node, npm, and Yarn when
28-
you run the first build.
29-
30-
[install]: https://bazel.build/versions/master/docs/install.html
31-
32-
Also add `ibazel` to your `$PATH`:
18+
Add `ibazel` to your `$PATH`:
3319

3420
```
3521
yarn global add @bazel/ibazel
@@ -49,7 +35,7 @@ Before building the app, we install packages, just as with any npm-based develop
4935
$ yarn install
5036
```
5137

52-
or
38+
or
5339

5440
```bash
5541
$ npm install
@@ -120,7 +106,7 @@ The production bundle is code split and the `/` and `/todos` routes
120106
are lazy loaded. Code splitting is handled by the rollup_bundle rule
121107
which now supports the new code splitting feature in rollup.
122108

123-
Note: code splitting is _not_ supported in development mode yet so the
109+
Note: code splitting is _not_ supported in development mode yet so the
124110
`//src:devserver` target does not serve a code split bundle. For this
125111
reason, development and production use different main entry points
126112
(`main.dev.ts` and `main.ts`) and different root modules

WORKSPACE

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,12 @@ http_archive(
2020
sha256 = "edf39af5fc257521e4af4c40829fffe8fba6d0ebff9f4dd69a6f8f1223ae047b",
2121
)
2222

23-
# Runs the TypeScript compiler
24-
local_repository(
25-
name = "build_bazel_rules_typescript",
26-
path = "node_modules/@bazel/typescript",
27-
)
28-
29-
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
30-
rules_typescript_dependencies()
31-
32-
# Runs the Sass CSS preprocessor
33-
http_archive(
34-
name = "io_bazel_rules_sass",
35-
url = "https://github.com/bazelbuild/rules_sass/archive/1.11.0.zip",
36-
strip_prefix = "rules_sass-1.11.0",
37-
sha256 = "dbe9fb97d5a7833b2a733eebc78c9c1e3880f676ac8af16e58ccf2139cbcad03",
38-
)
39-
4023
# The @angular repo contains rule for building Angular applications
4124
http_archive(
4225
name = "angular",
43-
url = "https://github.com/angular/angular/archive/6.1.8.zip",
44-
strip_prefix = "angular-6.1.8",
45-
sha256 = "5ac6694f7c694afe34767aff4a0dd0408e25b0493cea675c2bb075c123adc46a",
26+
url = "https://github.com/angular/angular/archive/2546c663769cdb8ba0b3979bb157fe58770f4325.zip",
27+
strip_prefix = "angular-2546c663769cdb8ba0b3979bb157fe58770f4325",
28+
#sha256 = "5ac6694f7c694afe34767aff4a0dd0408e25b0493cea675c2bb075c123adc46a",
4629
)
4730

4831
# The @rxjs repo contains targets for building rxjs with bazel
@@ -54,15 +37,25 @@ local_repository(
5437
####################################
5538
# Load and install our dependencies downloaded above.
5639

40+
load("@angular//packages/bazel:package.bzl", "rules_angular_dependencies")
41+
42+
rules_angular_dependencies()
43+
5744
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")
5845

5946
node_repositories(
60-
package_json = ["//:package.json"],
6147
preserve_symlinks = True,
6248
node_version = "10.9.0",
6349
yarn_version = "1.9.2",
6450
)
6551

52+
yarn_install(
53+
name = "npm",
54+
package_json = "//:package.json",
55+
yarn_lock = "//:yarn.lock",
56+
data = ["//:postinstall.tsconfig.json"],
57+
)
58+
6659
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
6760

6861
go_rules_dependencies()
@@ -80,18 +73,10 @@ load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace", "check_ru
8073

8174
ts_setup_workspace()
8275

83-
# Enforce that the version of @bazel/typescript installed by npm is compatible with the rules.
84-
# 0.16.0: tsc_wrapped uses user's typescript version & check_rules_typescript_version
85-
check_rules_typescript_version("0.16.0")
86-
8776
load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
8877

8978
sass_repositories()
9079

91-
#
92-
# Load and install our dependencies from local repositories
93-
#
94-
9580
load("@angular//:index.bzl", "ng_setup_workspace")
9681

9782
ng_setup_workspace()

e2e/BUILD.bazel

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,33 @@ ts_library(
55
name = "e2e",
66
testonly = 1,
77
srcs = glob(["src/*.ts"]),
8+
tsconfig = "//src:tsconfig-test",
9+
deps = [
10+
"@npm//@types/jasmine",
11+
"@npm//jasmine",
12+
"@npm//protractor",
13+
],
814
)
915

1016
protractor_web_test_suite(
1117
name = "prodserver_test",
12-
data = ["@angular//packages/bazel/src/protractor/utils"],
18+
data = [
19+
"@angular//packages/bazel/src/protractor/utils",
20+
"@npm//protractor",
21+
"@npm//zone.js",
22+
],
1323
on_prepare = ":protractor.on-prepare.js",
1424
server = "//src:prodserver",
1525
deps = [":e2e"],
1626
)
1727

1828
protractor_web_test_suite(
1929
name = "devserver_test",
20-
data = ["@angular//packages/bazel/src/protractor/utils"],
30+
data = [
31+
"@angular//packages/bazel/src/protractor/utils",
32+
"@npm//protractor",
33+
"@npm//zone.js",
34+
],
2135
on_prepare = ":protractor.on-prepare.js",
2236
server = "//src:devserver",
2337
deps = [":e2e"],

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@
1111
"zone.js": "0.8.26"
1212
},
1313
"devDependencies": {
14-
"@angular/compiler": "6.1.8",
15-
"@angular/compiler-cli": "6.1.8",
16-
"@angular/core": "6.1.8",
14+
"@angular/compiler": "github:angular/compiler-builds#bazel",
15+
"@angular/compiler-cli": "github:angular/compiler-cli-builds#bazel",
16+
"@angular/core": "github:angular/core-builds#bazel",
1717
"@bazel/benchmark-runner": "0.1.0",
1818
"@bazel/ibazel": "0.5.0",
19-
"@bazel/typescript": "0.17.0",
19+
"@bazel/karma": "0.19.1",
20+
"@bazel/typescript": "0.19.1",
2021
"@types/jasmine": "2.8.8",
2122
"@types/node": "6.0.117",
2223
"clang-format": "1.2.4",
2324
"husky": "0.14.3",
2425
"protractor": "5.4.1",
25-
"typescript": "2.9.2"
26+
"typescript": "3.1"
2627
},
2728
"scripts": {
2829
"build": "bazel build //src:bundle",

src/BUILD.bazel

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
package(default_visibility = ["//visibility:public"])
22

33
load("@angular//:index.bzl", "ng_module")
4-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
4+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_config", "ts_devserver")
5+
6+
ts_config(
7+
name = "tsconfig-test",
8+
src = "tsconfig-test.json",
9+
deps = [":tsconfig.json"],
10+
)
511

612
ng_module(
713
name = "src",
@@ -15,6 +21,7 @@ ng_module(
1521
"//src/todos",
1622
"@angular//packages/core",
1723
"@angular//packages/router",
24+
"@npm//@ngrx/store",
1825
],
1926
)
2027

@@ -26,9 +33,9 @@ ts_devserver(
2633
name = "devserver",
2734
# serve these files rooted at /
2835
additional_root_paths = [
29-
"angular_bazel_example/node_modules/zone.js/dist",
30-
"angular_bazel_example/node_modules/tslib",
31-
"angular_bazel_example/node_modules/@ngrx/store/bundles",
36+
"npm/node_modules/zone.js/dist",
37+
"npm/node_modules/tslib",
38+
"npm/node_modules/@ngrx/store/bundles",
3239
],
3340
# Start from the development version of the main
3441
entry_module = "angular_bazel_example/src/main.dev",
@@ -39,9 +46,9 @@ ts_devserver(
3946
serving_path = "/bundle.min.js",
4047
# Serve these files in addition to the JavaScript bundle
4148
static_files = [
42-
"//:node_modules/zone.js/dist/zone.min.js",
43-
"//:node_modules/tslib/tslib.js",
44-
"//:node_modules/@ngrx/store/bundles/store.umd.min.js",
49+
"@npm//node_modules/zone.js:dist/zone.min.js",
50+
"@npm//node_modules/tslib:tslib.js",
51+
"@npm//node_modules/@ngrx/store:bundles/store.umd.min.js",
4552
"index.html",
4653
],
4754
# Tell Bazel to build the sources first
@@ -62,24 +69,26 @@ rollup_bundle(
6269
"src/todos/todos.module.ngfactory",
6370
],
6471
entry_point = "src/main",
65-
node_modules = "//:node_modules",
66-
deps = ["//src"],
72+
deps = [
73+
"//src",
74+
"@npm//@ngrx/store",
75+
],
6776
)
6877

6978
# Copy zone.min.js to this package.
7079
# Needed because the prodserver only loads static files that appear under this
7180
# package.
7281
genrule(
7382
name = "copy_zonejs",
74-
srcs = ["//:node_modules/zone.js/dist/zone.min.js"],
83+
srcs = ["@npm//node_modules/zone.js:dist/zone.min.js"],
7584
outs = ["zone.min.js"],
7685
cmd = "cp $< $@",
7786
)
7887

7988
# See comment for zonejs above
8089
genrule(
8190
name = "copy_systemjs",
82-
srcs = ["//:node_modules/systemjs/dist/system.js"],
91+
srcs = ["@npm//node_modules/systemjs:dist/system.js"],
8392
outs = ["system.js"],
8493
cmd = "cp $< $@",
8594
)

src/hello-world/BUILD.bazel

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ng_module(
2525
"@angular//packages/core",
2626
"@angular//packages/forms",
2727
"@angular//packages/router",
28-
"@rxjs",
28+
"@npm//@types",
2929
],
3030
)
3131

@@ -39,20 +39,24 @@ ts_library(
3939
"@angular//packages/core/testing",
4040
"@angular//packages/platform-browser",
4141
"@angular//packages/platform-browser-dynamic/testing",
42+
"@npm//@types/jasmine",
43+
"@npm//@types/node",
4244
],
4345
)
4446

4547
ts_web_test_suite(
4648
name = "test",
47-
srcs = ["//:node_modules/tslib/tslib.js"],
49+
srcs = ["@npm//node_modules/tslib:tslib.js"],
4850
# do not sort
4951
bootstrap = [
50-
"//:node_modules/zone.js/dist/zone-testing-bundle.js",
51-
"//:node_modules/reflect-metadata/Reflect.js",
52+
"@npm//node_modules/zone.js:dist/zone-testing-bundle.js",
53+
"@npm//node_modules/reflect-metadata:Reflect.js",
5254
],
5355
browsers = [
5456
"@io_bazel_rules_webtesting//browsers:chromium-local",
55-
"@io_bazel_rules_webtesting//browsers:firefox-local",
57+
# TODO(gregmagolan): re-enable firefox testing once fixed
58+
# See https://github.com/bazelbuild/rules_typescript/issues/296
59+
#"@io_bazel_rules_webtesting//browsers:firefox-local",
5660
],
5761
deps = [
5862
":test_lib",

src/reducers/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
55
ts_library(
66
name = "reducers",
77
srcs = glob(["*.ts"]),
8+
deps = [
9+
"@npm//@ngrx/store",
10+
],
811
)

src/todos/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ ng_module(
2727
"@angular//packages/core",
2828
"@angular//packages/forms",
2929
"@angular//packages/router",
30+
"@npm//@ngrx/store",
31+
"@npm//@types",
3032
"@rxjs",
3133
],
3234
)

src/tsconfig-test.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"types": ["jasmine"]
5+
}
6+
}

src/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
".",
1212
"../dist/bin/src",
1313
],
14-
"experimentalDecorators": true
14+
"experimentalDecorators": true,
15+
"types": []
1516
}
1617
}

0 commit comments

Comments
 (0)