Skip to main content
Version: 0.21.x

repositories

Repository rules for fetching the swc toolchain.

For typical usage, see the snippets provided in the rules_swc release notes.

Rules

swc_repositories

Fetch external dependencies needed to run the SWC cli

Example usage (generated):

load("@aspect_rules_swc//swc:repositories.bzl", "swc_repositories")

swc_repositories(
# A unique name for this repository.
name = "",
platform = "",
# A dictionary from local repository name to global repository name
repo_mapping = {},
)

name

Required name.

A unique name for this repository.

integrity_hashes

Optional dictionary: String → String. Default: {}

platform

Required string.

repo_mapping

Required dictionary: String → String.

A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.

For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target).

swc_version

Optional string. Default: ""

Explicit version. If provided, the package.json is not read.

swc_version_from

Optional label. Default: None

Location of package.json which may have a version for @swc/core.

Macros and Functions

swc_register_toolchains

Convenience macro for users which does typical setup.

  • create a repository for each built-in platform like "swc_linux_amd64"
  • create a repository exposing toolchains for each platform like "swc_platforms"
  • register a toolchain pointing at each platform Users can avoid this macro and do these steps themselves, if they want more control.

Example usage (generated):

load("@aspect_rules_swc//swc:repositories.bzl", "swc_register_toolchains")

swc_register_toolchains(
# base name for all created repos; we recommend `swc`
name = "",
)

name

Required.

base name for all created repos; we recommend swc

swc_version

Optional. Default: None

version of the swc project, from https://github.com/swc-project/swc/releases Exactly one of swc_version or swc_version_from must be set.

swc_version_from

Optional. Default: None

label of a json file (typically package.json) which declares an exact @swc/core version in a dependencies or devDependencies property. Exactly one of swc_version or swc_version_from must be set.

register

Optional. Default: True

whether to call through to native.register_toolchains. Should be True for WORKSPACE users, but false when used under bzlmod extension

kwargs

Optional.

passed to each swc_repositories call