diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh index 05f74f566e..85008cee65 100755 --- a/.github/workflows/release_prep.sh +++ b/.github/workflows/release_prep.sh @@ -33,7 +33,7 @@ bazel_dep(name = "aspect_rules_js", version = "${TAG:1}") ####### Node.js version ######### # By default you get the node version from DEFAULT_NODE_VERSION in @rules_nodejs//nodejs:repositories.bzl # Optionally you can pin a different node version: -bazel_dep(name = "rules_nodejs", version = "5.8.2") +bazel_dep(name = "rules_nodejs", version = "6.0.5") node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node") node.toolchain(node_version = "16.14.2") ################################# diff --git a/MODULE.bazel b/MODULE.bazel index 01e43969b7..84cfdcb7aa 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -12,19 +12,16 @@ bazel_dep(name = "aspect_bazel_lib", version = "2.6.1") bazel_dep(name = "aspect_rules_lint", version = "0.12.0") bazel_dep(name = "bazel_features", version = "1.9.0") bazel_dep(name = "bazel_skylib", version = "1.5.0") +bazel_dep(name = "rules_nodejs", version = "6.0.5") +bazel_dep(name = "platforms", version = "0.0.5") -# Keep v5 in to avoid breaking changes. -# TODO(2.0): change minimum to v6 -bazel_dep(name = "rules_nodejs", version = "5.8.2") - -# Override rules_nodejs to v6 to test the latest and recommended version internally. -single_version_override( +archive_override( module_name = "rules_nodejs", - version = "6.0.5", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], ) -bazel_dep(name = "platforms", version = "0.0.5") - node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node") use_repo(node, "nodejs_darwin_amd64") use_repo(node, "nodejs_darwin_arm64") diff --git a/WORKSPACE b/WORKSPACE index 4f6f21f6ad..e1f8e2540a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,38 +3,23 @@ workspace( name = "aspect_rules_js", ) -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -# Override rules_nodejs to v6 to test the latest and recommended versional internally, -# while keeping v5 in rules_js_dependencies() to avoid breaking changes. -# TODO(2.0): change minimum to v6 in repositories.bzl -http_archive( - name = "rules_nodejs", - sha256 = "a50986c7d2f2dc43a5b9b81a6245fd89bdc4866f1d5e316d9cef2782dd859292", - strip_prefix = "rules_nodejs-6.0.5", - url = "https://github.com/bazelbuild/rules_nodejs/releases/download/v6.0.5/rules_nodejs-v6.0.5.tar.gz", -) - -load("//js:dev_repositories.bzl", "rules_js_dev_dependencies") +load("@aspect_rules_js//js:dev_repositories.bzl", "rules_js_dev_dependencies") rules_js_dev_dependencies() -load("//js:repositories.bzl", "rules_js_dependencies") +load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "register_jq_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -aspect_bazel_lib_dependencies() +rules_js_configure(node_version = "16.14.2") -register_jq_toolchains() +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") -load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") +aspect_bazel_lib_dependencies() -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.14.2", -) +load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") # Alternate toolchains for testing across versions nodejs_register_toolchains( diff --git a/docs/npm_import.md b/docs/npm_import.md index 7617c7edfb..11040adf78 100644 --- a/docs/npm_import.md +++ b/docs/npm_import.md @@ -28,8 +28,7 @@ npm_import(name, pa link_workspace, link_packages, lifecycle_hooks, lifecycle_hooks_execution_requirements, lifecycle_hooks_env, lifecycle_hooks_use_default_shell_env, integrity, url, commit, replace_package, package_visibility, patch_args, patches, custom_postinstall, npm_auth, - npm_auth_basic, npm_auth_username, npm_auth_password, bins, dev, - register_copy_directory_toolchains, register_copy_to_directory_toolchains, kwargs) + npm_auth_basic, npm_auth_username, npm_auth_password, bins, dev, kwargs) Import a single npm package into Bazel. @@ -161,8 +160,6 @@ Read more about the downloader config: <https://blog.aspect.dev/configuring-b | npm_auth_password | Auth password to authenticate with npm. When using Basic authentication. | "" | | bins | Dictionary of node_modules/.bin binary files to create mapped to their node entry points.

This is typically derived from the "bin" attribute in the package.json file of the npm package being linked.

For example:

 bins = {     "foo": "./foo.js",     "bar": "./bar.js", } 


In the future, this field may be automatically populated by npm_translate_lock from information in the pnpm lock file. That feature is currently blocked on https://github.com/pnpm/pnpm/issues/5131. | {} | | dev | Whether this npm package is a dev dependency | False | -| register_copy_directory_toolchains | if True, @aspect_bazel_lib//lib:repositories.bzl register_copy_directory_toolchains() is called if the toolchain is not already registered | True | -| register_copy_to_directory_toolchains | if True, @aspect_bazel_lib//lib:repositories.bzl register_copy_to_directory_toolchains() is called if the toolchain is not already registered | True | | kwargs | Internal use only | none | diff --git a/docs/npm_package.md b/docs/npm_package.md index 7f536f9cd0..434ce8fd1d 100644 --- a/docs/npm_package.md +++ b/docs/npm_package.md @@ -146,14 +146,6 @@ This ensures that actions which use the package.json file can get cache hits. For more information on stamping, read https://docs.aspect.build/rules/aspect_bazel_lib/docs/stamping. -Using this rule requires that you register the jq toolchain in your WORKSPACE: - -```starlark -load("@aspect_bazel_lib//lib:repositories.bzl", "register_jq_toolchains") - -register_jq_toolchains() -``` - **PARAMETERS** diff --git a/docs/npm_translate_lock.md b/docs/npm_translate_lock.md index b5a41caa73..6cfbceea01 100644 --- a/docs/npm_translate_lock.md +++ b/docs/npm_translate_lock.md @@ -67,8 +67,6 @@ npm_translate_lock(name, lifecycle_hooks_use_default_shell_env, replace_packages, bins, verify_node_modules_ignored, verify_patches, quiet, external_repository_action_cache, link_workspace, pnpm_version, use_pnpm, - register_copy_directory_toolchains, register_copy_to_directory_toolchains, - register_coreutils_toolchains, register_yq_toolchains, register_tar_toolchains, npm_package_target_name, use_starlark_yaml_parser, kwargs) @@ -133,11 +131,6 @@ For more about how to use npm_translate_lock, read [pnpm and rules_js](/docs/pnp | link_workspace | The workspace name where links will be created for the packages in this lock file.

This is typically set in rule sets and libraries that vendor the starlark generated by npm_translate_lock so the link_workspace passed to npm_import is set correctly so that links are created in the external repository and not the user workspace.

Can be left unspecified if the link workspace is the user workspace. | None | | pnpm_version | pnpm version to use when generating the @pnpm repository. Set to None to not create this repository.

Can be left unspecified and the rules_js default LATEST_PNPM_VERSION will be used.

Use use_pnpm for bzlmod. | "8.15.3" | | use_pnpm | label of the pnpm extension to use.

Can be left unspecified and the rules_js default pnpm extension (with the LATEST_PNPM_VERSION) will be used.

