# Building Angular with Bazel Note: this doc is for developing Angular, it is _not_ public documentation for building an Angular application with Bazel. The Bazel build tool (http://bazel.build) provides fast, reliable incremental builds. We plan to migrate Angular's build scripts to Bazel. ## Installation In order to ensure that everyone builds Angular in a _consistent_ way, Bazel will be installed through NPM and therefore it's not necessary to install Bazel manually. The binaries for Bazel will be provided by the [`@bazel/bazel`](https://github.com/bazelbuild/rules_nodejs/tree/master/packages) NPM package and its platform-specific dependencies. You can access Bazel with the `yarn bazel` command ## Configuration The `WORKSPACE` file indicates that our root directory is a Bazel project. It contains the version of the Bazel rules we use to execute build steps, from `npm_bazel_typescript`. The sources on [GitHub] are published from Google's internal repository (google3). Bazel accepts a lot of options. We check in some options in the `.bazelrc` file. See the [bazelrc doc]. For example, if you don't want Bazel to create several symlinks in your project directory (`bazel-*`) you can add the line `build --symlink_prefix=/` to your `.bazelrc` file. [GitHub]: https://github.com/bazelbuild/rules_typescript [bazelrc doc]: https://bazel.build/versions/master/docs/bazel-user-manual.html#bazelrc ## Building Angular - Build a package: `yarn bazel build packages/core` - Build all packages: `yarn bazel build packages/...` You can use [ibazel] to get a "watch mode" that continuously keeps the outputs up-to-date as you save sources. Note this is new as of May 2017 and not very stable yet. [ibazel]: https://github.com/bazelbuild/bazel-watcher ## Testing Angular - Test package in node: `yarn bazel test packages/core/test:test` - Test package in karma: `yarn bazel test packages/core/test:test_web` - Test all packages: `yarn bazel test packages/...` You can use [ibazel] to get a "watch mode" that continuously keeps the outputs up-to-date as you save sources. ### Various Flags Used For Tests If you're experiencing problems with seemingly unrelated tests failing, it may be because you're not using the proper flags with your Bazel test runs in Angular. See also: [`//.bazelrc`](https://github.com/angular/angular/blob/master/.bazelrc) where `--define=compile=legacy` is defined as default. - `--config=debug`: build and launch in debug mode (see [debugging](#debugging) instructions below) - `--test_arg=--node_options=--inspect=9228`: change the inspector port. - `--define=compile=