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/correctness.bazelrc b/.aspect/bazelrc/correctness.bazelrc index 56fad5f..a599f6d 100644 --- a/.aspect/bazelrc/correctness.bazelrc +++ b/.aspect/bazelrc/correctness.bazelrc @@ -60,3 +60,16 @@ query --experimental_allow_tags_propagation # https://github.com/bazelbuild/bazel/issues/10076. # Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_default_to_explicit_init_py build --incompatible_default_to_explicit_init_py + +# Set default value of `allow_empty` to `False` in `glob()`. This prevents a common mistake when +# attempting to use `glob()` to match files in a subdirectory that is opaque to the current package +# because it contains a BUILD file. See https://github.com/bazelbuild/bazel/issues/8195. +# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_disallow_empty_glob +common --incompatible_disallow_empty_glob + +# Always download coverage files for tests from the remote cache. By default, coverage files are not +# downloaded on test result cahce hits when --remote_download_minimal is enabled, making it impossible +# to generate a full coverage report. +# Docs: https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs +# detching remote cache results +test --experimental_fetch_all_coverage_outputs 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 fff4c7c..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. @@ -27,12 +18,3 @@ build --experimental_reuse_sandbox_directories # author. # Docs: https://bazel.build/reference/command-line-reference#flag--legacy_external_runfiles build --nolegacy_external_runfiles - -# Some actions are always IO-intensive but require little compute. It's wasteful to put the output -# in the remote cache, it just saturates the network and fills the cache storage causing earlier -# evictions. It's also not worth sending them for remote execution. -# For actions like PackageTar it's usually faster to just re-run the work locally every time. -# You'll have to look at an execution log to figure out what other action mnemonics you care about. -# In some cases you may need to patch rulesets to add a mnemonic to actions that don't have one. -# https://bazel.build/reference/command-line-reference#flag--modify_execution_info -build --modify_execution_info=PackageTar=+no-remote diff --git a/MODULE.bazel b/MODULE.bazel index 630704d..e4e2576 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -7,16 +7,14 @@ module( ) # Lower-bounds (minimum) versions for direct runtime dependencies -bazel_dep(name = "aspect_bazel_lib", version = "1.33.0") -bazel_dep(name = "aspect_rules_js", version = "1.31.0") -bazel_dep(name = "bazel_features", version = "1.9.0") -bazel_dep(name = "bazel_skylib", version = "1.4.1") -bazel_dep(name = "rules_nodejs", version = "5.8.2") +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") +bazel_dep(name = "rules_nodejs", version = "6.1.0") ####### Dev dependencies ######## bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True) bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", 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) bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc") diff --git a/WORKSPACE b/WORKSPACE index f9ab3ca..d429989 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -11,16 +11,9 @@ load("//jest:dependencies.bzl", "rules_jest_dependencies") # Fetch dependencies which users need as well rules_jest_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) - -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(node_version = DEFAULT_NODE_VERSION) # For running our own unit tests load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") @@ -48,7 +41,7 @@ local_repository( ############################################ # Example npm dependencies -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/docs/jest_test.md b/docs/jest_test.md index 1c4a40e..d8bedaf 100644 --- a/docs/jest_test.md +++ b/docs/jest_test.md @@ -2,7 +2,6 @@ # Public API for Jest rules - ## jest_test @@ -26,18 +25,18 @@ Supports updating snapshots with `bazel run {name}_update_snapshots` if `snapsho | Name | Description | Default Value | | :------------- | :------------- | :------------- | | name | A unique name for this target. | none | -| node_modules | Label pointing to the linked node_modules target where jest is linked, e.g. //:node_modules. jest-cli must be linked into the node_modules supplied. jest-junit is also required by default when auto_configure_reporters is True.

NB: Only the required npm packages are included in data from //:node_modules. Other npm packages are not included as inputs. | none | -| config | "Optional Jest config file. See https://jestjs.io/docs/configuration.

Supported config file types are ".js", ".cjs", ".mjs", ".json" which come from https://jestjs.io/docs/configuration minus TypeScript since we this rule extends from the configuration. TypeScript jest configs should be transpiled before being passed to jest_test with [rules_ts](https://github.com/aspect-build/rules_ts). | None | -| data | Runtime dependencies of the Jest test.

This should include all test files, configuration files & files under test. | [] | -| snapshots | If True, a {name}_update_snapshots binary target is generated that will update all existing __snapshots__ directories when bazel run. This is the equivalent to running jest -u or jest --updateSnapshot outside of Bazel, except that new __snapshots__ will not automatically be created on update. To bootstrap a new __snapshots__ directory, you can create an empty one and then run the {name}_update_snapshots target to populate it.

