build: update to rules_typescript 0.23.2 and rules_nodejs 0.16.8 (#28532)

PR Close #28532
This commit is contained in:
Greg Magolan 2019-02-04 15:53:32 -08:00 committed by Matias Niemelä
parent 8d11627e6c
commit 0d1e065a1c
20 changed files with 263 additions and 994 deletions

View File

@ -2,3 +2,4 @@ node_modules
dist dist
aio/node_modules aio/node_modules
aio/tools/examples/shared/node_modules aio/tools/examples/shared/node_modules
integration/bazel

View File

@ -1,17 +1,6 @@
workspace(name = "angular") workspace(name = "angular")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load(
"//packages/bazel:package.bzl",
"rules_angular_dependencies",
"rules_angular_dev_dependencies",
)
http_archive(
name = "io_bazel_rules_go",
sha256 = "b7a62250a3a73277ade0ce306d22f122365b513f5402222403e507f2f997d421",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.16.3/rules_go-0.16.3.tar.gz",
)
# Uncomment for local bazel rules development # Uncomment for local bazel rules development
#local_repository( #local_repository(
@ -23,25 +12,15 @@ http_archive(
# path = "../rules_typescript", # path = "../rules_typescript",
#) #)
# Angular Bazel users will call this function # Fetch rules_nodejs so we can install our npm dependencies
rules_angular_dependencies() http_archive(
name = "build_bazel_rules_nodejs",
strip_prefix = "rules_nodejs-0.16.8",
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/0.16.8.zip"],
)
# Install transitive deps of rules_nodejs # Fetch the rxjs repository since we build rxjs from source
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies") # TODO(gregmagolan): use rxjs bundles in the bazel build
rules_nodejs_dependencies()
# These are the dependencies only for us
rules_angular_dev_dependencies()
# Install transitive deps of rules_typescript
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
rules_typescript_dependencies()
#
# Point Bazel to WORKSPACEs that live in subdirectories
#
http_archive( http_archive(
name = "rxjs", name = "rxjs",
sha256 = "72b0b4e517f43358f554c125e40e39f67688cd2738a8998b4a266981ed32f403", sha256 = "72b0b4e517f43358f554c125e40e39f67688cd2738a8998b4a266981ed32f403",
@ -49,17 +28,25 @@ http_archive(
url = "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz", url = "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz",
) )
# Point to the integration test workspace just so that Bazel doesn't descend into it # TODO(gregmagolan): do we still need go dependencies?
# when expanding the //... pattern http_archive(
local_repository( name = "io_bazel_rules_go",
name = "bazel_integration_test", sha256 = "b7a62250a3a73277ade0ce306d22f122365b513f5402222403e507f2f997d421",
path = "integration/bazel", url = "https://github.com/bazelbuild/rules_go/releases/download/0.16.3/rules_go-0.16.3.tar.gz",
) )
# # Use a mock @npm repository while we are building angular from source
# Load and install our dependencies downloaded above. # downstream. Angular will get its npm dependencies with in @ngdeps which
# # is setup in ng_setup_workspace().
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install") # 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",
)
# Check the bazel version and download npm dependencies
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories")
# Bazel version must be at least v0.21.0 because: # 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` # - 0.21.0 Using --incompatible_strict_action_env flag fixes cache when running `yarn bazel`
@ -72,6 +59,7 @@ Try running `yarn bazel` instead.
""") """)
# Setup the Node.js toolchain
node_repositories( node_repositories(
node_version = "10.9.0", node_version = "10.9.0",
package_json = ["//:package.json"], package_json = ["//:package.json"],
@ -79,17 +67,34 @@ node_repositories(
yarn_version = "1.12.1", yarn_version = "1.12.1",
) )
local_repository( # Setup the angular toolchain which installs npm dependencies into @ngdeps
name = "npm", load("//tools:ng_setup_workspace.bzl", "ng_setup_workspace")
path = "tools/npm_workspace",
)
ng_setup_workspace()
# Install all bazel dependencies of the @ngdeps npm packages
load("@ngdeps//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
install_bazel_dependencies()
# Load angular dependencies
load("//packages/bazel:package.bzl", "rules_angular_dev_dependencies")
rules_angular_dev_dependencies()
# Load karma dependencies
load("@build_bazel_rules_karma//:package.bzl", "rules_karma_dependencies")
rules_karma_dependencies()
# TODO(gregmagolan): do we still need go dependencies?
load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies") load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies() go_rules_dependencies()
go_register_toolchains() go_register_toolchains()
# Setup the rules_webtesting toolchain
load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", "web_test_repositories") load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", "web_test_repositories")
web_test_repositories() web_test_repositories()
@ -99,21 +104,17 @@ browser_repositories(
firefox = True, firefox = True,
) )
# Setup the rules_typescript tooolchain
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace") load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
ts_setup_workspace() ts_setup_workspace()
load("@angular//:index.bzl", "ng_setup_workspace") # Setup the rules_sass toolchain
ng_setup_workspace()
##################################
# Skylark documentation generation
load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories") load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
sass_repositories() sass_repositories()
# Setup the skydoc toolchain
load("@io_bazel_skydoc//skylark:skylark.bzl", "skydoc_repositories") load("@io_bazel_skydoc//skylark:skylark.bzl", "skydoc_repositories")
skydoc_repositories() skydoc_repositories()

