Skip to content

Commit

Permalink
build(bazel): update to nodejs rules 0.31.1
Browse files Browse the repository at this point in the history
* entry_point attribute of nodejs_binary & rollup_bundle is now a label
* symlinking of node_modules for yarn_install temporarily disabled (except for integration/bazel) until the fix for bazelbuild/bazel#8487 makes it into a future bazel release
  • Loading branch information
gregmagolan committed Jun 10, 2019
1 parent 1ee920f commit 5b07d17
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,4 @@ try-import .bazelrc.user

# Turn on managed directories feature in Bazel
# This allows us to avoid installing a second copy of node_modules
build --experimental_allow_incremental_repository_updates
query --experimental_allow_incremental_repository_updates
common --experimental_allow_incremental_repository_updates
19 changes: 16 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,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 = "abcf497e89cfc1d09132adfcd8c07526d026e162ae2cb681dcb896046417ce91",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.30.1/rules_nodejs-0.30.1.tar.gz"],
sha256 = "e04a82a72146bfbca2d0575947daa60fda1878c8d3a3afe868a8ec39a6b968bb",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.31.1/rules_nodejs-0.31.1.tar.gz"],
)

# Check the bazel version and download npm dependencies
Expand All @@ -45,7 +45,8 @@ Try running `yarn bazel` instead.
# - 0.26.0 Fix for data files in yarn_install and npm_install
# - 0.27.12 Adds NodeModuleSources provider for transtive npm deps support
# - 0.30.0 yarn_install now uses symlinked node_modules with new managed directories Bazel 0.26.0 feature
check_rules_nodejs_version("0.30.0")
# - 0.31.1 entry_point attribute of nodejs_binary & rollup_bundle is now a label
check_rules_nodejs_version("0.31.1")

# Setup the Node.js toolchain
node_repositories(
Expand All @@ -64,8 +65,20 @@ node_repositories(

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",
yarn_lock = "//:yarn.lock",
# Temporarily disable node_modules symlinking until the fix for
# https://github.com/bazelbuild/bazel/issues/8487 makes it into a
# future Bazel release
symlink_node_modules = False,
# Don't install devDependencies, they are large and not used under Bazel
prod_only = True,
)

# Install all bazel dependencies of the @npm npm packages
Expand Down
3 changes: 1 addition & 2 deletions integration/bazel/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ build --symlink_prefix=/

# Turn on managed directories feature in Bazel
# This allows us to avoid installing a second copy of node_modules
build --experimental_allow_incremental_repository_updates
query --experimental_allow_incremental_repository_updates
common --experimental_allow_incremental_repository_updates
4 changes: 2 additions & 2 deletions integration/bazel/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,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 = "abcf497e89cfc1d09132adfcd8c07526d026e162ae2cb681dcb896046417ce91",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.30.1/rules_nodejs-0.30.1.tar.gz"],
sha256 = "e04a82a72146bfbca2d0575947daa60fda1878c8d3a3afe868a8ec39a6b968bb",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.31.1/rules_nodejs-0.31.1.tar.gz"],
)

# Fetch sass rules for compiling sass files
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"@angular-devkit/core": "^8.0.0-beta.15",
"@angular-devkit/schematics": "^8.0.0-beta.15",
"@angular/bazel": "file:./tools/npm/@angular_bazel",
"@bazel/jasmine": "0.30.1",
"@bazel/karma": "0.30.1",
"@bazel/typescript": "0.30.1",
"@bazel/jasmine": "0.31.1",
"@bazel/karma": "0.31.1",
"@bazel/typescript": "0.31.1",
"@microsoft/api-extractor": "^7.0.21",
"@schematics/angular": "^8.0.0-beta.15",
"@types/angular": "^1.6.47",
Expand Down
7 changes: 4 additions & 3 deletions packages/bazel/package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ def rules_angular_dev_dependencies():
#############################################
# Dependencies for generating documentation #
#############################################
# TODO(gregmagolan): update to upstream commit once https://github.com/bazelbuild/rules_sass/pull/87 lands
http_archive(
name = "io_bazel_rules_sass",
sha256 = "4c87befcb17282b039ba8341df9a6cc45f461bf05776dcf35c7e40c7e79ce374",
strip_prefix = "rules_sass-3a4f31c74513ccfacce3f955b5c006352f7e9587",
url = "https://github.com/bazelbuild/rules_sass/archive/3a4f31c74513ccfacce3f955b5c006352f7e9587.zip",
sha256 = "1c20d2ddc3d42712543e3b77bceac1bfea072849602569a6fc8b107e6d520ac6",
strip_prefix = "rules_sass-d033c0f9f7a2c75b73068f6647a5b0cc5070fd90",
url = "https://github.com/gregmagolan/rules_sass/archive/d033c0f9f7a2c75b73068f6647a5b0cc5070fd90.zip",
)