If the name of the snapshot directory is not the default __snapshots__ because of a custom snapshot resolver, you can specify customize the snapshot directories with a glob or a static list. For example,

 jest_test(     name = "test",     node_modules = "//:node_modules",     config = "jest.config.js",     data = [         "greetings/greetings.js",         "greetings/greetings.test.js",         "link/link.js",         "link/link.test.js",     ],     snapshots = glob(["**/__snaps__"], exclude_directories = 0), ) 


or with a static list,

     snapshots = [         "greetings/__greetings_snaps__",         "link/__link_snaps__",     ] 


Snapshots directories must not contain any files except for snapshots. There must also be no BUILD files in the snapshots directories since they must be part of the same Bazel package that the jest_test target is in.

If snapshots are _not_ configured to output to a directory that contains only snapshots, you may alternately set snapshots to a list of snapshot files expected to be generated by this jest_test target. These must be source files and all snapshots that are generated must be explicitly listed. You may use a glob such as glob(["**/*.snap"]) to generate this list, in which case all snapshots must already be on disk so they are discovered by glob. | False | -| run_in_band | When True, the --runInBand argument is passed to the Jest CLI so that all tests are run serially in the current process, rather than creating a worker pool of child processes that run tests. See https://jestjs.io/docs/cli#--runinband for more info.

This is the desired default behavior under Bazel since Bazel expect each test process to use up one CPU core. To parallelize a single jest_test across many cores, use shard_count instead which is supported by jest_test. See https://docs.bazel.build/versions/main/test-encyclopedia.html#test-sharding. | True | -| colors | When True, the --colors argument is passed to the Jest CLI. See https://jestjs.io/docs/cli#--colors. | True | -| auto_configure_reporters | Let jest_test configure reporters for Bazel test and xml test logs.

When enabled, jest-junit must be linked to the supplied node_modules tree.

The default reporter is used for the standard test log and jest-junit is used for the xml log. These reporters are appended to the list of reporters from the user Jest config only if they are not already set.

The JEST_JUNIT_OUTPUT_FILE environment variable is always set to where Bazel expects a test runner to write its xml test log so that if jest-junit is configured in the user Jest config it will output the junit xml file where Bazel expects by default. | True | -| auto_configure_test_sequencer | Let jest_test configure a custom test sequencer for Bazel test that support Bazel sharding.

Any custom testSequencer value in a user Jest config will be overridden.

See https://jestjs.io/docs/configuration#testsequencer-string for more information on Jest testSequencer config option. | True | -| snapshots_ext | The expected extensions for snapshot files. Defaults to .snap, the Jest default. | ".snap" | -| quiet_snapshot_updates | When True, snapshot update stdout & stderr is hidden when the snapshot update is successful.

On a snapshot update failure, its stdout & stderr will always be shown. | False | -| timeout | standard attribute for tests. Defaults to "short" if both timeout and size are unspecified. | None | -| size | standard attribute for tests | None | -| kwargs | Additional named parameters passed to both js_test and js_binary. See https://github.com/aspect-build/rules_js/blob/main/docs/js_binary.md | none | +| node_modules | Label pointing to the linked node_modules target where jest is linked, e.g. `//:node_modules`. `jest-cli` must be linked into the node_modules supplied. `jest-junit` is also required by default when `auto_configure_reporters` is True.

NB: Only the required npm packages are included in data from `//:node_modules`. Other npm packages are not included as inputs. | none | +| config | "Optional Jest config file. See https://jestjs.io/docs/configuration.

Supported config file types are ".js", ".cjs", ".mjs", ".json" which come from https://jestjs.io/docs/configuration minus TypeScript since we this rule extends from the configuration. TypeScript jest configs should be transpiled before being passed to jest_test with [rules_ts](https://github.com/aspect-build/rules_ts). | `None` | +| data | Runtime dependencies of the Jest test.

This should include all test files, configuration files & files under test. | `[]` | +| snapshots | If True, a `{name}_update_snapshots` binary target is generated that will update all existing `__snapshots__` directories when `bazel run`. This is the equivalent to running `jest -u` or `jest --updateSnapshot` outside of Bazel, except that new `__snapshots__` will not automatically be created on update. To bootstrap a new `__snapshots__` directory, you can create an empty one and then run the `{name}_update_snapshots` target to populate it.

