Skip to content

Commit

Permalink
feat: upgrade to rules_js 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed May 21, 2024
1 parent 97eb82c commit b3905a4
Show file tree
Hide file tree
Showing 37 changed files with 438 additions and 374 deletions.
7 changes: 0 additions & 7 deletions .aspect/bazelrc/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions .aspect/bazelrc/javascript.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
# details.
# Docs: https://nodejs.org/en/docs/guides/debugging-getting-started/#command-line-options
run:debug -- --node_options=--inspect-brk
test:debug --test_env=NODE_OPTIONS=--inspect-brk
8 changes: 4 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ module(
)

# Lower-bounds (minimum) versions for direct runtime dependencies
bazel_dep(name = "aspect_bazel_lib", version = "1.40.2")
bazel_dep(name = "aspect_rules_js", version = "1.34.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")
bazel_dep(name = "platforms", version = "0.0.5")

# TODO(4.x): remove support for non-toolchainized protoc
Expand All @@ -26,7 +26,7 @@ bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependenc
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, repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_nodejs", version = "5.8.2", dev_dependency = True)
bazel_dep(name = "rules_nodejs", version = "6.1.0", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc")

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
Expand Down
8 changes: 3 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,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", "register_coreutils_toolchains")
load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains")

aspect_bazel_lib_dependencies()

register_coreutils_toolchains()
rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION)

load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")

Expand Down Expand Up @@ -85,7 +83,7 @@ buildifier_prebuilt_register_toolchains()

###########################################
# A pnpm workspace so we can test 3p deps
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",
Expand Down
4 changes: 2 additions & 2 deletions docs/rules.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/transpiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ ts_project(name = a) --foo.d.ts--> npm_package ---> npm_link_package ---> ts_pro
In this diagram, we'd like to be able to change the TypeScript sources of `a` and then re-run the test target, without waiting for type-checking.
However, since `foo.d.ts` is declared as an input to the `npm_package` rule, Bazel needs to produce it.
To solve this, you can add the flag `--@aspect_rules_js//npm:exclude_declarations_from_npm_packages` to your `bazel` command.
To solve this, you can add the flag `--@aspect_rules_js//npm:exclude_types_from_npm_packages` to your `bazel` command.
Use this flag only for local development! You can add a line to your `.bazelrc` to make this easier to type, for example:
```
# Run bazel --config=dev to choose these options:
build:dev --@aspect_rules_js//npm:exclude_declarations_from_npm_packages
build:dev --@aspect_rules_js//npm:exclude_types_from_npm_packages
```
5 changes: 2 additions & 3 deletions e2e/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ local_path_override(
path = "../..",
)

# repeated here only because we use the platforms definitions for rbe
bazel_dep(name = "aspect_rules_js", version = "1.34.0", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.6", dev_dependency = True) # repeated here only because we use the platforms definitions for rbe
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "rules_proto", version = "5.3.0-21.7", dev_dependency = True)
bazel_dep(name = "toolchains_protoc", version = "0.2.4", dev_dependency = True)

Expand Down
86 changes: 37 additions & 49 deletions e2e/bzlmod/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions e2e/external_dep/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ local_path_override(
# no such package '@[unknown repo 'aspect_rules_js' requested from @]//platforms':
# The repository '@[unknown repo 'aspect_rules_js' requested from @]' could not be resolved:
# No repository visible as '@aspect_rules_js' from main repository
bazel_dep(name = "aspect_rules_js", version = "1.37.1", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.4.2", dev_dependency = True)
bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.6", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)

rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)
rules_ts_ext.deps()
Expand Down
10 changes: 3 additions & 7 deletions e2e/external_dep/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

# Fetch and register node, 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",
Expand Down
4 changes: 2 additions & 2 deletions e2e/external_dep/app/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ local_path_override(
)

# TODO: see note on rules_js in the parent MODULE.bazel
bazel_dep(name = "aspect_rules_js", version = "1.37.1", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.6", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)

rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)
rules_ts_ext.deps()
Expand Down
10 changes: 3 additions & 7 deletions e2e/external_dep/app/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

# Fetch and register node, 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",
Expand Down
Loading

0 comments on commit b3905a4

Please sign in to comment.