Skip to content
Merged
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
21 changes: 11 additions & 10 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ workspace(

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

NODE_VERSION = "20.11.1"

# The PKG rules are needed to build tar packages for integration tests. The builtin
# rule in `@bazel_tools` is not Windows compatible and outdated.
http_archive(
Expand All @@ -29,6 +27,9 @@ http_archive(
# Fetch rules_nodejs and install its dependencies so we can install our npm dependencies.
http_archive(
name = "build_bazel_rules_nodejs",
patches = [
"//tools:bazel-patches/build_bazel_rules_nodejs.patch",
],
sha256 = "709cc0dcb51cf9028dd57c268066e5bc8f03a119ded410a13b5c3925d6e43c48",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.4/rules_nodejs-5.8.4.tar.gz"],
)
Expand All @@ -42,15 +43,15 @@ load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
nodejs_register_toolchains(
name = "nodejs",
node_repositories = {
"20.11.1-darwin_arm64": ("node-v20.11.1-darwin-arm64.tar.gz", "node-v20.11.1-darwin-arm64", "e0065c61f340e85106a99c4b54746c5cee09d59b08c5712f67f99e92aa44995d"),
"20.11.1-darwin_amd64": ("node-v20.11.1-darwin-x64.tar.gz", "node-v20.11.1-darwin-x64", "c52e7fb0709dbe63a4cbe08ac8af3479188692937a7bd8e776e0eedfa33bb848"),
"20.11.1-linux_arm64": ("node-v20.11.1-linux-arm64.tar.xz", "node-v20.11.1-linux-arm64", "c957f29eb4e341903520caf362534f0acd1db7be79c502ae8e283994eed07fe1"),
"20.11.1-linux_ppc64le": ("node-v20.11.1-linux-ppc64le.tar.xz", "node-v20.11.1-linux-ppc64le", "51343cacf5cdf5c4b5e93e919d19dd373d6ef43d5f2c666eae299f26e31d08b5"),
"20.11.1-linux_s390x": ("node-v20.11.1-linux-s390x.tar.xz", "node-v20.11.1-linux-s390x", "b32616b705cd0ddbb230b95c693e3d7a37becc2ced9bcadea8dc824cceed6be0"),
"20.11.1-linux_amd64": ("node-v20.11.1-linux-x64.tar.xz", "node-v20.11.1-linux-x64", "d8dab549b09672b03356aa2257699f3de3b58c96e74eb26a8b495fbdc9cf6fbe"),
"20.11.1-windows_amd64": ("node-v20.11.1-win-x64.zip", "node-v20.11.1-win-x64", "bc032628d77d206ffa7f133518a6225a9c5d6d9210ead30d67e294ff37044bda"),
"20.19.0-darwin_arm64": ("node-v20.19.0-darwin-arm64.tar.gz", "node-v20.19.0-darwin-arm64", "c016cd1975a264a29dc1b07c6fbe60d5df0a0c2beb4113c0450e3d998d1a0d9c"),
"20.19.0-darwin_amd64": ("node-v20.19.0-darwin-x64.tar.gz", "node-v20.19.0-darwin-x64", "a8554af97d6491fdbdabe63d3a1cfb9571228d25a3ad9aed2df856facb131b20"),
"20.19.0-linux_arm64": ("node-v20.19.0-linux-arm64.tar.xz", "node-v20.19.0-linux-arm64", "dbe339e55eb393955a213e6b872066880bb9feceaa494f4d44c7aac205ec2ab9"),
"20.19.0-linux_ppc64le": ("node-v20.19.0-linux-ppc64le.tar.xz", "node-v20.19.0-linux-ppc64le", "84937108f005679e60b486ed8e801cebfe923f02b76d8e710463d32f82181f65"),
"20.19.0-linux_s390x": ("node-v20.19.0-linux-s390x.tar.xz", "node-v20.19.0-linux-s390x", "11f8ee99d792a83bba7b29911e0229dd6cd5e88987d7416346067db1cc76d89a"),
"20.19.0-linux_amd64": ("node-v20.19.0-linux-x64.tar.xz", "node-v20.19.0-linux-x64", "b4e336584d62abefad31baecff7af167268be9bb7dd11f1297112e6eed3ca0d5"),
"20.19.0-windows_amd64": ("node-v20.19.0-win-x64.zip", "node-v20.19.0-win-x64", "be72284c7bc62de07d5a9fd0ae196879842c085f11f7f2b60bf8864c0c9d6a4f"),
},
node_version = NODE_VERSION,
node_version = "20.19.0",
)

http_archive(
Expand Down
131 changes: 131 additions & 0 deletions tools/bazel-patches/build_bazel_rules_nodejs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
diff --git internal/node/node_patches.cjs internal/node/node_patches.cjs
index 239bb5f..1c02e06 100755
--- internal/node/node_patches.cjs
+++ internal/node/node_patches.cjs
@@ -15,7 +15,7 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof win

function createCommonjsModule(fn) {
var module = { exports: {} };
- return fn(module, module.exports), module.exports;
+ return fn(module, module.exports), module.exports;
}

var fs = createCommonjsModule(function (module, exports) {
@@ -95,7 +95,7 @@ const patcher = (fs = fs__default['default'], roots) => {
args[args.length - 1] = (err, stats) => {
if (err)
return cb(err);
- path__default['default'].resolve(args[0]);
+ path__default['default'].resolve(args[0].toString());
if (!stats.isSymbolicLink()) {
return cb(null, stats);
}
@@ -116,7 +116,7 @@ const patcher = (fs = fs__default['default'], roots) => {
return cb(err);
}
}
- str = path__default['default'].resolve(path__default['default'].dirname(args[0]), str);
+ str = path__default['default'].resolve(path__default['default'].dirname(args[0].toString()), str);
if (isEscape(str, args[0])) {
// if it's an out link we have to return the original stat.
return origStat(args[0], (err, plainStat) => {
@@ -143,7 +143,7 @@ const patcher = (fs = fs__default['default'], roots) => {
if (err)
return cb(err);
if (isEscape(str, args[0])) {
- cb(null, path__default['default'].resolve(args[0]));
+ cb(null, path__default['default'].resolve(args[0].toString()));
}
else {
cb(null, str);
@@ -161,7 +161,7 @@ const patcher = (fs = fs__default['default'], roots) => {
if (err)
return cb(err);
if (isEscape(str, args[0])) {
- cb(null, path__default['default'].resolve(args[0]));
+ cb(null, path__default['default'].resolve(args[0].toString()));
}
else {
cb(null, str);
@@ -176,9 +176,9 @@ const patcher = (fs = fs__default['default'], roots) => {
if (cb) {
cb = once(cb);
args[args.length - 1] = (err, str) => {
- args[0] = path__default['default'].resolve(args[0]);
+ args[0] = path__default['default'].resolve(args[0].toString());
if (str)
- str = path__default['default'].resolve(path__default['default'].dirname(args[0]), str);
+ str = path__default['default'].resolve(path__default['default'].dirname(args[0].toString()), str);
if (err)
return cb(err);
if (isEscape(str, args[0])) {
@@ -196,13 +196,13 @@ const patcher = (fs = fs__default['default'], roots) => {
// tslint:disable-next-line:no-any
fs.lstatSync = (...args) => {
const stats = origLstatSync(...args);
- const linkPath = path__default['default'].resolve(args[0]);
+ const linkPath = path__default['default'].resolve(args[0].toString());
if (!stats.isSymbolicLink()) {
return stats;
}
let linkTarget;
try {
- linkTarget = path__default['default'].resolve(path__default['default'].dirname(args[0]), origReadlinkSync(linkPath));
+ linkTarget = path__default['default'].resolve(path__default['default'].dirname(args[0].toString()), origReadlinkSync(linkPath));
}
catch (e) {
if (e.code === 'ENOENT') {
@@ -228,7 +228,7 @@ const patcher = (fs = fs__default['default'], roots) => {
fs.realpathSync = (...args) => {
const str = origRealpathSync(...args);
if (isEscape(str, args[0])) {
- return path__default['default'].resolve(args[0]);
+ return path__default['default'].resolve(args[0].toString());
}
return str;
};
@@ -236,14 +236,14 @@ const patcher = (fs = fs__default['default'], roots) => {
fs.realpathSync.native = (...args) => {
const str = origRealpathSyncNative(...args);
if (isEscape(str, args[0])) {
- return path__default['default'].resolve(args[0]);
+ return path__default['default'].resolve(args[0].toString());
}
return str;
};
// tslint:disable-next-line:no-any
fs.readlinkSync = (...args) => {
- args[0] = path__default['default'].resolve(args[0]);
- const str = path__default['default'].resolve(path__default['default'].dirname(args[0]), origReadlinkSync(...args));
+ args[0] = path__default['default'].resolve(args[0].toString());
+ const str = path__default['default'].resolve(path__default['default'].dirname(args[0].toString()), origReadlinkSync(...args));
if (isEscape(str, args[0]) || str === args[0]) {
const e = new Error('EINVAL: invalid argument, readlink \'' + args[0] + '\'');
// tslint:disable-next-line:no-any
@@ -254,7 +254,7 @@ const patcher = (fs = fs__default['default'], roots) => {
};
// tslint:disable-next-line:no-any
fs.readdir = (...args) => {
- const p = path__default['default'].resolve(args[0]);
+ const p = path__default['default'].resolve(args[0].toString());
let cb = args[args.length - 1];
if (typeof cb !== 'function') {
// this will likely throw callback required error.
@@ -284,7 +284,7 @@ const patcher = (fs = fs__default['default'], roots) => {
// tslint:disable-next-line:no-any
fs.readdirSync = (...args) => {
const res = origReaddirSync(...args);
- const p = path__default['default'].resolve(args[0]);
+ const p = path__default['default'].resolve(args[0].toString());
// tslint:disable-next-line:no-any
res.forEach((v) => {
handleDirentSync(p, v);
@@ -504,6 +504,8 @@ const escapeFunction = (roots) => {
// ensure roots are always absolute
roots = roots.map(root => path__default['default'].resolve(root));
function isEscape(linkTarget, linkPath) {
+ linkTarget = linkTarget.toString();
+ linkPath = linkPath.toString();
if (!path__default['default'].isAbsolute(linkPath)) {
linkPath = path__default['default'].resolve(linkPath);
}