diff --git a/.gitignore b/.gitignore index 2ea1e04..e05c3ca 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/template/.gitignore b/template/.gitignore index 733707c..49e70d5 100644 --- a/template/.gitignore +++ b/template/.gitignore @@ -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 diff --git a/template/Makefile b/template/Makefile index 9c96809..70cfe4e 100644 --- a/template/Makefile +++ b/template/Makefile @@ -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. @@ -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' @@ -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 diff --git a/template/README.md b/template/README.md index ddc8b2c..5f87b87 100644 --- a/template/README.md +++ b/template/README.md @@ -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 ``` @@ -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. diff --git a/template/tsconfig.json b/template/tsconfig.json index ac0d0fa..6782b63 100644 --- a/template/tsconfig.json +++ b/template/tsconfig.json @@ -17,5 +17,5 @@ "skipLibCheck": true }, "include": ["src"], - "exclude": ["node_modules", "dist", "src/index.jsx"] + "exclude": ["node_modules", "dist"] }