Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update to rules_typescript 0.23.2 and rules_nodejs 0.16.8 (PATCH VERSION) #28567

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
dist
aio/node_modules
aio/tools/examples/shared/node_modules
integration/bazel
89 changes: 38 additions & 51 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
workspace(name = "angular")

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
#local_repository(
Expand All @@ -23,43 +12,34 @@ http_archive(
# path = "../rules_typescript",
#)

# Angular Bazel users will call this function
rules_angular_dependencies()

# Install transitive deps of rules_nodejs
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")

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()
# Fetch rules_nodejs so we can install our npm 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"],
)

#
# Point Bazel to WORKSPACEs that live in subdirectories
#
# 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",
)

# Point to the integration test workspace just so that Bazel doesn't descend into it
# when expanding the //... pattern
# 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 = "bazel_integration_test",
path = "integration/bazel",
name = "npm",
path = "tools/npm_workspace",
)

#
# Load and install our dependencies downloaded above.
#
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install")
# 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:
# - 0.21.0 Using --incompatible_strict_action_env flag fixes cache when running `yarn bazel`
Expand All @@ -72,24 +52,35 @@ Try running `yarn bazel` instead.

""")

# Setup the Node.js toolchain
node_repositories(
node_version = "10.9.0",
package_json = ["//:package.json"],
preserve_symlinks = True,
yarn_version = "1.12.1",
)

local_repository(
name = "npm",
path = "tools/npm_workspace",
)
# Setup the angular toolchain which installs npm dependencies into @ngdeps
load("//tools:ng_setup_workspace.bzl", "ng_setup_workspace")

ng_setup_workspace()

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

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

go_rules_dependencies()
# Load angular dependencies
load("//packages/bazel:package.bzl", "rules_angular_dev_dependencies")

go_register_toolchains()
rules_angular_dev_dependencies()

# Load karma dependencies
load("@build_bazel_rules_karma//:package.bzl", "rules_karma_dependencies")

rules_karma_dependencies()

# Setup the rules_webtesting toolchain
load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", "web_test_repositories")

web_test_repositories()
Expand All @@ -99,21 +90,17 @@ browser_repositories(
firefox = True,
)

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

ts_setup_workspace()

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

ng_setup_workspace()

##################################
# Skylark documentation generation

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

sass_repositories()

# Setup the skydoc toolchain
load("@io_bazel_skydoc//skylark:skylark.bzl", "skydoc_repositories")

skydoc_repositories()
4 changes: 2 additions & 2 deletions integration/bazel-schematics/package.json.replace
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@angular/language-service": "file:../angular/dist/packages-dist/language-service",
"@bazel/bazel": "^0.21.0",
"@bazel/ibazel": "^0.9.0",
"@bazel/karma": "^0.22.1",
"@bazel/typescript": "^0.22.1",
"@bazel/karma": "^0.23.2",
"@bazel/typescript": "^0.23.2",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
Expand Down
39 changes: 30 additions & 9 deletions integration/bazel-schematics/replace_angular_repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,44 @@

const fs = require('fs');

function main(argv) {
argv = argv.slice(2);
if (argv.length !== 1) {
throw new Error('Expect WORKSPACE to be first parameter');
}
const workspace = argv[0];
const content = fs.readFileSync(workspace, 'utf-8');
function replaceAngular(content) {
const regex = /ANGULAR_VERSION.*\nhttp_archive\((.*\n){4}\)/;
if (!regex.test(content)) {
throw new Error("Failed to find http_archive rule for Angular in WORKSPACE");
}
const newContent = content.replace(regex, `
return content.replace(regex, `
local_repository(
name = "angular",
path = "../../..",
)`);
fs.writeFileSync(workspace, newContent);
}

function replaceNpm(content) {
const regex = /yarn_install\((.*\n){4}\)/;
if (!regex.test(content)) {
throw new Error("Failed to find yarn_install rule for Angular in WORKSPACE");
}
return content.replace(regex, `
yarn_install(
name = "npm",
# Need a reference to @angular here so that Bazel sets up the
# external repository before calling yarn_install
data = ["@angular//:LICENSE"],
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)`);
}

function main(argv) {
argv = argv.slice(2);
if (argv.length !== 1) {
throw new Error('Expect WORKSPACE to be first parameter');
}
const workspace = argv[0];
let content = fs.readFileSync(workspace, 'utf-8');
content = replaceAngular(content);
content = replaceNpm(content);
fs.writeFileSync(workspace, content);
}

main(process.argv)
18 changes: 12 additions & 6 deletions integration/bazel-schematics/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@
rxjs "6.3.3"

"@angular/bazel@file:../../dist/packages-dist/bazel":
version "8.0.0-beta.1"
version "8.0.0-beta.2"
dependencies:
"@angular-devkit/architect" "^0.10.6"
"@angular-devkit/core" "^7.0.4"
"@angular-devkit/schematics" "^7.3.0-rc.0"
"@bazel/typescript" "^0.22.1"
"@bazel/typescript" "^0.23.2"
"@schematics/angular" "^7.0.4"
"@types/node" "6.0.84"
semver "^5.6.0"
Expand Down Expand Up @@ -119,11 +119,12 @@
"@bazel/bazel-linux_x64" "0.22.0"
"@bazel/bazel-win32_x64" "0.22.0"

"@bazel/typescript@^0.22.1":
version "0.22.1"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.22.1.tgz#b52c00e8560019e2f9d273d45c04785e0ec9d9bd"
integrity sha512-88DaCCnNg8rPlKP0eAQEZuoiJkEPeiItpUS3oBR1sFQNBRJb56D25ahK8+N6LJk4qaH+ZQ1/AHOPDhfEEWvDzA==
"@bazel/typescript@^0.23.2":
version "0.23.2"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.23.2.tgz#a3ff199880855259d84216cb41644c1d9a0fad14"
integrity sha512-GrTyDW6Fvp/rgnxZGYampB5/QmDWvxtLEtUyMCPa/QXFR1OVxaMWeHxxuFEcES2UKJegqBDKAA8IzX21x4UbEw==
dependencies:
jasmine-core "2.8.0"
protobufjs "5.0.3"
semver "5.6.0"
source-map-support "0.5.9"
Expand Down Expand Up @@ -1215,6 +1216,11 @@ isobject@^3.0.0, isobject@^3.0.1:
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=

jasmine-core@2.8.0:
version "2.8.0"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.8.0.tgz#bcc979ae1f9fd05701e45e52e65d3a5d63f1a24e"
integrity sha1-vMl5rh+f0FcB5F5S5l06XWPxok4=

json-parse-better-errors@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"
Expand Down
75 changes: 45 additions & 30 deletions integration/bazel/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,78 @@ workspace(name = "bazel_integration_test")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

#
# Download Bazel toolchain dependencies as needed by build actions
#
# Fetch rules_nodejs so we can install our npm 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"],
)

# Fetch sass rules for compiling sass files
http_archive(
name = "io_bazel_rules_sass",
sha256 = "dbe9fb97d5a7833b2a733eebc78c9c1e3880f676ac8af16e58ccf2139cbcad03",
strip_prefix = "rules_sass-1.11.0",
url = "https://github.com/bazelbuild/rules_sass/archive/1.11.0.zip",
)

# Fetch the angular repository since we build angular from source
# 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",
)

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()

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

#
# Setup dependencies loaded above
#

# Check the bazel version and download npm dependencies
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_version = "10.9.0",
yarn_version = "1.12.1",
)

# Install our npm dependencies into @npm
yarn_install(
name = "npm",
# Need a reference to @angular here so that Bazel sets up the
# external repository before calling yarn_install
data = ["@angular//:LICENSE"],
package_json = "//src:package.json",
yarn_lock = "//src:yarn.lock",
)

load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
# Install all bazel dependencies of our npm packages
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")

install_bazel_dependencies()

go_rules_dependencies()
# Load karma dependencies
load("@build_bazel_rules_karma//:package.bzl", "rules_karma_dependencies")

go_register_toolchains()
rules_karma_dependencies()

# Setup the rules_webtesting toolchain
load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", "web_test_repositories")

web_test_repositories()
Expand All @@ -71,14 +83,17 @@ browser_repositories(
firefox = True,
)

# Setup the rules_typescript tooolchain
load("@build_bazel_rules_typescript//:defs.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
load("@angular//:index.bzl", "ng_setup_workspace")

ng_setup_workspace()
3 changes: 2 additions & 1 deletion integration/bazel/src/hello-world/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package(default_visibility = ["//visibility:public"])

load("@angular//:index.bzl", "ng_module", "ng_package")
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(
name = "hello-world-styles",
Expand Down