diff --git a/.bazeliskrc b/.bazeliskrc index a28c887..269fbb0 100644 --- a/.bazeliskrc +++ b/.bazeliskrc @@ -1,2 +1,2 @@ BAZELISK_BASE_URL=https://github.com/aspect-build/aspect-cli/releases/download -USE_BAZEL_VERSION=aspect/5.7.2 +USE_BAZEL_VERSION=aspect/5.9.25 diff --git a/.bazelversion b/.bazelversion index 6c7efdc..2b1ea10 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1,4 +1,4 @@ -6.3.2 +7.1.1 # The first line of this file is used by Bazelisk and Bazel to be sure # the right version of Bazel is used to build and test this repo. # This also defines which version is used on CI. diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 736adca..cc750e9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,8 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - # TODO(alex): add testing on Bazel 7 - - id: bazel_6 + - id: bazel_7 run: echo "bazelversion=$(head -n 1 .bazelversion)" >> $GITHUB_OUTPUT outputs: # Will look like ["", ...] diff --git a/.gitignore b/.gitignore index 47ddd74..1a4a203 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,13 @@ dist node_modules .DS_Store aspect-build-webpack-* -.bazelrc.user \ No newline at end of file +.bazelrc.user + +# Don't commit lockfile for now as it is unstable. Do allow for it to be +# created, however, since it gives a performance boost for local development. +# https://github.com/bazelbuild/bazel/issues/19026 +# https://github.com/bazelbuild/bazel/issues/19621 +# https://github.com/bazelbuild/bazel/issues/19971 +# https://github.com/bazelbuild/bazel/issues/20272 +# https://github.com/bazelbuild/bazel/issues/20369 +MODULE.bazel.lock diff --git a/BUILD.bazel b/BUILD.bazel index 9005145..37d0e94 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -3,6 +3,9 @@ load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary") load("@buildifier_prebuilt//:rules.bzl", "buildifier") load("@npm//:defs.bzl", "npm_link_all_packages") +# buildifier: disable=bzl-visibility +load("//webpack/private:is_bazel_7_or_greater.bzl", "is_bazel_7_or_greater") + npm_link_all_packages(name = "node_modules") gazelle_binary( @@ -33,5 +36,5 @@ bzl_library( deps = [ "@bazel_tools//tools/build_defs/repo:http.bzl", "@bazel_tools//tools/build_defs/repo:utils.bzl", - ], + ] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if is_bazel_7_or_greater() else []), ) diff --git a/MODULE.bazel b/MODULE.bazel index 8186689..895d7a4 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -10,6 +10,9 @@ bazel_dep(name = "aspect_bazel_lib", version = "1.38.1") bazel_dep(name = "aspect_rules_js", version = "1.34.0") bazel_dep(name = "bazel_skylib", version = "1.4.1") -bazel_dep(name = "gazelle", version = "0.29.0", dev_dependency = True, repo_name = "bazel_gazelle") -bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.1", dev_dependency = True) +####### Dev dependencies ######## + +bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True) bazel_dep(name = "buildifier_prebuilt", version = "6.1.2.1", dev_dependency = True) +bazel_dep(name = "gazelle", version = "0.36.0", dev_dependency = True, repo_name = "bazel_gazelle") +bazel_dep(name = "rules_go", version = "0.46.0", dev_dependency = True) diff --git a/internal_deps.bzl b/internal_deps.bzl index 34c08d8..a98a97b 100644 --- a/internal_deps.bzl +++ b/internal_deps.bzl @@ -20,20 +20,20 @@ def rules_webpack_internal_deps(): http_archive( name = "io_bazel_rules_go", - sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa", - urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip"], + sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184", + urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip"], ) http_archive( name = "bazel_gazelle", - sha256 = "448e37e0dbf61d6fa8f00aaa12d191745e14f07c31cabfa731f0c8e8a4f41b97", - urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz"], + integrity = "sha256-dd8ojEsxyB61D1Hi4U9HY8t1SNquEmgXJHBkY3/Z6mI=", + urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz"], ) http_archive( name = "bazel_skylib_gazelle_plugin", - sha256 = "0a466b61f331585f06ecdbbf2480b9edf70e067a53f261e0596acd573a7d2dc3", - urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-gazelle-plugin-1.4.1.tar.gz"], + sha256 = "747addf3f508186234f6232674dd7786743efb8c68619aece5fb0cac97b8f415", + urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-gazelle-plugin-1.5.0.tar.gz"], ) http_archive( diff --git a/webpack/BUILD.bazel b/webpack/BUILD.bazel index 555d35c..654bd58 100644 --- a/webpack/BUILD.bazel +++ b/webpack/BUILD.bazel @@ -1,4 +1,5 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") +load("//webpack/private:is_bazel_7_or_greater.bzl", "is_bazel_7_or_greater") exports_files(["defs.bzl"]) @@ -9,7 +10,7 @@ bzl_library( deps = [ "//webpack/private:webpack_bundle", "//webpack/private:webpack_devserver", - ], + ] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if is_bazel_7_or_greater() else []), ) bzl_library( @@ -19,5 +20,5 @@ bzl_library( deps = [ "@bazel_tools//tools/build_defs/repo:http.bzl", "@bazel_tools//tools/build_defs/repo:utils.bzl", - ], + ] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if is_bazel_7_or_greater() else []), ) diff --git a/webpack/private/is_bazel_7_or_greater.bzl b/webpack/private/is_bazel_7_or_greater.bzl new file mode 100644 index 0000000..0a9b740 --- /dev/null +++ b/webpack/private/is_bazel_7_or_greater.bzl @@ -0,0 +1,7 @@ +"is_bazel_7_or_greater" + +def is_bazel_7_or_greater(): + # Vendored in from https://github.com/aspect-build/bazel-lib/blob/adad7889c925c4f22a2f84568268f0a62e7c2fb0/lib/private/utils.bzl#L208 + # so that rules_js remains compatible with aspect_bazel_lib >= 2.0.0 and < 2.2.0. + # TODO(2.0): remove this and switch to the upstream function and bump minimum aspect_bazel_lib version to 2.2.0 + return "apple_binary" not in dir(native) and "cc_host_toolchain_alias" not in dir(native)