Skip to content

Commit

Permalink
refactor: bazel_patch_module_resolver default to false
Browse files Browse the repository at this point in the history
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 #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 #2344 as an example.
Another fix is to explicitly use our runfiles helper library, see #2341 as an example.

Fixes #2125
  • Loading branch information
Alex Eagle authored and alexeagle committed Dec 11, 2020
1 parent 24b5e22 commit fdde32f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions internal/node/launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ EXIT_CODE_CAPTURE=""

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

0 comments on commit fdde32f

Please sign in to comment.