Skip to content

Commit f36f89d

Browse files
authored
feat: upgrade to rules_js 2.0 (#86)
1 parent a640b20 commit f36f89d

File tree

13 files changed

+48
-98
lines changed

13 files changed

+48
-98
lines changed

.aspect/bazelrc/ci.bazelrc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# We recommend enforcing a policy that keeps your CI from being slowed down
2-
# by individual test targets that should be optimized
3-
# or split up into multiple test targets with sharding or manually.
4-
# Set this flag to exclude targets that have their timeout set to eternal (>15m) from running on CI.
5-
# Docs: https://bazel.build/docs/user-manual#test-timeout-filters
6-
test --test_timeout_filters=-eternal
7-
81
# Set this flag to enable re-tries of failed tests on CI.
92
# When any test target fails, try one or more times. This applies regardless of whether the "flaky"
103
# tag appears on the target definition.

.aspect/bazelrc/javascript.bazelrc

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,4 @@
88
# details.
99
# Docs: https://nodejs.org/en/docs/guides/debugging-getting-started/#command-line-options
1010
run:debug -- --node_options=--inspect-brk
11-
12-
# Enable runfiles on all platforms. Runfiles are on by default on Linux and MacOS but off on
13-
# Windows.
14-
#
15-
# In general, rules_js and derivate rule sets assume that runfiles are enabled and do not support no
16-
# runfiles case because it does not scale to teach all Node.js tools to use the runfiles manifest.
17-
#
18-
# If you are developing on Windows, you must either run bazel with administrator privileges or
19-
# enable developer mode. If you do not you may hit this error on Windows:
20-
#
21-
# Bazel needs to create symlinks to build the runfiles tree.
22-
# Creating symlinks on Windows requires one of the following:
23-
# 1. Bazel is run with administrator privileges.
24-
# 2. The system version is Windows 10 Creators Update (1703) or later
25-
# and developer mode is enabled.
26-
#
27-
# Docs: https://bazel.build/reference/command-line-reference#flag--enable_runfiles
28-
build --enable_runfiles
11+
test:debug --test_env=NODE_OPTIONS=--inspect-brk

.aspect/bazelrc/performance.bazelrc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
# Speed up all builds by not checking if output files have been modified. Lets you make changes to
2-
# the output tree without triggering a build for local debugging. For example, you can modify
3-
# [rules_js](https://github.com/aspect-build/rules_js) 3rd party npm packages in the output tree
4-
# when local debugging.
5-
# Docs: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/pkgcache/PackageOptions.java#L185
6-
build --noexperimental_check_output_files
7-
fetch --noexperimental_check_output_files
8-
query --noexperimental_check_output_files
9-
101
# Don't apply `--noremote_upload_local_results` and `--noremote_accept_cached` to the disk cache.
112
# If you have both `--noremote_upload_local_results` and `--disk_cache`, then this fixes a bug where
123
# Bazel doesn't write to the local disk cache as it treats as a remote cache.

.github/workflows/bazel6.bazelrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ build --reuse_sandbox_directories
1313
# Avoid this flag being enabled by remote_download_minimal or remote_download_toplevel
1414
# See https://meroton.com/blog/bazel-6-errors-build-without-the-bytes/
1515
build --noexperimental_action_cache_store_output_metadata
16+
17+
# Speed up all builds by not checking if output files have been modified. Lets you make changes to
18+
# the output tree without triggering a build for local debugging. For example, you can modify
19+
# [rules_js](https://github.com/aspect-build/rules_js) 3rd party npm packages in the output tree
20+
# when local debugging.
21+
# Docs: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/pkgcache/PackageOptions.java#L185
22+
# NB: This flag is in bazel6.bazelrc as when used in Bazel 7 is has been observed to break
23+
# "build without the bytes" --remote_download_outputs=toplevel. See https://github.com/aspect-build/bazel-lib/pull/711
24+
# for more info.
25+
build --noexperimental_check_output_files
26+
fetch --noexperimental_check_output_files
27+
query --noexperimental_check_output_files

.github/workflows/bazel7.bazelrc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,3 @@ query --noexperimental_check_external_repository_files
99
# build.
1010
# Docs: https://bazel.build/reference/command-line-reference#flag--reuse_sandbox_directories
1111
build --reuse_sandbox_directories
12-
13-
# Avoid this flag being enabled by remote_download_minimal or remote_download_toplevel
14-
# See https://meroton.com/blog/bazel-6-errors-build-without-the-bytes/
15-
build --noexperimental_action_cache_store_output_metadata

MODULE.bazel

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ module(
77
)
88

99
# Lower-bounds (minimum) versions for direct runtime dependencies
10-
bazel_dep(name = "aspect_bazel_lib", version = "1.38.0")
11-
bazel_dep(name = "aspect_rules_js", version = "1.31.0")
12-
bazel_dep(name = "bazel_skylib", version = "1.4.1")
10+
bazel_dep(name = "aspect_bazel_lib", version = "2.7.3")
11+
bazel_dep(name = "aspect_rules_js", version = "2.0.0-rc0")
12+
bazel_dep(name = "bazel_skylib", version = "1.5.0")
1313

1414
####### Dev dependencies ########
1515

16-
bazel_dep(name = "bazel_features", version = "0.1.0", dev_dependency = True)
1716
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
1817
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc")

WORKSPACE

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,11 @@ load("@aspect_rules_terser//terser:dependencies.bzl", "rules_terser_dependencies
1010

1111
rules_terser_dependencies()
1212

13-
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
13+
load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains")
1414

15-
aspect_bazel_lib_dependencies(override_local_config_platform = True)
15+
rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION)
1616

17-
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
18-
19-
nodejs_register_toolchains(
20-
name = "node16",
21-
node_version = "16.9.0",
22-
)
23-
24-
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
17+
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")
2518

2619
npm_translate_lock(
2720
name = "npm",

e2e/smoke/MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ local_path_override(
44
path = "../..",
55
)
66

7-
bazel_dep(name = "aspect_bazel_lib", version = "1.38.0", dev_dependency = True)
8-
bazel_dep(name = "aspect_rules_js", version = "1.31.0", dev_dependency = True)
7+
bazel_dep(name = "aspect_bazel_lib", version = "2.7.3", dev_dependency = True)
8+
bazel_dep(name = "aspect_rules_js", version = "2.0.0-rc0", dev_dependency = True)
99

1010
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
1111
npm.npm_translate_lock(

e2e/smoke/WORKSPACE.bazel

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@ rules_terser_dependencies()
1818

1919
# Fetch and register a nodejs interpreter, if you haven't already
2020

21-
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
21+
load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains")
2222

23-
nodejs_register_toolchains(
24-
name = "node",
25-
node_version = DEFAULT_NODE_VERSION,
26-
)
23+
rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION)
2724

28-
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
25+
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")
2926

3027
npm_translate_lock(
3128
name = "npm",

terser/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
load("@aspect_bazel_lib//lib:utils.bzl", bazel_lib_utils = "utils")
12
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2-
load("//terser/private:is_bazel_7_or_greater.bzl", "is_bazel_7_or_greater")
33

44
# For stardoc to reference the files
55
exports_files(["defs.bzl"])
@@ -11,7 +11,7 @@ bzl_library(
1111
deps = [
1212
"@bazel_tools//tools/build_defs/repo:http.bzl",
1313
"@bazel_tools//tools/build_defs/repo:utils.bzl",
14-
] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if is_bazel_7_or_greater() else []),
14+
] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if bazel_lib_utils.is_bazel_7_or_greater() else []),
1515
)
1616

