-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: explicitly use runfiles helper #2341
Conversation
This reduces our dependence on the monkey-patched require() that makes NodeJS look at the runfiles manifest when resolving modules. Pre-factoring for changing the default of --bazel_patch_module_resolver to false
7e0ff94
to
36fdb9a
Compare
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
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
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
Is there an example of how we can apply this fix without resorting to Also fwiw, it seems like this could be a really nasty bug for someone that tired using >3.0.0 first without needing to migrate. I would expect the code in the repro to work out of the box, and the error itself is not very searchable. Not sure how I would've found the fix if I didn't know that migrating versions was the cause. The examples with ts_project also doesn't have any that involve nodejs_binary afaik. |
Broken out from https://github.com/bazelbuild/rules_nodejs/pull/2324/files