Patch rules_nodejs library to fix wrong regex string escape

On stable-3.2 branch outdated version of rules_nodejs version is used:
1.5, that suffers from usage of wrong regular expression escapes. More
recent Bazel versions added a check for that regex string escape pattern
and flagging the external rules_nodejs repository as invalid.

Given that upgrade path to recent rules_nodejs version is not a trivial
one: 1.5 => 1.7 => 2.0, and given that also plugins would need to be
updated, we prefer to keep that outdated rules_nodejs version as-is and
patch the wrong line in rules_nodejs distribution instead.

That would allow us to upgrade to recent bazel versions on stable-3.2
branch. We prefer to keep the same Bazel version on all supported stable
branches to reduce/avoid rebuilds when switching between branches.

Note, that this workaround should be reverted when this change is merged
up to master branch.

Change-Id: Ia99ea8398ea87847c27d75f8e47099b2c04c9186
This commit is contained in:
David Ostrovsky 2021-02-07 15:56:55 +01:00
parent d505c2f32d
commit b5867f452b
2 changed files with 14 additions and 0 deletions

View File

@ -60,6 +60,8 @@ http_archive(
http_archive(
name = "build_bazel_rules_nodejs",
patch_args = ["-p1"],
patches = ["//:rules_nodejs-1.5.patch"],
sha256 = "d0c4bb8b902c1658f42eb5563809c70a06e46015d64057d25560b0eb4bdc9007",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.5.0/rules_nodejs-1.5.0.tar.gz"],
)

12
rules_nodejs-1.5.patch Normal file
View File

@ -0,0 +1,12 @@
--- build_bazel_rules_nodejs/internal/node/node.bzl 2021-02-07 16:09:38.099484740 +0100
+++ build_bazel_rules_nodejs/internal/node/node_fixed.bzl 2021-02-07 16:10:33.583847582 +0100
@@ -87,6 +87,6 @@
for d in ctx.attr.data:
if hasattr(d, "runfiles_module_mappings"):
for [mn, mr] in d.runfiles_module_mappings.items():
- escaped = mn.replace("/", "\/").replace(".", "\.")
+ escaped = mn.replace("/", "\\/").replace(".", "\\.")
mapping = "{module_name: /^%s\\b/, module_root: '%s'}" % (escaped, mr)
module_mappings.append(mapping)