Skip to content

Commit

Permalink
chore: update rules_js (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle authored May 31, 2022
1 parent c25602f commit 4d7096d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 40 deletions.
9 changes: 5 additions & 4 deletions example/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
load("@aspect_rules_rollup//rollup:rollup_bundle.bzl", "rollup_bundle")
load("@aspect_rules_js//js:defs.bzl", "link_js_package")
load("@npm//:defs.bzl", "link_js_packages", "package")
load("@npm//:defs.bzl", "link_js_packages")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")

link_js_packages()

link_js_package(
name = package("@rollup_example/lib").name,
name = "link_lib",
src = "//example/lib",
root_package = "example",
)

rollup_bundle(
Expand All @@ -16,8 +17,8 @@ rollup_bundle(
entry_point = "main.js",
sourcemap = "false",
deps = [
package("@rollup_example/lib"),
"@npm//@rollup/plugin-node-resolve",
":link_lib",
"@npm//example/@rollup/plugin-node-resolve",
],
)

Expand Down
6 changes: 3 additions & 3 deletions rollup/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def rules_rollup_dependencies():
maybe(
http_archive,
name = "aspect_rules_js",
sha256 = "7bce67d6bfc7992f29f55405a6e750075987c9fc142fdb5d4f452a4b669c3faf",
strip_prefix = "rules_js-0.6.2",
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v0.6.2.tar.gz",
sha256 = "06dd11130f05df3e8b9aa8cc1b93577e88f540cd4ece8f00035109cc17dcf5ff",
strip_prefix = "rules_js-0.8.0",
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v0.8.0.tar.gz",
)

maybe(
Expand Down
29 changes: 5 additions & 24 deletions rollup/private/v2.70.2/defs.bzl
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
"@generated by @aspect_rules_js//js/private:translate_pnpm_lock.bzl from pnpm lock file @//:pnpm-lock.yaml"

load("@aspect_rules_js//js/private:pnpm_utils.bzl", _pnpm_utils = "pnpm_utils")
load("@bazel_skylib//lib:paths.bzl", _paths = "paths")
load("@npm__rollup__2.70.2__links//:link_js_package.bzl", link_1 = "link_js_package")

# buildifier: disable=unnamed-macro
def link_js_packages():
"Generated list of link_js_package() target generators and first party linked packages corresponding to the packages in @//:pnpm-lock.yaml"
root_path = ""
"Generated list of link_js_package() target generators and first-party linked packages corresponding to the packages in @//:pnpm-lock.yaml"
root_package = ""
importer_paths = ["."]
is_root = native.package_name() == root_path
is_root = native.package_name() == root_package
is_direct = False
for import_path in importer_paths:
importer_package_path = _paths.normalize(_paths.join(root_path, import_path))
importer_package_path = _paths.normalize(_paths.join(root_package, import_path))
if importer_package_path == ".":
importer_package_path = ""
if importer_package_path == native.package_name():
Expand All @@ -21,22 +20,4 @@ def link_js_packages():
msg = "The link_js_packages() macro loaded from @npm//:defs.bzl and called in bazel package '%s' may only be called in the bazel package(s) corresponding to the root package '' and packages corresponding to importer paths ['.']" % native.package_name()
fail(msg)

link_1(False)

def package(name, import_path = "."):
package_path = _paths.normalize(_paths.join("", import_path))
if package_path == ".":
package_path = ""
return Label("@//{package_path}:jsp__{bazel_name}".format(
package_path = package_path,
bazel_name = _pnpm_utils.bazel_name(name),
))

def package_dir(name, import_path = "."):
package_path = _paths.normalize(_paths.join("", import_path))
if package_path == ".":
package_path = ""
return Label("@//{package_path}:jsp__{bazel_name}__dir".format(
package_path = package_path,
bazel_name = _pnpm_utils.bazel_name(name),
))
link_1(name = "direct__rollup", direct = None, fail_if_no_link = False)
5 changes: 3 additions & 2 deletions rollup/private/v2.70.2/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ def npm_repositories():
npm_import(
name = "npm__rollup__2.70.2",
integrity = "sha512-EitogNZnfku65I1DD5Mxe8JYRUCy0hkK5X84IlDtUs+O6JRMpRciXTzyCUuX11b5L5pvjH+OmFXiQ3XjabcXgg==",
root_path = "",
link_paths = ["."],
root_package = "",
link_workspace = "",
link_packages = [""],
package = "rollup",
version = "2.70.2",
transitive_closure = {
Expand Down
4 changes: 2 additions & 2 deletions rollup/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ link_js_packages()
directory_path(
name = "rollup_entrypoint",
directory = ":jsp__rollup__dir",
directory = ":direct__rollup__dir",
path = "dist/bin/rollup",
)
js_binary(
name = "{name}",
data = ["//:jsp__rollup"],
data = ["//:direct__rollup"],
entry_point = ":rollup_entrypoint",
visibility = ["//visibility:public"],
)
Expand Down
10 changes: 5 additions & 5 deletions scripts/mirror_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
set -o errexit -o nounset
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

version="$(curl --silent "https://registry.npmjs.org/rollup/latest" | jq --raw-output ".version")"
version="${1:-$(curl --silent "https://registry.npmjs.org/rollup/latest" | jq --raw-output ".version")}"
out="$SCRIPT_DIR/../rollup/private/v${version}"
mkdir -p "$out"

cd $(mktemp -d)
npx pnpm install rollup --lockfile-only
npx pnpm install "rollup@$version" --lockfile-only
touch BUILD
cat >WORKSPACE <<EOF
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "aspect_rules_js",
sha256 = "7bce67d6bfc7992f29f55405a6e750075987c9fc142fdb5d4f452a4b669c3faf",
strip_prefix = "rules_js-0.6.2",
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v0.6.2.tar.gz",
sha256 = "06dd11130f05df3e8b9aa8cc1b93577e88f540cd4ece8f00035109cc17dcf5ff",
strip_prefix = "rules_js-0.8.0",
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v0.8.0.tar.gz",
)
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
Expand Down

0 comments on commit 4d7096d

Please sign in to comment.