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

Fine grained deps #214

Merged
merged 6 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# We use a docker image as the basis for our build, so that all the toolchains we use
# are already installed and the build can start running right away. It also guarantees
# the environment is portable and reproducible on your local machine.
var_1: &docker_image angular/ngcontainer:0.3.3
var_1: &docker_image angular/ngcontainer:0.6.0

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

# Each job will inherit these defaults
anchor_1: &job_defaults
Expand Down
40 changes: 0 additions & 40 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,3 @@ alias(
name = "tsconfig.json",
actual = "//src:tsconfig.json",
)

# This export allows targets in other packages to reference files that live
# in this package.
exports_files([
# Let devserver and testing targets reference systemjs & zone.js distros
"node_modules/systemjs/dist/system.js",
"node_modules/zone.js/dist/zone.min.js",
"node_modules/zone.js/dist/zone-testing-bundle.js",
])

filegroup(
name = "node_modules",
srcs = glob(
[
# Include only .js, .json & .d.ts files to reduce the number of
# files in the //:node_modules filegroup
"node_modules/**/*.js",
"node_modules/**/*.json",
"node_modules/**/*.d.ts",
# All the files in the protractor package are necesssary
"node_modules/protractor/**",
# Also include all files in node_modules/.bin
"node_modules/.bin/*",
],
exclude = [
# Files under test & docs may contain file names that
# are not legal Bazel labels (e.g.,
# node_modules/ecstatic/test/public/中文/檔案.html)
"node_modules/**/test/**",
"node_modules/**/docs/**",
# Files with spaces in the name are not legal Bazel labels
"node_modules/**/* */**",
"node_modules/**/* *",
],
) + ["@build_bazel_rules_typescript//:node_modules"],
# "@build_bazel_rules_typescript//:node_modules" is incluced
# in `//:node_modules` so that npm dependencies that are hoisted to
# node_modules/@bazel/typescript/node_modules because of conflicting
# versions can be resolved correctly
)
20 changes: 3 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,7 @@ Follow https://github.com/angular/angular/issues/19058 for updates.

## Installation

Install Bazel from the distribution, see [install] instructions.
On Mac, if you have Homebrew installed you can

```bash
brew tap bazelbuild/tap
brew tap-pin bazelbuild/tap
brew install bazel
```

Bazel will install a hermetic version of Node, npm, and Yarn when
you run the first build.

[install]: https://bazel.build/versions/master/docs/install.html

Also add `ibazel` to your `$PATH`:
Add `ibazel` to your `$PATH`:

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

or
or

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

Note: code splitting is _not_ supported in development mode yet so the
Note: code splitting is _not_ supported in development mode yet so the
`//src:devserver` target does not serve a code split bundle. For this
reason, development and production use different main entry points
(`main.dev.ts` and `main.ts`) and different root modules
Expand Down
43 changes: 14 additions & 29 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,12 @@ http_archive(
sha256 = "edf39af5fc257521e4af4c40829fffe8fba6d0ebff9f4dd69a6f8f1223ae047b",
)

# Runs the TypeScript compiler
local_repository(
name = "build_bazel_rules_typescript",
path = "node_modules/@bazel/typescript",
)

load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
rules_typescript_dependencies()

# Runs the Sass CSS preprocessor
http_archive(
name = "io_bazel_rules_sass",
url = "https://github.com/bazelbuild/rules_sass/archive/1.11.0.zip",
strip_prefix = "rules_sass-1.11.0",
sha256 = "dbe9fb97d5a7833b2a733eebc78c9c1e3880f676ac8af16e58ccf2139cbcad03",
)

