| name | compile |
| description | Compile / build / type-check the skywalking-nodejs agent. Use when asked to "compile", "build", "type-check", "run tsc", "make sure it compiles", or to validate that changes under src/ build cleanly. Mirrors the CI pipeline in .github/workflows/build.yaml (npm i -> npm run lint -> npm run build) and handles the two things that trip up a fresh/Apple-Silicon checkout: the protobuf submodule and the grpc-tools native-binary download. |
Compile skywalking-nodejs
The source is TypeScript compiled by tsc, but it imports generated gRPC/protobuf stubs. So a build is
three stages: fetch the proto definitions -> generate the stubs -> compile.
What the build does (source of truth: package.json + .github/workflows/build.yaml)
npm i # install deps; the `prepare` hook runs scripts/protoc.sh -> generates src/proto/
npm run lint # eslint src/**/*.ts (eslint:recommended + prettier + Apache license-header check)
npm run build # clean -> prepare (regen src/proto) -> tsc --build src -> regen proto into lib/
npm run build expands to:
npm run clean && npm run prepare && tsc --build src && OUT_DIR=lib/proto/ scripts/protoc.sh
Output lands in lib/. CI runs this on Node 12/14/16/18 (Node 18 is the highest; Node 10 skips lint).
scripts/protoc.sh invokes node_modules/.bin/grpc_tools_node_protoc (from grpc-tools) and the
protoc-gen-ts plugin (from grpc_tools_node_protoc_ts) over protocol/**/*.proto.
Prerequisite for every path: the protobuf submodule
protocol/ is a git submodule (apache/skywalking-data-collect-protocol). A fresh clone leaves it empty,
and then tsc fails with a cascade of Cannot find module '../proto/...'. Initialize it first: