|
| 1 | +diff --git internal/node/node.bzl internal/node/node.bzl |
| 2 | +index 18d7ce4..3b8ce74 100755 |
| 3 | +--- internal/node/node.bzl |
| 4 | ++++ internal/node/node.bzl |
| 5 | +@@ -353,10 +353,22 @@ if (process.cwd() !== __dirname) { |
| 6 | + else: |
| 7 | + executable = ctx.outputs.launcher_sh |
| 8 | + |
| 9 | +- # syntax sugar: allows you to avoid repeating the entry point in data |
| 10 | +- # entry point is only needed in runfiles if it is a javascript file |
| 11 | +- if len(ctx.files.entry_point) == 1 and is_javascript_file(ctx.files.entry_point[0]): |
| 12 | +- runfiles.extend(ctx.files.entry_point) |
| 13 | ++ # Note: `to_list()` is expensive and should only be called once. |
| 14 | ++ sources_list = sources.to_list() |
| 15 | ++ entry_point_input_short_path = _ts_to_js(_get_entry_point_file(ctx).short_path) |
| 16 | ++ entry_point_script = None |
| 17 | ++ |
| 18 | ++ for f in sources_list: |
| 19 | ++ if f.short_path == entry_point_input_short_path: |
| 20 | ++ entry_point_script = f |
| 21 | ++ break |
| 22 | ++ |
| 23 | ++ if not entry_point_script and len(ctx.files.entry_point) == 1 and is_javascript_file(ctx.files.entry_point[0]): |
| 24 | ++ entry_point_script = ctx.files.entry_point[0] |
| 25 | ++ |
| 26 | ++ # Convenience: We add the entry point to the runfiles. This means that users would not |
| 27 | ++ # need to explicitly repeat the entry point in the `data` attribute. |
| 28 | ++ runfiles.append(entry_point_script) |
| 29 | + |
| 30 | + return [ |
| 31 | + DefaultInfo( |
| 32 | +@@ -371,14 +383,14 @@ if (process.cwd() !== __dirname) { |
| 33 | + # Calling the .to_list() method may have some perfs hits, |
| 34 | + # so we should be running this method only once per rule. |
| 35 | + # see: https://docs.bazel.build/versions/main/skylark/depsets.html#performance |
| 36 | +- node_modules.to_list() + sources.to_list(), |
| 37 | ++ node_modules.to_list() + sources_list, |
| 38 | + collect_data = True, |
| 39 | + ), |
| 40 | + ), |
| 41 | + # TODO(alexeagle): remove sources and node_modules from the runfiles |
| 42 | + # when downstream usage is ready to rely on linker |
| 43 | + NodeRuntimeDepsInfo( |
| 44 | +- deps = depset(ctx.files.entry_point, transitive = [node_modules, sources]), |
| 45 | ++ deps = depset([entry_point_script], transitive = [node_modules, sources]), |
| 46 | + pkgs = data, |
| 47 | + ), |
| 48 | + # indicates that the this binary should be instrumented by coverage |
0 commit comments