Examples demonstrate building TypeScript with Bazel.
Bazel | TypeScript | NodeJs | Yarn |
Run bazel query ...
to see all available labels.
Run yarn serve
to start local dev server with live reload.
Run yarn stat
to see file statistic of the repo. It will print number of each file extension.
There's a tool from the official buildtool repo called buildifier that can format our bazel files.
- Install the bazel VSCode extension
- Clone buildtools
- Run
bazel //buildifier:buildifier
to build the buildifier. - Set the path for the buildifier generated from above step in VSCode user setting
"bazel.buildifierPath": "private/var/tmp/_bazel_wayou/308cd286b0587bcdbdec05695018ee18/execroot/com_github_bazelbuild_buildtools/bazel-out/darwin-fastbuild/bin/buildifier/darwin_amd64_stripped/buildifier"
- Enable
"editor.formatOnSave": true
- If all types are discovered then all types need to be included as deps or typescript may error like
TS2688: Cannot find type definition file for 'foo'
. - If you move the location of a
ts_devserver
target and try start the server again you may get error that the bazel says cannot load/the/original/path/of/the/server/MF/file
. Just runbazel clean --expunge
and try rebuild againa. If that's still not work, try change a port for the server and start again.