View File

@ -32,8 +32,8 @@
"@angular/language-service": "file:../angular/dist/packages-dist/language-service", "@angular/language-service": "file:../angular/dist/packages-dist/language-service",
"@bazel/bazel": "^0.21.0", "@bazel/bazel": "^0.21.0",
"@bazel/ibazel": "^0.9.0", "@bazel/ibazel": "^0.9.0",
"@bazel/karma": "^0.22.1", "@bazel/karma": "^0.23.2",
"@bazel/typescript": "^0.22.1", "@bazel/typescript": "^0.23.2",
"@types/node": "~8.9.4", "@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8", "@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "~2.0.3",

View File

@ -2,34 +2,14 @@ workspace(name = "bazel_integration_test")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# # Fetch rules_nodejs so we can install our npm dependencies
# Download Bazel toolchain dependencies as needed by build actions
#
local_repository(
name = "angular",
path = "../..",
)
http_archive( http_archive(
name = "rxjs", name = "build_bazel_rules_nodejs",
sha256 = "72b0b4e517f43358f554c125e40e39f67688cd2738a8998b4a266981ed32f403", strip_prefix = "rules_nodejs-0.16.8",
strip_prefix = "package/src", urls = ["https://github.com/bazelbuild/rules_nodejs/archive/0.16.8.zip"],
url = "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz",
) )
load("@angular//packages/bazel:package.bzl", "rules_angular_dependencies") # Fetch sass rules for compiling sass files
rules_angular_dependencies()
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
rules_typescript_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
rules_nodejs_dependencies()
http_archive( http_archive(
name = "io_bazel_rules_sass", name = "io_bazel_rules_sass",
sha256 = "dbe9fb97d5a7833b2a733eebc78c9c1e3880f676ac8af16e58ccf2139cbcad03", sha256 = "dbe9fb97d5a7833b2a733eebc78c9c1e3880f676ac8af16e58ccf2139cbcad03",
@ -37,31 +17,67 @@ http_archive(
url = "https://github.com/bazelbuild/rules_sass/archive/1.11.0.zip", url = "https://github.com/bazelbuild/rules_sass/archive/1.11.0.zip",
) )
# # Fetch the angular repository since we build angular from source
# Setup dependencies loaded above # TODO(gregmagolan): use angular bundles in the Bazel build
# local_repository(
name = "angular",
path = "../..",
)
# Fetch the rxjs repository since we build rxjs from source
# TODO(gregmagolan): use rxjs bundles in the Bazel build
http_archive(
name = "rxjs",
sha256 = "72b0b4e517f43358f554c125e40e39f67688cd2738a8998b4a266981ed32f403",
strip_prefix = "package/src",
url = "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz",
)
# Check the bazel version and download npm dependencies
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install") load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install")
check_bazel_version("0.17.0") # 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`
# (see https://github.com/angular/angular/issues/27514#issuecomment-451438271)
check_bazel_version("0.21.0", """
You no longer need to install Bazel on your machine.
Angular has a dependency on the @bazel/bazel package which supplies it.
Try running `yarn bazel` instead.
(If you did run that, check that you've got a fresh `yarn install`)
""")
# Setup the Node.js toolchain
node_repositories( node_repositories(
node_version = "10.9.0", node_version = "10.9.0",
yarn_version = "1.12.1", yarn_version = "1.12.1",
) )
# Install our npm dependencies into @npm
yarn_install( yarn_install(
name = "npm", name = "npm",
package_json = "//src:package.json", package_json = "//src:package.json",
yarn_lock = "//src:yarn.lock", yarn_lock = "//src:yarn.lock",
) )
# Install all bazel dependencies of our npm packages
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
install_bazel_dependencies()
# Load karma dependencies
load("@build_bazel_rules_karma//:package.bzl", "rules_karma_dependencies")
rules_karma_dependencies()
# TODO(gregmagolan): do we still need go dependencies?
load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies") load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies() go_rules_dependencies()
go_register_toolchains() go_register_toolchains()
# Setup the rules_webtesting toolchain
load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", "web_test_repositories") load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", "web_test_repositories")
web_test_repositories() web_test_repositories()
@ -71,14 +87,17 @@ browser_repositories(
firefox = True, firefox = True,
) )
# Setup the rules_typescript tooolchain
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace") load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
ts_setup_workspace() ts_setup_workspace()
# Setup the rules_sass toolchain
load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories") load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
sass_repositories() sass_repositories()
# Setup the angular toolchain
load("@angular//:index.bzl", "ng_setup_workspace") load("@angular//:index.bzl", "ng_setup_workspace")
ng_setup_workspace() ng_setup_workspace()

View File

@ -2,7 +2,8 @@ package(default_visibility = ["//visibility:public"])
load("@angular//:index.bzl", "ng_module", "ng_package") load("@angular//:index.bzl", "ng_module", "ng_package")
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary") load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test_suite") load("@build_bazel_rules_karma//:defs.bzl", "ts_web_test_suite")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
sass_binary( sass_binary(
name = "hello-world-styles", name = "hello-world-styles",

View File

@ -13,8 +13,8 @@
"@angular/bazel": "file:../angular/dist/packages-dist/bazel", "@angular/bazel": "file:../angular/dist/packages-dist/bazel",
"@angular/compiler": "file:../angular/dist/packages-dist/compiler", "@angular/compiler": "file:../angular/dist/packages-dist/compiler",
"@angular/compiler-cli": "file:../angular/dist/packages-dist/compiler-cli", "@angular/compiler-cli": "file:../angular/dist/packages-dist/compiler-cli",
"@bazel/karma": "0.22.1", "@bazel/karma": "0.23.2",
"@bazel/typescript": "0.22.1", "@bazel/typescript": "0.23.2",
"@types/jasmine": "2.8.8", "@types/jasmine": "2.8.8",
"@types/source-map": "0.5.1", "@types/source-map": "0.5.1",
"protractor": "5.1.2", "protractor": "5.1.2",
@ -23,4 +23,4 @@
"scripts": { "scripts": {
"//": "TODO(gregmagolan): figure out how to keep dependencies here up to date with the root package.json" "//": "TODO(gregmagolan): figure out how to keep dependencies here up to date with the root package.json"
} }
} }

View File

