Skip to content

Commit

Permalink
Upgrade rules_nodejs to 4.2.0 (#5671)
Browse files Browse the repository at this point in the history
Make the default ts_library macro behave like pre-4.0 versions of rules_nodejs by automatically setting package_name to module_name if its not set.

Temporarily mark webgl tests as not testonly to work around bazel-contrib/rules_nodejs#2984 until the next release.

Add package_name to pkg_npm targets.
  • Loading branch information
mattsoulanille authored and pyu10055 committed Oct 13, 2021
1 parent 617db0f commit de260b8
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 81 deletions.
1 change: 1 addition & 0 deletions BAZEL_MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")

pkg_npm(
name = "tfjs-core_pkg",
package_name = "@tensorflow/tfjs-core",
srcs = [
# Add any static files the package should include here
"package.json",
Expand Down
38 changes: 5 additions & 33 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "8f5f192ba02319254aaf2cdcca00ec12eaafeb979a80a1e946773c520ae0a2c9",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.7.0/rules_nodejs-3.7.0.tar.gz"],
sha256 = "4e1a5633267a0ca1d550cced2919dd4148575c0bafd47608b88aea79c41b5ca3",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.2.0/rules_nodejs-4.2.0.tar.gz"],
)

load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
Expand Down Expand Up @@ -54,38 +54,10 @@ browser_repositories(
chromium = True,
)

# Install esbuild
_ESBUILD_VERSION = "0.12.1" # reminder: update SHAs below when changing this value
# Esbuild toolchain
load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")

http_archive(
name = "esbuild_darwin",
build_file_content = """exports_files(["bin/esbuild"])""",
sha256 = "efb34692bfa34db61139eb8e46cd6cf767a42048f41c8108267279aaf58a948f",
strip_prefix = "package",
urls = [
"https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-%s.tgz" % _ESBUILD_VERSION,
],
)

http_archive(
name = "esbuild_windows",
build_file_content = """exports_files(["esbuild.exe"])""",
sha256 = "10439647b11c7fd1d9647fd98d022fe2188b4877d2d0b4acbe857f4e764b17a9",
strip_prefix = "package",
urls = [
"https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-%s.tgz" % _ESBUILD_VERSION,
],
)

http_archive(
name = "esbuild_linux",
build_file_content = """exports_files(["bin/esbuild"])""",
sha256 = "de8409b90ec3c018ffd899b49ed5fc462c61b8c702ea0f9da013e0e1cd71549a",
strip_prefix = "package",
urls = [
"https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-%s.tgz" % _ESBUILD_VERSION,
],
)
esbuild_repositories(npm_repository = "npm")

# Emscripten toolchain
http_archive(
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"devDependencies": {
"@bazel/bazelisk": "^1.9.0",
"@bazel/buildifier": "^4.0.1",
"@bazel/concatjs": "^3.7.0",
"@bazel/esbuild": "^3.7.0",
"@bazel/jasmine": "^3.7.0",
"@bazel/rollup": "^3.7.0",
"@bazel/terser": "^3.7.0",
"@bazel/typescript": "^3.7.0",
"@bazel/buildifier": "^4.2.1",
"@bazel/concatjs": "^4.2.0",
"@bazel/esbuild": "^4.2.0",
"@bazel/jasmine": "^4.2.0",
"@bazel/rollup": "^4.2.0",
"@bazel/terser": "^4.2.0",
"@bazel/typescript": "^4.2.0",
"@octokit/rest": "15.17.0",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.1",
Expand Down
1 change: 1 addition & 0 deletions tfjs-backend-cpu/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ copy_to_dist(

pkg_npm(
name = "tfjs-backend-cpu_pkg",
package_name = "@tensorflow/tfjs-backend-cpu",
srcs = [
"README.md",
"package.json",
Expand Down
1 change: 1 addition & 0 deletions tfjs-backend-webgl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ copy_file(

pkg_npm(
name = "tfjs-backend-webgl_pkg",
package_name = "@tensorflow/tfjs-backend-webgl",
srcs = [
"README.md",
"package.json",
Expand Down
4 changes: 3 additions & 1 deletion tfjs-backend-webgl/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ ts_library(

ts_library(
name = "tfjs-backend-webgl_test_lib",
testonly = True,
# TODO(mattsoulanille): Mark as testonly when esbuild is fixed to allow it.
# https://github.com/bazelbuild/rules_nodejs/pull/2984
# testonly = True,
srcs = glob(TEST_SRCS) + [":tests"],
module_name = "@tensorflow/tfjs-backend-webgl/dist",
deps = [
Expand Down
1 change: 1 addition & 0 deletions tfjs-converter/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ copy_file(

pkg_npm(
name = "tfjs-converter_pkg",
package_name = "@tensorflow/tfjs-converter",
srcs = [
"README.md",
"package.json",
Expand Down
1 change: 1 addition & 0 deletions tfjs-core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ copy_file(

pkg_npm(
name = "tfjs-core_pkg",
package_name = "@tensorflow/tfjs-core",
srcs = [
"README.md",
"package.json",
Expand Down
1 change: 1 addition & 0 deletions tfjs-tflite/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ copy_to_dist(
# Package for npm.
pkg_npm(
name = "tfjs-tflite_pkg",
package_name = "@tensorflow/tfjs-tflite",
srcs = [
"README.md",
"package.json",
Expand Down
14 changes: 8 additions & 6 deletions tools/defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,25 @@ def ts_library(**kwargs):
devmode_target = kwargs.pop("devmode_target", "es5")
prodmode_target = kwargs.pop("prodmode_target", "es2017")

# By default, set package_name based on module_name to mimic pre-4.0 behavior
# of automatically linking the ts_library.
maybe_module_name = kwargs["module_name"] if "module_name" in kwargs else None
package_name = kwargs.pop("package_name", maybe_module_name)

_ts_library(
tsconfig = tsconfig,
devmode_target = devmode_target,
prodmode_target = prodmode_target,
package_name = package_name,
**kwargs
)

def esbuild(**kwargs):
# Make sure esbuild always resolve the module (.mjs) files before .js files.
args = kwargs.pop("args", []) + ["--resolve-extensions=.mjs,.js"]
args = kwargs.pop("args", {})
args["resolveExtensions"] = [".mjs", ".js"]

_esbuild(
tool = select({
"@bazel_tools//src/conditions:darwin": "@esbuild_darwin//:bin/esbuild",
"@bazel_tools//src/conditions:linux_x86_64": "@esbuild_linux//:bin/esbuild",
"@bazel_tools//src/conditions:windows": "@esbuild_windows//:esbuild.exe",
}),
args = args,
**kwargs
)
83 changes: 49 additions & 34 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,52 +49,62 @@
resolved "https://registry.yarnpkg.com/@bazel/bazelisk/-/bazelisk-1.10.1.tgz#46236a43ad58e310c55247f866da0dc6083c3d8b"
integrity sha512-IHszNzBO2UrUy6YtsSAsZtnU6I6qpzXGkWdEvGoMxLgJnDsEnsIYniDCUjvjU1KAP+A03eepmCHlyFcRHMSxRA==

"@bazel/buildifier@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-4.0.1.tgz#52cfbad5cbb86e9183a29dde2370cd465730ea0d"
integrity sha512-BTmtvJbeeEVrqRApI1gr5hvPgYcHLpdGJ5EXNXEWO692ztMPSj5fB/dH0xUlaW45jn6LimYx8ymqTMhj3538og==
"@bazel/buildifier@^4.2.1":
version "4.2.1"
resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-4.2.1.tgz#2ea4c0d5015a1f36174a139e8953c4eec509564e"
integrity sha512-eMBw//leW3xIbDrylsFKC7ejOMKAja2Z3BmQ5Zan/h7s/C+F2cMz3UFJhSVZRl4AaN3bXVvTNMz385abaTK/tA==

"@bazel/concatjs@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@bazel/concatjs/-/concatjs-3.7.0.tgz#f10649d97d93d96bfe815d6b0c620acad394f799"
integrity sha512-E+mA3huykyBMcRbhAOYbfmfMIOZD6QtXs6i+IhJQed8DYQLSYf9E2Jq8T/rFefFyZv+loJIAr4JhkAIO5vuFWg==
"@bazel/concatjs@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@bazel/concatjs/-/concatjs-4.2.0.tgz#594ed5a5d0bc8f4d72e1a0393cfbefa340c46fc0"
integrity sha512-ZAXnpVBR0z5kMKnekfGQ0Dtjx+mnZD1KMyAhqwqja5clU/Lc+32iNiqFTw9U7LgWKhLnyQoKu4ZyID6/UgPVog==
dependencies:
protobufjs "6.8.8"
source-map-support "0.5.9"
tsutils "2.27.2"
tsutils "3.21.0"

"@bazel/esbuild@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@bazel/esbuild/-/esbuild-3.7.0.tgz#1d59bba055afb0ca43bb626b595e2b3e2e89fcad"
integrity sha512-IWcK/7f17m5gMzbz+pzrgaalDDXQ/3xf2AVCllf8XUDay5HqbquL9dHy5xuZrM8Lap9hHmZGNAMmuV74x0HffQ==
"@bazel/esbuild@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@bazel/esbuild/-/esbuild-4.2.0.tgz#2bc69a1075a24f6fd7ebe1bc839e15c9ae568075"
integrity sha512-kT2WUtjHEDFAIcMqpA48x3tWnp7w4IkYitMGXvODjbAo3VGl1oNm4FCuSjD8bfvKDzh4unsDGr/h5Hi2RNTKoA==

"@bazel/jasmine@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-3.7.0.tgz#9d8ed4c73abb4a927cdffecf5c4c877f969d886b"
integrity sha512-q6Nt1T83isYjIcxQrLkvWCzX6R9oDBwDDN9Hx/vQuvLKMRHSCuj8hkhf42waR9SzTiVHXNDv39l4IwvFhVkfvA==
"@bazel/jasmine@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-4.2.0.tgz#1150e6fd8cbaf0805253bcd7a38562b11f728f56"
integrity sha512-XpGt96Ydl2tMlqLY3xv3oHUTKUL+mSoFQG+u9hqsqqHL8MY2LJjp3zodo9KtsM8zfu8/MYrUyYh8i9kjsk43sw==
dependencies:
c8 "~7.5.0"
jasmine-reporters "~2.4.0"

"@bazel/rollup@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@bazel/rollup/-/rollup-3.7.0.tgz#6045d44f39ebc213fd2f3672421a35d20d9abf37"
integrity sha512-B9Gut5wdANpnQCUwwp9q/UAU5MNhfUpjTyygNUWoRWAQXRFgmSgsC0Gr5RaWHx9bugaiyPQbPDmb3cYTU+4RQQ==
"@bazel/rollup@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@bazel/rollup/-/rollup-4.2.0.tgz#c291ab0ae8e1624e45cf6d3c5572e79b62791f0d"
integrity sha512-o977GjW1yYc2DDa/znpSHbGv7mbE+hOplFC2h4LGaLpbjjr/ziAHxr1MFQzs+LRbht56rUJ1E2Z4am5hiEJVMA==
dependencies:
"@bazel/worker" "4.2.0"

"@bazel/terser@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@bazel/terser/-/terser-3.7.0.tgz#a2b3e7488b0c2245add46e0cbf9e89e047223c79"
integrity sha512-uvs0ir7me/KSIm4YGhkPolIjs+Fzjg6JrkRg8CYjnVLz+I6Ajr2+X9e3ylZP+0lNWhqJkkCjXm1jybPTUV5RKQ==
"@bazel/terser@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@bazel/terser/-/terser-4.2.0.tgz#ab02281475a924e9a032138728f58ce323fd64cb"
integrity sha512-su7La+F6VVQCJ3ImdgWNK/azpf/8LMY08S3akWcL+z9U08ERUVs2o6LRCiY6IuaCD5AhXmfR1AWTpMJ7mfrbFA==

"@bazel/typescript@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-3.7.0.tgz#a4d648a36f7ef4960c8a16222f853a4c285a522d"
integrity sha512-bkNHZaCWg4Jk+10wzhFDhB+RRZkfob/yydC4qRzUVxCDLPFICYgC0PWeLhf/ixEhVeHtS0Cmv74M+QziqKSdbw==
"@bazel/typescript@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-4.2.0.tgz#41543c2808c4c475f33f5b1d9e071101a2385503"
integrity sha512-M0jqTrwt1Dqc7wFCvs0J5XU+aQ0DfVjkkcruIFBuEPOTTA5aaVs6XKr1xVPV9WL5QsbJFD7rYc55zr0jDlX22Q==
dependencies:
"@bazel/worker" "4.2.0"
protobufjs "6.8.8"
semver "5.6.0"
source-map-support "0.5.9"
tsutils "2.27.2"
tsutils "3.21.0"

"@bazel/worker@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-4.2.0.tgz#96d4f4f7807c8e3a583e3e9e78d81385882c8013"
integrity sha512-FQ88yaWtCAveauBXxZ9uuQvmAGAaHZUqu2ptTIf6R6Q8yblPB7w6VTKfkLoT162gqLzDclzhoidJ4YH93bidtA==
dependencies:
google-protobuf "^3.6.1"

"@bcoe/v8-coverage@^0.2.3":
version "0.2.3"
Expand Down Expand Up @@ -1159,6 +1169,11 @@ glob@^7.0.0, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, gl
once "^1.3.0"
path-is-absolute "^1.0.0"

google-protobuf@^3.6.1:
version "3.18.0"
resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.18.0.tgz#687449d8e858305d658dc1145852c306d8222f5a"
integrity sha512-WlaQWRkUOo/lm9uTgNH6nk9IQt814RggWPzKBfnAVewOFzSzRUSmS1yUWRT6ixW1vS7er5p6tmLSmwzpPpmc8A==

graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.6:
version "4.2.8"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a"
Expand Down Expand Up @@ -2481,10 +2496,10 @@ tslint@~6.1.3:
tslib "^1.13.0"
tsutils "^2.29.0"

tsutils@2.27.2:
version "2.27.2"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.27.2.tgz#60ba88a23d6f785ec4b89c6e8179cac9b431f1c7"
integrity sha512-qf6rmT84TFMuxAKez2pIfR8UCai49iQsfB7YWVjV1bKpy/d0PWT5rEOSM6La9PiHZ0k1RRZQiwVdVJfQ3BPHgg==
tsutils@3.21.0:
version "3.21.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==
dependencies:
tslib "^1.8.1"

Expand Down

0 comments on commit de260b8

Please sign in to comment.