# The @angular repo contains rule for building Angular applications
http_archive(
name = "angular",
url = "https://github.com/angular/angular/archive/6.1.8.zip",
strip_prefix = "angular-6.1.8",
sha256 = "5ac6694f7c694afe34767aff4a0dd0408e25b0493cea675c2bb075c123adc46a",
url = "https://github.com/angular/angular/archive/2546c663769cdb8ba0b3979bb157fe58770f4325.zip",
strip_prefix = "angular-2546c663769cdb8ba0b3979bb157fe58770f4325",
#sha256 = "5ac6694f7c694afe34767aff4a0dd0408e25b0493cea675c2bb075c123adc46a",
)

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

load("@angular//packages/bazel:package.bzl", "rules_angular_dependencies")

rules_angular_dependencies()

load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")

node_repositories(
package_json = ["//:package.json"],
preserve_symlinks = True,
node_version = "10.9.0",
yarn_version = "1.9.2",
)

yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
data = ["//:postinstall.tsconfig.json"],
)

load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")

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

ts_setup_workspace()

# Enforce that the version of @bazel/typescript installed by npm is compatible with the rules.
# 0.16.0: tsc_wrapped uses user's typescript version & check_rules_typescript_version
check_rules_typescript_version("0.16.0")

load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")

sass_repositories()

#
# Load and install our dependencies from local repositories
#

load("@angular//:index.bzl", "ng_setup_workspace")

ng_setup_workspace()
18 changes: 16 additions & 2 deletions e2e/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,33 @@ ts_library(
name = "e2e",
testonly = 1,
srcs = glob(["src/*.ts"]),
tsconfig = "//src:tsconfig-test",
deps = [
"@npm//@types/jasmine",
"@npm//jasmine",
"@npm//protractor",
],
)

protractor_web_test_suite(
name = "prodserver_test",
data = ["@angular//packages/bazel/src/protractor/utils"],
data = [
"@angular//packages/bazel/src/protractor/utils",
"@npm//protractor",
"@npm//zone.js",
],
on_prepare = ":protractor.on-prepare.js",
server = "//src:prodserver",
deps = [":e2e"],
)