@ -35,8 +35,8 @@
"@angular-devkit/build-optimizer": "^0.12.2", "@angular-devkit/build-optimizer": "^0.12.2",
"@angular-devkit/core": "^7.0.4", "@angular-devkit/core": "^7.0.4",
"@angular-devkit/schematics": "^7.3.0-rc.0", "@angular-devkit/schematics": "^7.3.0-rc.0",
"@bazel/karma": "~0.22.1", "@bazel/karma": "0.23.2",
"@bazel/typescript": "0.22.1-7-g68fed6a", "@bazel/typescript": "0.23.2",
"@schematics/angular": "^7.0.4", "@schematics/angular": "^7.0.4",
"@types/angular": "^1.6.47", "@types/angular": "^1.6.47",
"@types/base64-js": "1.2.5", "@types/base64-js": "1.2.5",
@ -151,4 +151,4 @@
"resolutions": { "resolutions": {
"natives": "1.1.6" "natives": "1.1.6"
} }
} }

View File

@ -9,41 +9,12 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def rules_angular_dependencies(): def rules_angular_dependencies():
""" print("""DEPRECATION WARNING:
Fetch our transitive dependencies. rules_angular_dependencies is no longer needed, and will be removed in a future release.
We assume you will fetch rules_nodejs in your WORKSPACE file, and no other dependencies remain here.
If the user wants to get a different version of these, they can just fetch it Simply remove any calls to this function and the corresponding call to
from their WORKSPACE before calling this function, or not call this function at all. load("@angular//:package.bzl", "rules_angular_dependencies")
""" """)
#
# Download Bazel toolchain dependencies as needed by build actions
# Use a SHA to get fix for needing symlink_prefix during npm publishing
_maybe(
http_archive,
name = "build_bazel_rules_nodejs",
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.16.5.zip",
strip_prefix = "rules_nodejs-0.16.5",
)
_maybe(
http_archive,
name = "build_bazel_rules_typescript",
url = "https://github.com/bazelbuild/rules_typescript/archive/0.22.1.zip",
strip_prefix = "rules_typescript-0.22.1",
)
# Needed for Remote Execution
_maybe(
http_archive,
name = "bazel_toolchains",
sha256 = "ee854b5de299138c1f4a2edb5573d22b21d975acfc7aa938f36d30b49ef97498",
strip_prefix = "bazel-toolchains-37419a124bdb9af2fec5b99a973d359b6b899b61",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/37419a124bdb9af2fec5b99a973d359b6b899b61.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/37419a124bdb9af2fec5b99a973d359b6b899b61.tar.gz",
],
)
def rules_angular_dev_dependencies(): def rules_angular_dev_dependencies():
""" """
@ -60,14 +31,16 @@ def rules_angular_dev_dependencies():
url = "https://github.com/google/brotli/archive/v1.0.5.zip", url = "https://github.com/google/brotli/archive/v1.0.5.zip",
) )
# The TypeScript rules transitively fetch a version of "rules_webtesting", but the version # Needed for Remote Execution
# does not include 239b491e8251588bb46297b899d306ae7024858e which updates the "chromedriver" _maybe(
# version so that e2e tests are able to capture the browser console output. This is needed http_archive,
# for a few e2e tests, so we manually fetch a version that includes that required SHA. name = "bazel_toolchains",
http_archive( sha256 = "ee854b5de299138c1f4a2edb5573d22b21d975acfc7aa938f36d30b49ef97498",
name = "io_bazel_rules_webtesting", strip_prefix = "bazel-toolchains-37419a124bdb9af2fec5b99a973d359b6b899b61",
url = "https://github.com/bazelbuild/rules_webtesting/archive/1f430d5e1cae10efc953a6511147e21b3bc03a5d.zip", urls = [
strip_prefix = "rules_webtesting-1f430d5e1cae10efc953a6511147e21b3bc03a5d", "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/37419a124bdb9af2fec5b99a973d359b6b899b61.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/37419a124bdb9af2fec5b99a973d359b6b899b61.tar.gz",
],
) )
############################################# #############################################

View File