http_archive(
Expand Down
9 changes: 7 additions & 2 deletions packages/bazel/src/builders/files/WORKSPACE.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ workspace(

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

RULES_NODEJS_VERSION = "0.30.1"
RULES_NODEJS_SHA256 = "abcf497e89cfc1d09132adfcd8c07526d026e162ae2cb681dcb896046417ce91"
RULES_NODEJS_VERSION = "0.31.1"
RULES_NODEJS_SHA256 = "e04a82a72146bfbca2d0575947daa60fda1878c8d3a3afe868a8ec39a6b968bb"
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = RULES_NODEJS_SHA256,
Expand Down Expand Up @@ -49,8 +49,13 @@ Try running `yarn bazel` instead.
)
yarn_install(
name = "npm",
data = ["//:angular-metadata.tsconfig.json"],
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
# Temporarily disable node_modules symlinking until the fix for
# https://github.com/bazelbuild/bazel/issues/8487 makes it into a
# future Bazel release
symlink_node_modules = False,
)

load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
Expand Down
3 changes: 1 addition & 2 deletions packages/bazel/src/builders/files/__dot__bazelrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ build --define=compile=legacy

# Turn on managed directories feature in Bazel
# This allows us to avoid installing a second copy of node_modules
build --experimental_allow_incremental_repository_updates
query --experimental_allow_incremental_repository_updates
common --experimental_allow_incremental_repository_updates
12 changes: 10 additions & 2 deletions packages/bazel/src/protractor/protractor_web_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def protractor_web_test(
data = [],
server = None,
tags = [],
protractor = "@npm//node_modules/protractor:bin/protractor",
**kwargs):
"""Runs a protractor test in a browser.
Expand All @@ -187,14 +188,17 @@ def protractor_web_test(
data: Runtime dependencies
server: Optional server executable target
tags: Standard Bazel tags, this macro adds one for ibazel
protractor: Protractor entry_point. Defaults to @npm//node_modules/protractor:bin/protractor
but should be changed to @your_npm_workspace//node_modules/protractor:bin/protractor if
you are not using @npm for your npm dependencies.
**kwargs: passed through to `_protractor_web_test`
"""

protractor_bin_name = name + "_protractor_bin"

nodejs_binary(
name = protractor_bin_name,
entry_point = "protractor/bin/protractor",
entry_point = protractor,
data = srcs + deps + data,
testonly = 1,
visibility = ["//visibility:private"],
Expand Down Expand Up @@ -244,6 +248,7 @@ def protractor_web_test_suite(
visibility = None,
web_test_data = [],
wrapped_test_tags = None,
protractor = "@npm//node_modules/protractor:bin/protractor",
**remaining_keyword_args):
"""Defines a test_suite of web_test targets that wrap a protractor_web_test target.
Expand Down Expand Up @@ -277,6 +282,9 @@ def protractor_web_test_suite(
visibility: List of labels; optional.
web_test_data: Data dependencies for the web_test.
wrapped_test_tags: A list of test tag strings to use for the wrapped test
protractor: Protractor entry_point. Defaults to @npm//node_modules/protractor:bin/protractor
but should be changed to @your_npm_workspace//node_modules/protractor:bin/protractor if
you are not using @npm for your npm dependencies.
**remaining_keyword_args: Arguments for the wrapped test target.
"""

Expand All @@ -294,7 +302,7 @@ def protractor_web_test_suite(

nodejs_binary(
name = protractor_bin_name,
entry_point = "protractor/bin/protractor",
entry_point = protractor,
data = srcs + deps + data,
testonly = 1,
visibility = ["//visibility:private"],
Expand Down
4 changes: 2 additions & 2 deletions packages/bazel/src/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ function addDevDependenciesToPackageJson(options: Schema) {
'@angular/bazel': angularCoreVersion,
'@bazel/bazel': '^0.26.0',
'@bazel/ibazel': '^0.10.2',
'@bazel/karma': '0.30.0',
'@bazel/typescript': '0.30.0',
'@bazel/karma': '0.31.1',
'@bazel/typescript': '0.31.1',
};

const recorder = host.beginUpdate(packageJson);
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,19 @@
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.9.0.tgz#fd60023acd36313d304cc2f8c2e181b88b5445cd"
integrity sha512-E31cefDcdJsx/oii6p/gqKZXSVw0kEg1O73DD2McFcSvnf/p1GYWcQtVgdRQmlviBEytJkJgdX8rtThitRvcow==

"@bazel/jasmine@0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-0.30.1.tgz#66835814dced5fe77db136c99befff34a6584fc5"
integrity sha512-D7nahHJI15ybm3IlPEXMuZ3BOECfC71SYXjL9b+paKp3DKqj0SN4ILfvREt+s65wx6RCmBSM4SLBYz2rjfE+eQ==
"@bazel/jasmine@0.31.1":
version "0.31.1"
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-0.31.1.tgz#da3de10760fe1e29e9fc748fabc4fcf604f4356a"
integrity sha512-heKo8qzm6DTm8eOlfL69RJJi1GLI9vJDSmBGYgol18K7oXz6JrspGWUL9/TlCYbRUUCt22kqX7f3R+QlD0KrCg==
dependencies:
jasmine "~3.3.1"
jasmine-core "~3.3.0"
v8-coverage "1.0.9"

"@bazel/karma@0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.30.1.tgz#5ef08da0abfa5b7e8536a7242a3fc60bf60ed143"
integrity sha512-nDy/Hct/XO1XY8zQeNBVBbff3F5XwRf/TTIM21VksqN0bwn6eVkAm6Pwc96eB/FQ75Xq60vib7v/K5MYjs3EGg==
"@bazel/karma@0.31.1":
version "0.31.1"
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.31.1.tgz#fecbb269c7693baa29ad78179cca752fe7c09068"
integrity sha512-PUOTQOD57IjM18iM+MOe9fRUFNJ8RQMq1i1qDaPLStMS/LtJAvDcvWhypK/2wNDdmAGz7U5uLlvl827XbwIuuA==
dependencies:
jasmine-core "2.8.0"
karma "^4.0.0"
Expand All @@ -163,10 +163,10 @@
semver "5.6.0"
tmp "0.0.33"

"@bazel/typescript@0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.30.1.tgz#58cf290a366418d713b29123d9c337da6500d764"
integrity sha512-tljA8Nv0of08L+I3cipJ096ni3548Qb4ZJS3bAV/pxPsEub4MB48TlASkWjQRp46oPUS3TrAes2kRQCF+kCxFg==
"@bazel/typescript@0.31.1":
version "0.31.1"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.31.1.tgz#2ccf9997d97903c51e73f82e29433fe444b8d672"
integrity sha512-jUTJjwdc4JSDMt4kIj74gGtctu8xe0YZPJuPxOIS4TdrWcn+dG9Fy7Z8bJLXhePheig1JLY7NBP6BGwrtggzPQ==
dependencies:
protobufjs "6.8.8"
semver "5.6.0"
Expand Down

0 comments on commit 5b07d17

Please sign in to comment.