Skip to content

Commit

Permalink
refactor: move http_archive back to WORKSPACE
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Apr 2, 2023
1 parent df7b4d3 commit d98eb4e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 81 deletions.
26 changes: 1 addition & 25 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module(

bazel_dep(name = "rules_nodejs", dev_dependency = True, version = "0.0.0")
bazel_dep(name = "bazel_skylib", dev_dependency = True, version = "1.3.0")
bazel_dep(name = "aspect_bazel_lib", dev_dependency = True, version = "1.30.2")

local_path_override(
module_name = "rules_nodejs",
Expand Down Expand Up @@ -38,28 +39,3 @@ use_repo(
"node16_darwin_amd64",
"node16_windows_amd64",
)

http = use_extension("//:deps.bzl", "http")

http.archive(
name = "npm_acorn-8.5.0",
build_file_content = """
load("@rules_nodejs//third_party/github.com/bazelbuild/bazel-skylib:rules/copy_file.bzl", "copy_file")
# Turn a source directory into a TreeArtifact for RBE-compat
copy_file(
name = "npm_acorn-8.5.0",
src = "package",
# This attribute comes from rules_nodejs patch of
# https://github.com/bazelbuild/bazel-skylib/pull/323
is_directory = True,
# We must give this as the directory in order for it to appear on NODE_PATH
out = "acorn",
visibility = ["//visibility:public"],
)
""",
sha256 = "d8f9d40c4656537a60bf0c6daae6f0553f54df5ff2518f86464b7c785f20376b",
urls = ["https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz"],
)

use_repo(http, "npm_acorn-8.5.0")
36 changes: 17 additions & 19 deletions e2e/smoke/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,26 @@ http_archive(
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.2/rules_nodejs-core-5.8.2.tar.gz"],
)

# Note: skylib 1.1.1 has some bug on Windows with diff_test, which we use in this example
http_archive(
name = "bazel_skylib",
sha256 = "afbe4d9d033c007940acd24bb9becf1580a0280ae0b2ebbb5a7cb12912d2c115",
strip_prefix = "bazel-skylib-ffad33e9bfc60bdfa98292ca655a4e7035792046",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/ffad33e9bfc60bdfa98292ca655a4e7035792046.tar.gz"],
sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
],
)

http_archive(
name = "aspect_bazel_lib",
sha256 = "97fa63d95cc9af006c4c7b2123ddd2a91fb8d273012f17648e6423bae2c69470",
strip_prefix = "bazel-lib-1.30.2",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.30.2/bazel-lib-v1.30.2.tar.gz",
)

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

aspect_bazel_lib_dependencies()

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

# The order matters because Bazel will provide the first registered toolchain when a rule asks Bazel to select it
Expand All @@ -32,21 +44,7 @@ nodejs_register_toolchains(

http_archive(
name = "npm_acorn-8.5.0",
build_file_content = """
load("@rules_nodejs//third_party/github.com/bazelbuild/bazel-skylib:rules/copy_file.bzl", "copy_file")
# Turn a source directory into a TreeArtifact for RBE-compat
copy_file(
name = "npm_acorn-8.5.0",
src = "package",
# This attribute comes from rules_nodejs patch of
# https://github.com/bazelbuild/bazel-skylib/pull/323
is_directory = True,
# We must give this as the directory in order for it to appear on NODE_PATH
out = "acorn",
visibility = ["//visibility:public"],
)
""",
build_file = "acorn.BUILD",
sha256 = "d8f9d40c4656537a60bf0c6daae6f0553f54df5ff2518f86464b7c785f20376b",
urls = ["https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz"],
)
9 changes: 9 additions & 0 deletions e2e/smoke/WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# Replaces WORKSPACE.bazel under --enable_bzlmod

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

http_archive(
name = "npm_acorn-8.5.0",
build_file = "acorn.BUILD",
sha256 = "d8f9d40c4656537a60bf0c6daae6f0553f54df5ff2518f86464b7c785f20376b",
urls = ["https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz"],
)
29 changes: 0 additions & 29 deletions e2e/smoke/deps.bzl

This file was deleted.

10 changes: 10 additions & 0 deletions e2e/smoke/external/acorn.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("@aspect_bazel_lib//lib:copy_directory.bzl", "copy_directory")

# Turn a source directory into a TreeArtifact for RBE-compat
copy_directory(
name = "npm_acorn-8.5.0",
src = "package",
# We must give this as the directory in order for it to appear on NODE_PATH
out = "acorn",
visibility = ["//visibility:public"],
)
8 changes: 0 additions & 8 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ def build_bazel_rules_nodejs_dev_dependencies():
],
)

maybe(
http_archive,
name = "com_google_protobuf",
sha256 = "98e615d592d237f94db8bf033fba78cd404d979b0b70351a9e5aaff725398357",
strip_prefix = "protobuf-3.9.1",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.9.1.tar.gz"],
)

# Needed for com_google_protobuf
maybe(
http_archive,
Expand Down

0 comments on commit d98eb4e

Please sign in to comment.