From de739706ab017138cc2ec3b6ff4728a7aebed08f Mon Sep 17 00:00:00 2001 From: Matthew Soulanille Date: Thu, 12 May 2022 14:04:16 -0700 Subject: [PATCH] Upgrade rules_nodejs to 5.4.2 (#6404) * Upgrade rules_nodejs to 5.4.2 * Lint and fix Bazel files --- WORKSPACE | 34 +++++++++--- package.json | 14 ++--- tfjs-converter/scripts/gen_op.bzl | 2 +- tfjs-converter/scripts/kernels_to_ops.bzl | 2 +- tools/defaults.bzl | 2 +- tools/enumerate_tests.bzl | 2 +- tools/make_version_test_file.bzl | 2 +- yarn.lock | 68 +++++++++++------------ 8 files changed, 71 insertions(+), 55 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index cc1be5458b7..80e83b00e86 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -37,26 +37,40 @@ bazel_skylib_workspace() http_archive( name = "build_bazel_rules_nodejs", - sha256 = "d63ecec7192394f5cc4ad95a115f8a6c9de55c60d56c1f08da79c306355e4654", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.6.1/rules_nodejs-4.6.1.tar.gz"], + sha256 = "e328cb2c9401be495fa7d79c306f5ee3040e8a03b2ebb79b022e15ca03770096", + urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.4.2/rules_nodejs-5.4.2.tar.gz"], ) -# Set up node version to use. Must come before rules_nodejs_dependencies() -load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install") +# Install rules_nodejs dependencies. +load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies") + +build_bazel_rules_nodejs_dependencies() + +load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") -node_repositories( +nodejs_register_toolchains( + name = "nodejs", node_version = "16.13.2", - package_json = ["//:package.json"], ) -# Install rules_nodejs dependencies. -load("@build_bazel_rules_nodejs//nodejs:repositories.bzl", "rules_nodejs_dependencies") +# Install the yarn tool +load("@rules_nodejs//nodejs:yarn_repositories.bzl", "yarn_repositories") + +yarn_repositories( + name = "yarn", + node_repository = "nodejs", +) -rules_nodejs_dependencies() +# Install yarn packages +load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install") yarn_install( name = "npm", + exports_directories_only = False, # Required for ts_library package_json = "//:package.json", + package_path = "/", + symlink_node_modules = True, + yarn = "@yarn//:bin/yarn", yarn_lock = "//:yarn.lock", ) @@ -86,6 +100,8 @@ esbuild_repositories(npm_repository = "npm") # Emscripten toolchain http_archive( name = "emsdk", + # TODO: Remove repo_mapping when emsdk updates to rules_nodejs 5 + repo_mapping = {"@nodejs": "@nodejs_host"}, sha256 = "7dc13d967705582e11ff62ae143425dbc63c38372f1a1b14f0cb681fda413714", strip_prefix = "emsdk-3.1.4/bazel", urls = ["https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.4.tar.gz"], diff --git a/package.json b/package.json index 3cfa1fb640f..354f6313b23 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "devDependencies": { "@bazel/bazelisk": "^1.11.0", - "@bazel/buildifier": "4.2.4", - "@bazel/concatjs": "4.6.1", - "@bazel/esbuild": "4.6.1", - "@bazel/jasmine": "4.6.1", - "@bazel/rollup": "4.6.1", - "@bazel/terser": "4.6.1", - "@bazel/typescript": "4.6.1", + "@bazel/buildifier": "5.1.0", + "@bazel/concatjs": "5.4.2", + "@bazel/esbuild": "5.4.2", + "@bazel/jasmine": "5.4.2", + "@bazel/rollup": "5.4.2", + "@bazel/terser": "5.4.2", + "@bazel/typescript": "5.4.2", "@octokit/rest": "15.17.0", "@rollup/plugin-commonjs": "^18.0.0", "@rollup/plugin-node-resolve": "^11.2.1", diff --git a/tfjs-converter/scripts/gen_op.bzl b/tfjs-converter/scripts/gen_op.bzl index 4d589d0cb84..7e337061167 100644 --- a/tfjs-converter/scripts/gen_op.bzl +++ b/tfjs-converter/scripts/gen_op.bzl @@ -47,7 +47,7 @@ gen_op = rule( ), "gen_op_bin": attr.label( executable = True, - cfg = "host", + cfg = "exec", default = Label("@//tfjs-converter/scripts:gen_op_bin"), doc = "The script that generates ts ops from json", ), diff --git a/tfjs-converter/scripts/kernels_to_ops.bzl b/tfjs-converter/scripts/kernels_to_ops.bzl index 836ab59ea6f..7e3177921e1 100644 --- a/tfjs-converter/scripts/kernels_to_ops.bzl +++ b/tfjs-converter/scripts/kernels_to_ops.bzl @@ -37,7 +37,7 @@ kernels_to_ops = rule( attrs = { "kernels_to_ops_bin": attr.label( executable = True, - cfg = "host", + cfg = "exec", default = Label("@//tfjs-converter/scripts:kernels_to_ops_bin"), doc = "The script that generates the kernel2op.json metadata file", ), diff --git a/tools/defaults.bzl b/tools/defaults.bzl index 94a482c78da..ab1e1483ec4 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -15,8 +15,8 @@ """Re-export of some bazel rules with repository-wide defaults.""" +load("@npm//@bazel/concatjs:index.bzl", _ts_library = "ts_library") load("@npm//@bazel/esbuild:index.bzl", _esbuild = "esbuild") -load("@npm//@bazel/typescript:index.bzl", _ts_library = "ts_library") def ts_library(**kwargs): # Use the ts_library tsconfig by default. The ts_library tsconfig does not diff --git a/tools/enumerate_tests.bzl b/tools/enumerate_tests.bzl index 1368c4f58ac..3449479638b 100644 --- a/tools/enumerate_tests.bzl +++ b/tools/enumerate_tests.bzl @@ -28,7 +28,7 @@ enumerate_tests = rule( attrs = { "enumerate_tests_bin": attr.label( executable = True, - cfg = "host", + cfg = "exec", default = Label("@//tools:enumerate_tests_bin"), doc = "The script that enumerates the tests", ), diff --git a/tools/make_version_test_file.bzl b/tools/make_version_test_file.bzl index 41f36687bf1..4ba5a855993 100644 --- a/tools/make_version_test_file.bzl +++ b/tools/make_version_test_file.bzl @@ -21,7 +21,7 @@ make_version_test_file = rule( attrs = { "make_version_test_file_bin": attr.label( executable = True, - cfg = "host", + cfg = "exec", default = Label("@//tools:make_version_test_file_bin"), doc = "The script that generates the version test", ), diff --git a/yarn.lock b/yarn.lock index 54a7a044dfa..230163c4b32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -35,60 +35,60 @@ resolved "https://registry.yarnpkg.com/@bazel/bazelisk/-/bazelisk-1.11.0.tgz#f98d8438b4c14e3328126618b96775d271caa5f8" integrity sha512-lxiQzVqSGDG0PIDQGJdVDjp7T+50p5NnM4EnRJa76mkZp6u5ul19GJNKhPKi81TZQALZEZDxAgxVqQKkWTUOxA== -"@bazel/buildifier@4.2.4": - version "4.2.4" - resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-4.2.4.tgz#48d4da5638ef0e0a650dda28beaa07d9c8124520" - integrity sha512-PwzTnPqD3W0fjdXY2qwnwh+BPeKAYsfOr4rPwH6u5j9MPHCOa9YRI7Qj8ZwmHC1hhORBYJoTQt589/mXYwfX+g== +"@bazel/buildifier@5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-5.1.0.tgz#ae0b93c5d14b2b080d5a492a8bfee231101b5385" + integrity sha512-gO0+//hkH+iE3AQ02mYttJAcWiE+rapP8IxmstDhwSqs+CmZJJI8Q1vAaIvMyJUT3NIf7lGljRNpzclkCPk89w== -"@bazel/concatjs@4.6.1": - version "4.6.1" - resolved "https://registry.yarnpkg.com/@bazel/concatjs/-/concatjs-4.6.1.tgz#c40abc3fbe362cbad1e3383c4e78b58d1f4c8e13" - integrity sha512-eI79oS1F8vK9kw8ttg/zeQYyOiN9FfhJjYyammkc3q4WlNs3Xm717Cp/CquSwPyFh022mB00Tib4gHJ7zp+VpA== +"@bazel/concatjs@5.4.2": + version "5.4.2" + resolved "https://registry.yarnpkg.com/@bazel/concatjs/-/concatjs-5.4.2.tgz#2ec0943b50e229a163a277a6de2cc38aeb852e14" + integrity sha512-MoQfmY+6N8RCgqDI2+bRuD+I0p3CLI1JCYZZNSnbZySv1SnT5oQHxoerojEYwyOmsS5sUt2sR8uGtMYZSdoycQ== dependencies: protobufjs "6.8.8" source-map-support "0.5.9" tsutils "3.21.0" -"@bazel/esbuild@4.6.1": - version "4.6.1" - resolved "https://registry.yarnpkg.com/@bazel/esbuild/-/esbuild-4.6.1.tgz#823178fc3959ce880c1c89d0b29be215137eb0fc" - integrity sha512-EkLQN+DnqCTz1jDKgLA8dKwJUaehznhy/+0qH8Vz3MG4Zy7ibV3qJsNPYBHOndRJMoxoxv3OMybFLnHfQsuPWQ== +"@bazel/esbuild@5.4.2": + version "5.4.2" + resolved "https://registry.yarnpkg.com/@bazel/esbuild/-/esbuild-5.4.2.tgz#07b46fd7b10667b6e56b94df2c316c19de17ab33" + integrity sha512-k1ZJzFlpfzTcJyHvVxSoOmiPwWNmJSVE0A2ygtXlyB4/dTnGAC6vcX03ECXovd+wk8py/DuFQDb6Xpv6RnWtAg== -"@bazel/jasmine@4.6.1": - version "4.6.1" - resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-4.6.1.tgz#f1b618d8190fe30db03e6613255704c92c90c8b7" - integrity sha512-SkzBYh4f4BALB6du3/g0Z3lu3N9jcH3kVQHxqwmKkBHCp9Nny0xzhhEje/o5ncSNt+SMwIPwBrTGMPQnUUfmfg== +"@bazel/jasmine@5.4.2": + version "5.4.2" + resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-5.4.2.tgz#073eef1a1b4c9a4f69522b4b96acd01d44daa05d" + integrity sha512-w0eco1CAipjLX1GFr8GqMTGpIiW9s/kkPDMAFuIVorZzMnAHov25ztr1Zjt5RBUpzMPBY+Sm0cp1d4x9UsjwIQ== dependencies: c8 "~7.5.0" jasmine-reporters "~2.5.0" -"@bazel/rollup@4.6.1": - version "4.6.1" - resolved "https://registry.yarnpkg.com/@bazel/rollup/-/rollup-4.6.1.tgz#7e5054b1b43c1052bdd8824d9f1a11a410d540e2" - integrity sha512-8a2halG0dnzjs0BgGiHOM47LVCotGW0I9lSWLdwrTxTNOp8fEdbZ8C7TMHFE+8Zc3Z5oerqR8uvIpMarOJQumQ== +"@bazel/rollup@5.4.2": + version "5.4.2" + resolved "https://registry.yarnpkg.com/@bazel/rollup/-/rollup-5.4.2.tgz#4b640740f1d57f9acc39b407045ff69bea896057" + integrity sha512-IIawuwfh3OE1u7KAGagqw+3EOFW5O01W/HUtV48ereSOMILDsHi85oY9fQNJ76O1ZxrI3mRLCPKs9xWmHAenUQ== dependencies: - "@bazel/worker" "4.6.1" + "@bazel/worker" "5.4.2" -"@bazel/terser@4.6.1": - version "4.6.1" - resolved "https://registry.yarnpkg.com/@bazel/terser/-/terser-4.6.1.tgz#a3f70672cef7b9383b42930691d6fc8be4b8d993" - integrity sha512-LOXNSLCscyiNDxhLEgIL+Unj7UQpH6s+IkujizRpEyMrVVrhun5do972ab4TdqCXi9rxQKBBkgj8EL43gMimwg== +"@bazel/terser@5.4.2": + version "5.4.2" + resolved "https://registry.yarnpkg.com/@bazel/terser/-/terser-5.4.2.tgz#c3ecf9be0c6c589bc981e67d0af2457d5a596e2a" + integrity sha512-bQFbsxaUTu0vhVCX+P6yY1t/Fg9vo/irOcB3OzX1iTBBS1eDK36fChMx6sFQu6QD5yq7zZxzpb6YH3RyPyri9w== -"@bazel/typescript@4.6.1": - version "4.6.1" - resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-4.6.1.tgz#5c674698bda53006d784cb40ba1e2cb1263ecc20" - integrity sha512-T/2mOB9lSySaIQH47JsbKE8UG7eEChFltXCVNw2xk1+Eu7ym+osSIjaXoQVBPmAl/6qmIEzTyBIjFPEU2ohVrw== +"@bazel/typescript@5.4.2": + version "5.4.2" + resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-5.4.2.tgz#73ff56d124841eeb3e55aa10c146d9cc25b0e973" + integrity sha512-QtCNPJHEeJhVGnRijRxzA3bUaY5mpURJ/Ss4QCjNTyJXbJAQ+F05LiEeFmxlhvouRXy4lW4/4EIhfucZ9YG5tw== dependencies: - "@bazel/worker" "4.6.1" + "@bazel/worker" "5.4.2" protobufjs "6.8.8" semver "5.6.0" source-map-support "0.5.9" tsutils "3.21.0" -"@bazel/worker@4.6.1": - version "4.6.1" - resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-4.6.1.tgz#96925f5819344225d4fe40ffa630a3c5f4847a0b" - integrity sha512-D6TsHxGSljmlLoz8FXL1+ISh8XnDuRkBpT6Mz0wD62eWajUZASTfX9I4HNiLNbsWY4Omc7nKXI+j4R8/BLciFg== +"@bazel/worker@5.4.2": + version "5.4.2" + resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-5.4.2.tgz#b5229140c2087b7f3977ee671624f3c65c6a46a4" + integrity sha512-wQZ1ybgiCPkuITaiPfh91zB/lBYqBglf1XYh9hJZCQnWZ+oz9krCnZcywI/i1U9/E9p3A+4Y1ni5akAwTMmfUA== dependencies: google-protobuf "^3.6.1"