rules.md
March 21, 2025 ยท View on GitHub
elm_binary
load("@rules_elm//elm:defs.bzl", "elm_binary")
elm_binary(name, deps, main)
Transpiles an Elm application to Javascript.
The resulting Javascript file will be named ${name}.js.
Note: When the compilation mode (-c) is equal to dbg, the
resulting Javascript file will have the time traveling debugger enabled.
When the compilation mode is opt, optimizations are performed and the
resulting code is minified using UglifyJS.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | List of elm_library() or elm_package() targets on which the application depends. | List of labels | optional | [] |
| main | The name of the source file containing the Program. | Label | required |
elm_library
load("@rules_elm//elm:defs.bzl", "elm_library")
elm_library(name, deps, srcs, strip_import_prefix)
Declare a collection of Elm source files that can be reused
by multiple elm_binary() targets.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | List of elm_library() or elm_package() targets on which the library depends. | List of labels | optional | [] |
| srcs | List of source files to package together. | List of labels | required | |
| strip_import_prefix | Workspace root relative path prefix that should be removed from pathname resolution. For example, if the source file my/project/Foo/Bar.elm contains module Foo.Bar, strip_import_prefix should be set to my/project for module resolution to work. | String | optional | "" |
elm_package
load("@rules_elm//elm:defs.bzl", "elm_package")
elm_package(name, deps, srcs, package_name, package_version)
Makes an off-the-shelf Elm package usable as a dependency.
**Note:** This function is typically not used directly; it is often
sufficient to use elm_repository().
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | List of packages on which this package depends. | List of labels | optional | [] |
| srcs | Files that are part of this package. This list SHOULD include "elm.json". | List of labels | required | |
| package_name | The publicly used name of the package (e.g., elm/json) | String | required | |
| package_version | The version of the package (e.g., 1.0.2). | String | required |
elm_test
load("@rules_elm//elm:defs.bzl", "elm_test")
elm_test(name, deps, main)
Compiles an Elm testing application to JavaScript and executes it using Node.js.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | List of elm_library() or elm_package() targets on which the testing application depends. | List of labels | optional | [] |
| main | The name of the source file containing one or more Tests | Label | required |