Skip to content

Commit 4feaa88

Browse files
author
Alex Eagle
committed
refactor: bazel_patch_module_resolver default to false
This turns off our monkey-patches for require() for nodejs_binary, nodejs_test, and macros like jasmine_node_test. Note it was previously disabled for npm_package_bin and generated index.bzl binaries in bazel-contrib#1440 BREAKING CHANGE: By default, we no longer patch the require() function, instead you should rely on the linker to make node modules resolvable at the standard location if this breaks you, the quickest fix is to flip the flag back on a nodejs_binary/nodejs_test/npm_package_bin with `templated_args = ["--bazel_patch_module_resolver"]`, see bazel-contrib#2344 as an example. Another fix is to explicitly use our runfiles helper library, see bazel-contrib#2341 as an example. Fixes bazel-contrib#2125
1 parent 24b5e22 commit 4feaa88

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

internal/node/launcher.sh

+2-4
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ EXIT_CODE_CAPTURE=""
179179

180180
RUN_LINKER=true
181181
NODE_PATCHES=true
182-
# TODO(alex): change the default to false
183-
PATCH_REQUIRE=true
182+
PATCH_REQUIRE=false
184183
for ARG in ${ALL_ARGS[@]+"${ALL_ARGS[@]}"}; do
185184
case "$ARG" in
186185
# Supply custom linker arguments for first-party dependencies
@@ -193,10 +192,9 @@ for ARG in ${ALL_ARGS[@]+"${ALL_ARGS[@]}"}; do
193192
--bazel_capture_exit_code=*) EXIT_CODE_CAPTURE="${ARG#--bazel_capture_exit_code=}" ;;
194193
# Disable the node_loader.js monkey patches for require()
195194
# Note that this means you need an explicit runfiles helper library
195+
# This flag is now a no-op since the default is also false
196196
--nobazel_patch_module_resolver) PATCH_REQUIRE=false ;;
197197
# Enable the node_loader.js monkey patches for require()
198-
# Currently a no-op, but specifying this makes the behavior unchanged when we update
199-
# the default for PATCH_REQUIRE above
200198
--bazel_patch_module_resolver) PATCH_REQUIRE=true ;;
201199
# Disable the --require node-patches (undocumented and unused; only here as an escape value)
202200
--nobazel_node_patches) NODE_PATCHES=false ;;

0 commit comments

Comments
 (0)