If the name of the snapshot directory is not the default `__snapshots__` because of a custom snapshot resolver, you can specify customize the snapshot directories with a `glob` or a static list. For example,

jest_test(
    name = "test",
    node_modules = "//:node_modules",
    config = "jest.config.js",
    data = [
        "greetings/greetings.js",
        "greetings/greetings.test.js",
        "link/link.js",
        "link/link.test.js",
    ],
    snapshots = glob(["**/__snaps__"], exclude_directories = 0),
)


or with a static list,

    snapshots = [
        "greetings/__greetings_snaps__",
        "link/__link_snaps__",
    ]


Snapshots directories must not contain any files except for snapshots. There must also be no BUILD files in the snapshots directories since they must be part of the same Bazel package that the `jest_test` target is in.

If snapshots are _not_ configured to output to a directory that contains only snapshots, you may alternately set `snapshots` to a list of snapshot files expected to be generated by this `jest_test` target. These must be source files and all snapshots that are generated must be explicitly listed. You may use a `glob` such as `glob(["**/*.snap"])` to generate this list, in which case all snapshots must already be on disk so they are discovered by `glob`. | `False` | +| run_in_band | When True, the `--runInBand` argument is passed to the Jest CLI so that all tests are run serially in the current process, rather than creating a worker pool of child processes that run tests. See https://jestjs.io/docs/cli#--runinband for more info.

This is the desired default behavior under Bazel since Bazel expect each test process to use up one CPU core. To parallelize a single jest_test across many cores, use `shard_count` instead which is supported by `jest_test`. See https://docs.bazel.build/versions/main/test-encyclopedia.html#test-sharding. | `True` | +| colors | When True, the `--colors` argument is passed to the Jest CLI. See https://jestjs.io/docs/cli#--colors. | `True` | +| auto_configure_reporters | Let jest_test configure reporters for Bazel test and xml test logs.

When enabled, `jest-junit` must be linked to the supplied node_modules tree.

The `default` reporter is used for the standard test log and `jest-junit` is used for the xml log. These reporters are appended to the list of reporters from the user Jest `config` only if they are not already set.

The `JEST_JUNIT_OUTPUT_FILE` environment variable is always set to where Bazel expects a test runner to write its xml test log so that if `jest-junit` is configured in the user Jest `config` it will output the junit xml file where Bazel expects by default. | `True` | +| auto_configure_test_sequencer | Let jest_test configure a custom test sequencer for Bazel test that support Bazel sharding.

Any custom testSequencer value in a user Jest `config` will be overridden.

See https://jestjs.io/docs/configuration#testsequencer-string for more information on Jest testSequencer config option. | `True` | +| snapshots_ext | The expected extensions for snapshot files. Defaults to `.snap`, the Jest default. | `".snap"` | +| quiet_snapshot_updates | When True, snapshot update stdout & stderr is hidden when the snapshot update is successful.

