https://github.com/pulseengine/rules_moonbit
Bazel rules for MoonBit with hermetic toolchain support
https://github.com/pulseengine/rules_moonbit
bazel moonbit pulseengine toolchain
Last synced: 3 months ago
JSON representation
Bazel rules for MoonBit with hermetic toolchain support
- Host: GitHub
- URL: https://github.com/pulseengine/rules_moonbit
- Owner: pulseengine
- License: apache-2.0
- Created: 2026-01-11T07:07:04.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-03-02T08:05:28.000Z (3 months ago)
- Last Synced: 2026-03-02T12:20:11.940Z (3 months ago)
- Topics: bazel, moonbit, pulseengine, toolchain
- Language: Starlark
- Size: 268 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# rules_moonbit
Bazel rules for MoonBit projects


Bazel rules for building MoonBit projects with hermetic toolchain support, multi-target compilation, and WebAssembly Component Model integration.
> [!NOTE]
> Part of the PulseEngine toolchain. Provides build infrastructure for MoonBit-based components. See [moonbit_checksum_updater](https://github.com/pulseengine/moonbit_checksum_updater) for checksum management tooling.
## Status
Early development phase. The goal is to create Bazel rules that integrate with MoonBit's build system while maintaining Bazel's core principles.
## Getting Started
### Prerequisites
- Bazel 8.5+ (required for modern toolchain support)
### Quick Start
**Using Bzlmod (Modern Bazel):**
```python
# MODULE.bazel
bazel_dep(name = "rules_moonbit", version = "0.1.0")
```
**Using WORKSPACE:**
```python
local_repository(
name = "rules_moonbit",
path = "/path/to/rules_moonbit",
)
register_toolchains("@moonbit_toolchain//:moonbit_toolchain")
```
**When Hermetic Downloads Become Available:**
```python
load("@rules_moonbit//moonbit/tools:hermetic_toolchain.bzl", "moonbit_toolchain_repository")
moonbit_toolchain_repository(
name = "moonbit_toolchain",
version = "0.6.33",
)
register_toolchains("@moonbit_toolchain//:moonbit_toolchain")
```
### BUILD file
```python
load("@rules_moonbit//moonbit:defs.bzl", "moonbit_library", "moonbit_binary")
moonbit_library(
name = "mylib",
srcs = ["mylib.mbt"],
deps = ["//:otherlib"],
)
moonbit_binary(
name = "myapp",
srcs = ["main.mbt"],
deps = [":mylib"],
)
```
## Features
### Core
- MoonBit compilation with multi-target support (WASM, JavaScript, C, native)
- Cross-compilation for different platforms
- WebAssembly Component Model with WIT interface support
- Package management with MoonBit registry integration
- Hermetic toolchain with automatic download and management
### Advanced
- Incremental compilation for faster rebuilds
- Multiple optimization levels (debug, release, aggressive)
- Content-addressable caching for build acceleration
- Integration with rules_wasm_component
- Checksum verification for hermetic builds
## Advanced Usage
### Cross-Compilation
```python
moonbit_binary(
name = "linux_app",
srcs = ["main.mbt"],
target_platform = "linux_x86_64",
optimization = "aggressive",
)
```
### WebAssembly Component Model
```python
moonbit_component(
name = "math_component",
srcs = ["math.mbt"],
wit_deps = [":math_wit"],
target_platform = "wasm",
)
```
## Development
```bash
bazel build //... # Build
bazel test //... # Test
bazel test //test/... # Run test suite
```
## Contributing
See CONTRIBUTING.md for contribution guidelines.
## License
Apache-2.0
---
Part of PulseEngine — formally verified WebAssembly toolchain for safety-critical systems