Bazel rules for JavaScript, TypeScript, and related technologies.
See documentation.
- Flexibility and extensibility
- Performance
- Bazel idioms
- Clear separation of concerns
MODULE.bazel
RULES_JAVACRIPT_VERSION = "<commit>"
bazel_dep(name = "rules_javascript")
archive_override(
module_name = "rules_javascript",
sha256 = "<sha256>",
strip_prefix = "rules_javascript-%s" % RULES_JAVACRIPT_VERSION,
url = "https://github.com/redoapp/rules_javascript/archive/%s.tar.gz" % RULES_JAVACRIPT_VERSION,
)main.ts
console.log("Hello world");tsconfig.json
{ "compilerOptions": { "lib": ["dom"] } }BUILD.bazel
load("@rules_javascript//commonjs:rules.bzl", "cjs_root")
load("@rules_javascript//javascript:rules.bzl", "js_library")
load("@rules_javascript//typescript:rules.bzl", "tsconfig", "ts_library")
load("@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 worldSee DEVELOPING.md.