@ -15,7 +15,7 @@
"@angular-devkit/architect": "^0.10.6", "@angular-devkit/architect": "^0.10.6",
"@angular-devkit/core": "^7.0.4", "@angular-devkit/core": "^7.0.4",
"@angular-devkit/schematics": "^7.3.0-rc.0", "@angular-devkit/schematics": "^7.3.0-rc.0",
"@bazel/typescript": "^0.22.1", "@bazel/typescript": "^0.23.2",
"@schematics/angular": "^7.0.4", "@schematics/angular": "^7.0.4",
"@types/node": "6.0.84", "@types/node": "6.0.84",
"semver": "^5.6.0", "semver": "^5.6.0",
@ -38,4 +38,4 @@
"scripts": { "scripts": {
"postinstall": "node ./check_version.js" "postinstall": "node ./check_version.js"
} }
} }

View File

@ -5,17 +5,9 @@
"Install toolchain dependencies" "Install toolchain dependencies"
load("@build_bazel_rules_typescript//:defs.bzl", "check_rules_typescript_version")
def ng_setup_workspace(): def ng_setup_workspace():
"""This repository rule should be called from your WORKSPACE file. """This repository rule should be called from your WORKSPACE file.
It creates some additional Bazel external repositories that are used internally It creates some additional Bazel external repositories that are used internally
by the Angular rules. by the Angular rules.
""" """
# 0.16.0: minimal version required to work with ng_module
# 0.16.2: bazel type resolution for zone.js types
# 0.20.1: fine grained deps
# 0.20.2: version check fix
check_rules_typescript_version("0.20.2")

View File

