diff --git a/.aspect/bazelrc/ci.bazelrc b/.aspect/bazelrc/ci.bazelrc index 4d91ee0..11aae33 100644 --- a/.aspect/bazelrc/ci.bazelrc +++ b/.aspect/bazelrc/ci.bazelrc @@ -1,10 +1,3 @@ -# We recommend enforcing a policy that keeps your CI from being slowed down -# by individual test targets that should be optimized -# or split up into multiple test targets with sharding or manually. -# Set this flag to exclude targets that have their timeout set to eternal (>15m) from running on CI. -# Docs: https://bazel.build/docs/user-manual#test-timeout-filters -test --test_timeout_filters=-eternal - # Set this flag to enable re-tries of failed tests on CI. # When any test target fails, try one or more times. This applies regardless of whether the "flaky" # tag appears on the target definition. diff --git a/.aspect/bazelrc/javascript.bazelrc b/.aspect/bazelrc/javascript.bazelrc index dc76864..ace9d60 100644 --- a/.aspect/bazelrc/javascript.bazelrc +++ b/.aspect/bazelrc/javascript.bazelrc @@ -8,21 +8,4 @@ # details. # Docs: https://nodejs.org/en/docs/guides/debugging-getting-started/#command-line-options run:debug -- --node_options=--inspect-brk - -# Enable runfiles on all platforms. Runfiles are on by default on Linux and MacOS but off on -# Windows. -# -# In general, rules_js and derivate rule sets assume that runfiles are enabled and do not support no -# runfiles case because it does not scale to teach all Node.js tools to use the runfiles manifest. -# -# If you are developing on Windows, you must either run bazel with administrator privileges or -# enable developer mode. If you do not you may hit this error on Windows: -# -# Bazel needs to create symlinks to build the runfiles tree. -# Creating symlinks on Windows requires one of the following: -# 1. Bazel is run with administrator privileges. -# 2. The system version is Windows 10 Creators Update (1703) or later -# and developer mode is enabled. -# -# Docs: https://bazel.build/reference/command-line-reference#flag--enable_runfiles -build --enable_runfiles +test:debug --test_env=NODE_OPTIONS=--inspect-brk diff --git a/.aspect/bazelrc/performance.bazelrc b/.aspect/bazelrc/performance.bazelrc index 26dbbe1..acc48c5 100644 --- a/.aspect/bazelrc/performance.bazelrc +++ b/.aspect/bazelrc/performance.bazelrc @@ -1,12 +1,3 @@ -# Speed up all builds by not checking if output files have been modified. Lets you make changes to -# the output tree without triggering a build for local debugging. For example, you can modify -# [rules_js](https://github.com/aspect-build/rules_js) 3rd party npm packages in the output tree -# when local debugging. -# Docs: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/pkgcache/PackageOptions.java#L185 -build --noexperimental_check_output_files -fetch --noexperimental_check_output_files -query --noexperimental_check_output_files - # Don't apply `--noremote_upload_local_results` and `--noremote_accept_cached` to the disk cache. # If you have both `--noremote_upload_local_results` and `--disk_cache`, then this fixes a bug where # Bazel doesn't write to the local disk cache as it treats as a remote cache. diff --git a/MODULE.bazel b/MODULE.bazel index d7caa7e..28f75a5 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -7,12 +7,11 @@ module( ) # Lower-bounds (minimum) versions for direct runtime dependencies -bazel_dep(name = "aspect_bazel_lib", version = "1.38.0") -bazel_dep(name = "aspect_rules_js", version = "1.31.0") -bazel_dep(name = "bazel_skylib", version = "1.4.1") +bazel_dep(name = "aspect_bazel_lib", version = "2.7.3") +bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.6") +bazel_dep(name = "bazel_skylib", version = "1.5.0") ####### Dev dependencies ######## -bazel_dep(name = "bazel_features", version = "0.1.0", dev_dependency = True) bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True) bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc") diff --git a/WORKSPACE b/WORKSPACE index 788346d..420e9ea 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -10,18 +10,11 @@ load("@aspect_rules_terser//terser:dependencies.bzl", "rules_terser_dependencies rules_terser_dependencies() -load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") +load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains") -aspect_bazel_lib_dependencies(override_local_config_platform = True) +rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) -load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") - -nodejs_register_toolchains( - name = "node16", - node_version = "16.9.0", -) - -load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") +load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") npm_translate_lock( name = "npm", diff --git a/e2e/smoke/MODULE.bazel b/e2e/smoke/MODULE.bazel index 33f78e1..2b2df53 100644 --- a/e2e/smoke/MODULE.bazel +++ b/e2e/smoke/MODULE.bazel @@ -4,8 +4,8 @@ local_path_override( path = "../..", ) -bazel_dep(name = "aspect_bazel_lib", version = "1.38.0", dev_dependency = True) -bazel_dep(name = "aspect_rules_js", version = "1.31.0", dev_dependency = True) +bazel_dep(name = "aspect_bazel_lib", version = "2.7.3", dev_dependency = True) +bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.6", dev_dependency = True) npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True) npm.npm_translate_lock( diff --git a/e2e/smoke/WORKSPACE.bazel b/e2e/smoke/WORKSPACE.bazel index a9773da..aeb223e 100644 --- a/e2e/smoke/WORKSPACE.bazel +++ b/e2e/smoke/WORKSPACE.bazel @@ -18,14 +18,11 @@ rules_terser_dependencies() # Fetch and register a nodejs interpreter, if you haven't already -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 = "node", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) -load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") +load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") npm_translate_lock( name = "npm", diff --git a/terser/BUILD.bazel b/terser/BUILD.bazel index bf1cf4e..3e4fc31 100644 --- a/terser/BUILD.bazel +++ b/terser/BUILD.bazel @@ -1,5 +1,5 @@ +load("@aspect_bazel_lib//lib:utils.bzl", bazel_lib_utils = "utils") load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("//terser/private:is_bazel_7_or_greater.bzl", "is_bazel_7_or_greater") # For stardoc to reference the files exports_files(["defs.bzl"]) @@ -11,7 +11,7 @@ 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 []), + ] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if bazel_lib_utils.is_bazel_7_or_greater() else []), ) bzl_library( @@ -22,5 +22,5 @@ bzl_library( "//terser/private:terser", "@aspect_bazel_lib//lib:copy_file", "@aspect_rules_js//js:defs", - ] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if is_bazel_7_or_greater() else []), + ] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if bazel_lib_utils.is_bazel_7_or_greater() else []), ) diff --git a/terser/dependencies.bzl b/terser/dependencies.bzl index d840848..b5a8401 100644 --- a/terser/dependencies.bzl +++ b/terser/dependencies.bzl @@ -6,33 +6,27 @@ load("//terser/private:maybe.bzl", http_archive = "maybe_http_archive") def rules_terser_dependencies(): http_archive( name = "bazel_skylib", - sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7", - urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz"], + sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", + urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"], ) http_archive( name = "aspect_bazel_lib", - sha256 = "b848cd8e93be7f18c3deda6d2f3ade92a657d3585e119953bc50dc75fef535c2", - strip_prefix = "bazel-lib-1.38.0", - url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.38.0/bazel-lib-v1.38.0.tar.gz", + sha256 = "87ab4ec479ebeb00d286266aca2068caeef1bb0b1765e8f71c7b6cfee6af4226", + strip_prefix = "bazel-lib-2.7.3", + url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.3/bazel-lib-v2.7.3.tar.gz", ) http_archive( name = "aspect_rules_js", - sha256 = "7b2a4d1d264e105eae49a27e2e78065b23e2e45724df2251eacdd317e95bfdfd", - strip_prefix = "rules_js-1.31.0", - url = "https://github.com/aspect-build/rules_js/releases/download/v1.31.0/rules_js-v1.31.0.tar.gz", + sha256 = "03d9e0c1da0ee9dd8ff52ba0f6ee5d173848c00ef4c85ec558aad0a9cf56ac46", + strip_prefix = "rules_js-2.0.0-alpha.6", + url = "https://github.com/aspect-build/rules_js/releases/download/v2.0.0-alpha.6/rules_js-v2.0.0-alpha.6.tar.gz", ) http_archive( name = "rules_nodejs", - sha256 = "764a3b3757bb8c3c6a02ba3344731a3d71e558220adcb0cf7e43c9bba2c37ba8", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.2/rules_nodejs-core-5.8.2.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", + sha256 = "dddd60acc3f2f30359bef502c9d788f67e33814b0ddd99aa27c5a15eb7a41b8c", + strip_prefix = "rules_nodejs-6.1.0", + url = "https://github.com/bazelbuild/rules_nodejs/releases/download/v6.1.0/rules_nodejs-v6.1.0.tar.gz", ) diff --git a/terser/private/is_bazel_7_or_greater.bzl b/terser/private/is_bazel_7_or_greater.bzl deleted file mode 100644 index 0a9b740..0000000 --- a/terser/private/is_bazel_7_or_greater.bzl +++ /dev/null @@ -1,7 +0,0 @@ -"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) diff --git a/terser/private/terser.bzl b/terser/private/terser.bzl index 82e8147..02d36b4 100644 --- a/terser/private/terser.bzl +++ b/terser/private/terser.bzl @@ -110,18 +110,18 @@ def _impl(ctx): targets = ctx.attr.srcs, ) - transitive_declarations = js_lib_helpers.gather_transitive_declarations( - declarations = [], + transitive_types = js_lib_helpers.gather_transitive_types( + types = [], targets = ctx.attr.srcs, ) - npm_linked_packages = js_lib_helpers.gather_npm_linked_packages( + npm_sources = js_lib_helpers.gather_npm_sources( srcs = ctx.attr.srcs, deps = [], ) - npm_package_store_deps = js_lib_helpers.gather_npm_package_store_deps( - targets = ctx.attr.data, + npm_package_store_infos = js_lib_helpers.gather_npm_package_store_infos( + targets = ctx.attr.srcs + ctx.attr.data, ) runfiles = js_lib_helpers.gather_runfiles( @@ -133,14 +133,13 @@ def _impl(ctx): return [ js_info( - npm_linked_package_files = npm_linked_packages.direct_files, - npm_linked_packages = npm_linked_packages.direct, - npm_package_store_deps = npm_package_store_deps, + target = ctx.label, sources = output_sources_depset, - transitive_declarations = transitive_declarations, - transitive_npm_linked_package_files = npm_linked_packages.transitive_files, - transitive_npm_linked_packages = npm_linked_packages.transitive, + types = depset(), # terser does not emit types directly transitive_sources = transitive_sources, + transitive_types = transitive_types, + npm_sources = npm_sources, + npm_package_store_infos = npm_package_store_infos, ), DefaultInfo( files = output_sources_depset,