Skip to content

Commit

Permalink
fix: simplify WORKSPACE install for users
Browse files Browse the repository at this point in the history
Instead of getting the cli npm repositories from a dynamically generated .bzl file,
we can just check in the result of that generation, like rules_go update-repos command does.

This will let us use bzlmod now, and also makes WORKSPACE usage a tad simpler.
  • Loading branch information
alexeagle committed Dec 20, 2021
1 parent e0d5c19 commit 7e88e26
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 9 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/workspace_snippet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,5 @@ nodejs_register_toolchains(
name = "node16",
node_version = "16.9.0",
)
# Fetches the npm packages needed to run @swc/cli
load("@swc_cli//:repositories.bzl", _swc_cli_deps = "npm_repositories")
_swc_cli_deps()
\`\`\`
EOF
4 changes: 0 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ nodejs_register_toolchains(
node_version = "16.9.0",
)

load("@swc_cli//:repositories.bzl", "npm_repositories")

npm_repositories()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()
Expand Down
2 changes: 1 addition & 1 deletion swc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ write_file(
nodejs_binary(
name = "cli",
data = [
"@npm__swc_cli-0.1.52",
"@npm__swc_core-1.2.119",
"@swc_cli//@swc/cli",
],
entry_point = "main.js",
visibility = ["//visibility:public"],
Expand Down
215 changes: 215 additions & 0 deletions swc/private/cli_repositories.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
"""repositories for @swc/cli package.
Until we have https://github.com/aspect-build/rules_js/issues/10
this file is manually generated from the translate_package_lock
in ../repositories.bzl
To update the content of this file, run
% bazel sync --only=swc_cli
% cp $(bazel info output_base)/external/swc_cli/repositories.bzl swc/private/cli_repositories.bzl
Then restore this comment at the top.
"""

# @generated by package_lock.bzl from {package_lock}

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

def npm_repositories():
"Define external repositories to fetch each tarball individually from npm on-demand."

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm__nodelib_fs.scandir-2.1.5",
integrity = "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
package = "@nodelib/fs.scandir",
version = "2.1.5",
deps = ["@npm__nodelib_fs.stat-2.0.5", "@npm_run-parallel-1.2.0"],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm__nodelib_fs.stat-2.0.5",
integrity = "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==",
package = "@nodelib/fs.stat",
version = "2.0.5",
deps = [],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm__nodelib_fs.walk-1.2.8",
integrity = "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==",
package = "@nodelib/fs.walk",
version = "1.2.8",
deps = ["@npm__nodelib_fs.scandir-2.1.5", "@npm_fastq-1.13.0"],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm__swc_cli-0.1.52",
integrity = "sha512-LAWnsTG6BNGinyPN5U0wPKA6OSMX+sl4VUzzo1dpS33V4osLQOXxLdITQnQbfI8zS74ekERvIwa8vvXKXCoc+A==",
package = "@swc/cli",
version = "0.1.52",
deps = ["@npm_commander-7.2.0", "@npm_fast-glob-3.2.7", "@npm_slash-3.0.0", "@npm_source-map-0.7.3"],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_braces-3.0.2",
integrity = "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
package = "braces",
version = "3.0.2",
deps = ["@npm_fill-range-7.0.1"],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_commander-7.2.0",
integrity = "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",
package = "commander",
version = "7.2.0",
deps = [],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_fast-glob-3.2.7",
integrity = "sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==",
package = "fast-glob",
version = "3.2.7",
deps = ["@npm__nodelib_fs.stat-2.0.5", "@npm__nodelib_fs.walk-1.2.8", "@npm_glob-parent-5.1.2", "@npm_merge2-1.4.1", "@npm_micromatch-4.0.4"],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_fastq-1.13.0",
integrity = "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==",
package = "fastq",
version = "1.13.0",
deps = ["@npm_reusify-1.0.4"],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_fill-range-7.0.1",
integrity = "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
package = "fill-range",
version = "7.0.1",
deps = ["@npm_to-regex-range-5.0.1"],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_glob-parent-5.1.2",
integrity = "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
package = "glob-parent",
version = "5.1.2",
deps = ["@npm_is-glob-4.0.3"],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_is-extglob-2.1.1",
integrity = "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
package = "is-extglob",
version = "2.1.1",
deps = [],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_is-glob-4.0.3",
integrity = "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
package = "is-glob",
version = "4.0.3",
deps = ["@npm_is-extglob-2.1.1"],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_is-number-7.0.0",
integrity = "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
package = "is-number",
version = "7.0.0",
deps = [],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_merge2-1.4.1",
integrity = "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
package = "merge2",
version = "1.4.1",
deps = [],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_micromatch-4.0.4",
integrity = "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==",
package = "micromatch",
version = "4.0.4",
deps = ["@npm_braces-3.0.2", "@npm_picomatch-2.3.0"],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_picomatch-2.3.0",
integrity = "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==",
package = "picomatch",
version = "2.3.0",
deps = [],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_queue-microtask-1.2.3",
integrity = "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
package = "queue-microtask",
version = "1.2.3",
deps = [],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_reusify-1.0.4",
integrity = "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
package = "reusify",
version = "1.0.4",
deps = [],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_run-parallel-1.2.0",
integrity = "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
package = "run-parallel",
version = "1.2.0",
deps = ["@npm_queue-microtask-1.2.3"],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_slash-3.0.0",
integrity = "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
package = "slash",
version = "3.0.0",
deps = [],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_source-map-0.7.3",
integrity = "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==",
package = "source-map",
version = "0.7.3",
deps = [],
)

# @generated from [package-lock.json snippet here]
npm_import(
name = "npm_to-regex-range-5.0.1",
integrity = "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
package = "to-regex-range",
version = "5.0.1",
deps = ["@npm_is-number-7.0.0"],
)
6 changes: 6 additions & 0 deletions swc/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ See https://docs.bazel.build/versions/main/skylark/deploying.html#dependencies
load("@aspect_rules_js//js:npm_import.bzl", "npm_import", "translate_package_lock")
load("//swc/private:toolchains_repo.bzl", "PLATFORMS", "toolchains_repo")
load("//swc/private:versions.bzl", "TOOL_VERSIONS")
load("//swc/private:cli_repositories.bzl", _cli_repositories = "npm_repositories")

_DOC = "Fetch external tools needed for swc toolchain"
_ATTRS = {
Expand Down Expand Up @@ -88,7 +89,12 @@ def swc_register_toolchains(name, **kwargs):
version = "1.1.0",
)

# See comments at the top of /swc/private/cli_repositories.bzl
# This is used to generate code in this repo, but otherwise unused
# at runtime or by users directly.
translate_package_lock(
name = "swc_cli",
package_lock = "@aspect_rules_swc//swc/private:package-lock.json",
)

_cli_repositories()

0 comments on commit 7e88e26

Please sign in to comment.