diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 8bc076b0e8f0b..891389d803a56 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -11,15 +11,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_nodejs", patch_args = ["-p1"], - patches = ["//:src/dev/bazel/rules_nodejs_patches/exclude_npm_directory_copies_from_remote_cache.patch"], - sha256 = "2b2004784358655f334925e7eadc7ba80f701144363df949b3293e1ae7a2fb7b", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.4.0/rules_nodejs-5.4.0.tar.gz"], + patches = ["//:src/dev/bazel/rules_nodejs_patches/normalized_paths_for_windows_runfiles.patch"], + sha256 = "6f15d75f9e99c19d9291ff8e64e4eb594a6b7d25517760a75ad3621a7a48c2df", + urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.7.0/rules_nodejs-4.7.0.tar.gz"], ) -# Build Node.js rules dependencies -load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies") -build_bazel_rules_nodejs_dependencies() - # Now that we have the rules let's import from them to complete the work load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install") @@ -41,7 +37,7 @@ node_repositories( node_urls = [ "https://nodejs.org/dist/v{version}/{filename}", ], - yarn_releases = { + yarn_repositories = { "1.21.1": ("yarn-v1.21.1.tar.gz", "yarn-v1.21.1", "d1d9f4a0f16f5ed484e814afeb98f39b82d4728c6c8beaafb5abc99c02db6674"), }, yarn_version = "1.21.1", diff --git a/package.json b/package.json index 2d8c60eeb67b4..e87b66ef0d6cf 100644 --- a/package.json +++ b/package.json @@ -459,7 +459,7 @@ "@babel/traverse": "^7.17.3", "@babel/types": "^7.17.0", "@bazel/ibazel": "^0.16.2", - "@bazel/typescript": "5.4.0", + "@bazel/typescript": "4.6.2", "@cypress/code-coverage": "^3.9.12", "@cypress/snapshot": "^2.1.7", "@cypress/webpack-preprocessor": "^5.6.0", diff --git a/packages/kbn-type-summarizer/BUILD.bazel b/packages/kbn-type-summarizer/BUILD.bazel index 4399e62f11a77..13a28657f2f0e 100644 --- a/packages/kbn-type-summarizer/BUILD.bazel +++ b/packages/kbn-type-summarizer/BUILD.bazel @@ -1,6 +1,5 @@ load("@npm//@bazel/typescript:index.bzl", "ts_config") -load("@rules_nodejs//nodejs:directory_file_path.bzl", "directory_file_path") -load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "nodejs_binary") +load("@build_bazel_rules_nodejs//:index.bzl", "directory_file_path", "js_library", "nodejs_binary") load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") PKG_BASE_NAME = "kbn-type-summarizer" diff --git a/src/dev/bazel/pkg_npm_types.bzl b/src/dev/bazel/pkg_npm_types.bzl index 392a8185d9563..e5caba5149053 100644 --- a/src/dev/bazel/pkg_npm_types.bzl +++ b/src/dev/bazel/pkg_npm_types.bzl @@ -6,7 +6,7 @@ # Side Public License, v 1. # -load("@rules_nodejs//nodejs/private:ts_config.bzl", "TsConfigInfo") +load("@npm//@bazel/typescript/internal:ts_config.bzl", "TsConfigInfo") load("@build_bazel_rules_nodejs//:providers.bzl", "run_node", "LinkablePackageInfo", "DeclarationInfo", "declaration_info") load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "module_mappings_aspect") @@ -142,7 +142,7 @@ pkg_npm_types = rule( "_packager": attr.label( doc = "Target that executes the npm types package assembler binary", executable = True, - cfg = "exec", + cfg = "host", default = Label("//packages/kbn-type-summarizer:bazel-cli"), ), }, diff --git a/src/dev/bazel/rules_nodejs_patches/exclude_npm_directory_copies_from_remote_cache.patch b/src/dev/bazel/rules_nodejs_patches/exclude_npm_directory_copies_from_remote_cache.patch deleted file mode 100644 index 71a99ced83d72..0000000000000 --- a/src/dev/bazel/rules_nodejs_patches/exclude_npm_directory_copies_from_remote_cache.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/third_party/github.com/bazelbuild/bazel-skylib/rules/private/copy_file_private.bzl b/third_party/github.com/bazelbuild/bazel-skylib/rules/private/copy_file_private.bzl -index a719174c..273322d0 100644 ---- a/third_party/github.com/bazelbuild/bazel-skylib/rules/private/copy_file_private.bzl -+++ b/third_party/github.com/bazelbuild/bazel-skylib/rules/private/copy_file_private.bzl -@@ -30,7 +30,9 @@ _execution_requirements = { - # Also, remote-execution does not allow source directory inputs, see - # https://github.com/bazelbuild/bazel/commit/c64421bc35214f0414e4f4226cc953e8c55fa0d2 - # So we must not attempt to execute remotely in that case. -- "no-remote-exec": "1", -+ # no-remote | Prevents the action or test from being executed remotely or cached remotely. -+ # | This is equivalent to using both `no-remote-cache` and `no-remote-exec`. -+ "no-remote": "1", - } - - def _hash_file(file): diff --git a/src/dev/bazel/rules_nodejs_patches/normalized_paths_for_windows_runfiles.patch b/src/dev/bazel/rules_nodejs_patches/normalized_paths_for_windows_runfiles.patch new file mode 100644 index 0000000000000..84a9e4a497919 --- /dev/null +++ b/src/dev/bazel/rules_nodejs_patches/normalized_paths_for_windows_runfiles.patch @@ -0,0 +1,52 @@ +diff --git a/internal/node/launcher.sh b/internal/node/launcher.sh +index fd832d02..64820f48 100644 +--- a/internal/node/launcher.sh ++++ b/internal/node/launcher.sh +@@ -13,6 +13,32 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + ++# It helps to determine if we are running on a Windows environment (excludes WSL as it acts like Unix) ++function isWindows { ++ case "$(uname -s)" in ++ CYGWIN*) local IS_WINDOWS=1 ;; ++ MINGW*) local IS_WINDOWS=1 ;; ++ MSYS_NT*) local IS_WINDOWS=1 ;; ++ *) local IS_WINDOWS=0 ;; ++ esac ++ ++ echo $IS_WINDOWS ++ return ++} ++ ++# It helps to normalizes paths when running on Windows. ++# ++# Example: ++# C:/Users/XUser/_bazel_XUser/7q7kkv32/execroot/A/b/C -> /c/users/xuser/_bazel_xuser/7q7kkv32/execroot/a/b/c ++function normalizeWindowsPath { ++ # Apply the followings paths transformations to normalize paths on Windows ++ # -process driver letter ++ # -convert path separator ++ # -lowercase everything ++ echo $(sed -e 's#^\(.\):#/\L\1#' -e 's#\\#/#g' -e 's/[A-Z]/\L&/g' <<< "$1") ++ return ++} ++ + # --- begin runfiles.bash initialization v2 --- + # Copy-pasted from the Bazel Bash runfiles library v2. + set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash +@@ -49,7 +75,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + # Case 6a is handled like case 3. + if [[ -n "${RUNFILES_MANIFEST_ONLY:-}" ]]; then + # Windows only has a manifest file instead of symlinks. +- RUNFILES=${RUNFILES_MANIFEST_FILE%/MANIFEST} ++ if [[ $(isWindows) -eq "1" ]]; then ++ # If Windows normalizing the path and case insensitive removing the `/MANIFEST` part of the path ++ NORMALIZED_RUNFILES_MANIFEST_FILE_PATH=$(normalizeWindowsPath $RUNFILES_MANIFEST_FILE) ++ RUNFILES=$(sed 's|\/MANIFEST$||i' <<< $NORMALIZED_RUNFILES_MANIFEST_FILE_PATH) ++ else ++ RUNFILES=${RUNFILES_MANIFEST_FILE%/MANIFEST} ++ fi + elif [[ -n "${TEST_SRCDIR:-}" ]]; then + # Case 4, bazel has identified runfiles for us. + RUNFILES="${TEST_SRCDIR:-}" diff --git a/yarn.lock b/yarn.lock index 3c5ef9358a8b2..541610bd2e854 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1228,21 +1228,21 @@ resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.16.2.tgz#05dd7f06659759fda30f87b15534f1e42f1201bb" integrity sha512-KgqAWMH0emL6f3xH6nqyTryoBMqlJ627LBIe9PT1PRRQPz2FtHib3FIHJPukp1slzF3hJYZvdiVwgPnHbaSOOA== -"@bazel/typescript@5.4.0": - version "5.4.0" - resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-5.4.0.tgz#0a24e8d47152728f71b26b73adc3913645e5309e" - integrity sha512-AWmS9HcnjqGsPQv5lnqecA8xof+d4ChpbI/Z6aiSM0qOemc8e1WT9wb1VzM6g6hRfV5foWyIHt0VhTonTsPhYw== +"@bazel/typescript@4.6.2": + version "4.6.2" + resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-4.6.2.tgz#9f07b6f8cfb6b0a0e228e5971de412911c910a90" + integrity sha512-AUF7kq82bP6DX9Brihr/eQqvNccxVfSXosFxt80h94og5cmMyoc/euXha6rxlOBP3yWXmSo+/qjzO7o8PWJduQ== dependencies: - "@bazel/worker" "5.4.0" + "@bazel/worker" "4.6.2" protobufjs "6.8.8" semver "5.6.0" source-map-support "0.5.9" tsutils "3.21.0" -"@bazel/worker@5.4.0": - version "5.4.0" - resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-5.4.0.tgz#ce50e34951ccf7233b651f0be665bbd43d7ed7f1" - integrity sha512-Rtkol9WoYs0NCZl1wt4Q8T7Rs0wbQjIvFiJzVeeoC/00TG0e/qi4mYE5iQwUJmO8st3N8VnaWz2N31UHc6yhRA== +"@bazel/worker@4.6.2": + version "4.6.2" + resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-4.6.2.tgz#0bd105344533335327c2edfa3fc65b04c39cdea8" + integrity sha512-DLpN6iQAH6uiUraAs4CESyqs60u55fcKmYgOOVObGuLSQQuX49Lw7XRIN90NibRPwpbBDQichWE3zfra0yKTTw== dependencies: google-protobuf "^3.6.1"