Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ js/private/coverage/coverage.js linguist-generated=true
js/private/devserver/js_run_devserver.mjs linguist-generated=true
js/private/watch/aspect_watch_protocol.mjs linguist-generated=true
js/private/watch/aspect_watch_protocol.d.mts linguist-generated=true
js/private/node-patches/fs.cjs linguist-generated=true
js/private/node-patches/fs*.cjs linguist-generated=true
js/private/js_image_layer.mjs linguist-generated=true
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ examples/**/*-docs.md
js/private/coverage/coverage.js
js/private/devserver/js_run_devserver.mjs
js/private/node-patches/fs.cjs
js/private/node-patches/fs_stat.cjs
js/private/watch/aspect_watch_protocol.mjs
js/private/watch/aspect_watch_protocol.d.mts
min/
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bazel_dep(name = "bazel_features", version = "1.9.0")
bazel_dep(name = "bazel_lib", version = "3.0.0")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "platforms", version = "0.0.5")
bazel_dep(name = "rules_nodejs", version = "6.3.0")
bazel_dep(name = "rules_nodejs", version = "6.4.0")
bazel_dep(name = "yq.bzl", version = "0.3.2")

tel = use_extension("@aspect_tools_telemetry//:extension.bzl", "telemetry")
Expand Down
19 changes: 18 additions & 1 deletion js/private/js_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ _ATTRS = {
which can lead to non-hermetic behavior.""",
default = True,
),
"patch_node_esm_loader": attr.bool(
doc = """Apply the internal lstat patch to prevent the program from following symlinks out of
the execroot, runfiles and the sandbox even when using the ESM loader.
This flag only has an effect when `patch_node_fs` is True.""",
default = False,
),
"include_sources": attr.bool(
doc = """When True, `sources` from `JsInfo` providers in `data` targets are included in the runfiles of the target.""",
default = True,
Expand Down Expand Up @@ -320,7 +327,10 @@ _ATTRS = {
"_windows_constraint": attr.label(default = "@platforms//os:windows"),
"_node_patches_files": attr.label_list(
allow_files = True,
default = [Label("@aspect_rules_js//js/private/node-patches:fs.cjs")],
default = [
Label("@aspect_rules_js//js/private/node-patches:fs.cjs"),
Label("@aspect_rules_js//js/private/node-patches:fs_stat.cjs"),
],
),
"_node_patches": attr.label(
allow_single_file = True,
Expand Down Expand Up @@ -566,11 +576,18 @@ def _create_launcher(ctx, log_prefix_rule_set, log_prefix_rule, fixed_args = [],
)

def _js_binary_impl(ctx):
# Only apply lstat patch if it's requested
JS_BINARY__PATCH_NODE_ESM_LOADER = "1" if ctx.attr.patch_node_esm_loader else "0"
fixed_env = {
"JS_BINARY__PATCH_NODE_ESM_LOADER": JS_BINARY__PATCH_NODE_ESM_LOADER,
}

launcher = _create_launcher(
ctx,
log_prefix_rule_set = "aspect_rules_js",
log_prefix_rule = "js_test" if ctx.attr.testonly else "js_binary",
fixed_args = ctx.attr.fixed_args,
fixed_env = fixed_env,
)
runfiles = launcher.runfiles

Expand Down
2 changes: 2 additions & 0 deletions js/private/node-patches/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ write_source_files(
name = "checked_in_compile",
files = {
"fs.cjs": "//js/private/node-patches/src:fs-generated.cjs",
"fs_stat.cjs": "//js/private/node-patches/src:fs_stat.cjs",
},
)

exports_files([
"fs.cjs",
"fs_stat.cjs",
"register.cjs",
])
185 changes: 101 additions & 84 deletions js/private/node-patches/fs.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading