Repository rules for fetching the swc toolchain.
For typical usage, see the snippets provided in the rules_swc release notes.
To keep the swc version in sync with non-Bazel tooling, use swc_version_from
.
Currently this only works when a single, pinned version appears, see: aspect-build/rules_ts#308
For example, package.json
:
{
"devDependencies": {
"@swc/core": "1.3.37"
}
}
Allows this in WORKSPACE
:
swc_register_toolchains(
name = "swc",
swc_version_from = "//:package.json",
)
load("@aspect_rules_swc//swc:repositories.bzl", "swc_register_toolchains") swc_register_toolchains(name, swc_version, swc_version_from, register, kwargs)
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.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | base name for all created repos; we recommend swc |
none |
swc_version | 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. |
None |
swc_version_from | label of a json file which declares an @swc/core version.This may be a package.json file, with "@swc/core" in the dependencies or devDependencies property, and the version exactly specified.With rules_js v1.32.0 or greater, it may also be a resolved.json file produced by npm_translate_lock , such as @npm//path/to/linked:@swc/core/resolved.json Exactly one of swc_version or swc_version_from must be set. |
None |
register | whether to call through to native.register_toolchains. Should be True for WORKSPACE users, but false when used under bzlmod extension | True |
kwargs | passed to each swc_repositories call | none |
load("@aspect_rules_swc//swc:repositories.bzl", "swc_repositories") swc_repositories(name, integrity_hashes, platform, repo_mapping, swc_version, swc_version_from)
Fetch external dependencies needed to run the SWC cli
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this repository. | Name | required | |
integrity_hashes | A mapping from platform to integrity hash. | Dictionary: String -> String | optional | {} |
platform | - | String | required | |
repo_mapping | In WORKSPACE context only: 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 ).This attribute is not supported in MODULE.bazel context (when invoking a repository rule inside a module extension's implementation function). |
Dictionary: String -> String | optional | |
swc_version | Explicit version. If provided, the package.json is not read. | String | optional | "" |
swc_version_from | Location of package.json which has a version for @swc/core. | Label | optional | None |