From 8c28cb910f1b93d0fa3289a11ec62ef1710172d5 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Tue, 17 Dec 2019 11:34:55 -0800 Subject: [PATCH] Update rules_nodejs to 0.42.3 release (#1324) --- .gitignore | 3 +++ README.md | 16 +++++++--------- WORKSPACE | 15 +++++++-------- nodejs/image.bzl | 2 +- testdata/yarn.lock | 8 ++++++++ tests/container/nodejs/BUILD | 30 +++++++++++++++--------------- 6 files changed, 41 insertions(+), 33 deletions(-) create mode 100644 testdata/yarn.lock diff --git a/.gitignore b/.gitignore index e87686c91..7e3fe2ab2 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,6 @@ bazel-testlogs # Eclipse and PyDev .project .pydevproject + +# Npm packages +node_modules \ No newline at end of file diff --git a/README.md b/README.md index a4d2dd88e..5770e681f 100644 --- a/README.md +++ b/README.md @@ -577,20 +577,18 @@ http_archive( name = "build_bazel_rules_nodejs", # Replace with a real SHA256 checksum sha256 = "{SHA256}" - # Replace with a real commit SHA - strip_prefix = "rules_nodejs-{HEAD}", - urls = ["https://github.com/bazelbuild/rules_nodejs/archive/{HEAD}.tar.gz"], + # Replace with a real release version + urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/{VERSION}/rules_nodejs-{VERSION}.tar.gz"], ) -load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "npm_install") -# Download Node toolchain, etc. -node_repositories(package_json = ["//:package.json"]) +load("@build_bazel_rules_nodejs//:index.bzl", "npm_install") # Install your declared Node.js dependencies npm_install( - name = "npm_deps", + name = "npm", package_json = "//:package.json", + yarn_lock = "//:yarn.lock", ) load( @@ -620,9 +618,9 @@ load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image") nodejs_image( name = "nodejs_image", - entry_point = "your_workspace/path/to/file.js", + entry_point = "@your_workspace//path/to:file.js", # This will be put into its own layer. - node_modules = "@npm_deps//:node_modules", + node_modules = "@npm//:node_modules", data = [":file.js"], ... ) diff --git a/WORKSPACE b/WORKSPACE index 797248393..bd6fa146a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -352,18 +352,17 @@ d_repositories() http_archive( name = "build_bazel_rules_nodejs", - sha256 = "9b72bb0aea72d7cbcfc82a01b1e25bf3d85f791e790ddec16c65e2d906382ee0", - strip_prefix = "rules_nodejs-0.16.2", - urls = ["https://github.com/bazelbuild/rules_nodejs/archive/0.16.2.zip"], + sha256 = "a54b2511d6dae42c1f7cdaeb08144ee2808193a088004fc3b464a04583d5aa2e", + urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.42.3/rules_nodejs-0.42.3.tar.gz"], ) -load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "npm_install") +load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install") -node_repositories(package_json = ["//testdata:package.json"]) - -npm_install( - name = "npm_deps", +yarn_install( + name = "npm", package_json = "//testdata:package.json", + symlink_node_modules = False, + yarn_lock = "//testdata:yarn.lock", ) load( diff --git a/nodejs/image.bzl b/nodejs/image.bzl index a01ea3e2a..617aa069a 100644 --- a/nodejs/image.bzl +++ b/nodejs/image.bzl @@ -17,7 +17,7 @@ The signature of this rule is compatible with nodejs_binary. """ load("@bazel_skylib//lib:dicts.bzl", "dicts") -load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") +load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") load( "//container:container.bzl", "container_pull", diff --git a/testdata/yarn.lock b/testdata/yarn.lock new file mode 100644 index 000000000..edcfe1ad6 --- /dev/null +++ b/testdata/yarn.lock @@ -0,0 +1,8 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +jsesc@2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" + integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== diff --git a/tests/container/nodejs/BUILD b/tests/container/nodejs/BUILD index 23999626c..f01036311 100644 --- a/tests/container/nodejs/BUILD +++ b/tests/container/nodejs/BUILD @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") +load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") load("//contrib:test.bzl", "container_test") load("//nodejs:image.bzl", "nodejs_image") @@ -26,8 +26,8 @@ nodejs_image( "arg1", ], data = ["//testdata:nodejs_image.js"], - entry_point = "io_bazel_rules_docker/testdata/nodejs_image.js", - node_modules = "@npm_deps//:node_modules", + entry_point = "@io_bazel_rules_docker//testdata:nodejs_image.js", + node_modules = "@npm//:node_modules", ) # Docker Cmd value should be `[""]`. @@ -35,16 +35,16 @@ nodejs_image( name = "nodejs_image_list_with_empty_string_args", args = [""], data = ["//testdata:nodejs_image.js"], - entry_point = "io_bazel_rules_docker/testdata/nodejs_image.js", - node_modules = "@npm_deps//:node_modules", + entry_point = "@io_bazel_rules_docker//testdata:nodejs_image.js", + node_modules = "@npm//:node_modules", ) # Docker Cmd value should be `null`. nodejs_image( name = "nodejs_image_no_args", data = ["//testdata:nodejs_image.js"], - entry_point = "io_bazel_rules_docker/testdata/nodejs_image.js", - node_modules = "@npm_deps//:node_modules", + entry_point = "@io_bazel_rules_docker//testdata:nodejs_image.js", + node_modules = "@npm//:node_modules", ) # Docker Cmd value should be `null`. @@ -52,8 +52,8 @@ nodejs_image( name = "nodejs_image_empty_list_args", args = [], data = ["//testdata:nodejs_image.js"], - entry_point = "io_bazel_rules_docker/testdata/nodejs_image.js", - node_modules = "@npm_deps//:node_modules", + entry_point = "@io_bazel_rules_docker//testdata:nodejs_image.js", + node_modules = "@npm//:node_modules", ) # Docker Cmd value should be `null`. @@ -61,8 +61,8 @@ nodejs_image( name = "nodejs_image_none_args", args = None, data = ["//testdata:nodejs_image.js"], - entry_point = "io_bazel_rules_docker/testdata/nodejs_image.js", - node_modules = "@npm_deps//:node_modules", + entry_point = "@io_bazel_rules_docker//testdata:nodejs_image.js", + node_modules = "@npm//:node_modules", ) nodejs_binary( @@ -72,14 +72,14 @@ nodejs_binary( "arg1", ], data = ["//testdata:nodejs_image.js"], - entry_point = "io_bazel_rules_docker/testdata/nodejs_image.js", - node_modules = "@npm_deps//:node_modules", + entry_point = "@io_bazel_rules_docker//testdata:nodejs_image.js", + node_modules = "@npm//:node_modules", ) nodejs_image( name = "nodejs_image_custom_binary", binary = ":my_custom_binary", - node_modules = "@npm_deps//:node_modules", + node_modules = "@npm//:node_modules", ) nodejs_image( @@ -89,7 +89,7 @@ nodejs_image( "arg1", ], binary = ":my_custom_binary", - node_modules = "@npm_deps//:node_modules", + node_modules = "@npm//:node_modules", ) container_test(