Use pnpm_version for non-bzlmod. | None | -| register_copy_directory_toolchains | if True, @aspect_bazel_lib//lib:repositories.bzl register_copy_directory_toolchains() is called if the toolchain is not already registered | True | -| register_copy_to_directory_toolchains | if True, @aspect_bazel_lib//lib:repositories.bzl register_copy_to_directory_toolchains() is called if the toolchain is not already registered | True | -| register_coreutils_toolchains | if True, @aspect_bazel_lib//lib:repositories.bzl register_coreutils_toolchains() is called if the toolchain is not already registered | True | -| register_yq_toolchains | if True, @aspect_bazel_lib//lib:repositories.bzl register_yq_toolchains() is called if the toolchain is not already registered | True | -| register_tar_toolchains | if True, @aspect_bazel_lib//lib:repositories.bzl register_tar_toolchains() is called if the toolchain is not already registered | True | | npm_package_target_name | The name of linked npm_package targets. When npm_package targets are linked as pnpm workspace packages, the name of the target must align with this value.

The {dirname} placeholder is replaced with the directory name of the target.

By default the directory name of the target is used.

Default: {dirname} | "{dirname}" | | use_starlark_yaml_parser | Opt-out of using yq to parse the pnpm-lock file which was added in https://github.com/aspect-build/rules_js/pull/1458 and use the legacy starlark yaml parser instead.

