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 Apr 29, 2024
1 parent a66680d commit a2140d1
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .bazeliskrc
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
7.0.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.
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ bazel-*
.bazelrc.user
node_modules

# Don't share lockfile for now. It is unstable.
# 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
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ default_stages: [commit]
repos:
# Check formatting and lint for starlark code
- repo: https://github.com/keith/pre-commit-buildifier
rev: 4.0.1.1
rev: 6.4.0
hooks:
- id: buildifier
- id: buildifier-lint
# Enforce that commit messages allow for later changelog generation
- repo: https://github.com/commitizen-tools/commitizen
rev: v2.18.0
rev: v3.24.0
hooks:
# Requires that commitizen is already installed
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v2.4.0'
rev: v3.1.0
hooks:
- id: prettier
13 changes: 10 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")

buildifier(
name = "buildifier",
exclude_patterns = ["./.git/*"],
lint_mode = "fix",
mode = "fix",
tags = ["manual"], # tag as manual so windows ci does not build it by default
)

buildifier(
name = "buildifier.check",
exclude_patterns = [
"./.git/*",
],
exclude_patterns = ["./.git/*"],
lint_mode = "warn",
mode = "diff",
tags = ["manual"], # tag as manual so windows ci does not build it by default
)

bzl_library(
Expand Down
34 changes: 10 additions & 24 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ module(
compatibility_level = 1,
)

# Lower-bound (minimum) versions of direct dependencies
bazel_dep(name = "bazel_skylib", version = "1.3.0")

# Need feat: backport 2.x features for interoperability by @kormide in #657
bazel_dep(name = "aspect_bazel_lib", version = "1.38.0")

# Need feat: import toolchains to use for copy actions by @kormide in #1355
bazel_dep(name = "aspect_rules_js", version = "1.34.0")
bazel_dep(name = "rules_nodejs", version = "5.5.3")
# Lower-bounds (minimum) versions for direct runtime dependencies
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1")
bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.3")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "rules_nodejs", version = "6.1.0")
bazel_dep(name = "platforms", version = "0.0.5")

rollup = use_extension("@aspect_rules_rollup//rollup:extensions.bzl", "rollup")
Expand All @@ -24,26 +20,16 @@ rollup.toolchain(
)
use_repo(rollup, "rollup")

bazel_dep(name = "buildifier_prebuilt", version = "6.1.2", dev_dependency = True)
####### Dev dependencies ########

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
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")

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")

# We want the stardoc handling from bazel-lib 2.x for dev use here,
# but not force users to upgrade yet.
archive_override(
module_name = "aspect_bazel_lib",
integrity = "sha256-9ep2aCsgnMC9kND1o7JtL3pqKIXwxfYV5ykT9IBduw0=",
strip_prefix = "bazel-lib-2.5.0",
urls = ["https://github.com/aspect-build/bazel-lib/releases/download/v2.5.0/bazel-lib-v2.5.0.tar.gz"],
)
28 changes: 14 additions & 14 deletions docs/rollup.md

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

12 changes: 5 additions & 7 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
"Bazel dependencies"

bazel_dep(name = "aspect_rules_rollup", version = "0.0.0", dev_dependency = True)
bazel_dep(name = "aspect_bazel_lib", version = "2.2.0", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.3.0", dev_dependency = True)
bazel_dep(name = "aspect_rules_js", version = "1.35.0", dev_dependency = True)

local_path_override(
module_name = "aspect_rules_rollup",
path = "../..",
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1", dev_dependency = True)
bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.3", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
pnpm_lock = "@aspect_rules_rollup//:pnpm-lock.yaml",
Expand Down
10 changes: 4 additions & 6 deletions e2e/smoke/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
rules_js_dependencies()

# Fetch and register a node toolchain, if you haven't already
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")

nodejs_register_toolchains(
name = "node",
node_version = DEFAULT_NODE_VERSION,
)
load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains")

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 a2140d1

Please sign in to comment.