All Projects → EdSchouten → rules_elm

EdSchouten / rules_elm

Licence: Apache-2.0 license
Bazel rules for building web applications written in Elm

Programming Languages

Starlark
911 projects
python
139335 projects - #7 most used programming language
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to rules elm

rules openapi
🍃 bazel rules for generating code from openapi specifications
Stars: ✭ 49 (+122.73%)
Mutual labels:  bazel, bazel-rules
rules antlr
ANTLR rules for Bazel
Stars: ✭ 24 (+9.09%)
Mutual labels:  bazel, bazel-rules
bazel-maven-proxy
A local (read-only) proxy for Bazel to access Maven resources behind a secure repository or from the local Maven repository
Stars: ✭ 22 (+0%)
Mutual labels:  bazel, bazel-rules
Rules python
Experimental Bazel Python Rules
Stars: ✭ 233 (+959.09%)
Mutual labels:  bazel, bazel-rules
rules java
Java rules for Bazel
Stars: ✭ 44 (+100%)
Mutual labels:  bazel, bazel-rules
Rules kotlin
Bazel rules for Kotlin
Stars: ✭ 235 (+968.18%)
Mutual labels:  bazel, bazel-rules
rules appengine
AppEngine rules for Bazel
Stars: ✭ 28 (+27.27%)
Mutual labels:  bazel, bazel-rules
Rules haskell
Haskell rules for Bazel.
Stars: ✭ 196 (+790.91%)
Mutual labels:  bazel, bazel-rules
rules dart
Dart rules for Bazel
Stars: ✭ 35 (+59.09%)
Mutual labels:  bazel, bazel-rules
rules ocaml
OCaml build rules for Bazel
Stars: ✭ 38 (+72.73%)
Mutual labels:  bazel, bazel-rules
Rules k8s
This repository contains rules for interacting with Kubernetes configurations / clusters.
Stars: ✭ 222 (+909.09%)
Mutual labels:  bazel, bazel-rules
rules gitops
This repository contains rules for continuous, GitOps driven Kubernetes deployments.
Stars: ✭ 112 (+409.09%)
Mutual labels:  bazel, bazel-rules
Rules apple
Bazel rules to build apps for Apple platforms.
Stars: ✭ 217 (+886.36%)
Mutual labels:  bazel, bazel-rules
Rules rust
Rust rules for Bazel
Stars: ✭ 241 (+995.45%)
Mutual labels:  bazel, bazel-rules
Rules protobuf
Bazel rules for building protocol buffers and gRPC services (java, c++, go, ...)
Stars: ✭ 206 (+836.36%)
Mutual labels:  bazel, bazel-rules
rules proto grpc
Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
Stars: ✭ 201 (+813.64%)
Mutual labels:  bazel, bazel-rules
Bazel Skylib
Common useful functions and rules for Bazel
Stars: ✭ 153 (+595.45%)
Mutual labels:  bazel, bazel-rules
Rules kotlin
Bazel rules for Kotlin
Stars: ✭ 162 (+636.36%)
Mutual labels:  bazel, bazel-rules
bazel-latex
Bazel build system rules for LaTeX
Stars: ✭ 67 (+204.55%)
Mutual labels:  bazel, bazel-rules
rules sass
Sass rules for Bazel
Stars: ✭ 47 (+113.64%)
Mutual labels:  bazel, bazel-rules

Bazel build rules for Elm

Elm is a functional programming language that can be transpiled to Javascript. This repository contains rules for building Elm applications using the Bazel build system. These rules depend on their own copy of the Elm compiler, meaning that Elm and any libraries used may be versioned as part of your Bazel project.

Adding these rules to your project

Add the following declarations to your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "com_github_edschouten_rules_elm",
    sha256 = "0b8a4e288ce9fe255074adb07be443cdda3a9fa9667de775b01decb93507a6d7",
    strip_prefix = "rules_elm-0.3",
    urls = ["https://github.com/EdSchouten/rules_elm/archive/v0.3.tar.gz"],
)

load("@com_github_edschouten_rules_elm//elm:deps.bzl", "elm_register_toolchains")

elm_register_toolchains()

As some of these rules depend on Node.js and UglifyJS, you should also add rules_nodejs to your WORKSPACE file, calling yarn_install() on a yarn.lock file that provides UglifyJS.

Examples on how to use these rules

The Bazel Elm SPA Example repository contains a concrete example of how these rules may be used to build a web application written in Elm. This repository contains a copy of a well-known demonstration application that has been adjusted to be buildable using Bazel.

Build rules provided by this project

elm_binary()

load("@com_github_edschouten_rules_elm//elm:def.bzl", "elm_binary")

elm_binary(name, main, deps, visibility)

Purpose: transpile an Elm application to Javascript. The resulting Javascript file will be named ${name}.js.

  • main: The name of the source file containing the Program.
  • deps: List of elm_library() and elm_package() targets on which the application depends.

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.

elm_library()

load("@com_github_edschouten_rules_elm//elm:def.bzl", "elm_library")

elm_library(name, srcs, deps, strip_import_prefix, visibility)

Purpose: declare a collection of Elm source files that can be reused by multiple elm_binary()s.

  • srcs: List of source files to package together.
  • deps: List of elm_library() and elm_package() targets on which the library depends.
  • 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.

elm_package()

load("@com_github_edschouten_rules_elm//elm:def.bzl", "elm_package")

elm_package(name, package_name, package_version, srcs, deps, visibility)

Purpose: make an off-the-shelf Elm package usable as a dependency.

  • package_name: The publicly used name of the package (e.g., elm/json).
  • package_version: The version of the package (e.g., 1.0.2).
  • srcs: Files that are part of this package. This list SHOULD include "elm.json".
  • deps: List of packages on which this package depends.

Note: This function is typically not used directly; it is often sufficient to use elm_repository().

elm_proto_library()

load("@com_github_edschouten_rules_elm//proto:def.bzl", "elm_proto_library")

elm_proto_library(name, proto, visibility)

Purpose: generate Elm bindings for Protocol Buffers definitions using tiziano88/elm-protobuf and package them as an elm_library().

  • proto: The proto_library() that should be converted to Elm.

Note: This function is implemented using Bazel aspects, meaning that it automatically instantiates build rules for all transitive dependencies of the proto_library() and sets up dependencies between them accordingly.

elm_test()

load("@com_github_edschouten_rules_elm//elm:def.bzl", "elm_test")

elm_test(name, main, deps, visibility)

Purpose: compile an Elm testing application to Javascript and execute it using Node.js.

  • main: The name of the source file containing one or more Tests
  • deps: List of elm_library() and elm_package() targets on which the testing application depends.

Repository rules provided by this project

elm_repository()

load("@com_github_edschouten_rules_elm//repository:def.bzl", "elm_repository")

elm_repository(name, urls, sha256, strip_prefix, patches)

Purpose: download an Elm package over HTTP, extract it and create a BUILD.bazel file containing either an elm_package() or elm_library() declaration. For elm/* and elm-explorations/* an elm_package() is used. For others, elm_library() is used to prevent the Elm compiler from returning hard to debug dependency management related errors.

  • urls: List of URLs where the package tarball may be downloaded.
  • sha256: SHA-256 checksum of the tarball.
  • strip_prefix: Directory prefix that may be removed from the files upon extraction.
  • patches: List of labels of patches to apply after extraction.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].