Skip to content

Commit

Permalink
build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that dow…
Browse files Browse the repository at this point in the history
…nstream angular build uses angular bundles (angular#28871)

PR Close angular#28871
  • Loading branch information
gregmagolan authored and AndrewKushnir committed Feb 28, 2019
1 parent cd83a43 commit ea09430
Show file tree
Hide file tree
Showing 220 changed files with 660 additions and 781 deletions.
46 changes: 15 additions & 31 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ filegroup(
name = "web_test_bootstrap_scripts",
# do not sort
srcs = [
"@ngdeps//node_modules/core-js:client/core.js",
"@ngdeps//node_modules/zone.js:dist/zone.js",
"@ngdeps//node_modules/zone.js:dist/zone-testing.js",
"@ngdeps//node_modules/zone.js:dist/task-tracking.js",
"@npm//node_modules/core-js:client/core.js",
"@npm//node_modules/zone.js:dist/zone.js",
"@npm//node_modules/zone.js:dist/zone-testing.js",
"@npm//node_modules/zone.js:dist/task-tracking.js",
"//:test-events.js",
"//:shims_for_IE.js",
# Including systemjs because it defines `__eval`, which produces correct stack traces.
"@ngdeps//node_modules/systemjs:dist/system.src.js",
"@ngdeps//node_modules/reflect-metadata:Reflect.js",
"@npm//node_modules/systemjs:dist/system.src.js",
"@npm//node_modules/reflect-metadata:Reflect.js",
],
)

Expand All @@ -33,34 +33,18 @@ filegroup(
srcs = [
# We also declare the unminfied AngularJS files since these can be used for
# local debugging (e.g. see: packages/upgrade/test/common/test_helpers.ts)
"@ngdeps//node_modules/angular:angular.js",
"@ngdeps//node_modules/angular:angular.min.js",
"@ngdeps//node_modules/angular-1.5:angular.js",
"@ngdeps//node_modules/angular-1.5:angular.min.js",
"@ngdeps//node_modules/angular-1.6:angular.js",
"@ngdeps//node_modules/angular-1.6:angular.min.js",
"@ngdeps//node_modules/angular-mocks:angular-mocks.js",
"@ngdeps//node_modules/angular-mocks-1.5:angular-mocks.js",
"@ngdeps//node_modules/angular-mocks-1.6:angular-mocks.js",
"@npm//node_modules/angular:angular.js",
"@npm//node_modules/angular:angular.min.js",
"@npm//node_modules/angular-1.5:angular.js",
"@npm//node_modules/angular-1.5:angular.min.js",
"@npm//node_modules/angular-1.6:angular.js",
"@npm//node_modules/angular-1.6:angular.min.js",
"@npm//node_modules/angular-mocks:angular-mocks.js",
"@npm//node_modules/angular-mocks-1.5:angular-mocks.js",
"@npm//node_modules/angular-mocks-1.6:angular-mocks.js",
],
)

# A nodejs_binary for @angular/bazel/ngc-wrapped to use by default in
# ng_module that depends on @npm//@angular/bazel instead of the
# output of the //packages/bazel/src/ngc-wrapped ts_library rule. This
# default is for downstream users that depend on the @angular/bazel npm
# package. The generated @npm//@angular/bazel/ngc-wrapped target
# does not work because it does not have the node `--expose-gc` flag
# set which is required to support the call to `global.gc()`.
nodejs_binary(
name = "@angular/bazel/ngc-wrapped",
configuration_env_vars = ["compile"],
data = ["@npm//@angular/bazel"],
entry_point = "@angular/bazel/src/ngc-wrapped/index.js",
install_source_map_support = False,
templated_args = ["--node_options=--expose-gc"],
)

# To run a karma_web_test target locally on SauceLabs:
# 1) have SAUCE_USERNAME, SAUCE_ACCESS_KEY (and optionally a SAUCE_TUNNEL_IDENTIFIER) set in your environment
# 2) open a sauce connection with `./scripts/saucelabs/start-tunnel.sh`
Expand Down
50 changes: 31 additions & 19 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,13 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Fetch rules_nodejs so we can install our npm dependencies
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "86ea92217dfd4a84e1e335cc07dfd942b12899796b080492546b947f12c5ab77",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.26.0-beta.0/rules_nodejs-0.26.0-beta.0.tar.gz"],
)

# Use a mock @npm repository while we are building angular from source
# downstream. Angular will get its npm dependencies with in @ngdeps which
# is setup in ng_setup_workspace().
# TODO(gregmagolan): remove @ngdeps once angular is no longer build from source
# downstream and have build use @npm for npm dependencies
local_repository(
name = "npm",
path = "tools/npm_workspace",
sha256 = "5c86b055c57e15bf32d9009a15bcd6d8e190c41b1ff2fb18037b75e0012e4e7c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.26.0/rules_nodejs-0.26.0.tar.gz"],
)

# Check the bazel version and download npm dependencies
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories")
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install")
load("@build_bazel_rules_nodejs//:package.bzl", "check_rules_nodejs_version")