@ -19,13 +19,6 @@ http_archive(
strip_prefix = "rules_nodejs-%s" % RULES_NODEJS_VERSION, strip_prefix = "rules_nodejs-%s" % RULES_NODEJS_VERSION,
) )
RULES_TYPESCRIPT_VERSION = "<%= RULES_TYPESCRIPT_VERSION %>"
http_archive(
name = "build_bazel_rules_typescript",
url = "https://github.com/bazelbuild/rules_typescript/archive/%s.zip" % RULES_TYPESCRIPT_VERSION,
strip_prefix = "rules_typescript-%s" % RULES_TYPESCRIPT_VERSION,
)
# The @angular repo contains rule for building Angular applications # The @angular repo contains rule for building Angular applications
ANGULAR_VERSION = "<%= ANGULAR_VERSION %>" ANGULAR_VERSION = "<%= ANGULAR_VERSION %>"
http_archive( http_archive(
@ -53,15 +46,6 @@ http_archive(
#################################### ####################################
# Load and install our dependencies downloaded above. # Load and install our dependencies downloaded above.
load("@angular//packages/bazel:package.bzl", "rules_angular_dependencies")
rules_angular_dependencies()
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
rules_typescript_dependencies()
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
rules_nodejs_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install") load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install")
# 0.18.0 is needed for .bazelignore # 0.18.0 is needed for .bazelignore
check_bazel_version("0.18.0") check_bazel_version("0.18.0")
@ -72,6 +56,12 @@ yarn_install(
yarn_lock = "//:yarn.lock", yarn_lock = "//:yarn.lock",
) )
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
install_bazel_dependencies()
load("@build_bazel_rules_karma//:package.bzl", "rules_karma_dependencies")
rules_karma_dependencies()
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains") load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies() go_rules_dependencies()
go_register_toolchains() go_register_toolchains()

View File

@ -1,10 +1,10 @@
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load("@angular//:index.bzl", "ng_module") load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test_suite") load("@build_bazel_rules_karma//:defs.bzl", "ts_web_test_suite")
load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle", "history_server") load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle", "history_server")
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package") load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver") load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver", "ts_library")
<% if (sass) { %>load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") <% if (sass) { %>load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
[ [

View File

@ -92,7 +92,6 @@ export default function(options: BazelWorkspaceOptions): Rule {
const workspaceVersions = { const workspaceVersions = {
'RULES_NODEJS_VERSION': '0.16.5', 'RULES_NODEJS_VERSION': '0.16.5',
'RULES_TYPESCRIPT_VERSION': '0.22.1',
'ANGULAR_VERSION': existingVersions.Angular || clean(latestVersions.Angular), 'ANGULAR_VERSION': existingVersions.Angular || clean(latestVersions.Angular),
'RXJS_VERSION': existingVersions.RxJs || clean(latestVersions.RxJs), 'RXJS_VERSION': existingVersions.RxJs || clean(latestVersions.RxJs),
// TODO(kyliau): Consider moving this to latest-versions.ts // TODO(kyliau): Consider moving this to latest-versions.ts

View File

@ -8,12 +8,12 @@
* @fileoverview Schematics for ng-new project that builds with Bazel. * @fileoverview Schematics for ng-new project that builds with Bazel.
*/ */
import {SchematicContext, apply, applyTemplates, chain, mergeWith, move, Rule, schematic, Tree, url, SchematicsException, UpdateRecorder,} from '@angular-devkit/schematics'; import { SchematicContext, apply, applyTemplates, chain, mergeWith, move, Rule, schematic, Tree, url, SchematicsException, UpdateRecorder, } from '@angular-devkit/schematics';
import {parseJsonAst, JsonAstObject, strings, JsonValue} from '@angular-devkit/core'; import { parseJsonAst, JsonAstObject, strings, JsonValue } from '@angular-devkit/core';
import {findPropertyInAstObject, insertPropertyInAstObjectInOrder} from '@schematics/angular/utility/json-utils'; import { findPropertyInAstObject, insertPropertyInAstObjectInOrder } from '@schematics/angular/utility/json-utils';
import {validateProjectName} from '@schematics/angular/utility/validation'; import { validateProjectName } from '@schematics/angular/utility/validation';
import {getWorkspacePath} from '@schematics/angular/utility/config'; import { getWorkspacePath } from '@schematics/angular/utility/config';
import {Schema} from './schema'; import { Schema } from './schema';
/** /**
* Packages that build under Bazel require additional dev dependencies. This * Packages that build under Bazel require additional dev dependencies. This
@ -40,18 +40,18 @@ function addDevDependenciesToPackageJson(options: Schema) {
} }
const angularCoreVersion = angularCoreNode.value as string; const angularCoreVersion = angularCoreNode.value as string;
const devDependencies: {[k: string]: string} = { const devDependencies: { [ k: string ]: string } = {
'@angular/bazel': angularCoreVersion, '@angular/bazel': angularCoreVersion,
// TODO(kyliau): Consider moving this to latest-versions.ts // TODO(kyliau): Consider moving this to latest-versions.ts
'@bazel/bazel': '^0.22.1', '@bazel/bazel': '^0.22.1',
'@bazel/ibazel': '^0.9.0', '@bazel/ibazel': '^0.9.0',
'@bazel/karma': '^0.22.1', '@bazel/karma': '^0.23.2',
'@bazel/typescript': '^0.22.1', '@bazel/typescript': '^0.23.2',
}; };
const recorder = host.beginUpdate(packageJson); const recorder = host.beginUpdate(packageJson);
for (const packageName of Object.keys(devDependencies)) { for (const packageName of Object.keys(devDependencies)) {
const version = devDependencies[packageName]; const version = devDependencies[ packageName ];
const indent = 4; const indent = 4;
insertPropertyInAstObjectInOrder(recorder, devDeps, packageName, version, indent); insertPropertyInAstObjectInOrder(recorder, devDeps, packageName, version, indent);
} }
@ -103,23 +103,23 @@ function updateGitignore() {
} }
function replacePropertyInAstObject( function replacePropertyInAstObject(
recorder: UpdateRecorder, node: JsonAstObject, propertyName: string, value: JsonValue, recorder: UpdateRecorder, node: JsonAstObject, propertyName: string, value: JsonValue,
indent: number) { indent: number) {
const property = findPropertyInAstObject(node, propertyName); const property = findPropertyInAstObject(node, propertyName);
if (property === null) { if (property === null) {
throw new Error(`Property ${propertyName} does not exist in JSON object`); throw new Error(`Property ${propertyName} does not exist in JSON object`);
} }
const {start, text} = property; const { start, text } = property;
recorder.remove(start.offset, text.length); recorder.remove(start.offset, text.length);
const indentStr = '\n' + const indentStr = '\n' +
' '.repeat(indent); ' '.repeat(indent);
const content = JSON.stringify(value, null, ' ').replace(/\n/g, indentStr); const content = JSON.stringify(value, null, ' ').replace(/\n/g, indentStr);
recorder.insertLeft(start.offset, content); recorder.insertLeft(start.offset, content);
} }
function updateAngularJsonToUseBazelBuilder(options: Schema): Rule { function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
return (host: Tree, context: SchematicContext) => { return (host: Tree, context: SchematicContext) => {
const {name} = options; const { name } = options;
const workspacePath = getWorkspacePath(host); const workspacePath = getWorkspacePath(host);
if (!workspacePath) { if (!workspacePath) {
throw new Error('Could not find angular.json'); throw new Error('Could not find angular.json');
@ -137,61 +137,61 @@ function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
const recorder = host.beginUpdate(workspacePath); const recorder = host.beginUpdate(workspacePath);
const indent = 8; const indent = 8;
const architect = const architect =
findPropertyInAstObject(project as JsonAstObject, 'architect') as JsonAstObject; findPropertyInAstObject(project as JsonAstObject, 'architect') as JsonAstObject;
replacePropertyInAstObject( replacePropertyInAstObject(
recorder, architect, 'build', { recorder, architect, 'build', {
builder: '@angular/bazel:build', builder: '@angular/bazel:build',
options: { options: {
targetLabel: '//src:bundle.js', targetLabel: '//src:bundle.js',
bazelCommand: 'build', bazelCommand: 'build',
}, },
configurations: { configurations: {
production: { production: {
targetLabel: '//src:bundle', targetLabel: '//src:bundle',
},
}, },
}, },
indent); },
indent);
replacePropertyInAstObject( replacePropertyInAstObject(
recorder, architect, 'serve', { recorder, architect, 'serve', {
builder: '@angular/bazel:build', builder: '@angular/bazel:build',
options: { options: {
targetLabel: '//src:devserver', targetLabel: '//src:devserver',
bazelCommand: 'run', bazelCommand: 'run',
}, },
configurations: { configurations: {
production: { production: {
targetLabel: '//src:prodserver', targetLabel: '//src:prodserver',
},
}, },
}, },
indent); },
indent);
replacePropertyInAstObject( replacePropertyInAstObject(
recorder, architect, 'test', { recorder, architect, 'test', {
builder: '@angular/bazel:build', builder: '@angular/bazel:build',
options: {'bazelCommand': 'test', 'targetLabel': '//src/...'}, options: { 'bazelCommand': 'test', 'targetLabel': '//src/...' },
}, },
indent); indent);
const e2e = `${options.name}-e2e`; const e2e = `${options.name}-e2e`;
const e2eNode = findPropertyInAstObject(projects as JsonAstObject, e2e); const e2eNode = findPropertyInAstObject(projects as JsonAstObject, e2e);
if (e2eNode) { if (e2eNode) {
const architect = const architect =
findPropertyInAstObject(e2eNode as JsonAstObject, 'architect') as JsonAstObject; findPropertyInAstObject(e2eNode as JsonAstObject, 'architect') as JsonAstObject;
replacePropertyInAstObject( replacePropertyInAstObject(
recorder, architect, 'e2e', { recorder, architect, 'e2e', {
builder: '@angular/bazel:build', builder: '@angular/bazel:build',
options: { options: {
bazelCommand: 'test', bazelCommand: 'test',
targetLabel: '//e2e:devserver_test', targetLabel: '//e2e:devserver_test',
},
configurations: {
production: {
targetLabel: '//e2e:prodserver_test',
},
}
}, },
indent); configurations: {
production: {
targetLabel: '//e2e:prodserver_test',
},
}
},
indent);
} }
host.commitUpdate(recorder); host.commitUpdate(recorder);
@ -210,13 +210,13 @@ function backupAngularJson(): Rule {
return; return;
} }
host.create( host.create(
`${workspacePath}.bak`, '// This is a backup file of the original angular.json. ' + `${workspacePath}.bak`, '// This is a backup file of the original angular.json. ' +
'This file is needed in case you want to revert to the workflow without Bazel.\n\n' + 'This file is needed in case you want to revert to the workflow without Bazel.\n\n' +
host.read(workspacePath)); host.read(workspacePath));
}; };
} }
export default function(options: Schema): Rule { export default function (options: Schema): Rule {
return (host: Tree) => { return (host: Tree) => {
validateProjectName(options.name); validateProjectName(options.name);

View File

@ -8,11 +8,11 @@
* @fileoverview Schematics for ng-new project that builds with Bazel. * @fileoverview Schematics for ng-new project that builds with Bazel.
*/ */
import {Rule, Tree, chain, externalSchematic, schematic} from '@angular-devkit/schematics'; import { Rule, Tree, chain, externalSchematic, schematic } from '@angular-devkit/schematics';
import {validateProjectName} from '@schematics/angular/utility/validation'; import { validateProjectName } from '@schematics/angular/utility/validation';
import {Schema} from './schema'; import { Schema } from './schema';
export default function(options: Schema): Rule { export default function (options: Schema): Rule {
return (host: Tree) => { return (host: Tree) => {
validateProjectName(options.name); validateProjectName(options.name);

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {PluginCompilerHost} from '@bazel/typescript/tsc_wrapped/plugin_api'; import {PluginCompilerHost} from '@bazel/typescript/internal/tsc_wrapped/plugin_api';
import * as ts from 'typescript'; import * as ts from 'typescript';
/** /**

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {PluginCompilerHost, TscPlugin} from '@bazel/typescript/tsc_wrapped/plugin_api'; import {PluginCompilerHost, TscPlugin} from '@bazel/typescript/internal/tsc_wrapped/plugin_api';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {SyntheticFilesCompilerHost} from './synthetic_files_compiler_host'; import {SyntheticFilesCompilerHost} from './synthetic_files_compiler_host';

View File

@ -1,7 +1,8 @@
"""Re-export of some bazel rules with repository-wide defaults.""" """Re-export of some bazel rules with repository-wide defaults."""
load("@build_bazel_rules_karma//:defs.bzl", _ts_web_test_suite = "ts_web_test_suite")
load("@build_bazel_rules_nodejs//:defs.bzl", _jasmine_node_test = "jasmine_node_test", _nodejs_binary = "nodejs_binary", _npm_package = "npm_package") load("@build_bazel_rules_nodejs//:defs.bzl", _jasmine_node_test = "jasmine_node_test", _nodejs_binary = "nodejs_binary", _npm_package = "npm_package")
load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library", _ts_web_test_suite = "ts_web_test_suite") load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library")
load("//packages/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package") load("//packages/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package")
load("//packages/bazel/src:ng_rollup_bundle.bzl", _ng_rollup_bundle = "ng_rollup_bundle") load("//packages/bazel/src:ng_rollup_bundle.bzl", _ng_rollup_bundle = "ng_rollup_bundle")

View File

@ -19,7 +19,8 @@ def ng_setup_workspace():
# The NodeJS rules version must be at least v0.15.3 because: # 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.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.15.3 Includes a fix for the `jasmine_node_test` rule ignoring target tags
check_rules_nodejs_version("0.15.3") # - 0.16.8 Supports npm installed bazel workspaces
check_rules_nodejs_version("0.16.8")
yarn_install( yarn_install(
name = "ngdeps", name = "ngdeps",

825
yarn.lock

File diff suppressed because it is too large Load Diff