1717
bzl_library(
@@ -22,5 +22,5 @@ bzl_library(
2222
"//terser/private:terser",
2323
"@aspect_bazel_lib//lib:copy_file",
2424
"@aspect_rules_js//js:defs",
25-
] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if is_bazel_7_or_greater() else []),
25+
] + (["@bazel_tools//tools/build_defs/repo:cache.bzl"] if bazel_lib_utils.is_bazel_7_or_greater() else []),
2626
)

terser/dependencies.bzl

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,27 @@ load("//terser/private:maybe.bzl", http_archive = "maybe_http_archive")
66
def rules_terser_dependencies():
77
http_archive(
88
name = "bazel_skylib",
9-
sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7",
10-
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz"],
9+
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
10+
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"],
1111
)
1212

1313
http_archive(
1414
name = "aspect_bazel_lib",
15-
sha256 = "b848cd8e93be7f18c3deda6d2f3ade92a657d3585e119953bc50dc75fef535c2",
16-
strip_prefix = "bazel-lib-1.38.0",
17-
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.38.0/bazel-lib-v1.38.0.tar.gz",
15+
sha256 = "87ab4ec479ebeb00d286266aca2068caeef1bb0b1765e8f71c7b6cfee6af4226",
16+
strip_prefix = "bazel-lib-2.7.3",
17+
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.3/bazel-lib-v2.7.3.tar.gz",
1818
)
1919

