{"id":28146463,"url":"https://github.com/aspect-build/rules_swc","last_synced_at":"2026-03-15T21:55:16.763Z","repository":{"id":37045817,"uuid":"434738180","full_name":"aspect-build/rules_swc","owner":"aspect-build","description":"Bazel rules for the swc toolchain https://swc.rs/","archived":false,"fork":false,"pushed_at":"2026-01-16T01:26:09.000Z","size":3295,"stargazers_count":48,"open_issues_count":10,"forks_count":38,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-01-16T03:18:36.976Z","etag":null,"topics":["bazel","bazel-rules"],"latest_commit_sha":null,"homepage":"","language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aspect-build.png","metadata":{"funding":{"github":null,"patreon":null,"open_collective":"aspect-build","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null},"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-12-03T21:27:47.000Z","updated_at":"2026-01-16T01:03:39.000Z","dependencies_parsed_at":"2025-05-05T11:33:22.154Z","dependency_job_id":"7b84119b-9e50-4b85-a84e-48f41321abc8","html_url":"https://github.com/aspect-build/rules_swc","commit_stats":{"total_commits":271,"total_committers":21,"mean_commits":"12.904761904761905","dds":0.5904059040590406,"last_synced_commit":"9498a51454efc51ec5c2da9bac9fad610a3f4eab"},"previous_names":[],"tags_count":64,"template":false,"template_full_name":null,"purl":"pkg:github/aspect-build/rules_swc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspect-build%2Frules_swc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspect-build%2Frules_swc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspect-build%2Frules_swc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspect-build%2Frules_swc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aspect-build","download_url":"https://codeload.github.com/aspect-build/rules_swc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspect-build%2Frules_swc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28609887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T18:56:40.769Z","status":"ssl_error","status_checked_at":"2026-01-20T18:54:26.653Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bazel","bazel-rules"],"created_at":"2025-05-14T23:12:36.568Z","updated_at":"2026-01-20T19:12:02.361Z","avatar_url":"https://github.com/aspect-build.png","language":"Starlark","funding_links":["https://opencollective.com/aspect-build"],"categories":["Starlark","Development Tools Mcp Servers"],"sub_categories":[],"readme":"# Bazel rules for swc\n\nSWC (\u003chttps://swc.rs/\u003e) is a fast JavaScript compiler, written in Rust.\nIt performs the same work as Babel among other things, but is 20x faster.\n\nMany companies are successfully building with rules_swc. If you're getting value from the project, please let us know! Just comment on our [Adoption Discussion](https://github.com/aspect-build/rules_js/discussions/1000).\n\nSWC is a natural fit with Bazel.\nBazel does best when it orchestrates the work of many short-lived compiler processes.\nNodeJS is not a good runtime for such tools, because it is an interpreter, and is only fast after the code has been running for a while and is Just-In-Time optimized.\nSWC is fast from the beginning since it is compiled to optimized machine code.\nThis makes it a better choice for most developer workflows than tools like `tsc` or `babel`.\n\nAt the same, Bazel is a good fit for SWC too. Instead of waiting for swc plugins,\ncan already use whatever tools you like, for example you could choose any bundler, such as esbuild.\nBazel's agnostic unix-pipeline-style composition of tools allows you to mix-and-match the best parts of\nthe JS ecosystem, regardless what language they run on.\nWith Bazel, you won't need to figure out SWC's plugin infrastructure.\nYou can have SWC do what it's good at, and not even have it involved with the rest.\n\n_Need help?_ This ruleset has support provided by https://aspect.build/services.\n\n## Features\n\nThese rules provide a hermetic toolchain that runs the SWC cli, so it doesn't matter what is\nalready installed on a developer's machine, they're guaranteed to get the same result.\nIt caches all the tools using Bazel's downloader.\nThis means that even when Bazel determines that a repository is invalidated and re-runs the setup\n(due to running `bazel sync --configure` for example, or after a `bazel clean --expunge`)\nnothing is fetched from the network. Also the downloader can be configured to use corporate policy\nlike fetching exclusively through Artifactory.\n\nWe use a [Bazel toolchain](https://docs.bazel.build/versions/main/toolchains.html) to expose\nthe SWC compiler to the Bazel actions that run it.\nThis allows a user to register their own toolchain, for example to build SWC Rust code from source.\nBy default, we download pre-built binaries from https://github.com/swc-project/swc/releases.\nThis means we do not run `npm install` or `yarn`.\n\n## Installation\n\nFollow instructions from the release you wish to use:\n\u003chttps://github.com/aspect-build/rules_swc/releases\u003e.\n\n## Usage\n\n### From a BUILD file\n\nThe simplest usage is with the [swc rule](/docs/swc.md), used to compile TypeScript code to JavaScript in a tight developer loop. Each `.ts` or `.tsx` file is compiled to `bazel-bin/[.../file].js` and available to downstream\ntools such as bundlers, which are in their own Bazel rules.\n\nSee the example in /examples/simple.\n\n### In a macro\n\nOften the repetition of hand-writing BUILD files needs to be overcome with a Bazel macro.\nThis composes a few rules together into a common pattern which is shared in your repo.\n\nSee the example in [`examples/macro`](examples/macro).\n\n### In a custom rule\n\nThe most advanced usage is to write your own rule that uses the swc toolchain.\n\nThis is a good choice if you need to integrate with other Bazel rules via\n[Providers](https://docs.bazel.build/versions/main/skylark/rules.html#providers)\n\nYou'll basically follow the example of /swc/private/swc.bzl in this repo, by using\nthe `ctx.actions.run` Starlark API.\n\n- Use `ctx.toolchains[\"@aspect_rules_swc//swc:toolchain_type\"].swcinfo.swc_binary` to locate the binary tool to execute\n- To pass the relevant files to the action, `inputs` should include\n  `ctx.toolchains[\"@aspect_rules_swc//swc:toolchain_type\"].swcinfo.tool_files`\n\nYou can load helper functions from the private API like our implementation does,\nbut note that this may have breaking changes between major releases.\n\nAlternatively you can write a rule from scratch, using the toolchains and\nSWC cli provided in aspect_rules_swc.\n\n### Synchronizing settings with tsconfig.json\n\nSee [`tsconfig.md`](docs/tsconfig.md)\n\n# Telemetry \u0026 privacy policy\n\nThis ruleset collects limited usage data via [`tools_telemetry`](https://github.com/aspect-build/tools_telemetry), which is reported to Aspect Build Inc and governed by our [privacy policy](https://www.aspect.build/privacy-policy).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspect-build%2Frules_swc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faspect-build%2Frules_swc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspect-build%2Frules_swc/lists"}