build: upgrade to rules_nodejs 1.0.0 (first stable release) (#34736)

Brings in the fix for stamping which was preventing many targets from getting cached.

PR Close #34736
This commit is contained in:
Greg Magolan 2019-12-28 16:37:59 -08:00 committed by Matias Niemelä
parent 3d5bcd5883
commit 93c2df23bf
21 changed files with 78 additions and 79 deletions

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
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "16fc00ab0d1e538e88f084272316c0693a2e9007d64f45529b82f6230aedb073",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.42.2/rules_nodejs-0.42.2.tar.gz"],
sha256 = "3887b948779431ac443e6a64f31b9e1e17b8d386a31eebc50ec1d9b0a6cabd2b",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.0.0/rules_nodejs-1.0.0.tar.gz"],
)
# Check the bazel version and download npm dependencies
@ -29,7 +29,7 @@ Try running `yarn bazel` instead.
minimum_bazel_version = "1.1.0",
)
check_rules_nodejs_version(minimum_version_string = "0.42.1")
check_rules_nodejs_version(minimum_version_string = "1.0.0")
# Setup the Node.js toolchain
node_repositories(

View File

@ -41,12 +41,12 @@
"@angular-devkit/schematics": "^9.0.0-rc.3",
"@angular/bazel": "file:./tools/npm/@angular_bazel",
"@babel/core": "^7.6.4",
"@bazel/jasmine": "0.42.2",
"@bazel/karma": "0.42.2",
"@bazel/protractor": "0.42.2",
"@bazel/rollup": "0.42.2",
"@bazel/terser": "0.42.2",
"@bazel/typescript": "0.42.2",
"@bazel/jasmine": "1.0.0",
"@bazel/karma": "1.0.0",
"@bazel/protractor": "1.0.0",
"@bazel/rollup": "1.0.0",
"@bazel/terser": "1.0.0",
"@bazel/typescript": "1.0.0",
"@microsoft/api-extractor": "^7.3.9",
"@schematics/angular": "^9.0.0-rc.3",
"@types/angular": "^1.6.47",

View File

@ -1,6 +1,6 @@
load("//tools:defaults.bzl", "npm_package")
load("//tools:defaults.bzl", "pkg_npm")
npm_package(
pkg_npm(
name = "npm_package",
srcs = glob(
["*"],
@ -14,10 +14,10 @@ npm_package(
"//packages/bazel/src/schematics:package_assets",
"//packages/bazel/third_party/github.com/bazelbuild/bazel/src/main/protobuf:package_assets",
],
packages = [
nested_packages = [
"//packages/bazel/docs",
],
replacements = {
substitutions = {
"(#|\/\/)\\s+BEGIN-DEV-ONLY[\\w\W]+?(#|\/\/)\\s+END-DEV-ONLY": "",
"//packages/bazel/": "//",
"angular/packages/bazel/": "npm_angular_bazel/",

View File

@ -15,9 +15,9 @@ specification of this format at https://goo.gl/jB3GVv
load("@build_bazel_rules_nodejs//:providers.bzl", "JSEcmaScriptModuleInfo", "JSNamedModuleInfo", "NpmPackageInfo", "node_modules_aspect")
load(
"@build_bazel_rules_nodejs//internal/npm_package:npm_package.bzl",
"NPM_PACKAGE_ATTRS",
"NPM_PACKAGE_OUTPUTS",
"@build_bazel_rules_nodejs//internal/pkg_npm:pkg_npm.bzl",
"PKG_NPM_ATTRS",
"PKG_NPM_OUTPUTS",
"create_package",
)
load("//packages/bazel/src:external.bzl", "FLAT_DTS_FILE_SUFFIX")
@ -623,7 +623,7 @@ def _ng_package_impl(ctx):
package_dir = create_package(
ctx,
devfiles.to_list(),
[npm_package_directory] + ctx.files.packages,
[npm_package_directory] + ctx.files.nested_packages,
)
return [DefaultInfo(
files = depset([package_dir]),
@ -631,7 +631,7 @@ def _ng_package_impl(ctx):
_NG_PACKAGE_DEPS_ASPECTS = [esm5_outputs_aspect, ng_package_module_mappings_aspect, node_modules_aspect]
_NG_PACKAGE_ATTRS = dict(NPM_PACKAGE_ATTRS, **{
_NG_PACKAGE_ATTRS = dict(PKG_NPM_ATTRS, **{
"srcs": attr.label_list(
doc = """JavaScript source files from the workspace.
These can use ES2015 syntax and ES Modules (import/export)""",
@ -807,12 +807,12 @@ def _ng_package_outputs(name, entry_point, entry_point_name):
"umd": "%s.umd.js" % basename,
"umd_min": "%s.umd.min.js" % basename,
}
for key in NPM_PACKAGE_OUTPUTS:
# NPM_PACKAGE_OUTPUTS is a "normal" dict-valued outputs so it looks like
for key in PKG_NPM_OUTPUTS:
# PKG_NPM_OUTPUTS is a "normal" dict-valued outputs so it looks like
# "pack": "%{name}.pack",
# But this is a function-valued outputs.
# Bazel won't replace the %{name} token so we have to do it.
outputs[key] = NPM_PACKAGE_OUTPUTS[key].replace("%{name}", name)
outputs[key] = PKG_NPM_OUTPUTS[key].replace("%{name}", name)
return outputs
ng_package = rule(

View File

@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "ng_module", "ng_package", "npm_package")
load("//tools:defaults.bzl", "ng_module", "ng_package", "pkg_npm")
package(default_visibility = ["//packages/bazel/test:__subpackages__"])
@ -26,7 +26,7 @@ ng_package(
],
entry_point = ":index.ts",
entry_point_name = "waffels",
packages = [
nested_packages = [
":arbitrary_npm_package",
],
deps = [
@ -52,7 +52,7 @@ genrule(
output_to_bindir = True,
)
npm_package(
pkg_npm(
name = "arbitrary_npm_package",
srcs = [":arbitrary-npm-package-main.js"],
)

View File

@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "npm_package", "ts_library")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
package(default_visibility = ["//visibility:public"])
@ -18,7 +18,7 @@ ts_library(
],
)
npm_package(
pkg_npm(
name = "npm_package",
srcs = [
"README.md",

View File

@ -26,7 +26,7 @@ ng_package(
"//packages/common/upgrade:package.json",
],
entry_point = ":index.ts",
packages = ["//packages/common/locales:package"],
nested_packages = ["//packages/common/locales:package"],
tags = [
"release-with-framework",
],

View File

@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "npm_package", "ts_library")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
package(default_visibility = ["//visibility:public"])
@ -10,11 +10,10 @@ ts_library(
),
)
npm_package(
pkg_npm(
name = "package",
srcs = glob(["global/*.js"]) + ["package.json"],
replacements = {
substitutions = {
# Workaround for `.d.ts`` containing `/// <amd-module .../>`
# which are generated in TypeScript v2.9, but not before.
"/// <amd-module name=.*/>": "",

View File

@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "npm_package", "ts_library")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("@npm_bazel_typescript//:index.bzl", "ts_config")
ts_config(
@ -53,7 +53,7 @@ ts_library(
],
)
npm_package(
pkg_npm(
name = "npm_package",
srcs = [
"package.json",

View File

@ -30,7 +30,7 @@ ng_package(
"//packages/core/testing:package.json",
],
entry_point = ":index.ts",
packages = [
nested_packages = [
"//packages/core/schematics:npm_package",
],
tags = [

View File

@ -1,11 +1,11 @@
load("//tools:defaults.bzl", "npm_package")
load("//tools:defaults.bzl", "pkg_npm")
exports_files([
"tsconfig.json",
"migrations.json",
])
npm_package(
pkg_npm(
name = "npm_package",
srcs = ["migrations.json"],
visibility = ["//packages/core:__pkg__"],

View File

@ -24,7 +24,7 @@ ng_package(
"**/package.json",
]),
entry_point = ":index.ts",
packages = [
nested_packages = [
"//packages/elements/schematics:npm_package",
],
tags = [

View File

@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "npm_package")
load("//tools:defaults.bzl", "pkg_npm")
package(default_visibility = ["//visibility:public"])
@ -15,7 +15,7 @@ genrule(
output_to_bindir = 1,
)
npm_package(
pkg_npm(
name = "npm_package",
srcs = [
"collection.json",

View File

@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "npm_package", "ts_library")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
package(default_visibility = ["//visibility:public"])
@ -20,7 +20,7 @@ ts_library(
],
)
npm_package(
pkg_npm(
name = "npm_package",
srcs = ["package.json"],
tags = [

View File

@ -24,7 +24,7 @@ ng_package(
"//packages/localize/init:package.json",
],
entry_point = ":index.ts",
packages = [
nested_packages = [
"//packages/localize/schematics:npm_package",
"//packages/localize/src/tools:npm_package",
],

View File

@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "npm_package")
load("//tools:defaults.bzl", "pkg_npm")
package(default_visibility = ["//visibility:public"])
@ -10,7 +10,7 @@ filegroup(
visibility = ["//packages/localize:__subpackages__"],
)
npm_package(
pkg_npm(
name = "npm_package",
srcs = [
"collection.json",

View File

@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "npm_package", "ts_library")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("@npm_bazel_typescript//:index.bzl", "ts_config")
ts_config(
@ -30,7 +30,7 @@ ts_library(
],
)
npm_package(
pkg_npm(
name = "npm_package",
srcs = [
],

View File

@ -1,4 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "npm_package")
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
load("//packages/zone.js:bundles.bzl", "ES2015_BUNDLES", "ES5_BUNDLES", "ES5_GLOBAL_BUNDLES")
exports_files([
@ -21,7 +21,7 @@ genrule(
cmd = "(echo '/**\n @license' && cat $< && echo '*/') > $@",
)
npm_package(
pkg_npm(
name = "npm_package",
srcs = [
"CHANGELOG.md",

View File

@ -160,7 +160,7 @@ def ng_package(name, readme_md = None, license_banner = None, deps = [], **kwarg
deps = deps,
readme_md = readme_md,
license_banner = license_banner,
replacements = PKG_GROUP_REPLACEMENTS,
substitutions = PKG_GROUP_REPLACEMENTS,
ng_packager = _INTERNAL_NG_PACKAGE_PACKAGER,
terser_config_file = _INTERNAL_NG_PACKAGE_DEFALUT_TERSER_CONFIG_FILE,
rollup_config_tmpl = _INTERNAL_NG_PACKAGE_DEFAULT_ROLLUP_CONFIG_TMPL,
@ -168,11 +168,11 @@ def ng_package(name, readme_md = None, license_banner = None, deps = [], **kwarg
**kwargs
)
def npm_package(name, replacements = {}, **kwargs):
def pkg_npm(name, substitutions = {}, **kwargs):
"""Default values for npm_package"""
_npm_package(
_pkg_npm(
name = name,
replacements = dict(replacements, **PKG_GROUP_REPLACEMENTS),
substitutions = dict(substitutions, **PKG_GROUP_REPLACEMENTS),
**kwargs
)

View File

@ -1,5 +1,5 @@
# BEGIN-INTERNAL
load("@build_bazel_rules_nodejs//:index.bzl", "npm_package")
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
@ -29,7 +29,7 @@ genrule(
cmd = "cp $< $@",
)
npm_package(
pkg_npm(
name = "ts-api-guardian",
srcs = [
"BUILD.bazel",
@ -38,7 +38,7 @@ npm_package(
"index.bzl",
"package.json",
],
replacements = {
substitutions = {
"@angular//tools/ts-api-guardian:bin": "@npm_ts_api_guardian//:bin",
"@angular//tools/ts-api-guardian:lib": "@npm//ts-api-guardian",
"angular/tools/ts-api-guardian/": "npm_ts_api_guardian/",

View File

@ -981,41 +981,41 @@
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.11.1.tgz#c07ceaded388f1e39d6aa732953e0dd04f3dbdf0"
integrity sha512-qAdEquFAudYyN+CYfLzvuRWNubdsh6C8+o5CiViUEfchq1HQM5Rs8xAOE3fzGsTZ1EUsvgca/PY0kn0VIxckBA==
"@bazel/jasmine@0.42.2":
version "0.42.2"
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-0.42.2.tgz#38e0d715e519e7ce4bce7d55b3e8accb2aad8217"
integrity sha512-OgxX84wPeWlHi4O2m0ezH9gTGx+wp3MR7QcC46PIIjWKL4W4L0Buss0R9AJeNTtxpjfv+8hfrDUI0bf2ZEIIjQ==
"@bazel/jasmine@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-1.0.0.tgz#12aa82c0e4b7b5658e9e496b73c0cf660df2b0ae"
integrity sha512-cheQWMYs0PaS4kYwJC9tmAiyd0tLbPNcgoM+S8plNUp5k0gUVosCvQ0TOrxvRlKEY0ni1hdn9owPx2rUO1J+Wg==
dependencies:
jasmine "~3.4.0"
jasmine-core "~3.4.0"
v8-coverage "1.0.9"
"@bazel/karma@0.42.2":
version "0.42.2"
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.42.2.tgz#24e2cf150a5da1fbdeb9382822b0ba7e662455a1"
integrity sha512-fNrZ8fIHTFwr7DGKtZLFLZxV/7+txZfiHH6bDN73qOId91RY7rr82BHgZx/iDQqnaKCW0+o9i2gPqu7lutVc8g==
"@bazel/karma@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-1.0.0.tgz#6f1e31bc2cb698e50d76f43ec9f1ee095d8e72b8"
integrity sha512-esfsHRVWVcp6OyTk/QI1sBV7bcygFiXY6LUMPLPYqVZkQvJ0x+/L1weiwuRrqFf+FCwCajhYjwiR6S9kX2Z9LA==
dependencies:
tmp "0.1.0"
"@bazel/protractor@0.42.2":
version "0.42.2"
resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-0.42.2.tgz#f20acd64e9456434cdc56903186fa31144a462a6"
integrity sha512-0LpRnaeL6/QHnNTK561aKFxAh4nECUNxrouC15XGWb57emj1q4a/IScAGwPrnb5dBQl1ZlgDXzyz/bqG928L1g==
"@bazel/protractor@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-1.0.0.tgz#b77fde3bb53a008c330c13a953a0bf93aa06b5f1"
integrity sha512-8kGuM3NkFfokjzKBlYxK9rUwJO/ICnYTHC567KJk6T4pjm4kfyh6iVI3Df3K+ONRCEYmiuZrQ37U06lzMMGN9g==
"@bazel/rollup@0.42.2":
version "0.42.2"
resolved "https://registry.yarnpkg.com/@bazel/rollup/-/rollup-0.42.2.tgz#b7a6495e1c506e3684448140395be80c45420271"
integrity sha512-SiXxuydxC3+jZIfS8oib3YyXBXeoA816bYdnIdVJX0WNgIMStdvGm7a/UU20KlbOWBx7qKB+mCSjSQa6C2FBnQ==
"@bazel/rollup@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@bazel/rollup/-/rollup-1.0.0.tgz#85f38cf07ba8ea192e54c42cb53a44d1fd1f56ac"
integrity sha512-pOWwyeM/H+LWRpKm3xuSAXoZ1gl6o8kFh5ltf0tM+ZfqGnSNbakME6ZswfmVj7FHUgF40BXzSoFTUdqgn1xy/w==
"@bazel/terser@0.42.2":
version "0.42.2"
resolved "https://registry.yarnpkg.com/@bazel/terser/-/terser-0.42.2.tgz#392e150af530d1eaf56ba388161e6f7f107e6be3"
integrity sha512-DlsmZyTWQFKiQbCKK/CDcRism1xrV1f7fLU166cXUIokXfkCaVCbN2ViaB5fDFcRpBQaNKowdM37Y5O7282Low==
"@bazel/terser@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@bazel/terser/-/terser-1.0.0.tgz#f9ef724cd4a81776dae71ae904934994d5006960"
integrity sha512-L+Q7YH+OA0W7Qp30DrnTKdNA6gasip9CdzI0zSvFOk18B7XBR+WswkIY2RkwwhH+y4SROqkHbX16z02jDHsnng==
"@bazel/typescript@0.42.2":
version "0.42.2"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.42.2.tgz#6c8e2187e9f7f937650c8b4e2350dc7d46284cb1"
integrity sha512-9HS8W6Wv74zhjvyP2rwym05TwzB8/c3Pxxi4gfjwjwxaDAIZCQfC8UGSRxeCm5t0JNz485W1/0WScoACjcASCQ==
"@bazel/typescript@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-1.0.0.tgz#2c7318b9a3aaa730f282b094ddf41dd16fda7b5a"
integrity sha512-caNOKz7EjVMgbedjVTreao9++9Sb9oYlU2nqDOMIK8MyoOUQvgGQWhFwF65XXGSb79Tzv8kaFQskoaH/iAs4ng==
dependencies:
protobufjs "6.8.8"
semver "5.6.0"