protractor_web_test_suite(
name = "devserver_test",
data = ["@angular//packages/bazel/src/protractor/utils"],
data = [
"@angular//packages/bazel/src/protractor/utils",
"@npm//protractor",
"@npm//zone.js",
],
on_prepare = ":protractor.on-prepare.js",
server = "//src:devserver",
deps = [":e2e"],
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@
"zone.js": "0.8.26"
},
"devDependencies": {
"@angular/compiler": "6.1.8",
"@angular/compiler-cli": "6.1.8",
"@angular/core": "6.1.8",
"@angular/compiler": "github:angular/compiler-builds#bazel",
"@angular/compiler-cli": "github:angular/compiler-cli-builds#bazel",
"@angular/core": "github:angular/core-builds#bazel",
"@bazel/benchmark-runner": "0.1.0",
"@bazel/ibazel": "0.5.0",
"@bazel/typescript": "0.17.0",
"@bazel/karma": "0.19.1",
"@bazel/typescript": "0.19.1",
"@types/jasmine": "2.8.8",
"@types/node": "6.0.117",
"clang-format": "1.2.4",
"husky": "0.14.3",
"protractor": "5.4.1",
"typescript": "2.9.2"
"typescript": "3.1"
},
"scripts": {
"build": "bazel build //src:bundle",
Expand Down
31 changes: 20 additions & 11 deletions src/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package(default_visibility = ["//visibility:public"])

load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_config", "ts_devserver")

ts_config(
name = "tsconfig-test",
src = "tsconfig-test.json",
deps = [":tsconfig.json"],
)

ng_module(
name = "src",
Expand All @@ -15,6 +21,7 @@ ng_module(
"//src/todos",
"@angular//packages/core",
"@angular//packages/router",
"@npm//@ngrx/store",
],
)

Expand All @@ -26,9 +33,9 @@ ts_devserver(
name = "devserver",
# serve these files rooted at /
additional_root_paths = [
"angular_bazel_example/node_modules/zone.js/dist",
"angular_bazel_example/node_modules/tslib",
"angular_bazel_example/node_modules/@ngrx/store/bundles",
"npm/node_modules/zone.js/dist",
"npm/node_modules/tslib",
"npm/node_modules/@ngrx/store/bundles",
],
# Start from the development version of the main
entry_module = "angular_bazel_example/src/main.dev",
Expand All @@ -39,9 +46,9 @@ ts_devserver(
serving_path = "/bundle.min.js",
# Serve these files in addition to the JavaScript bundle
static_files = [
"//:node_modules/zone.js/dist/zone.min.js",
"//:node_modules/tslib/tslib.js",
"//:node_modules/@ngrx/store/bundles/store.umd.min.js",
"@npm//node_modules/zone.js:dist/zone.min.js",
"@npm//node_modules/tslib:tslib.js",
"@npm//node_modules/@ngrx/store:bundles/store.umd.min.js",
"index.html",
],
# Tell Bazel to build the sources first
Expand All @@ -62,24 +69,26 @@ rollup_bundle(
"src/todos/todos.module.ngfactory",
],
entry_point = "src/main",
node_modules = "//:node_modules",
deps = ["//src"],
deps = [
"//src",
"@npm//@ngrx/store",
],
)

# Copy zone.min.js to this package.
# Needed because the prodserver only loads static files that appear under this
# package.
genrule(
name = "copy_zonejs",
srcs = ["//:node_modules/zone.js/dist/zone.min.js"],
srcs = ["@npm//node_modules/zone.js:dist/zone.min.js"],
outs = ["zone.min.js"],
cmd = "cp $< $@",
)

# See comment for zonejs above
genrule(
name = "copy_systemjs",
srcs = ["//:node_modules/systemjs/dist/system.js"],
srcs = ["@npm//node_modules/systemjs:dist/system.js"],
outs = ["system.js"],
cmd = "cp $< $@",
)
Expand Down
14 changes: 9 additions & 5 deletions src/hello-world/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ng_module(
"@angular//packages/core",
"@angular//packages/forms",
"@angular//packages/router",
"@rxjs",
"@npm//@types",
],
)

Expand All @@ -39,20 +39,24 @@ ts_library(
"@angular//packages/core/testing",
"@angular//packages/platform-browser",
"@angular//packages/platform-browser-dynamic/testing",
"@npm//@types/jasmine",
"@npm//@types/node",
],
)

ts_web_test_suite(
name = "test",
srcs = ["//:node_modules/tslib/tslib.js"],
srcs = ["@npm//node_modules/tslib:tslib.js"],
# do not sort
bootstrap = [
"//:node_modules/zone.js/dist/zone-testing-bundle.js",
"//:node_modules/reflect-metadata/Reflect.js",
"@npm//node_modules/zone.js:dist/zone-testing-bundle.js",
"@npm//node_modules/reflect-metadata:Reflect.js",
],
browsers = [
"@io_bazel_rules_webtesting//browsers:chromium-local",
"@io_bazel_rules_webtesting//browsers:firefox-local",
# TODO(gregmagolan): re-enable firefox testing once fixed
# See https://github.com/bazelbuild/rules_typescript/issues/296
#"@io_bazel_rules_webtesting//browsers:firefox-local",
],
deps = [
":test_lib",
Expand Down
3 changes: 3 additions & 0 deletions src/reducers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
ts_library(
name = "reducers",
srcs = glob(["*.ts"]),
deps = [
"@npm//@ngrx/store",
],
)
2 changes: 2 additions & 0 deletions src/todos/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ ng_module(
"@angular//packages/core",
"@angular//packages/forms",
"@angular//packages/router",
"@npm//@ngrx/store",
"@npm//@types",
"@rxjs",
],
)
6 changes: 6 additions & 0 deletions src/tsconfig-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"types": ["jasmine"]
}
}
3 changes: 2 additions & 1 deletion src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
".",
"../dist/bin/src",
],
"experimentalDecorators": true
"experimentalDecorators": true,
"types": []
}
}
Loading