diff --git a/internal/node/launcher.sh b/internal/node/launcher.sh index ba149e03d4..de8fddc754 100644 --- a/internal/node/launcher.sh +++ b/internal/node/launcher.sh @@ -191,10 +191,7 @@ for ARG in "${ALL_ARGS[@]:-}"; do case "$ARG" in --bazel_node_modules_manifest=*) MODULES_MANIFEST="${ARG#--bazel_node_modules_manifest=}" ;; --nobazel_patch_module_resolver) - declare MAIN="TEMPLATED_entry_point_execroot_path" - if [[ ! -f "$MAIN" ]]; then - MAIN=$(rlocation "TEMPLATED_entry_point_manifest_path") - fi + MAIN="TEMPLATED_script_path" LAUNCHER_NODE_OPTIONS=( "--require" "$node_patches_script" ) # In this case we should always run the linker diff --git a/internal/node/node.bzl b/internal/node/node.bzl index 858bfa738d..d2ea625196 100644 --- a/internal/node/node.bzl +++ b/internal/node/node.bzl @@ -246,8 +246,6 @@ fi # Need a smarter split operation than `expanded_arg.split(" ")` as it will split # up args with intentional spaces and it will fail for expanded files with spaces. "TEMPLATED_args": " ".join(expanded_args), - "TEMPLATED_entry_point_execroot_path": _to_execroot_path(ctx, ctx.file.entry_point), - "TEMPLATED_entry_point_manifest_path": _to_manifest_path(ctx, ctx.file.entry_point), "TEMPLATED_env_vars": env_vars, "TEMPLATED_expected_exit_code": str(expected_exit_code), "TEMPLATED_link_modules_script": _to_manifest_path(ctx, ctx.file._link_modules_script), @@ -259,6 +257,12 @@ fi "TEMPLATED_runfiles_helper_script": _to_manifest_path(ctx, ctx.file._runfiles_helper_script), "TEMPLATED_vendored_node": "" if is_builtin else strip_external(ctx.file._node.path), } + + if ctx.file.entry_point.is_source: + substitutions["TEMPLATED_script_path"] = _to_execroot_path(ctx, ctx.file.entry_point) + else: + substitutions["TEMPLATED_script_path"] = _to_manifest_path(ctx, ctx.file.entry_point) + ctx.actions.expand_template( template = ctx.file._launcher_template, output = ctx.outputs.launcher_sh,