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

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsList of elm_library() or elm_package() targets on which the application depends.List of labelsoptional[]
mainThe name of the source file containing the Program.Labelrequired

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

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsList of elm_library() or elm_package() targets on which the library depends.List of labelsoptional[]
srcsList of source files to package together.List of labelsrequired
strip_import_prefixWorkspace 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.Stringoptional""

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

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsList of packages on which this package depends.List of labelsoptional[]
srcsFiles that are part of this package. This list SHOULD include "elm.json".List of labelsrequired
package_nameThe publicly used name of the package (e.g., elm/json)Stringrequired
package_versionThe version of the package (e.g., 1.0.2).Stringrequired

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

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsList of elm_library() or elm_package() targets on which the testing application depends.List of labelsoptional[]
mainThe name of the source file containing one or more TestsLabelrequired