On a snapshot update failure, its stdout & stderr will always be shown. | `False` | +| timeout | standard attribute for tests. Defaults to "short" if both timeout and size are unspecified. | `None` | +| size | standard attribute for tests | `None` | +| kwargs | Additional named parameters passed to both `js_test` and `js_binary`. See https://github.com/aspect-build/rules_js/blob/main/docs/js_binary.md | none | diff --git a/e2e/case4/WORKSPACE.bazel b/e2e/case4/WORKSPACE.bazel index 182085e..60c104d 100644 --- a/e2e/case4/WORKSPACE.bazel +++ b/e2e/case4/WORKSPACE.bazel @@ -7,14 +7,11 @@ load("@aspect_rules_jest//jest:dependencies.bzl", "rules_jest_dependencies") rules_jest_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, -) +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/e2e/npm_packages/MODULE.bazel b/e2e/npm_packages/MODULE.bazel index dd4cb1b..f512ce1 100644 --- a/e2e/npm_packages/MODULE.bazel +++ b/e2e/npm_packages/MODULE.bazel @@ -4,8 +4,8 @@ local_path_override( path = "../..", ) -bazel_dep(name = "aspect_bazel_lib", version = "1.33.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/npm_packages/WORKSPACE.bazel b/e2e/npm_packages/WORKSPACE.bazel index 3ee99cd..60c104d 100644 --- a/e2e/npm_packages/WORKSPACE.bazel +++ b/e2e/npm_packages/WORKSPACE.bazel @@ -7,19 +7,11 @@ load("@aspect_rules_jest//jest:dependencies.bzl", "rules_jest_dependencies") rules_jest_dependencies() -# Register a nodejs toolchain, if you haven't already done so. -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, -) - -load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") - -rules_js_dependencies() +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/e2e/npm_packages/packages/lib/BUILD.bazel b/e2e/npm_packages/packages/lib/BUILD.bazel index b2beac1..6ef0ad7 100644 --- a/e2e/npm_packages/packages/lib/BUILD.bazel +++ b/e2e/npm_packages/packages/lib/BUILD.bazel @@ -7,7 +7,7 @@ npm_link_all_packages(name = "node_modules") # Basic js with 1 npm dep js_library( - name = "lib_jslib", + name = "lib", srcs = ["index.js"], deps = [ ":node_modules/@aspect-test/a", @@ -16,20 +16,20 @@ js_library( # Basic npm package wrapping the js npm_package( - name = "lib", + name = "pkg", srcs = [ "package.json", - ":lib_jslib", + ":lib", ], visibility = ["//visibility:public"], ) # Library of tests js_library( - name = "lib_tests", + name = "test_lib", srcs = glob(["*.spec.js"]), deps = [ - ":lib_jslib", + ":lib", ":node_modules/uvu", ], ) @@ -40,7 +40,7 @@ jest_test( config = "//:jest.config.cjs", data = [ "babel.config.json", - ":lib_tests", + ":test_lib", ], node_modules = "//:node_modules", ) @@ -50,7 +50,7 @@ jest_test( config = "//:jest.config.esm", data = [ "package.json", # required for jest to determine this package .js is esm - ":lib_tests", + ":test_lib", ], node_modules = "//:node_modules", node_options = [ diff --git a/e2e/smoke/MODULE.bazel b/e2e/smoke/MODULE.bazel index e5b88b0..95498b2 100644 --- a/e2e/smoke/MODULE.bazel +++ b/e2e/smoke/MODULE.bazel @@ -4,8 +4,9 @@ local_path_override( path = "../..", ) -bazel_dep(name = "aspect_rules_js", version = "1.31.0", dev_dependency = True) -bazel_dep(name = "platforms", version = "0.0.4", 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) +bazel_dep(name = "platforms", version = "0.0.9", 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 32aa48c..c05e20f 100644 --- a/e2e/smoke/WORKSPACE.bazel +++ b/e2e/smoke/WORKSPACE.bazel @@ -18,14 +18,11 @@ load("@aspect_rules_jest//jest:dependencies.bzl", "rules_jest_dependencies") rules_jest_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, -) +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/e2e/swc/MODULE.bazel b/e2e/swc/MODULE.bazel index cb410fa..abd113f 100644 --- a/e2e/swc/MODULE.bazel +++ b/e2e/swc/MODULE.bazel @@ -4,10 +4,17 @@ local_path_override( path = "../..", ) -bazel_dep(name = "aspect_bazel_lib", version = "1.33.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) bazel_dep(name = "aspect_rules_swc", version = "1.2.2", dev_dependency = True) -bazel_dep(name = "platforms", version = "0.0.4", dev_dependency = True) +bazel_dep(name = "platforms", version = "0.0.9", dev_dependency = True) + +archive_override( + module_name = "aspect_rules_swc", + integrity = "sha256-+BUkMlB7mYzuSBEuVWLM08zlh8BXnwsKSlgkBqFjF7Q=", + strip_prefix = "rules_swc-3843ada2222c537e3c1982dec16b8d3d62a9da49", + urls = ["https://github.com/aspect-build/rules_swc/archive/3843ada2222c537e3c1982dec16b8d3d62a9da49/3843ada2222c537e3c1982dec16b8d3d62a9da49.tar.gz"], +) npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True) npm.npm_translate_lock( diff --git a/e2e/swc/WORKSPACE.bazel b/e2e/swc/WORKSPACE.bazel index 7991cca..13faed3 100644 --- a/e2e/swc/WORKSPACE.bazel +++ b/e2e/swc/WORKSPACE.bazel @@ -7,19 +7,11 @@ load("@aspect_rules_jest//jest:dependencies.bzl", "rules_jest_dependencies") rules_jest_dependencies() -# Register a nodejs toolchain, if you haven't already done so. -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, -) - -load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") - -rules_js_dependencies() +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", @@ -36,9 +28,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "aspect_rules_swc", - sha256 = "cde09df7dea773adaed896612434559f8955d2dfb2cfd6429ee333f30299ed34", - strip_prefix = "rules_swc-1.2.2", - url = "https://github.com/aspect-build/rules_swc/releases/download/v1.2.2/rules_swc-v1.2.2.tar.gz", + integrity = "sha256-+BUkMlB7mYzuSBEuVWLM08zlh8BXnwsKSlgkBqFjF7Q=", + strip_prefix = "rules_swc-3843ada2222c537e3c1982dec16b8d3d62a9da49", + url = "https://github.com/aspect-build/rules_swc/archive/3843ada2222c537e3c1982dec16b8d3d62a9da49/3843ada2222c537e3c1982dec16b8d3d62a9da49.tar.gz", ) load("@aspect_rules_swc//swc:dependencies.bzl", "rules_swc_dependencies") diff --git a/jest/BUILD.bazel b/jest/BUILD.bazel index fbee60a..16dcb77 100644 --- a/jest/BUILD.bazel +++ b/jest/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("//jest/private:is_bazel_7_or_greater.bzl", "is_bazel_7_or_greater") # For stardoc to reference the files exports_files(["defs.bzl"]) @@ -21,7 +21,7 @@ bzl_library( "@aspect_bazel_lib//lib:copy_file", "@aspect_bazel_lib//lib:directory_path", "@aspect_bazel_lib//lib:utils", - ] + (["@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( diff --git a/jest/defs.bzl b/jest/defs.bzl index fe40116..a611cc0 100644 --- a/jest/defs.bzl +++ b/jest/defs.bzl @@ -23,11 +23,7 @@ def _jest_from_node_modules(jest_rule, name, node_modules, auto_configure_report jest_rule( name = name, enable_runfiles = select({ - "@aspect_rules_js//js:enable_runfiles": True, - "//conditions:default": False, - }), - unresolved_symlinks_enabled = select({ - "@aspect_rules_js//js:allow_unresolved_symlinks": True, + "@aspect_bazel_lib//lib:enable_runfiles": True, "//conditions:default": False, }), data = data, diff --git a/jest/dependencies.bzl b/jest/dependencies.bzl index 4316f79..e68d55b 100644 --- a/jest/dependencies.bzl +++ b/jest/dependencies.bzl @@ -6,28 +6,29 @@ load("//jest/private:maybe.bzl", http_archive = "maybe_http_archive") def rules_jest_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 = "d488d8ecca98a4042442a4ae5f1ab0b614f896c0ebf6e3eafff363bcc51c6e62", - strip_prefix = "bazel-lib-1.33.0", - url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.33.0/bazel-lib-v1.33.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"], + 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", ) http_archive( diff --git a/jest/private/BUILD.bazel b/jest/private/BUILD.bazel index 6eebb69..0234f50 100644 --- a/jest/private/BUILD.bazel +++ b/jest/private/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("//jest/private:is_bazel_7_or_greater.bzl", "is_bazel_7_or_greater") exports_files([ "jest_config_template.mjs", @@ -37,11 +37,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 []), -) - -bzl_library( - name = "is_bazel_7_or_greater", - srcs = ["is_bazel_7_or_greater.bzl"], - visibility = ["//jest:__subpackages__"], + ] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if bazel_lib_utils.is_bazel_7_or_greater() else []), ) diff --git a/jest/private/is_bazel_7_or_greater.bzl b/jest/private/is_bazel_7_or_greater.bzl deleted file mode 100644 index 0a9b740..0000000 --- a/jest/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/jest/private/jest_test.bzl b/jest/private/jest_test.bzl index 6c5c4b5..24dd019 100644 --- a/jest/private/jest_test.bzl +++ b/jest/private/jest_test.bzl @@ -129,11 +129,13 @@ def _impl(ctx): runfiles = ctx.runfiles( files = files, - transitive_files = js_lib_helpers.gather_files_from_js_providers( - targets = ctx.attr.data + [ctx.attr.config] if ctx.attr.config else [], + transitive_files = js_lib_helpers.gather_files_from_js_infos( + targets = ctx.attr.data + [ctx.attr.config] if ctx.attr.config else ctx.attr.data, + include_sources = ctx.attr.include_sources, + include_types = ctx.attr.include_types, include_transitive_sources = ctx.attr.include_transitive_sources, - include_declarations = ctx.attr.include_declarations, - include_npm_linked_packages = ctx.attr.include_npm_linked_packages, + include_transitive_types = ctx.attr.include_transitive_types, + include_npm_sources = ctx.attr.include_npm_sources, ), ).merge(launcher.runfiles).merge_all([ target[DefaultInfo].default_runfiles