Skip to content

Commit

Permalink
refactor: upgrade to latest rules_nodejs 6.x and move toolchain regis…
Browse files Browse the repository at this point in the history
…tration call to new rules_js_configure WORKSPACE function
  • Loading branch information
gregmagolan committed Apr 5, 2024
1 parent b407431 commit 8527b49
Show file tree
Hide file tree
Showing 79 changed files with 434 additions and 327 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bazel_dep(name = "aspect_rules_js", version = "${TAG:1}")
####### Node.js version #########
# By default you get the node version from DEFAULT_NODE_VERSION in @rules_nodejs//nodejs:repositories.bzl
# Optionally you can pin a different node version:
bazel_dep(name = "rules_nodejs", version = "5.8.2")
bazel_dep(name = "rules_nodejs", version = "6.0.5")
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
node.toolchain(node_version = "16.14.2")
#################################
Expand Down
15 changes: 6 additions & 9 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@ bazel_dep(name = "aspect_bazel_lib", version = "2.6.1")
bazel_dep(name = "aspect_rules_lint", version = "0.12.0")
bazel_dep(name = "bazel_features", version = "1.9.0")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "rules_nodejs", version = "6.0.5")
bazel_dep(name = "platforms", version = "0.0.5")

# Keep v5 in to avoid breaking changes.
# TODO(2.0): change minimum to v6
bazel_dep(name = "rules_nodejs", version = "5.8.2")

# Override rules_nodejs to v6 to test the latest and recommended version internally.
single_version_override(
archive_override(
module_name = "rules_nodejs",
version = "6.0.5",
integrity = "sha256-7oUb51pi91gSXCT8tPEE7+qyW6VD8Wr7ti3lMBPg2O0=",
strip_prefix = "rules_nodejs-113efd11503a0c622887e945c237089c54938b77",
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/113efd11503a0c622887e945c237089c54938b77.tar.gz"],
)

bazel_dep(name = "platforms", version = "0.0.5")

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
use_repo(node, "nodejs_darwin_amd64")
use_repo(node, "nodejs_darwin_arm64")
Expand Down
29 changes: 7 additions & 22 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,23 @@ workspace(
name = "aspect_rules_js",
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Override rules_nodejs to v6 to test the latest and recommended versional internally,
# while keeping v5 in rules_js_dependencies() to avoid breaking changes.
# TODO(2.0): change minimum to v6 in repositories.bzl
http_archive(
name = "rules_nodejs",
sha256 = "a50986c7d2f2dc43a5b9b81a6245fd89bdc4866f1d5e316d9cef2782dd859292",
strip_prefix = "rules_nodejs-6.0.5",
url = "https://github.com/bazelbuild/rules_nodejs/releases/download/v6.0.5/rules_nodejs-v6.0.5.tar.gz",
)

load("//js:dev_repositories.bzl", "rules_js_dev_dependencies")
load("@aspect_rules_js//js:dev_repositories.bzl", "rules_js_dev_dependencies")

rules_js_dev_dependencies()

load("//js:repositories.bzl", "rules_js_dependencies")
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_jq_toolchains")
load("@aspect_rules_js//js:configure.bzl", "rules_js_configure")

aspect_bazel_lib_dependencies()
rules_js_configure(node_version = "16.14.2")

register_jq_toolchains()
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")

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

nodejs_register_toolchains(
name = "nodejs",
node_version = "16.14.2",
)
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")

# Alternate toolchains for testing across versions
nodejs_register_toolchains(
Expand Down
5 changes: 1 addition & 4 deletions docs/npm_import.md

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

8 changes: 0 additions & 8 deletions docs/npm_package.md

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

7 changes: 0 additions & 7 deletions docs/npm_translate_lock.md

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

7 changes: 7 additions & 0 deletions e2e/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ local_path_override(
path = "../..",
)

archive_override(
module_name = "rules_nodejs",
integrity = "sha256-7oUb51pi91gSXCT8tPEE7+qyW6VD8Wr7ti3lMBPg2O0=",
strip_prefix = "rules_nodejs-113efd11503a0c622887e945c237089c54938b77",
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/113efd11503a0c622887e945c237089c54938b77.tar.gz"],
)

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
Expand Down
7 changes: 7 additions & 0 deletions e2e/git_dep_metadata/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ local_path_override(
path = "../..",
)

archive_override(
module_name = "rules_nodejs",
integrity = "sha256-7oUb51pi91gSXCT8tPEE7+qyW6VD8Wr7ti3lMBPg2O0=",
strip_prefix = "rules_nodejs-113efd11503a0c622887e945c237089c54938b77",
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/113efd11503a0c622887e945c237089c54938b77.tar.gz"],
)

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
Expand Down
7 changes: 2 additions & 5 deletions e2e/git_dep_metadata/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
load("@aspect_rules_js//js:configure.bzl", "rules_js_configure")

nodejs_register_toolchains(
name = "nodejs",
node_version = DEFAULT_NODE_VERSION,
)
rules_js_configure()

load("@aspect_rules_js//npm:repositories.bzl", "npm_import")

Expand Down
7 changes: 7 additions & 0 deletions e2e/gyp_no_install_script/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ local_path_override(
path = "../..",
)

archive_override(
module_name = "rules_nodejs",
integrity = "sha256-7oUb51pi91gSXCT8tPEE7+qyW6VD8Wr7ti3lMBPg2O0=",
strip_prefix = "rules_nodejs-113efd11503a0c622887e945c237089c54938b77",
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/113efd11503a0c622887e945c237089c54938b77.tar.gz"],
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "npm",
Expand Down
7 changes: 2 additions & 5 deletions e2e/gyp_no_install_script/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
load("@aspect_rules_js//js:configure.bzl", "rules_js_configure")

nodejs_register_toolchains(
name = "nodejs",
node_version = DEFAULT_NODE_VERSION,
)
rules_js_configure()

load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

Expand Down
7 changes: 2 additions & 5 deletions e2e/js_image_docker/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
load("@aspect_rules_js//js:configure.bzl", "rules_js_configure")

nodejs_register_toolchains(
name = "nodejs",
node_version = "16.14.2",
)
rules_js_configure(node_version = "16.14.2")

load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

Expand Down
7 changes: 2 additions & 5 deletions e2e/js_image_oci/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
load("@aspect_rules_js//js:configure.bzl", "rules_js_configure")

nodejs_register_toolchains(
name = "nodejs",
node_version = "16.14.2",
)
rules_js_configure(node_version = "16.14.2")

load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

Expand Down
7 changes: 7 additions & 0 deletions e2e/js_run_devserver/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ local_path_override(
path = "../..",
)

archive_override(
module_name = "rules_nodejs",
integrity = "sha256-7oUb51pi91gSXCT8tPEE7+qyW6VD8Wr7ti3lMBPg2O0=",
strip_prefix = "rules_nodejs-113efd11503a0c622887e945c237089c54938b77",
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/113efd11503a0c622887e945c237089c54938b77.tar.gz"],
)

pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
use_repo(pnpm, "pnpm")

Expand Down
7 changes: 2 additions & 5 deletions e2e/js_run_devserver/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
load("@aspect_rules_js//js:configure.bzl", "rules_js_configure")

nodejs_register_toolchains(
name = "nodejs",
node_version = DEFAULT_NODE_VERSION,
)
rules_js_configure()

load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

Expand Down
7 changes: 2 additions & 5 deletions e2e/npm_link_package-esm/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
load("@aspect_rules_js//js:configure.bzl", "rules_js_configure")

nodejs_register_toolchains(
name = "nodejs",
node_version = "16.9.0",
)
rules_js_configure(node_version = "16.9.0")

load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

Expand Down
7 changes: 2 additions & 5 deletions e2e/npm_link_package/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
load("@aspect_rules_js//js:configure.bzl", "rules_js_configure")

nodejs_register_toolchains(
name = "nodejs",
node_version = "16.14.2",
)
rules_js_configure(node_version = "16.14.2")

load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

Expand Down
7 changes: 7 additions & 0 deletions e2e/npm_translate_lock/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ local_path_override(
path = "../..",
)

archive_override(
module_name = "rules_nodejs",
integrity = "sha256-7oUb51pi91gSXCT8tPEE7+qyW6VD8Wr7ti3lMBPg2O0=",
strip_prefix = "rules_nodejs-113efd11503a0c622887e945c237089c54938b77",
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/113efd11503a0c622887e945c237089c54938b77.tar.gz"],
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "npm",
Expand Down
7 changes: 2 additions & 5 deletions e2e/npm_translate_lock/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
load("@aspect_rules_js//js:configure.bzl", "rules_js_configure")

nodejs_register_toolchains(
name = "nodejs",
node_version = DEFAULT_NODE_VERSION,
)
rules_js_configure()

load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

Expand Down
7 changes: 7 additions & 0 deletions e2e/npm_translate_lock_auth/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ local_path_override(
path = "../..",
)

archive_override(
module_name = "rules_nodejs",
integrity = "sha256-7oUb51pi91gSXCT8tPEE7+qyW6VD8Wr7ti3lMBPg2O0=",
strip_prefix = "rules_nodejs-113efd11503a0c622887e945c237089c54938b77",
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/113efd11503a0c622887e945c237089c54938b77.tar.gz"],
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "npm",
Expand Down
Loading

0 comments on commit 8527b49

Please sign in to comment.