Skip to content

Commit

Permalink
Minimize the performance cost of checking bazel version
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbarsky authored and jbedard committed Jun 10, 2024
1 parent 7a88898 commit f730556
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 4 additions & 0 deletions npm/private/npm_translate_lock.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Advanced users may want to directly fetch a package from npm rather than start f
[`npm_import`](./npm_import) does this.
"""

load("@aspect_bazel_lib//lib:utils.bzl", bazel_lib_utils = "utils")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
load("@bazel_skylib//lib:paths.bzl", "paths")
load(":list_sources.bzl", "list_sources")
Expand Down Expand Up @@ -504,6 +505,9 @@ def npm_translate_lock(
**kwargs: Internal use only
"""
if not bazel_lib_utils.is_bazel_6_or_greater():
# ctx.actions.declare_symlink was added in Bazel 6
fail("A minimum version of Bazel 6 required to use rules_js")

# Gather undocumented attributes
root_package = kwargs.pop("root_package", None)
Expand Down
4 changes: 0 additions & 4 deletions npm/private/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

load("@aspect_bazel_lib//lib:paths.bzl", "relative_file")
load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils")
load("@aspect_bazel_lib//lib:utils.bzl", bazel_lib_utils = "utils")
load("@bazel_skylib//lib:paths.bzl", "paths")

INTERNAL_ERROR_MSG = "ERROR: rules_js internal error, please file an issue: https://github.com/aspect-build/rules_js/issues"
Expand Down Expand Up @@ -72,9 +71,6 @@ def _package_store_name(pnpm_name, pnpm_version):
return "%s@%s" % (escaped_name, escaped_version)

def _make_symlink(ctx, symlink_path, target_path):
if not bazel_lib_utils.is_bazel_6_or_greater():
# ctx.actions.declare_symlink was added in Bazel 6
fail("A minimum version of Bazel 6 required to use rules_js")
symlink = ctx.actions.declare_symlink(symlink_path)
ctx.actions.symlink(
output = symlink,
Expand Down

0 comments on commit f730556

Please sign in to comment.