build(bazel): update to nodejs rules 0.31.1 (#30627)

* 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 https://github.com/bazelbuild/bazel/issues/8487 makes it into a future bazel release

PR Close #30627
This commit is contained in:
Greg Magolan 2019-06-07 09:28:41 -07:00 committed by Igor Minar
parent ba83d33dd0
commit a794143820
11 changed files with 59 additions and 35 deletions

View File

@ -153,5 +153,4 @@ try-import .bazelrc.user
# Turn on managed directories feature in Bazel # Turn on managed directories feature in Bazel
# This allows us to avoid installing a second copy of node_modules # This allows us to avoid installing a second copy of node_modules
build --experimental_allow_incremental_repository_updates common --experimental_allow_incremental_repository_updates
query --experimental_allow_incremental_repository_updates

View File

@ -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 # Fetch rules_nodejs so we can install our npm dependencies
http_archive( http_archive(
name = "build_bazel_rules_nodejs", name = "build_bazel_rules_nodejs",
sha256 = "abcf497e89cfc1d09132adfcd8c07526d026e162ae2cb681dcb896046417ce91", sha256 = "e04a82a72146bfbca2d0575947daa60fda1878c8d3a3afe868a8ec39a6b968bb",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.30.1/rules_nodejs-0.30.1.tar.gz"], 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 # Check the bazel version and download npm dependencies
@ -45,7 +45,8 @@ Try running `yarn bazel` instead.
# - 0.26.0 Fix for data files in yarn_install and npm_install # - 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.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 # - 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 # Setup the Node.js toolchain
node_repositories( node_repositories(
@ -64,8 +65,20 @@ node_repositories(
yarn_install( yarn_install(
name = "npm", 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", package_json = "//:package.json",
yarn_lock = "//:yarn.lock", 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 # Install all bazel dependencies of the @npm npm packages

View File

@ -19,5 +19,4 @@ build --symlink_prefix=/
# Turn on managed directories feature in Bazel # Turn on managed directories feature in Bazel
# This allows us to avoid installing a second copy of node_modules # This allows us to avoid installing a second copy of node_modules
build --experimental_allow_incremental_repository_updates common --experimental_allow_incremental_repository_updates
query --experimental_allow_incremental_repository_updates

View File

@ -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 # Fetch rules_nodejs so we can install our npm dependencies
http_archive( http_archive(
name = "build_bazel_rules_nodejs", name = "build_bazel_rules_nodejs",
sha256 = "abcf497e89cfc1d09132adfcd8c07526d026e162ae2cb681dcb896046417ce91", sha256 = "e04a82a72146bfbca2d0575947daa60fda1878c8d3a3afe868a8ec39a6b968bb",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.30.1/rules_nodejs-0.30.1.tar.gz"], 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 # Fetch sass rules for compiling sass files

View File

@ -35,9 +35,9 @@
"@angular-devkit/core": "^8.0.0-beta.15", "@angular-devkit/core": "^8.0.0-beta.15",
"@angular-devkit/schematics": "^8.0.0-beta.15", "@angular-devkit/schematics": "^8.0.0-beta.15",
"@angular/bazel": "file:./tools/npm/@angular_bazel", "@angular/bazel": "file:./tools/npm/@angular_bazel",
"@bazel/jasmine": "0.30.1", "@bazel/jasmine": "0.31.1",
"@bazel/karma": "0.30.1", "@bazel/karma": "0.31.1",
"@bazel/typescript": "0.30.1", "@bazel/typescript": "0.31.1",
"@microsoft/api-extractor": "^7.0.21", "@microsoft/api-extractor": "^7.0.21",
"@schematics/angular": "^8.0.0-beta.15", "@schematics/angular": "^8.0.0-beta.15",
"@types/angular": "^1.6.47", "@types/angular": "^1.6.47",

View File

@ -38,11 +38,12 @@ def rules_angular_dev_dependencies():
############################################# #############################################
# Dependencies for generating documentation # # Dependencies for generating documentation #
############################################# #############################################
# TODO(gregmagolan): update to upstream commit once https://github.com/bazelbuild/rules_sass/pull/87 lands
http_archive( http_archive(
name = "io_bazel_rules_sass", name = "io_bazel_rules_sass",
sha256 = "4c87befcb17282b039ba8341df9a6cc45f461bf05776dcf35c7e40c7e79ce374", sha256 = "1c20d2ddc3d42712543e3b77bceac1bfea072849602569a6fc8b107e6d520ac6",
strip_prefix = "rules_sass-3a4f31c74513ccfacce3f955b5c006352f7e9587", strip_prefix = "rules_sass-d033c0f9f7a2c75b73068f6647a5b0cc5070fd90",
url = "https://github.com/bazelbuild/rules_sass/archive/3a4f31c74513ccfacce3f955b5c006352f7e9587.zip", url = "https://github.com/gregmagolan/rules_sass/archive/d033c0f9f7a2c75b73068f6647a5b0cc5070fd90.zip",
) )
http_archive( http_archive(

View File

@ -15,8 +15,8 @@ workspace(
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_NODEJS_VERSION = "0.30.1" RULES_NODEJS_VERSION = "0.31.1"
RULES_NODEJS_SHA256 = "abcf497e89cfc1d09132adfcd8c07526d026e162ae2cb681dcb896046417ce91" RULES_NODEJS_SHA256 = "e04a82a72146bfbca2d0575947daa60fda1878c8d3a3afe868a8ec39a6b968bb"
http_archive( http_archive(
name = "build_bazel_rules_nodejs", name = "build_bazel_rules_nodejs",
sha256 = RULES_NODEJS_SHA256, sha256 = RULES_NODEJS_SHA256,
@ -49,8 +49,13 @@ Try running `yarn bazel` instead.
) )
yarn_install( yarn_install(
name = "npm", name = "npm",
data = ["//:angular-metadata.tsconfig.json"],
package_json = "//:package.json", package_json = "//:package.json",
yarn_lock = "//:yarn.lock", 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") load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")

View File

@ -32,5 +32,4 @@ build --define=compile=legacy
# Turn on managed directories feature in Bazel # Turn on managed directories feature in Bazel
# This allows us to avoid installing a second copy of node_modules # This allows us to avoid installing a second copy of node_modules
build --experimental_allow_incremental_repository_updates common --experimental_allow_incremental_repository_updates
query --experimental_allow_incremental_repository_updates

View File

@ -173,6 +173,7 @@ def protractor_web_test(
data = [], data = [],
server = None, server = None,
tags = [], tags = [],
protractor = "@npm//node_modules/protractor:bin/protractor",
**kwargs): **kwargs):
"""Runs a protractor test in a browser. """Runs a protractor test in a browser.
@ -187,6 +188,9 @@ def protractor_web_test(
data: Runtime dependencies data: Runtime dependencies
server: Optional server executable target server: Optional server executable target
tags: Standard Bazel tags, this macro adds one for ibazel 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` **kwargs: passed through to `_protractor_web_test`
""" """
@ -194,7 +198,7 @@ def protractor_web_test(
nodejs_binary( nodejs_binary(
name = protractor_bin_name, name = protractor_bin_name,
entry_point = "protractor/bin/protractor", entry_point = protractor,
data = srcs + deps + data, data = srcs + deps + data,
testonly = 1, testonly = 1,
visibility = ["//visibility:private"], visibility = ["//visibility:private"],
@ -244,6 +248,7 @@ def protractor_web_test_suite(
visibility = None, visibility = None,
web_test_data = [], web_test_data = [],
wrapped_test_tags = None, wrapped_test_tags = None,
protractor = "@npm//node_modules/protractor:bin/protractor",
**remaining_keyword_args): **remaining_keyword_args):
"""Defines a test_suite of web_test targets that wrap a protractor_web_test target. """Defines a test_suite of web_test targets that wrap a protractor_web_test target.
@ -277,6 +282,9 @@ def protractor_web_test_suite(
visibility: List of labels; optional. visibility: List of labels; optional.
web_test_data: Data dependencies for the web_test. web_test_data: Data dependencies for the web_test.
wrapped_test_tags: A list of test tag strings to use for the wrapped 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. **remaining_keyword_args: Arguments for the wrapped test target.
""" """
@ -294,7 +302,7 @@ def protractor_web_test_suite(
nodejs_binary( nodejs_binary(
name = protractor_bin_name, name = protractor_bin_name,
entry_point = "protractor/bin/protractor", entry_point = protractor,
data = srcs + deps + data, data = srcs + deps + data,
testonly = 1, testonly = 1,
visibility = ["//visibility:private"], visibility = ["//visibility:private"],

View File

@ -50,8 +50,8 @@ function addDevDependenciesToPackageJson(options: Schema) {
'@angular/bazel': angularCoreVersion, '@angular/bazel': angularCoreVersion,
'@bazel/bazel': '^0.26.0', '@bazel/bazel': '^0.26.0',
'@bazel/ibazel': '^0.10.2', '@bazel/ibazel': '^0.10.2',
'@bazel/karma': '0.30.0', '@bazel/karma': '0.31.1',
'@bazel/typescript': '0.30.0', '@bazel/typescript': '0.31.1',
}; };
const recorder = host.beginUpdate(packageJson); const recorder = host.beginUpdate(packageJson);

View File

@ -137,19 +137,19 @@
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.9.0.tgz#fd60023acd36313d304cc2f8c2e181b88b5445cd" resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.9.0.tgz#fd60023acd36313d304cc2f8c2e181b88b5445cd"
integrity sha512-E31cefDcdJsx/oii6p/gqKZXSVw0kEg1O73DD2McFcSvnf/p1GYWcQtVgdRQmlviBEytJkJgdX8rtThitRvcow== integrity sha512-E31cefDcdJsx/oii6p/gqKZXSVw0kEg1O73DD2McFcSvnf/p1GYWcQtVgdRQmlviBEytJkJgdX8rtThitRvcow==
"@bazel/jasmine@0.30.1": "@bazel/jasmine@0.31.1":
version "0.30.1" version "0.31.1"
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-0.30.1.tgz#66835814dced5fe77db136c99befff34a6584fc5" resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-0.31.1.tgz#da3de10760fe1e29e9fc748fabc4fcf604f4356a"
integrity sha512-D7nahHJI15ybm3IlPEXMuZ3BOECfC71SYXjL9b+paKp3DKqj0SN4ILfvREt+s65wx6RCmBSM4SLBYz2rjfE+eQ== integrity sha512-heKo8qzm6DTm8eOlfL69RJJi1GLI9vJDSmBGYgol18K7oXz6JrspGWUL9/TlCYbRUUCt22kqX7f3R+QlD0KrCg==
dependencies: dependencies:
jasmine "~3.3.1" jasmine "~3.3.1"
jasmine-core "~3.3.0" jasmine-core "~3.3.0"
v8-coverage "1.0.9" v8-coverage "1.0.9"
"@bazel/karma@0.30.1": "@bazel/karma@0.31.1":
version "0.30.1" version "0.31.1"
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.30.1.tgz#5ef08da0abfa5b7e8536a7242a3fc60bf60ed143" resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.31.1.tgz#fecbb269c7693baa29ad78179cca752fe7c09068"
integrity sha512-nDy/Hct/XO1XY8zQeNBVBbff3F5XwRf/TTIM21VksqN0bwn6eVkAm6Pwc96eB/FQ75Xq60vib7v/K5MYjs3EGg== integrity sha512-PUOTQOD57IjM18iM+MOe9fRUFNJ8RQMq1i1qDaPLStMS/LtJAvDcvWhypK/2wNDdmAGz7U5uLlvl827XbwIuuA==
dependencies: dependencies:
jasmine-core "2.8.0" jasmine-core "2.8.0"
karma "^4.0.0" karma "^4.0.0"
@ -163,10 +163,10 @@
semver "5.6.0" semver "5.6.0"
tmp "0.0.33" tmp "0.0.33"
"@bazel/typescript@0.30.1": "@bazel/typescript@0.31.1":
version "0.30.1" version "0.31.1"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.30.1.tgz#58cf290a366418d713b29123d9c337da6500d764" resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.31.1.tgz#2ccf9997d97903c51e73f82e29433fe444b8d672"
integrity sha512-tljA8Nv0of08L+I3cipJ096ni3548Qb4ZJS3bAV/pxPsEub4MB48TlASkWjQRp46oPUS3TrAes2kRQCF+kCxFg== integrity sha512-jUTJjwdc4JSDMt4kIj74gGtctu8xe0YZPJuPxOIS4TdrWcn+dG9Fy7Z8bJLXhePheig1JLY7NBP6BGwrtggzPQ==
dependencies: dependencies:
protobufjs "6.8.8" protobufjs "6.8.8"
semver "5.6.0" semver "5.6.0"