Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# nothing is built here. Guard against stray artifacts if someone runs a
# build inside template/ while editing it.
template/node_modules/
template/src/index.jsx
template/dist/
template/.build/
template/bin/*
!template/bin/.gitkeep
Expand Down
4 changes: 2 additions & 2 deletions template/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# build artifacts
# build artifacts (the esbuild bundle lands in dist/index.jsx)
/node_modules/
/src/index.jsx
/dist/
/.build/

# compiled BPF objects + generated CO-RE header
Expand Down
9 changes: 5 additions & 4 deletions template/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ all: bpf bundle

# Bundle the entry with the vendored esbuild. esbuild honors tsconfig `paths`
# (so `@/` resolves at bundle time), while `yeet:*` builtins and `*.bpf.o`
# objects stay external. The bundle is written to src/index.jsx, which the
# entry ladder prefers over src/main.jsx — so once built, that is what runs.
# objects stay external. The bundle is written to dist/index.jsx: the entry
# ladder tries dist/ before src/, so once built, that is what runs — and the
# generated file stays out of the source tree (dist/ is gitignored).
# The .jsx extension keeps the bundle eligible for component auto-mount.
# Compiled BPF objects in bin/ are loaded by path at runtime, never imported,
# so they are not bundled.
Expand All @@ -41,7 +42,7 @@ all: bpf bundle
ESBUILD_FLAGS := --bundle --format=esm --platform=neutral \
--main-fields=module,main --conditions=import,module \
--define:import.meta.main=false \
--outfile=src/index.jsx --jsx=automatic --jsx-import-source=yeet:tui
--outfile=dist/index.jsx --jsx=automatic --jsx-import-source=yeet:tui

bundle: | toolchain
$(ESBUILD) src/main.jsx $(ESBUILD_FLAGS) '--external:yeet:*' '--external:*.bpf.o'
Expand All @@ -62,6 +63,6 @@ postgen: | vendored-git
fi

clean: clean-bpf
rm -rf node_modules dist src/index.jsx
rm -rf node_modules dist

.PHONY: all bundle clean postgen
5 changes: 3 additions & 2 deletions template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ src/lib/format.js pure render helpers (rate, duration, heat color)
src/bpf/cpusched.bpf.c sched_switch program + the runtime knob
src/bpf/runqlat.bpf.c wakeup→on-CPU latency histogram
bin/ the linked BPF object lands here
dist/ the esbuild JS bundle lands here (gitignored)
.github/workflows/kernel-matrix.yml CI: verify the object across kernels
build/verify-kernel.sh the in-VM gate that workflow runs
```
Expand All @@ -63,12 +64,12 @@ the `@/` alias; `main.jsx` wires them together and owns input.

```sh
make # compile BPF (clang + bpftool) + bundle JS (esbuild)
yeet run . # runs the bundled src/index.jsx (needs root for BPF)
yeet run . # runs the bundled dist/index.jsx (needs root for BPF)
```

`make` runs two independent compilers: **clang + bpftool** compile
`src/bpf/*.bpf.c` and link them into one loadable object `bin/probe.bpf.o`;
**esbuild** bundles `src/main.jsx` into `src/index.jsx`, resolving the `@/`
**esbuild** bundles `src/main.jsx` into `dist/index.jsx`, resolving the `@/`
alias (and inlining any npm/jsr deps you add) and leaving `yeet:*` builtins
external. esbuild is vendored by the toolchain, so the build needs no
node/npm.
Expand Down
2 changes: 1 addition & 1 deletion template/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist", "src/index.jsx"]
"exclude": ["node_modules", "dist"]
}
Loading