https://github.com/wayou/bazel-ts-example
Example demonstrates building TypeScript & React with Bazel
https://github.com/wayou/bazel-ts-example
bazel bazel-examples bazel-rules react sass typescript
Last synced: 5 days ago
JSON representation
Example demonstrates building TypeScript & React with Bazel
- Host: GitHub
- URL: https://github.com/wayou/bazel-ts-example
- Owner: wayou
- Created: 2018-10-15T18:19:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T06:16:42.000Z (12 months ago)
- Last Synced: 2025-03-18T06:22:36.131Z (7 months ago)
- Topics: bazel, bazel-examples, bazel-rules, react, sass, typescript
- Language: Starlark
- Homepage:
- Size: 170 KB
- Stars: 26
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bazel TypeScript Examples
Examples demonstrate building TypeScript with Bazel.
## Build
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.
### Setup buidifier
There's a tool from the official [buildtool repo](https://github.com/bazelbuild/buildtools.git) called buildifier that can format our bazel files.
1. Install the [bazel VSCode extension](https://marketplace.visualstudio.com/items?itemName=DevonDCarew.bazel-code)
2. Clone [buildtools](https://github.com/bazelbuild/buildtools.git)
3. Run `bazel //buildifier:buildifier` to build the buildifier.
4. 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"`
5. Enable `"editor.formatOnSave": true`### Troubleshooting
- 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 run `bazel clean --expunge` and try rebuild againa. If that's still not work, try change a port for the server and start again.