This opt-out is a return safety in cases where yq is not able to parse the pnpm generated yaml file. For example, this has been observed to happen due to a line such as the following in the pnpm generated lock file:

 resolution: {tarball: https://gitpkg.vercel.app/blockprotocol/blockprotocol/packages/%40blockprotocol/type-system-web?6526c0e} 


where the ? character in the tarball value causes yq to fail with:

 $ yq pnpm-lock.yaml -o=json Error: bad file 'pnpm-lock.yaml': yaml: line 7129: did not find expected ',' or '}' 


If the tarball value is quoted or escaped then yq would accept it but as of this writing, the latest version of pnpm (8.14.3) does not quote or escape such a value and the latest version of yq (4.40.5) does not handle it as is.

Possibly related to https://github.com/pnpm/pnpm/issues/5414. | False | | kwargs | Internal use only | none | diff --git a/e2e/bzlmod/MODULE.bazel b/e2e/bzlmod/MODULE.bazel index 63dc45f18f..34fdd06c60 100644 --- a/e2e/bzlmod/MODULE.bazel +++ b/e2e/bzlmod/MODULE.bazel @@ -13,6 +13,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension( "@aspect_rules_js//npm:extensions.bzl", "npm", diff --git a/e2e/git_dep_metadata/MODULE.bazel b/e2e/git_dep_metadata/MODULE.bazel index 53790230c4..6c51686e57 100644 --- a/e2e/git_dep_metadata/MODULE.bazel +++ b/e2e/git_dep_metadata/MODULE.bazel @@ -9,6 +9,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension( "@aspect_rules_js//npm:extensions.bzl", "npm", diff --git a/e2e/git_dep_metadata/WORKSPACE b/e2e/git_dep_metadata/WORKSPACE index 639f1b98cf..3aff4b101b 100644 --- a/e2e/git_dep_metadata/WORKSPACE +++ b/e2e/git_dep_metadata/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_import") diff --git a/e2e/gyp_no_install_script/MODULE.bazel b/e2e/gyp_no_install_script/MODULE.bazel index 1372781b93..cee18937c0 100644 --- a/e2e/gyp_no_install_script/MODULE.bazel +++ b/e2e/gyp_no_install_script/MODULE.bazel @@ -5,6 +5,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/gyp_no_install_script/WORKSPACE b/e2e/gyp_no_install_script/WORKSPACE index a7c5ba1c23..32a7bbbd8d 100644 --- a/e2e/gyp_no_install_script/WORKSPACE +++ b/e2e/gyp_no_install_script/WORKSPACE @@ -16,12 +16,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/js_image_docker/WORKSPACE b/e2e/js_image_docker/WORKSPACE index 0c87270dac..bfbc19295e 100644 --- a/e2e/js_image_docker/WORKSPACE +++ b/e2e/js_image_docker/WORKSPACE @@ -12,12 +12,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.14.2", -) +rules_js_configure(node_version = "16.14.2") load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/js_image_oci/WORKSPACE b/e2e/js_image_oci/WORKSPACE index 9e7df1dd8b..69fb64f45a 100644 --- a/e2e/js_image_oci/WORKSPACE +++ b/e2e/js_image_oci/WORKSPACE @@ -14,12 +14,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.14.2", -) +rules_js_configure(node_version = "16.14.2") load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/js_run_devserver/MODULE.bazel b/e2e/js_run_devserver/MODULE.bazel index d618ac47af..c4065af92b 100644 --- a/e2e/js_run_devserver/MODULE.bazel +++ b/e2e/js_run_devserver/MODULE.bazel @@ -14,6 +14,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm") use_repo(pnpm, "pnpm") diff --git a/e2e/js_run_devserver/WORKSPACE b/e2e/js_run_devserver/WORKSPACE index 762ce191fe..0df90cadca 100644 --- a/e2e/js_run_devserver/WORKSPACE +++ b/e2e/js_run_devserver/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_link_package-esm/WORKSPACE b/e2e/npm_link_package-esm/WORKSPACE index cfe378efb9..8003b7365a 100644 --- a/e2e/npm_link_package-esm/WORKSPACE +++ b/e2e/npm_link_package-esm/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.9.0", -) +rules_js_configure(node_version = "16.9.0") load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_link_package/WORKSPACE b/e2e/npm_link_package/WORKSPACE index 4a853a1cf3..3efb3984b3 100644 --- a/e2e/npm_link_package/WORKSPACE +++ b/e2e/npm_link_package/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.14.2", -) +rules_js_configure(node_version = "16.14.2") load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock/MODULE.bazel b/e2e/npm_translate_lock/MODULE.bazel index a662b2d829..44c2cf3917 100644 --- a/e2e/npm_translate_lock/MODULE.bazel +++ b/e2e/npm_translate_lock/MODULE.bazel @@ -14,6 +14,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/npm_translate_lock/WORKSPACE b/e2e/npm_translate_lock/WORKSPACE index 5631b25e93..a385453a8a 100644 --- a/e2e/npm_translate_lock/WORKSPACE +++ b/e2e/npm_translate_lock/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_auth/MODULE.bazel b/e2e/npm_translate_lock_auth/MODULE.bazel index a08b9d0c39..72de027d28 100644 --- a/e2e/npm_translate_lock_auth/MODULE.bazel +++ b/e2e/npm_translate_lock_auth/MODULE.bazel @@ -12,6 +12,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/npm_translate_lock_auth/WORKSPACE b/e2e/npm_translate_lock_auth/WORKSPACE index 8e31b65456..025bd07a5d 100644 --- a/e2e/npm_translate_lock_auth/WORKSPACE +++ b/e2e/npm_translate_lock_auth/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_empty/MODULE.bazel b/e2e/npm_translate_lock_empty/MODULE.bazel index 0951f49973..aee100bf49 100644 --- a/e2e/npm_translate_lock_empty/MODULE.bazel +++ b/e2e/npm_translate_lock_empty/MODULE.bazel @@ -14,6 +14,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/npm_translate_lock_empty/WORKSPACE b/e2e/npm_translate_lock_empty/WORKSPACE index 6d21251f8f..699955a86b 100644 --- a/e2e/npm_translate_lock_empty/WORKSPACE +++ b/e2e/npm_translate_lock_empty/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_git+ssh/MODULE.bazel b/e2e/npm_translate_lock_git+ssh/MODULE.bazel index 8fdfa23f49..6466ac46e4 100644 --- a/e2e/npm_translate_lock_git+ssh/MODULE.bazel +++ b/e2e/npm_translate_lock_git+ssh/MODULE.bazel @@ -12,6 +12,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/npm_translate_lock_git+ssh/WORKSPACE b/e2e/npm_translate_lock_git+ssh/WORKSPACE index 8e31b65456..025bd07a5d 100644 --- a/e2e/npm_translate_lock_git+ssh/WORKSPACE +++ b/e2e/npm_translate_lock_git+ssh/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_multi/MODULE.bazel b/e2e/npm_translate_lock_multi/MODULE.bazel index 9be8a7e1b9..ebb6e1d5d8 100644 --- a/e2e/npm_translate_lock_multi/MODULE.bazel +++ b/e2e/npm_translate_lock_multi/MODULE.bazel @@ -12,6 +12,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "app1_npm", diff --git a/e2e/npm_translate_lock_multi/WORKSPACE b/e2e/npm_translate_lock_multi/WORKSPACE index bdd846b2a0..d9dea8cc7f 100644 --- a/e2e/npm_translate_lock_multi/WORKSPACE +++ b/e2e/npm_translate_lock_multi/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_partial_clone/MODULE.bazel b/e2e/npm_translate_lock_partial_clone/MODULE.bazel index 6ab0ba32f3..5974e9f0c1 100644 --- a/e2e/npm_translate_lock_partial_clone/MODULE.bazel +++ b/e2e/npm_translate_lock_partial_clone/MODULE.bazel @@ -12,6 +12,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/npm_translate_lock_partial_clone/WORKSPACE b/e2e/npm_translate_lock_partial_clone/WORKSPACE index 58a8f42bb5..dbf6cc5755 100644 --- a/e2e/npm_translate_lock_partial_clone/WORKSPACE +++ b/e2e/npm_translate_lock_partial_clone/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_subdir_patch/MODULE.bazel b/e2e/npm_translate_lock_subdir_patch/MODULE.bazel index 07f4464bb0..d638129a09 100644 --- a/e2e/npm_translate_lock_subdir_patch/MODULE.bazel +++ b/e2e/npm_translate_lock_subdir_patch/MODULE.bazel @@ -5,6 +5,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/npm_translate_lock_subdir_patch/WORKSPACE b/e2e/npm_translate_lock_subdir_patch/WORKSPACE index 5d76c85843..4623334162 100644 --- a/e2e/npm_translate_lock_subdir_patch/WORKSPACE +++ b/e2e/npm_translate_lock_subdir_patch/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_package_lock/MODULE.bazel b/e2e/npm_translate_package_lock/MODULE.bazel index cfb93b3cf3..dbc816ae20 100644 --- a/e2e/npm_translate_package_lock/MODULE.bazel +++ b/e2e/npm_translate_package_lock/MODULE.bazel @@ -12,6 +12,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/npm_translate_package_lock/WORKSPACE b/e2e/npm_translate_package_lock/WORKSPACE index c679ded11c..a1dba35c5d 100644 --- a/e2e/npm_translate_package_lock/WORKSPACE +++ b/e2e/npm_translate_package_lock/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_yarn_lock/MODULE.bazel b/e2e/npm_translate_yarn_lock/MODULE.bazel index a963a45c13..56fe685fe5 100644 --- a/e2e/npm_translate_yarn_lock/MODULE.bazel +++ b/e2e/npm_translate_yarn_lock/MODULE.bazel @@ -12,6 +12,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm") pnpm.pnpm( name = "pnpm-old-version", diff --git a/e2e/npm_translate_yarn_lock/WORKSPACE b/e2e/npm_translate_yarn_lock/WORKSPACE index f14e83126e..fccd508c07 100644 --- a/e2e/npm_translate_yarn_lock/WORKSPACE +++ b/e2e/npm_translate_yarn_lock/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/package_json_module/MODULE.bazel b/e2e/package_json_module/MODULE.bazel index e50d4f9fe9..6415c54ffb 100644 --- a/e2e/package_json_module/MODULE.bazel +++ b/e2e/package_json_module/MODULE.bazel @@ -11,6 +11,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/package_json_module/WORKSPACE b/e2e/package_json_module/WORKSPACE index ea3ccba585..ce9aad1139 100644 --- a/e2e/package_json_module/WORKSPACE +++ b/e2e/package_json_module/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/patch_from_repo/MODULE.bazel b/e2e/patch_from_repo/MODULE.bazel index b59a59ab91..9630f8b00f 100644 --- a/e2e/patch_from_repo/MODULE.bazel +++ b/e2e/patch_from_repo/MODULE.bazel @@ -8,6 +8,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + local_path_override( module_name = "local_repo", path = "./local_repo", diff --git a/e2e/patch_from_repo/WORKSPACE b/e2e/patch_from_repo/WORKSPACE index 1ccc9e8d57..4a553dfd25 100644 --- a/e2e/patch_from_repo/WORKSPACE +++ b/e2e/patch_from_repo/WORKSPACE @@ -12,12 +12,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/pnpm_repo_install/MODULE.bazel b/e2e/pnpm_repo_install/MODULE.bazel index 7d9cdfa334..121f8cf365 100644 --- a/e2e/pnpm_repo_install/MODULE.bazel +++ b/e2e/pnpm_repo_install/MODULE.bazel @@ -11,6 +11,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node") use_repo(node, "nodejs_toolchains") use_repo(node, "nodejs_darwin_amd64") diff --git a/e2e/pnpm_repo_install/WORKSPACE b/e2e/pnpm_repo_install/WORKSPACE index ea3ccba585..ce9aad1139 100644 --- a/e2e/pnpm_repo_install/WORKSPACE +++ b/e2e/pnpm_repo_install/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/pnpm_workspace/MODULE.bazel b/e2e/pnpm_workspace/MODULE.bazel index bc99a1027c..9c714d02c0 100644 --- a/e2e/pnpm_workspace/MODULE.bazel +++ b/e2e/pnpm_workspace/MODULE.bazel @@ -13,6 +13,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node") use_repo(node, "nodejs_toolchains") use_repo(node, "nodejs_darwin_amd64") diff --git a/e2e/pnpm_workspace/WORKSPACE b/e2e/pnpm_workspace/WORKSPACE index dd33ea19dc..3647d6ecef 100644 --- a/e2e/pnpm_workspace/WORKSPACE +++ b/e2e/pnpm_workspace/WORKSPACE @@ -20,12 +20,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/pnpm_workspace_deps/MODULE.bazel b/e2e/pnpm_workspace_deps/MODULE.bazel index 1943f8cb17..8b47895283 100644 --- a/e2e/pnpm_workspace_deps/MODULE.bazel +++ b/e2e/pnpm_workspace_deps/MODULE.bazel @@ -11,6 +11,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/pnpm_workspace_deps/WORKSPACE b/e2e/pnpm_workspace_deps/WORKSPACE index aaeb000e73..3918784976 100644 --- a/e2e/pnpm_workspace_deps/WORKSPACE +++ b/e2e/pnpm_workspace_deps/WORKSPACE @@ -20,12 +20,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/pnpm_workspace_rerooted/MODULE.bazel b/e2e/pnpm_workspace_rerooted/MODULE.bazel index a7e77bf4b0..f1678d5d75 100644 --- a/e2e/pnpm_workspace_rerooted/MODULE.bazel +++ b/e2e/pnpm_workspace_rerooted/MODULE.bazel @@ -12,6 +12,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node") node.toolchain( name = "nodejs", diff --git a/e2e/pnpm_workspace_rerooted/WORKSPACE b/e2e/pnpm_workspace_rerooted/WORKSPACE index 1245ca46f1..03313e9bae 100644 --- a/e2e/pnpm_workspace_rerooted/WORKSPACE +++ b/e2e/pnpm_workspace_rerooted/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.14.2", -) +rules_js_configure(node_version = "16.14.2") load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/rules_foo/WORKSPACE b/e2e/rules_foo/WORKSPACE index 4a82155329..a2ca683983 100644 --- a/e2e/rules_foo/WORKSPACE +++ b/e2e/rules_foo/WORKSPACE @@ -10,12 +10,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.14.2", -) +rules_js_configure(node_version = "16.14.2") load("@rules_foo//foo:repositories.bzl", "foo_repositories") diff --git a/e2e/stamped_package_json/MODULE.bazel b/e2e/stamped_package_json/MODULE.bazel index 47783e1b8e..9221f2d799 100644 --- a/e2e/stamped_package_json/MODULE.bazel +++ b/e2e/stamped_package_json/MODULE.bazel @@ -10,3 +10,10 @@ local_path_override( module_name = "aspect_rules_js", path = "../..", ) + +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) diff --git a/e2e/stamped_package_json/WORKSPACE b/e2e/stamped_package_json/WORKSPACE index 568e0f5dcd..f9c2003be6 100644 --- a/e2e/stamped_package_json/WORKSPACE +++ b/e2e/stamped_package_json/WORKSPACE @@ -7,6 +7,6 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@aspect_bazel_lib//lib:repositories.bzl", "register_jq_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -register_jq_toolchains() +rules_js_configure() diff --git a/e2e/update_pnpm_lock/MODULE.bazel b/e2e/update_pnpm_lock/MODULE.bazel index 665bfe9a47..6d3c937e69 100644 --- a/e2e/update_pnpm_lock/MODULE.bazel +++ b/e2e/update_pnpm_lock/MODULE.bazel @@ -12,6 +12,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/update_pnpm_lock/WORKSPACE b/e2e/update_pnpm_lock/WORKSPACE index 144abdba32..b2b8dacdc5 100644 --- a/e2e/update_pnpm_lock/WORKSPACE +++ b/e2e/update_pnpm_lock/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/update_pnpm_lock_with_import/MODULE.bazel b/e2e/update_pnpm_lock_with_import/MODULE.bazel index 0c823fa761..5b3af67879 100644 --- a/e2e/update_pnpm_lock_with_import/MODULE.bazel +++ b/e2e/update_pnpm_lock_with_import/MODULE.bazel @@ -12,6 +12,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") # Validate that we can use a yarn.lock file in place of pnpm-lock.yaml diff --git a/e2e/update_pnpm_lock_with_import/WORKSPACE b/e2e/update_pnpm_lock_with_import/WORKSPACE index 9d2b79e4a5..ec61b568db 100644 --- a/e2e/update_pnpm_lock_with_import/WORKSPACE +++ b/e2e/update_pnpm_lock_with_import/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/vendored_node/MODULE.bazel b/e2e/vendored_node/MODULE.bazel index 9edb4ac54b..deac42a65b 100644 --- a/e2e/vendored_node/MODULE.bazel +++ b/e2e/vendored_node/MODULE.bazel @@ -14,4 +14,11 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + register_toolchains("//toolchains:all") diff --git a/e2e/vendored_node/WORKSPACE b/e2e/vendored_node/WORKSPACE index bf9bddbcf6..a9743def62 100644 --- a/e2e/vendored_node/WORKSPACE +++ b/e2e/vendored_node/WORKSPACE @@ -7,9 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@bazel_features//:deps.bzl", "bazel_features_deps") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -bazel_features_deps() +rules_js_configure(register_nodejs_toolchain = False) load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") diff --git a/e2e/vendored_node/toolchains/BUILD.bazel b/e2e/vendored_node/toolchains/BUILD.bazel index 6e439e7594..afb898fc1f 100644 --- a/e2e/vendored_node/toolchains/BUILD.bazel +++ b/e2e/vendored_node/toolchains/BUILD.bazel @@ -11,7 +11,7 @@ load("@rules_nodejs//nodejs:toolchain.bzl", "node_toolchain") [ toolchain( - name = "node15_%s_toolchain" % os, + name = "node_vendored_%s_toolchain" % os, exec_compatible_with = [ "@platforms//os:" + os, "@platforms//cpu:x86_64", @@ -28,15 +28,15 @@ load("@rules_nodejs//nodejs:toolchain.bzl", "node_toolchain") node_toolchain( name = "node_linux", - target_tool = "@vendored_node_linux_amd64//:bin/node", + node = "@vendored_node_linux_amd64//:bin/node", ) node_toolchain( name = "node_macos", - target_tool = "@vendored_node_darwin_amd64//:bin/node", + node = "@vendored_node_darwin_amd64//:bin/node", ) node_toolchain( name = "node_windows", - target_tool = "@vendored_node_windows_amd64//:node.exe", + node = "@vendored_node_windows_amd64//:node.exe", ) diff --git a/e2e/vendored_tarfile/MODULE.bazel b/e2e/vendored_tarfile/MODULE.bazel index b8b4c539c6..cdc7a6233b 100644 --- a/e2e/vendored_tarfile/MODULE.bazel +++ b/e2e/vendored_tarfile/MODULE.bazel @@ -12,6 +12,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/vendored_tarfile/WORKSPACE b/e2e/vendored_tarfile/WORKSPACE index 4c75f2cfb3..08c0c9177c 100644 --- a/e2e/vendored_tarfile/WORKSPACE +++ b/e2e/vendored_tarfile/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/verify_patches/MODULE.bazel b/e2e/verify_patches/MODULE.bazel index 41b0f53703..41167a4bd3 100644 --- a/e2e/verify_patches/MODULE.bazel +++ b/e2e/verify_patches/MODULE.bazel @@ -12,6 +12,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/verify_patches/WORKSPACE b/e2e/verify_patches/WORKSPACE index 1e7cc86665..a00aa0d39a 100644 --- a/e2e/verify_patches/WORKSPACE +++ b/e2e/verify_patches/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/webpack_devserver/MODULE.bazel b/e2e/webpack_devserver/MODULE.bazel index 31b71c38e8..025362fdf8 100644 --- a/e2e/webpack_devserver/MODULE.bazel +++ b/e2e/webpack_devserver/MODULE.bazel @@ -7,6 +7,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/webpack_devserver/WORKSPACE b/e2e/webpack_devserver/WORKSPACE index afeb53a424..61814fa89a 100644 --- a/e2e/webpack_devserver/WORKSPACE +++ b/e2e/webpack_devserver/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/webpack_devserver_esm/MODULE.bazel b/e2e/webpack_devserver_esm/MODULE.bazel index 74621c676c..cdf47170f1 100644 --- a/e2e/webpack_devserver_esm/MODULE.bazel +++ b/e2e/webpack_devserver_esm/MODULE.bazel @@ -7,6 +7,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") npm.npm_translate_lock( name = "npm", diff --git a/e2e/webpack_devserver_esm/WORKSPACE b/e2e/webpack_devserver_esm/WORKSPACE index afeb53a424..61814fa89a 100644 --- a/e2e/webpack_devserver_esm/WORKSPACE +++ b/e2e/webpack_devserver_esm/WORKSPACE @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_configure() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/worker/MODULE.bazel b/e2e/worker/MODULE.bazel index 5761643951..d1d1beb1f4 100644 --- a/e2e/worker/MODULE.bazel +++ b/e2e/worker/MODULE.bazel @@ -11,6 +11,13 @@ local_path_override( path = "../..", ) +archive_override( + module_name = "rules_nodejs", + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + urls = ["https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz"], +) + node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node") use_repo(node, "nodejs_toolchains") use_repo(node, "nodejs_darwin_amd64") diff --git a/e2e/worker/WORKSPACE b/e2e/worker/WORKSPACE index fd70c11374..267b700391 100644 --- a/e2e/worker/WORKSPACE +++ b/e2e/worker/WORKSPACE @@ -7,14 +7,7 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - # nodejs 14 is used intentionally here, to assert AbortController polyfill is installed properly. - node_version = "14.20.0", -) - -load("@bazel_features//:deps.bzl", "bazel_features_deps") - -bazel_features_deps() +# nodejs 14 is used intentionally here, to assert AbortController polyfill is installed properly. +rules_js_configure(node_version = "14.20.0") diff --git a/e2e/workspace/WORKSPACE b/e2e/workspace/WORKSPACE index 6b21dcbc09..eb33107da4 100644 --- a/e2e/workspace/WORKSPACE +++ b/e2e/workspace/WORKSPACE @@ -9,17 +9,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:configure.bzl", "DEFAULT_NODE_VERSION", "rules_js_configure") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) - -# For convenience, npm_translate_lock does this call automatically. -# Uncomment if you don't call npm_translate_lock at all. -#load("@bazel_features//:deps.bzl", "bazel_features_deps") -#bazel_features_deps() +rules_js_configure(node_version = DEFAULT_NODE_VERSION) load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/js/configure.bzl b/js/configure.bzl new file mode 100644 index 0000000000..e62854249c --- /dev/null +++ b/js/configure.bzl @@ -0,0 +1,84 @@ +"""Configures transitive deps and registers toolchains required by rules_js. +""" + +load( + "@aspect_bazel_lib//lib:repositories.bzl", + _register_copy_directory_toolchains = "register_copy_directory_toolchains", + _register_copy_to_directory_toolchains = "register_copy_to_directory_toolchains", + _register_coreutils_toolchains = "register_coreutils_toolchains", + _register_jq_toolchains = "register_jq_toolchains", + _register_tar_toolchains = "register_tar_toolchains", + _register_yq_toolchains = "register_yq_toolchains", +) +load("@bazel_features//:deps.bzl", "bazel_features_deps") +load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains", _DEFAULT_NODE_REPOSITORY = "DEFAULT_NODE_REPOSITORY", _DEFAULT_NODE_VERSION = "DEFAULT_NODE_VERSION") + +DEFAULT_NODE_REPOSITORY = _DEFAULT_NODE_REPOSITORY +DEFAULT_NODE_VERSION = _DEFAULT_NODE_VERSION + +def rules_js_configure( + node_download_auth = {}, + node_repositories = {}, + node_urls = None, + node_version = DEFAULT_NODE_VERSION, + node_version_from_nvmrc = None, + **kwargs): + """Configures transitive deps and toolchains required by rules_js. + + Node.js toolchain comes from [rules_nodejs](https://docs.aspect.build/rulesets/rules_nodejs). + For more details on Node.js toolchain registration see + https://docs.aspect.build/rulesets/rules_nodejs/docs/core#node_repositories. + + Additional required toolchains (jq, yq, copy_directory and copy_to_directory) come + from [Aspect bazel-lib](https://docs.aspect.build/rulesets/aspect_bazel_lib). + + Args: + node_download_auth: Auth to use for all url requests when downloading Node + + Example: {"type": "basic", "login": "", "password": "" } + + node_repositories: Custom list of node repositories to use + + A dictionary mapping NodeJS versions to sets of hosts and their corresponding (filename, strip_prefix, sha256) tuples. + You should list a node binary for every platform users have, likely Mac, Windows, and Linux. + + By default, if this attribute has no items, we'll use a list of all public NodeJS releases. + + node_urls: Custom list of URLs to use to download NodeJS + + Each entry is a template for downloading a node distribution. + + The `{version}` parameter is substituted with the `node_version` attribute, + and `{filename}` with the matching entry from the `node_repositories` attribute. + + node_version: The specific version of NodeJS to install + + node_version_from_nvmrc: The label of the .nvmrc file containing the version of node + + If set then the version is set to the version found in the .nvmrc file. + + **kwargs: Other args + """ + bazel_features_deps() + + if kwargs.pop("register_copy_directory_toolchain", True) and not native.existing_rule("copy_directory_toolchains"): + _register_copy_directory_toolchains() + if kwargs.pop("register_copy_to_directory_toolchain", True) and not native.existing_rule("copy_to_directory_toolchains"): + _register_copy_to_directory_toolchains() + if kwargs.pop("register_coreutils_toolchain", True) and not native.existing_rule("coreutils_toolchains"): + _register_coreutils_toolchains() + if kwargs.pop("register_jq_toolchain", True) and not native.existing_rule("jq_toolchains"): + _register_jq_toolchains() + if kwargs.pop("register_tar_toolchain", True) and not native.existing_rule("tar_toolchains"): + _register_tar_toolchains() + if kwargs.pop("register_yq_toolchain", True) and not native.existing_rule("yq_toolchains"): + _register_yq_toolchains() + if kwargs.pop("register_nodejs_toolchain", True) and not native.existing_rule("{}_toolchains".format(DEFAULT_NODE_REPOSITORY)): + nodejs_register_toolchains( + name = DEFAULT_NODE_REPOSITORY, + node_download_auth = node_download_auth, + node_repositories = node_repositories, + node_urls = node_urls, + node_version = node_version, + node_version_from_nvmrc = node_version_from_nvmrc, + ) diff --git a/js/private/coverage/merger.bzl b/js/private/coverage/merger.bzl index d3681380de..6167f8d622 100644 --- a/js/private/coverage/merger.bzl +++ b/js/private/coverage/merger.bzl @@ -16,17 +16,23 @@ _ATTRS = { # Do the opposite of _to_manifest_path in # https://github.com/bazelbuild/rules_nodejs/blob/8b5d27400db51e7027fe95ae413eeabea4856f8e/nodejs/toolchain.bzl#L50 # to get back to the short_path. -# TODO(2.0): fix toolchain so we don't have to do this -def _target_tool_path_to_short_path(tool_path): +# TODO(3.0): remove this after a grace period for the DEPRECATED toolchain attributes +# buildifier: disable=unused-variable +def _deprecated_target_tool_path_to_short_path(tool_path): return ("../" + tool_path[len("external/"):]) if tool_path.startswith("external/") else tool_path def _coverage_merger_impl(ctx): is_windows = ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) - node_bin = ctx.toolchains["@rules_nodejs//nodejs:toolchain_type"].nodeinfo + nodeinfo = ctx.toolchains["@rules_nodejs//nodejs:toolchain_type"].nodeinfo + + if hasattr(nodeinfo, "node"): + node_path = nodeinfo.node.short_path if nodeinfo.node else nodeinfo.node_path + else: + # TODO(3.0): drop support for deprecated toolchain attributes + node_path = nodeinfo.target_tool_path # Create launcher bash_launcher = ctx.actions.declare_file(ctx.label.name) - node_path = _target_tool_path_to_short_path(ctx.toolchains["@rules_nodejs//nodejs:toolchain_type"].nodeinfo.target_tool_path) ctx.actions.expand_template( template = ctx.file._launcher_template, output = bash_launcher, @@ -41,13 +47,18 @@ def _coverage_merger_impl(ctx): launcher = create_windows_native_launcher_script(ctx, bash_launcher) if is_windows else bash_launcher - runfiles = ctx.runfiles( - files = [ctx.file.entry_point] + node_bin.tool_files, - ) + runfiles = [ctx.file.entry_point] + + if hasattr(nodeinfo, "node"): + if nodeinfo.node: + runfiles.append(nodeinfo.node) + else: + # TODO(3.0): drop support for deprecated toolchain attributes + runfiles.extend(nodeinfo.tool_files) return DefaultInfo( executable = launcher, - runfiles = runfiles, + runfiles = ctx.runfiles(files = runfiles), ) coverage_merger = rule( diff --git a/js/private/js_binary.bzl b/js/private/js_binary.bzl index 8cb1629034..10529ea123 100644 --- a/js/private/js_binary.bzl +++ b/js/private/js_binary.bzl @@ -304,11 +304,12 @@ _NODE_OPTION = """JS_BINARY__NODE_OPTIONS+=(\"{value}\")""" # Do the opposite of _to_manifest_path in # https://github.com/bazelbuild/rules_nodejs/blob/8b5d27400db51e7027fe95ae413eeabea4856f8e/nodejs/toolchain.bzl#L50 # to get back to the short_path. -# TODO(2.0): fix toolchain so we don't have to do this -def _target_tool_path_to_short_path(tool_path): +# TODO(3.0): remove this after a grace period for the DEPRECATED toolchain attributes +# buildifier: disable=unused-variable +def _deprecated_target_tool_path_to_short_path(tool_path): return ("../" + tool_path[len("external/"):]) if tool_path.startswith("external/") else tool_path -def _bash_launcher(ctx, node_toolchain, entry_point_path, log_prefix_rule_set, log_prefix_rule, fixed_args, fixed_env, is_windows): +def _bash_launcher(ctx, nodeinfo, entry_point_path, log_prefix_rule_set, log_prefix_rule, fixed_args, fixed_env, is_windows): # Explicitly disable node fs patches on Windows: # https://github.com/aspect-build/rules_js/issues/1137 if is_windows: @@ -406,7 +407,11 @@ def _bash_launcher(ctx, node_toolchain, entry_point_path, log_prefix_rule_set, l npm_path = "" if ctx.attr.include_npm: - npm_path = _target_tool_path_to_short_path(node_toolchain.nodeinfo.npm_path) + if hasattr(nodeinfo, "npm"): + npm_path = nodeinfo.npm.short_path if nodeinfo.npm else nodeinfo.npm_path + else: + # TODO(3.0): drop support for deprecated toolchain attributes + npm_path = nodeinfo.npm_path if is_windows: npm_wrapper = ctx.actions.declare_file("%s_node_bin/npm.bat" % ctx.label.name) ctx.actions.expand_template( @@ -425,7 +430,11 @@ def _bash_launcher(ctx, node_toolchain, entry_point_path, log_prefix_rule_set, l ) toolchain_files.append(npm_wrapper) - node_path = _target_tool_path_to_short_path(node_toolchain.nodeinfo.target_tool_path) + if hasattr(nodeinfo, "node"): + node_path = nodeinfo.node.short_path if nodeinfo.node else nodeinfo.node_path + else: + # TODO(3.0): drop support for deprecated toolchain attributes + node_path = nodeinfo.target_tool_path launcher_subst = { "{{target_label}}": str(ctx.label), @@ -459,12 +468,9 @@ def _create_launcher(ctx, log_prefix_rule_set, log_prefix_rule, fixed_args = [], is_windows = ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) if ctx.attr.node_toolchain: - node_toolchain = ctx.attr.node_toolchain[platform_common.ToolchainInfo] + nodeinfo = ctx.attr.node_toolchain[platform_common.ToolchainInfo].nodeinfo else: - node_toolchain = ctx.toolchains["@rules_nodejs//nodejs:toolchain_type"] - - if ctx.attr.include_npm and not hasattr(node_toolchain.nodeinfo, "npm_files"): - fail("include_npm requires a minimum @rules_nodejs version of 5.7.0") + nodeinfo = ctx.toolchains["@rules_nodejs//nodejs:toolchain_type"].nodeinfo if DirectoryPathInfo in ctx.attr.entry_point: entry_point = ctx.attr.entry_point[DirectoryPathInfo].directory @@ -478,14 +484,26 @@ def _create_launcher(ctx, log_prefix_rule_set, log_prefix_rule, fixed_args = [], entry_point = ctx.files.entry_point[0] entry_point_path = entry_point.short_path - bash_launcher, toolchain_files = _bash_launcher(ctx, node_toolchain, entry_point_path, log_prefix_rule_set, log_prefix_rule, fixed_args, fixed_env, is_windows) + bash_launcher, toolchain_files = _bash_launcher(ctx, nodeinfo, entry_point_path, log_prefix_rule_set, log_prefix_rule, fixed_args, fixed_env, is_windows) launcher = create_windows_native_launcher_script(ctx, bash_launcher) if is_windows else bash_launcher - launcher_files = [bash_launcher] + toolchain_files + launcher_files = [bash_launcher] + launcher_files.extend(toolchain_files) + if hasattr(nodeinfo, "node"): + if nodeinfo.node: + launcher_files.append(nodeinfo.node) + else: + # TODO(3.0): drop support for deprecated toolchain attributes + launcher_files.extend(nodeinfo.tool_files) launcher_files.extend(ctx.files._node_patches_files + [ctx.file._node_patches]) - launcher_files.extend(node_toolchain.nodeinfo.tool_files) + + transitive_launcher_files = None if ctx.attr.include_npm: - launcher_files.extend(node_toolchain.nodeinfo.npm_files) + if hasattr(nodeinfo, "npm_sources"): + transitive_launcher_files = nodeinfo.npm_sources + else: + # TODO(3.0): drop support for deprecated toolchain attributes + launcher_files.extend(nodeinfo.npm_files) runfiles = gather_runfiles( ctx = ctx, @@ -498,7 +516,10 @@ def _create_launcher(ctx, log_prefix_rule_set, log_prefix_rule, fixed_args = [], include_transitive_sources = ctx.attr.include_transitive_sources, include_declarations = ctx.attr.include_declarations, include_npm_linked_packages = ctx.attr.include_npm_linked_packages, - ).merge(ctx.runfiles(files = launcher_files)) + ).merge(ctx.runfiles( + files = launcher_files, + transitive_files = transitive_launcher_files, + )) return struct( executable = launcher, diff --git a/js/private/test/snapshots/bzlmod/launcher.sh b/js/private/test/snapshots/bzlmod/launcher.sh index dec9ef78bd..8ddf0c0954 100644 --- a/js/private/test/snapshots/bzlmod/launcher.sh +++ b/js/private/test/snapshots/bzlmod/launcher.sh @@ -365,7 +365,7 @@ if [ ! -f "$entry_point" ]; then exit 1 fi -node="$(_normalize_path "../rules_nodejs~6.0.5~node~nodejs_linux_amd64/bin/nodejs/bin/node")" +node="$(_normalize_path "../rules_nodejs~override~node~nodejs_linux_amd64/bin/nodejs/bin/node")" if [ "${node:0:1}" = "/" ]; then # A user may specify an absolute path to node using target_tool_path in node_toolchain export JS_BINARY__NODE_BINARY="$node" @@ -376,9 +376,9 @@ if [ "${node:0:1}" = "/" ]; then else if [ "${JS_BINARY__NO_RUNFILES:-}" ]; then export JS_BINARY__NODE_BINARY - JS_BINARY__NODE_BINARY=$(resolve_execroot_src_path "../rules_nodejs~6.0.5~node~nodejs_linux_amd64/bin/nodejs/bin/node") + JS_BINARY__NODE_BINARY=$(resolve_execroot_src_path "../rules_nodejs~override~node~nodejs_linux_amd64/bin/nodejs/bin/node") else - export JS_BINARY__NODE_BINARY="$JS_BINARY__RUNFILES/_main/../rules_nodejs~6.0.5~node~nodejs_linux_amd64/bin/nodejs/bin/node" + export JS_BINARY__NODE_BINARY="$JS_BINARY__RUNFILES/_main/../rules_nodejs~override~node~nodejs_linux_amd64/bin/nodejs/bin/node" fi if [ ! -f "$JS_BINARY__NODE_BINARY" ]; then logf_fatal "node binary '%s' not found" "$JS_BINARY__NODE_BINARY" diff --git a/js/repositories.bzl b/js/repositories.bzl index bac885697a..025612fe62 100644 --- a/js/repositories.bzl +++ b/js/repositories.bzl @@ -17,8 +17,12 @@ def rules_js_dependencies(): # TODO(2.0): update to rules_nodejs v6 http_archive( name = "rules_nodejs", - sha256 = "8fc8e300cb67b89ceebd5b8ba6896ff273c84f6099fc88d23f24e7102319d8fd", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.4/rules_nodejs-core-5.8.4.tar.gz"], + integrity = "sha256-pqOPIuJHFcv7kOCqYExYr6p0j/wPxdd4ywK/PMYXiBA=", + strip_prefix = "rules_nodejs-dd02dc8bda04ab272e392f3b6dbef8dab71587e6", + url = "https://github.com/bazelbuild/rules_nodejs/archive/dd02dc8bda04ab272e392f3b6dbef8dab71587e6.tar.gz", + # sha256 = "a50986c7d2f2dc43a5b9b81a6245fd89bdc4866f1d5e316d9cef2782dd859292", + # strip_prefix = "rules_nodejs-6.0.5", + # url = "https://github.com/bazelbuild/rules_nodejs/releases/download/v6.0.5/rules_nodejs-v6.0.5.tar.gz", ) http_archive( diff --git a/npm/extensions.bzl b/npm/extensions.bzl index e8427101a8..f9e766220e 100644 --- a/npm/extensions.bzl +++ b/npm/extensions.bzl @@ -46,11 +46,6 @@ def _npm_extension_impl(module_ctx): prod = attr.prod, public_hoist_packages = attr.public_hoist_packages, quiet = attr.quiet, - register_copy_directory_toolchains = False, # this registration is handled elsewhere with bzlmod - register_copy_to_directory_toolchains = False, # this registration is handled elsewhere with bzlmod - register_coreutils_toolchains = False, # this registration is handled elsewhere with bzlmod - register_yq_toolchains = False, # this registration is handled elsewhere with bzlmod - register_tar_toolchains = False, # this registration is handled elsewhere with bzlmod replace_packages = attr.replace_packages, root_package = attr.root_package, run_lifecycle_hooks = attr.run_lifecycle_hooks, @@ -173,8 +168,6 @@ WARNING: Cannot determine home directory in order to load home `.npmrc` file in transitive_closure = i.transitive_closure, url = i.url, version = i.version, - register_copy_directory_toolchains = False, # this registration is handled elsewhere with bzlmod - register_copy_to_directory_toolchains = False, # this registration is handled elsewhere with bzlmod ) for i in mod.tags.npm_import: @@ -206,8 +199,6 @@ WARNING: Cannot determine home directory in order to load home `.npmrc` file in transitive_closure = i.transitive_closure, url = i.url, version = i.version, - register_copy_directory_toolchains = False, # this registration is handled elsewhere with bzlmod - register_copy_to_directory_toolchains = False, # this registration is handled elsewhere with bzlmod ) if bazel_features.external_deps.extension_metadata_has_reproducible: diff --git a/npm/private/npm_import.bzl b/npm/private/npm_import.bzl index fb711448b9..300e0b756a 100644 --- a/npm/private/npm_import.bzl +++ b/npm/private/npm_import.bzl @@ -18,7 +18,6 @@ for a given lockfile. """ load("@aspect_bazel_lib//lib:repo_utils.bzl", "patch", "repo_utils") -load("@aspect_bazel_lib//lib:repositories.bzl", _register_copy_directory_toolchains = "register_copy_directory_toolchains", _register_copy_to_directory_toolchains = "register_copy_to_directory_toolchains") load("@bazel_skylib//lib:dicts.bzl", "dicts") load("@bazel_skylib//lib:paths.bzl", "paths") load( @@ -888,8 +887,6 @@ def npm_import( npm_auth_password = "", bins = {}, dev = False, - register_copy_directory_toolchains = True, - register_copy_to_directory_toolchains = True, **kwargs): """Import a single npm package into Bazel. @@ -1134,19 +1131,9 @@ def npm_import( dev: Whether this npm package is a dev dependency - register_copy_directory_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_copy_directory_toolchains()` is called if the toolchain is not already registered - - register_copy_to_directory_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_copy_to_directory_toolchains()` is called if the toolchain is not already registered - **kwargs: Internal use only """ - # TODO(2.0): move this to a new required rules_js_repositories() WORKSPACE function - if register_copy_directory_toolchains and not native.existing_rule("copy_directory_toolchains"): - _register_copy_directory_toolchains() - if register_copy_to_directory_toolchains and not native.existing_rule("copy_to_directory_toolchains"): - _register_copy_to_directory_toolchains() - generate_bzl_library_targets = kwargs.pop("generate_bzl_library_targets", None) extract_full_archive = kwargs.pop("extract_full_archive", None) if len(kwargs): diff --git a/npm/private/npm_package.bzl b/npm/private/npm_package.bzl index 0478be7c3f..45847a72bb 100644 --- a/npm/private/npm_package.bzl +++ b/npm/private/npm_package.bzl @@ -506,14 +506,6 @@ def stamped_package_json(name, stamp_var, **kwargs): For more information on stamping, read https://docs.aspect.build/rules/aspect_bazel_lib/docs/stamping. - Using this rule requires that you register the jq toolchain in your WORKSPACE: - - ```starlark - load("@aspect_bazel_lib//lib:repositories.bzl", "register_jq_toolchains") - - register_jq_toolchains() - ``` - Args: name: name of the resulting `jq` target, must be "package" stamp_var: a key from the bazel-out/stable-status.txt or bazel-out/volatile-status.txt files diff --git a/npm/private/npm_translate_lock.bzl b/npm/private/npm_translate_lock.bzl index be112d9781..c74bc77825 100644 --- a/npm/private/npm_translate_lock.bzl +++ b/npm/private/npm_translate_lock.bzl @@ -26,14 +26,6 @@ Advanced users may want to directly fetch a package from npm rather than start f """ load("@bazel_skylib//lib:paths.bzl", "paths") -load( - "@aspect_bazel_lib//lib:repositories.bzl", - _register_copy_directory_toolchains = "register_copy_directory_toolchains", - _register_copy_to_directory_toolchains = "register_copy_to_directory_toolchains", - _register_coreutils_toolchains = "register_coreutils_toolchains", - _register_tar_toolchains = "register_tar_toolchains", - _register_yq_toolchains = "register_yq_toolchains", -) load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file") load(":list_sources.bzl", "list_sources") load(":npm_translate_lock_generate.bzl", "generate_repository_files") @@ -193,11 +185,6 @@ def npm_translate_lock( link_workspace = None, pnpm_version = LATEST_PNPM_VERSION, use_pnpm = None, - register_copy_directory_toolchains = True, - register_copy_to_directory_toolchains = True, - register_coreutils_toolchains = True, - register_yq_toolchains = True, - register_tar_toolchains = True, npm_package_target_name = "{dirname}", use_starlark_yaml_parser = False, **kwargs): @@ -518,16 +505,6 @@ def npm_translate_lock( Use `pnpm_version` for non-bzlmod. - register_copy_directory_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_copy_directory_toolchains()` is called if the toolchain is not already registered - - register_copy_to_directory_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_copy_to_directory_toolchains()` is called if the toolchain is not already registered - - register_coreutils_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_coreutils_toolchains()` is called if the toolchain is not already registered - - register_yq_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_yq_toolchains()` is called if the toolchain is not already registered - - register_tar_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_tar_toolchains()` is called if the toolchain is not already registered - npm_package_target_name: The name of linked `npm_package` targets. When `npm_package` targets are linked as pnpm workspace packages, the name of the target must align with this value. @@ -565,18 +542,6 @@ def npm_translate_lock( **kwargs: Internal use only """ - # TODO(2.0): move this to a new required rules_js_repositories() WORKSPACE function - if register_copy_directory_toolchains and not native.existing_rule("copy_directory_toolchains"): - _register_copy_directory_toolchains() - if register_copy_to_directory_toolchains and not native.existing_rule("copy_to_directory_toolchains"): - _register_copy_to_directory_toolchains() - if register_coreutils_toolchains and not native.existing_rule("register_coreutils_toolchains"): - _register_coreutils_toolchains() - if register_yq_toolchains and not native.existing_rule("yq_toolchains"): - _register_yq_toolchains() - if register_tar_toolchains and not native.existing_rule("tar_toolchains"): - _register_tar_toolchains() - # Gather undocumented attributes root_package = kwargs.pop("root_package", None) additional_file_contents = kwargs.pop("additional_file_contents", {}) diff --git a/npm/private/pnpm_repository.bzl b/npm/private/pnpm_repository.bzl index dbcec6337c..5e868ce44b 100644 --- a/npm/private/pnpm_repository.bzl +++ b/npm/private/pnpm_repository.bzl @@ -40,6 +40,4 @@ def pnpm_repository(name, pnpm_version = LATEST_PNPM_VERSION): """js_binary(name = "pnpm", data = glob(["package/**"]), entry_point = "package/dist/pnpm.cjs", visibility = ["//visibility:public"])""", ]), extract_full_archive = True, - register_copy_directory_toolchains = False, # this code path should work for both WORKSPACE and bzlmod - register_copy_to_directory_toolchains = False, # this code path should work for both WORKSPACE and bzlmod ) diff --git a/npm/repositories.bzl b/npm/repositories.bzl index c9ef2993a1..96b76abc85 100644 --- a/npm/repositories.bzl +++ b/npm/repositories.bzl @@ -1,16 +1,12 @@ """Repository rules to fetch third-party npm packages""" -load("@bazel_features//:deps.bzl", "bazel_features_deps") load("//npm/private:npm_import.bzl", _npm_import = "npm_import") load("//npm/private:npm_translate_lock.bzl", _list_patches = "list_patches", _npm_translate_lock = "npm_translate_lock") load("//npm/private:pnpm_repository.bzl", _LATEST_PNPM_VERSION = "LATEST_PNPM_VERSION", _pnpm_repository = "pnpm_repository") -npm_import = _npm_import - -def npm_translate_lock(**kwargs): - bazel_features_deps() - _npm_translate_lock(**kwargs) - -pnpm_repository = _pnpm_repository LATEST_PNPM_VERSION = _LATEST_PNPM_VERSION + list_patches = _list_patches +npm_import = _npm_import +npm_translate_lock = _npm_translate_lock +pnpm_repository = _pnpm_repository