2020
http_archive(
2121
name = "aspect_rules_js",
22-
sha256 = "7b2a4d1d264e105eae49a27e2e78065b23e2e45724df2251eacdd317e95bfdfd",
23-
strip_prefix = "rules_js-1.31.0",
24-
url = "https://github.com/aspect-build/rules_js/releases/download/v1.31.0/rules_js-v1.31.0.tar.gz",
22+
sha256 = "389021e29b3aeed2f6fb3a7a1478f8fc52947a6500b198a7ec0f3358c2842415",
23+
strip_prefix = "rules_js-2.0.0-rc0",
24+
url = "https://github.com/aspect-build/rules_js/releases/download/v2.0.0-rc0/rules_js-v2.0.0-rc0.tar.gz",
2525
)
2626

2727
http_archive(
2828
name = "rules_nodejs",
29-
sha256 = "764a3b3757bb8c3c6a02ba3344731a3d71e558220adcb0cf7e43c9bba2c37ba8",
30-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.2/rules_nodejs-core-5.8.2.tar.gz"],
31-
)
32-
33-
http_archive(
34-
name = "bazel_features",
35-
sha256 = "f3082bfcdca73dc77dcd68faace806135a2e08c230b02b1d9fbdbd7db9d9c450",
36-
strip_prefix = "bazel_features-0.1.0",
37-
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v0.1.0/bazel_features-v0.1.0.tar.gz",
29+
sha256 = "dddd60acc3f2f30359bef502c9d788f67e33814b0ddd99aa27c5a15eb7a41b8c",
30+
strip_prefix = "rules_nodejs-6.1.0",
31+
url = "https://github.com/bazelbuild/rules_nodejs/releases/download/v6.1.0/rules_nodejs-v6.1.0.tar.gz",
3832
)

terser/private/is_bazel_7_or_greater.bzl

Lines changed: 0 additions & 7 deletions
This file was deleted.

terser/private/terser.bzl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,18 @@ def _impl(ctx):
110110
targets = ctx.attr.srcs,
111111
)
112112

113-
transitive_declarations = js_lib_helpers.gather_transitive_declarations(
114-
declarations = [],
113+
transitive_types = js_lib_helpers.gather_transitive_types(
114+
types = [],
115115
targets = ctx.attr.srcs,
116116
)
117117

118-
npm_linked_packages = js_lib_helpers.gather_npm_linked_packages(
118+
npm_sources = js_lib_helpers.gather_npm_sources(
119119
srcs = ctx.attr.srcs,
120120
deps = [],
121121
)
122122

123-
npm_package_store_deps = js_lib_helpers.gather_npm_package_store_deps(
124-
targets = ctx.attr.data,
123+
npm_package_store_infos = js_lib_helpers.gather_npm_package_store_infos(
124+
targets = ctx.attr.srcs + ctx.attr.data,
125125
)
126126

127127
runfiles = js_lib_helpers.gather_runfiles(
@@ -133,14 +133,13 @@ def _impl(ctx):
133133

134134
return [
135135
js_info(
136-
npm_linked_package_files = npm_linked_packages.direct_files,
137-
npm_linked_packages = npm_linked_packages.direct,
138-
npm_package_store_deps = npm_package_store_deps,
136+
target = ctx.label,
139137
sources = output_sources_depset,
140-
transitive_declarations = transitive_declarations,
141-
transitive_npm_linked_package_files = npm_linked_packages.transitive_files,
142-
transitive_npm_linked_packages = npm_linked_packages.transitive,
138+
types = depset(), # terser does not emit types directly
143139
transitive_sources = transitive_sources,
140+
transitive_types = transitive_types,
141+
npm_sources = npm_sources,
142+
npm_package_store_infos = npm_package_store_infos,
144143
),
145144
DefaultInfo(
146145
files = output_sources_depset,

0 commit comments

Comments
 (0)