Wassim Chegham PRO
Senior Developer Advocate @Microsoft ★ Angular contributor ★ Bazel contributor ★ GDE @Google ★ creator of @itsjustangular / hueaction.dev / ngx.tools / xlayers.dev / angular.run / thundr.dev
hexa.run
xLayers.dev
nitr.ooo
ngx.tools
catsify.app
Just what you need to know to get started
@rules_nodejs// on master and ⬢ v14.1.0
➜ find ./ -iname "WORKSPACE"
.//WORKSPACE
.//examples/angular/WORKSPACE
.//examples/kotlin/WORKSPACE
.//examples/angular_view_engine/WORKSPACE
.//examples/nestjs/WORKSPACE
.//packages/labs/src/WORKSPACE
.//packages/typescript/src/WORKSPACE
.//packages/karma/src/WORKSPACE
.//packages/rollup/src/WORKSPACE
.//packages/terser/src/WORKSPACE
.//packages/jasmine/src/WORKSPACE
.//packages/protractor/src/WORKSPACE
.//e2e/jasmine/WORKSPACE
...
A package defines a set of instructions about how to build, test and run the current package.
The primary unit of code organization in a workspace. A folder containing a file named
BUILD.bazel
@rules_nodejs// on master and ⬢ v13.7.0
➜ find ./ -iname "BUILD.bazel"
./internal/BUILD.bazel
./internal/linker/test/BUILD.bazel
./internal/linker/BUILD.bazel
./internal/pkg_npm/test/BUILD.bazel
./internal/pkg_npm/BUILD.bazel
./internal/golden_file_test/BUILD.bazel
./internal/providers/BUILD.bazel
./internal/js_library/BUILD.bazel
./internal/common/test/BUILD.bazel
./internal/common/BUILD.bazel
./internal/bazel_integration_test/BUILD.bazel
./internal/node/test/lib1/BUILD.bazel
./internal/node/test/BUILD.bazel
...
package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_binary")
load("@io_bazel_rules_rust//wasm_bindgen:wasm_bindgen.bzl", "rust_wasm_bindgen")
rust_binary(
name = "hello_world_rust",
srcs = ["main.rs"],
edition = "2018",
deps = [
"@io_bazel_rules_rust//wasm_bindgen/raze:wasm_bindgen"
]
)
rust_wasm_bindgen(
name = "hello_world_bindgen",
wasm_file = ":hello_world_rust",
bindgen_flags = ["--nodejs"]
)
# //src/lib/shorten/BUILD.bazel
ts_library(
name = "shorten",
srcs = ["shorten.ts"],
module_name = "@bazel/shorten",
module_root = "shorten",
deps = [
"//some/dep",
"@npm//other/dep",
],
)
# Output:
# - shorten.d.ts
# - shorten.js
ts_library()
rollup_bundle()
@angular/core/**/*.ts
./core.js
./core.d.ts
./bundles/core.umd.js
tsc -p tsconfig.json ...
ts_library()
* Needs to be configured separately! (read more)
az group create --name bazel-cache --location eastus
az vm create \
--resource-group bazel-cache \
--name bazelCache \
--image UbuntuLTS \
--admin-username bazel \
--generate-ssh-keys
az vm open-port --port 80 \
--resource-group bazel-cache \
--name bazelCache
ssh bazel@ip
sudo apt-get install -y nginx nginx-extras
sudo mkdir /cache
sudo chmod 0777 -R /cache
bazel build //... --remote_cache=http://ip/cache/
Read the QuickStart
npm init @bazel my_workspace
All cartoons used in this deck are under the Adobe Stock Standard License terms. Read more: https://stock.adobe.com/license-terms
dev.to/wassimchegham
dev.to/angular
dev.to/bazel
By Wassim Chegham
This is a short introduction to Bazel, the orchestration build and test tool. We will cover the concepts of Bazel such as Workspaces, Packages, and Labels, as well as writing custom rules. We will demo how to build a WASM code written in Rust and deploy it on Azure Functions.
Senior Developer Advocate @Microsoft ★ Angular contributor ★ Bazel contributor ★ GDE @Google ★ creator of @itsjustangular / hueaction.dev / ngx.tools / xlayers.dev / angular.run / thundr.dev