build: update dependency build_bazel_rules_nodejs to v5.8.2 (#49910)

See associated pull request for more information.

PR Close #49910
This commit is contained in:
Angular Robot
2023-03-10 14:07:12 +00:00
committed by Jessica Janiuk
parent ded7ede1d4
commit de0d0b4757
2 changed files with 2 additions and 52 deletions
+2 -4
View File
@@ -26,12 +26,10 @@ http_archive(
http_archive(
name = "build_bazel_rules_nodejs",
patches = [
# TODO(devversion): remove when https://github.com/bazelbuild/rules_nodejs/pull/3605 is available.
"//tools:bazel-repo-patches/rules_nodejs__#3605.patch",
"//tools/esm-interop:patches/bazel/nodejs_binary_esm_support.patch",
],
sha256 = "c29944ba9b0b430aadcaf3bf2570fece6fc5ebfb76df145c6cdad40d65c20811",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.7.0/rules_nodejs-5.7.0.tar.gz"],
sha256 = "94070eff79305be05b7699207fbac5d2608054dd53e6109f7d00d923919ff45a",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.2/rules_nodejs-5.8.2.tar.gz"],
)
load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
@@ -1,48 +0,0 @@
diff --git internal/node/node.bzl internal/node/node.bzl
index 18d7ce4..3b8ce74 100755
--- internal/node/node.bzl
+++ internal/node/node.bzl
@@ -353,10 +353,22 @@ if (process.cwd() !== __dirname) {
else:
executable = ctx.outputs.launcher_sh
- # syntax sugar: allows you to avoid repeating the entry point in data
- # entry point is only needed in runfiles if it is a javascript file
- if len(ctx.files.entry_point) == 1 and is_javascript_file(ctx.files.entry_point[0]):
- runfiles.extend(ctx.files.entry_point)
+ # Note: `to_list()` is expensive and should only be called once.
+ sources_list = sources.to_list()
+ entry_point_input_short_path = _ts_to_js(_get_entry_point_file(ctx).short_path)
+ entry_point_script = None
+
+ for f in sources_list:
+ if f.short_path == entry_point_input_short_path:
+ entry_point_script = f
+ break
+
+ if not entry_point_script and len(ctx.files.entry_point) == 1 and is_javascript_file(ctx.files.entry_point[0]):
+ entry_point_script = ctx.files.entry_point[0]
+
+ # Convenience: We add the entry point to the runfiles. This means that users would not
+ # need to explicitly repeat the entry point in the `data` attribute.
+ runfiles.append(entry_point_script)
return [
DefaultInfo(
@@ -371,14 +383,14 @@ if (process.cwd() !== __dirname) {
# Calling the .to_list() method may have some perfs hits,
# so we should be running this method only once per rule.
# see: https://docs.bazel.build/versions/main/skylark/depsets.html#performance
- node_modules.to_list() + sources.to_list(),
+ node_modules.to_list() + sources_list,
collect_data = True,
),
),
# TODO(alexeagle): remove sources and node_modules from the runfiles
# when downstream usage is ready to rely on linker
NodeRuntimeDepsInfo(
- deps = depset(ctx.files.entry_point, transitive = [node_modules, sources]),
+ deps = depset([entry_point_script], transitive = [node_modules, sources]),
pkgs = data,
),
# indicates that the this binary should be instrumented by coverage