Skip to content

Rules for JavaScript, with an emphasis on idiomatic Bazel APIs

License

Notifications You must be signed in to change notification settings

rivethealth/rules_javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rules_javascript

Build

Bazel rules for JavaScript, TypeScript, and related technologies.

Documentation

See documentation.

Philosophy

  1. Flexibility and extensibility
  2. Performance
  3. Bazel idioms
  4. Clear separation of concerns

Install

WORKSPACE.bazel

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

# skylib

SKYLIB_VERSION = "16de038c484145363340eeaf0e97a0c9889a931b"
http_archive(
    name = "bazel_skylib",
    sha256 = "96e0cd3f731f0caef9e9919aa119ecc6dace36b149c2f47e40aa50587790402b",
    strip_prefix = "bazel-skylib-%s" % SKYLIB_VERSION,
    urls = ["https://github.com/bazelbuild/bazel-skylib/archive/%s.tar.gz" % SKYLIB_VERSION],
)

# better_rules_javascript

JAVACRIPT_VERSION = "..."
http_archive(
    name = "better_rules_javascript",
    strip_prefix = "rules_javascript-%s" % JAVASCRIPT_VERSION,
    urls = ["https://github.com/rivethealth/rules_javascript/archive/%s.tar.gz" % JAVACRIPT_VERSION],
)

load("@better_rules_javascript//rules:workspace.bzl", javascript_repositories = "respositories")
javascript_respositories()

Example

main.ts

console.log("Hello world");

tsconfig.json

{ "compilerOptions": { "lib": ["dom"] } }

BUILD.bazel

load("@better_rules_javascript//commonjs:rules.bzl", "cjs_root")
load("@better_rules_javascript//javascript:rules.bzl", "js_library")
load("@better_rules_javascript//typescript:rules.bzl", "tsconfig", "ts_library")
load("@better_rules_javascript//nodejs:rules.bzl", "nodejs_binary")

nodejs_binary(
    name = "bin",
    dep = ":lib",
    main = "main.js",
)

ts_library(
    name = "lib",
    config = ":tsconfig",
    root = ":root",
    srcs = ["main.ts"],
    deps = [":lib"],
)

cjs_root(
  name = "root",
  package_name = "example",
)

js_library(
    name = "tsconfig",
    root = ":root",
    srcs = ["tsconfig.json"],
)

Running:

$ bazel run //:bin
Hello world

Developing

See DEVELOPING.md.

About

Rules for JavaScript, with an emphasis on idiomatic Bazel APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published