diff --git a/WORKSPACE b/WORKSPACE index 7324503e7..244f696ee 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -7,22 +7,19 @@ load("//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", "register_expand_template_toolchains", "register_jq_toolchains") +load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains") -register_expand_template_toolchains() +rules_js_register_toolchains(node_version = "16.14.2") -register_jq_toolchains() +load("@aspect_bazel_lib//lib:repositories.bzl", "register_expand_template_toolchains") -load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") +register_expand_template_toolchains() -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 7ee1f88ab..9e6b77a9b 100644 --- a/docs/npm_import.md +++ b/docs/npm_import.md @@ -26,8 +26,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. @@ -159,8 +158,6 @@ Read more about the downloader config: 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 54222a3b7..04d81be89 100644 --- a/docs/npm_package.md +++ b/docs/npm_package.md @@ -145,14 +145,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 639bcf21d..423dca412 100644 --- a/docs/npm_translate_lock.md +++ b/docs/npm_translate_lock.md @@ -66,8 +66,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) @@ -132,11 +130,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. | `"8.15.3"` | | use_pnpm | label of the pnpm entry point to use. | `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/git_dep_metadata/WORKSPACE b/e2e/git_dep_metadata/WORKSPACE index 639f1b98c..97e0c35af 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_import") diff --git a/e2e/gyp_no_install_script/WORKSPACE b/e2e/gyp_no_install_script/WORKSPACE index a43d69b45..6b0254806 100644 --- a/e2e/gyp_no_install_script/WORKSPACE +++ b/e2e/gyp_no_install_script/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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_bazel_lib//lib:repositories.bzl", "register_coreutils_toolchains") diff --git a/e2e/js_image_docker/.nvmrc b/e2e/js_image_docker/.nvmrc new file mode 100644 index 000000000..a1fe18788 --- /dev/null +++ b/e2e/js_image_docker/.nvmrc @@ -0,0 +1 @@ +16.14.2 \ No newline at end of file diff --git a/e2e/js_image_docker/WORKSPACE b/e2e/js_image_docker/WORKSPACE index e956c2aaa..d6bb744b9 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.14.2", -) +rules_js_register_toolchains(node_version_from_nvmrc = "//:.nvmrc") 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 fb38d7fdf..c6d28ba0d 100644 --- a/e2e/js_image_oci/WORKSPACE +++ b/e2e/js_image_oci/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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.14.2", -) +rules_js_register_toolchains(node_version = "16.14.2") load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/js_run_devserver/WORKSPACE b/e2e/js_run_devserver/WORKSPACE index 762ce191f..dae2de6ce 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() 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 dea84e165..24f3d24ef 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.9.0", -) +rules_js_register_toolchains(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 12b26ccda..4a84efd25 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.14.2", -) +rules_js_register_toolchains(node_version = "16.14.2") load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock/WORKSPACE b/e2e/npm_translate_lock/WORKSPACE index 5631b25e9..7f014805b 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_auth/WORKSPACE b/e2e/npm_translate_lock_auth/WORKSPACE index 8e31b6545..1a8d239b8 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_empty/WORKSPACE b/e2e/npm_translate_lock_empty/WORKSPACE index 6d21251f8..66df89aac 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_git+ssh/WORKSPACE b/e2e/npm_translate_lock_git+ssh/WORKSPACE index 8e31b6545..1a8d239b8 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_multi/WORKSPACE b/e2e/npm_translate_lock_multi/WORKSPACE index bdd846b2a..2f245588c 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_partial_clone/WORKSPACE b/e2e/npm_translate_lock_partial_clone/WORKSPACE index 58a8f42bb..92af2aff5 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_lock_subdir_patch/WORKSPACE b/e2e/npm_translate_lock_subdir_patch/WORKSPACE index 9746888a7..2cf64fad1 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_package_lock/WORKSPACE b/e2e/npm_translate_package_lock/WORKSPACE index c679ded11..a22a72c91 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/npm_translate_yarn_lock/WORKSPACE b/e2e/npm_translate_yarn_lock/WORKSPACE index f14e83126..bca9968b9 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/package_json_module/WORKSPACE b/e2e/package_json_module/WORKSPACE index da6a67d73..d15f16c3a 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/patch_from_repo/WORKSPACE b/e2e/patch_from_repo/WORKSPACE index f58b6572b..9bb35ed48 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/pnpm_lockfiles/WORKSPACE b/e2e/pnpm_lockfiles/WORKSPACE index 044be8f84..489aa3e38 100644 --- a/e2e/pnpm_lockfiles/WORKSPACE +++ b/e2e/pnpm_lockfiles/WORKSPACE @@ -7,6 +7,10 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() +load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains") + +rules_js_register_toolchains() + load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") nodejs_register_toolchains( diff --git a/e2e/pnpm_repo_install/WORKSPACE b/e2e/pnpm_repo_install/WORKSPACE index da6a67d73..d15f16c3a 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/pnpm_workspace/WORKSPACE b/e2e/pnpm_workspace/WORKSPACE index 94f6b80b7..308be9668 100644 --- a/e2e/pnpm_workspace/WORKSPACE +++ b/e2e/pnpm_workspace/WORKSPACE @@ -7,16 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") +load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains") -aspect_bazel_lib_dependencies() - -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") - -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/pnpm_workspace_deps/WORKSPACE b/e2e/pnpm_workspace_deps/WORKSPACE index 2706ec3ab..e7e8b4e46 100644 --- a/e2e/pnpm_workspace_deps/WORKSPACE +++ b/e2e/pnpm_workspace_deps/WORKSPACE @@ -7,16 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") +load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains") -aspect_bazel_lib_dependencies() - -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") - -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/pnpm_workspace_rerooted/WORKSPACE b/e2e/pnpm_workspace_rerooted/WORKSPACE index eda07ec9e..18a7cbeb4 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.14.2", -) +rules_js_register_toolchains(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 4a8215532..e3893c614 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = "16.14.2", -) +rules_js_register_toolchains(node_version = "16.14.2") load("@rules_foo//foo:repositories.bzl", "foo_repositories") diff --git a/e2e/stamped_package_json/WORKSPACE b/e2e/stamped_package_json/WORKSPACE index 568e0f5dc..47606b86a 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:toolchains.bzl", "rules_js_register_toolchains") -register_jq_toolchains() +rules_js_register_toolchains() diff --git a/e2e/update_pnpm_lock/WORKSPACE b/e2e/update_pnpm_lock/WORKSPACE index 144abdba3..1207427b3 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/update_pnpm_lock_with_import/WORKSPACE b/e2e/update_pnpm_lock_with_import/WORKSPACE index 9d2b79e4a..9e9f619ff 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/vendored_node/WORKSPACE b/e2e/vendored_node/WORKSPACE index fbd512df1..86a70feca 100644 --- a/e2e/vendored_node/WORKSPACE +++ b/e2e/vendored_node/WORKSPACE @@ -7,28 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") rules_js_dependencies() -load( - "@aspect_bazel_lib//lib:repositories.bzl", - "register_copy_directory_toolchains", - "register_copy_to_directory_toolchains", - "register_coreutils_toolchains", - "register_tar_toolchains", - "register_yq_toolchains", -) - -register_copy_directory_toolchains() - -register_copy_to_directory_toolchains() - -register_coreutils_toolchains() - -register_tar_toolchains() - -register_yq_toolchains() - -load("@bazel_features//:deps.bzl", "bazel_features_deps") +load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains") -bazel_features_deps() +rules_js_register_toolchains(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 6e439e759..43bd7bbc2 100644 --- a/e2e/vendored_node/toolchains/BUILD.bazel +++ b/e2e/vendored_node/toolchains/BUILD.bazel @@ -7,11 +7,11 @@ In a real project you would vendor the binaries you need, or build them from source, so there shouldn't be any fetches required. """ -load("@rules_nodejs//nodejs:toolchain.bzl", "node_toolchain") +load("@rules_nodejs//nodejs:toolchain.bzl", "nodejs_toolchain") [ toolchain( - name = "node15_%s_toolchain" % os, + name = "node_vendored_%s_toolchain" % os, exec_compatible_with = [ "@platforms//os:" + os, "@platforms//cpu:x86_64", @@ -26,17 +26,17 @@ load("@rules_nodejs//nodejs:toolchain.bzl", "node_toolchain") ] ] -node_toolchain( +nodejs_toolchain( name = "node_linux", - target_tool = "@vendored_node_linux_amd64//:bin/node", + node = "@vendored_node_linux_amd64//:bin/node", ) -node_toolchain( +nodejs_toolchain( name = "node_macos", - target_tool = "@vendored_node_darwin_amd64//:bin/node", + node = "@vendored_node_darwin_amd64//:bin/node", ) -node_toolchain( +nodejs_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/WORKSPACE b/e2e/vendored_tarfile/WORKSPACE index 4c75f2cfb..bfe1b00be 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/verify_patches/WORKSPACE b/e2e/verify_patches/WORKSPACE index 1e7cc8666..aebbb4534 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/webpack_devserver/WORKSPACE b/e2e/webpack_devserver/WORKSPACE index afeb53a42..3ee7a5a70 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/webpack_devserver_esm/WORKSPACE b/e2e/webpack_devserver_esm/WORKSPACE index afeb53a42..3ee7a5a70 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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains() load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/e2e/worker/WORKSPACE b/e2e/worker/WORKSPACE index 85cb981c6..1027fcdcd 100644 --- a/e2e/worker/WORKSPACE +++ b/e2e/worker/WORKSPACE @@ -7,33 +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:toolchains.bzl", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - # nodejs 14 is used intentionally here, to assert AbortController polyfill is installed properly. - node_version = "14.20.0", -) - -load( - "@aspect_bazel_lib//lib:repositories.bzl", - "register_copy_directory_toolchains", - "register_copy_to_directory_toolchains", - "register_coreutils_toolchains", - "register_tar_toolchains", - "register_yq_toolchains", -) - -register_copy_directory_toolchains() - -register_copy_to_directory_toolchains() - -register_coreutils_toolchains() - -register_tar_toolchains() - -register_yq_toolchains() - -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_register_toolchains(node_version = "14.20.0") diff --git a/e2e/workspace/WORKSPACE b/e2e/workspace/WORKSPACE index 53e244a7c..3e3567506 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:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains") -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_register_toolchains(node_version = DEFAULT_NODE_VERSION) load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") diff --git a/js/repositories.bzl b/js/repositories.bzl index 0167909ad..7a45d15c0 100644 --- a/js/repositories.bzl +++ b/js/repositories.bzl @@ -27,10 +27,3 @@ def rules_js_dependencies(): strip_prefix = "bazel-lib-2.7.1", url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.1/bazel-lib-v2.7.1.tar.gz", ) - - http_archive( - name = "bazel_features", - sha256 = "f3082bfcdca73dc77dcd68faace806135a2e08c230b02b1d9fbdbd7db9d9c450", - strip_prefix = "bazel_features-0.1.0", - url = "https://github.com/bazel-contrib/bazel_features/releases/download/v0.1.0/bazel_features-v0.1.0.tar.gz", - ) diff --git a/js/toolchains.bzl b/js/toolchains.bzl new file mode 100644 index 000000000..cf9fbe113 --- /dev/null +++ b/js/toolchains.bzl @@ -0,0 +1,86 @@ +"""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("@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_register_toolchains( + 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. + + Requires a minimum rules_nodejs version of 6.1.0. + + **kwargs: Other args + """ + 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)): + maybe_args = dict() + if node_version_from_nvmrc: + maybe_args["node_version_from_nvmrc"] = node_version_from_nvmrc + 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, + **maybe_args + ) diff --git a/npm/extensions.bzl b/npm/extensions.bzl index 4fcdf270c..4c80b7da0 100644 --- a/npm/extensions.bzl +++ b/npm/extensions.bzl @@ -65,11 +65,6 @@ def _npm_translate_lock_bzlmod(attr): 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, @@ -165,8 +160,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 ) def _npm_import_bzlmod(i): @@ -198,8 +191,6 @@ def _npm_import_bzlmod(i): 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 ) def _npm_translate_lock_attrs(): diff --git a/npm/private/npm_import.bzl b/npm/private/npm_import.bzl index 4cfe3817d..b82c08bfa 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 8065c9f56..4c3c1d462 100644 --- a/npm/private/npm_package.bzl +++ b/npm/private/npm_package.bzl @@ -511,14 +511,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 1821ea2de..e59d05826 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): @@ -512,16 +499,6 @@ def npm_translate_lock( use_pnpm: label of the pnpm entry point to use. - 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. @@ -559,18 +536,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 dbcec6337..5e868ce44 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 c9ef2993a..96b76abc8 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