# Bazel version must be at least v0.21.0 because:
# - 0.21.0 Using --incompatible_strict_action_env flag fixes cache when running `yarn bazel`
Expand All @@ -46,6 +37,12 @@ Try running `yarn bazel` instead.
minimum_bazel_version = "0.21.0",
)

# The NodeJS rules version must be at least v0.15.3 because:
# - 0.15.2 Re-introduced the prod_only attribute on yarn_install
# - 0.15.3 Includes a fix for the `jasmine_node_test` rule ignoring target tags
# - 0.16.8 Supports npm installed bazel workspaces
check_rules_nodejs_version("0.16.8")

# Setup the Node.js toolchain
node_repositories(
node_version = "10.9.0",
Expand All @@ -54,13 +51,28 @@ node_repositories(
yarn_version = "1.12.1",
)

# Setup the angular toolchain which installs npm dependencies into @ngdeps
load("//tools:ng_setup_workspace.bzl", "ng_setup_workspace")
yarn_install(
name = "npm",
data = [
"//:tools/npm/@angular_bazel/index.js",
"//:tools/npm/@angular_bazel/package.json",
"//:tools/postinstall-patches.js",
"//:tools/yarn/check-yarn.js",
],
package_json = "//:package.json",
# Don't install devDependencies, they are large and not used under Bazel
prod_only = True,
yarn_lock = "//:yarn.lock",
)

ng_setup_workspace()
yarn_install(
name = "ts-api-guardian_deps",
package_json = "@angular//tools/ts-api-guardian:package.json",
yarn_lock = "@angular//tools/ts-api-guardian:yarn.lock",
)

# Install all bazel dependencies of the @ngdeps npm packages
load("@ngdeps//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
# Install all bazel dependencies of the @npm npm packages
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")

install_bazel_dependencies()

Expand All @@ -86,7 +98,7 @@ load("@npm_bazel_karma//:browser_repositories.bzl", "browser_repositories")
browser_repositories()

# Setup the rules_typescript tooolchain
load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace")
load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")

ts_setup_workspace()

Expand Down
28 changes: 0 additions & 28 deletions index.bzl

This file was deleted.

14 changes: 3 additions & 11 deletions integration/bazel/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Fetch rules_nodejs so we can install our npm dependencies
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "86ea92217dfd4a84e1e335cc07dfd942b12899796b080492546b947f12c5ab77",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.26.0-beta.0/rules_nodejs-0.26.0-beta.0.tar.gz"],
sha256 = "5c86b055c57e15bf32d9009a15bcd6d8e190c41b1ff2fb18037b75e0012e4e7c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.26.0/rules_nodejs-0.26.0.tar.gz"],
)

# Fetch sass rules for compiling sass files
Expand Down Expand Up @@ -73,19 +73,11 @@ load("@npm_bazel_karma//:browser_repositories.bzl", "browser_repositories")
browser_repositories()

# Setup the rules_typescript tooolchain
load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace")
load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")

ts_setup_workspace()

# Setup the rules_sass toolchain
load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")

sass_repositories()

# Setup the angular toolchain. This integration test no longer builds Angular from source,
# but we still need to set up the "angular" workspace since some Bazel rules depend on
# the "ngdeps" repository. This can be fixed if we switched the Angular repository to the
# "npm" repository for the bazel managed dependencies.
load("@npm_angular_bazel//:index.bzl", "ng_setup_workspace")

ng_setup_workspace()
2 changes: 1 addition & 1 deletion integration/bazel/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package(default_visibility = ["//visibility:public"])
load("@npm_angular_bazel//:index.bzl", "ng_module")
load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "rollup_bundle")
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")

# Allow targets under sub-packages to reference the tsconfig.json file
exports_files(["tsconfig.json"])
Expand Down
4 changes: 2 additions & 2 deletions integration/bazel/src/hello-world/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("@npm_bazel_karma//:defs.bzl", "ts_web_test_suite")
load("@npm_bazel_typescript//:defs.bzl", "ts_library")
load("@npm_bazel_karma//:index.bzl", "ts_web_test_suite")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary")
load("@npm_angular_bazel//:index.bzl", "ng_module", "ng_package")

Expand Down
2 changes: 1 addition & 1 deletion integration/bazel/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@angular/bazel": "packages-dist:bazel",
"@angular/compiler": "packages-dist:compiler",
"@angular/compiler-cli": "packages-dist:compiler-cli",
"@bazel/karma": "0.26.0-beta.0",
"@bazel/karma": "0.26.0",
"@types/jasmine": "2.8.8",
"@types/source-map": "0.5.1",
"protractor": "5.1.2",
Expand Down
2 changes: 1 addition & 1 deletion integration/bazel/test/e2e/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@npm_bazel_typescript//:defs.bzl", "ts_library")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
load("@npm_angular_bazel//:index.bzl", "protractor_web_test_suite")

ts_library(
Expand Down
2 changes: 1 addition & 1 deletion karma-js.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module.exports = function(config) {
// don't need this entire config file.
proxies: {
'/base/angular/': '/base/',
'/base/ngdeps/': '/base/',
'/base/npm/': '/base/',
},

reporters: ['dots'],
Expand Down
4 changes: 2 additions & 2 deletions modules/benchmarks/benchmark_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def benchmark_test(name, server, deps, tags = []):
server = server,
tags = tags,
deps = [
"@ngdeps//protractor",
"@ngdeps//yargs",
"@npm//protractor",
"@npm//yargs",
] + deps,
)
4 changes: 2 additions & 2 deletions modules/benchmarks/src/largeform/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ts_library(
tsconfig = "//modules/benchmarks:tsconfig-e2e.json",
deps = [
"//modules/e2e_util",
"@ngdeps//@types/jasminewd2",
"@ngdeps//protractor",
"@npm//@types/jasminewd2",
"@npm//protractor",
],
)
8 changes: 4 additions & 4 deletions modules/benchmarks/src/largeform/ng2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("//tools:defaults.bzl", "ng_module")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")

package(default_visibility = ["//modules/benchmarks:__subpackages__"])
Expand Down Expand Up @@ -29,12 +29,12 @@ ts_devserver(
index_html = "index.html",
port = 4200,
scripts = [
"@ngdeps//node_modules/tslib:tslib.js",
"@npm//node_modules/tslib:tslib.js",
"//tools/rxjs:rxjs_umd_modules",
],
static_files = [
"@ngdeps//node_modules/zone.js:dist/zone.js",
"@ngdeps//node_modules/reflect-metadata:Reflect.js",
"@npm//node_modules/zone.js:dist/zone.js",
"@npm//node_modules/reflect-metadata:Reflect.js",
],
tags = ["fixme-ivy-aot"],
deps = [":ng2"],
Expand Down
2 changes: 1 addition & 1 deletion modules/benchmarks/src/largetable/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ ts_library(
srcs = ["largetable_perf.spec.ts"],
deps = [
"//modules/e2e_util",
"@ngdeps//protractor",
"@npm//protractor",
],
)
2 changes: 1 addition & 1 deletion modules/benchmarks/src/largetable/baseline/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("//tools:defaults.bzl", "ts_library")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")

package(default_visibility = ["//modules/benchmarks:__subpackages__"])
Expand Down
4 changes: 2 additions & 2 deletions modules/benchmarks/src/largetable/incremental_dom/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("//tools:defaults.bzl", "ts_library")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")

package(default_visibility = ["//modules/benchmarks:__subpackages__"])
Expand All @@ -20,7 +20,7 @@ ts_devserver(
index_html = "index.html",
port = 4200,
static_files = [
"@ngdeps//node_modules/incremental-dom:dist/incremental-dom.js",
"@npm//node_modules/incremental-dom:dist/incremental-dom.js",
],
deps = [":incremental_dom"],
)
Expand Down
8 changes: 4 additions & 4 deletions modules/benchmarks/src/largetable/ng2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("//tools:defaults.bzl", "ng_module")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")

package(default_visibility = ["//modules/benchmarks:__subpackages__"])
Expand Down Expand Up @@ -28,12 +28,12 @@ ts_devserver(
index_html = "index.html",
port = 4200,
scripts = [
"@ngdeps//node_modules/tslib:tslib.js",
"@npm//node_modules/tslib:tslib.js",
"//tools/rxjs:rxjs_umd_modules",
],
static_files = [
"@ngdeps//node_modules/zone.js:dist/zone.js",
"@ngdeps//node_modules/reflect-metadata:Reflect.js",
"@npm//node_modules/zone.js:dist/zone.js",
"@npm//node_modules/reflect-metadata:Reflect.js",
],
deps = [":ng2"],
)
Expand Down
8 changes: 4 additions & 4 deletions modules/benchmarks/src/largetable/ng2_switch/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("//tools:defaults.bzl", "ng_module")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")

package(default_visibility = ["//modules/benchmarks:__subpackages__"])
Expand All @@ -25,12 +25,12 @@ ts_devserver(
index_html = "index.html",
port = 4200,
scripts = [
"@ngdeps//node_modules/tslib:tslib.js",
"@npm//node_modules/tslib:tslib.js",
"//tools/rxjs:rxjs_umd_modules",
],
static_files = [
"@ngdeps//node_modules/zone.js:dist/zone.js",
"@ngdeps//node_modules/reflect-metadata:Reflect.js",
"@npm//node_modules/zone.js:dist/zone.js",
"@npm//node_modules/reflect-metadata:Reflect.js",
],
deps = [":ng2_switch"],
)
Expand Down
6 changes: 3 additions & 3 deletions modules/benchmarks/src/largetable/render3/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")

ng_module(
Expand All @@ -14,7 +14,7 @@ ng_module(
"//packages:types",
"//packages/common",
"//packages/core",
"@ngdeps//reflect-metadata",
"@npm//reflect-metadata",
],
)

Expand All @@ -24,7 +24,7 @@ ng_rollup_bundle(
tags = ["ivy-only"],
deps = [
":largetable_lib",
"@ngdeps//rxjs",
"@npm//rxjs",
],
)

Expand Down
Loading

0 comments on commit ea09430

Please sign in to comment.