message: fix(bazel): Disable sandbox on Mac OS
  Removing the sandbox improves build time by almost 40%.
  For a hello world (ng new) application:
  ng build with sandbox: 22.0 seconds
  ng build without sandbox: 13.3 seconds
  PR Close
diff: import {spawn} from 'child_process';
  import {copyFileSync, existsSync, readFileSync, readdirSync, statSync, unlinkSync, writeFileSync} from 'fs';
  +import {platform} from 'os';
  import {dirname, join, normalize} from 'path';
  export type Executable = 'bazel' | 'ibazel';
  @@ -133,6 +134,24 @@ function replaceYarnWithNpm(source: string, dest: string) {
  writeFileSync(dest, destContent);
  }
  +/**
  + * Disable sandbox on Mac OS by setting spawn_strategy in .bazelrc.
  + * For a hello world (ng new) application, removing the sandbox improves build
  + * time by almost 40%.
  + * ng build with sandbox: 22.0 seconds
  + * ng build without sandbox: 13.3 seconds
  + */
  +function disableSandbox(source: string, dest: string) {
  + const srcContent = readFileSync(source, 'utf-8');
  + const destContent = `${srcContent}
  +# Disable sandbox on Mac OS for performance reason.
  +build --spawn_strategy=local
  +run --spawn_strategy=local
  +test --spawn_strategy=local
  +`;
  + writeFileSync(dest, destContent);
  +}
  +
  /**
  * Copy Bazel files (WORKSPACE, BUILD.bazel, etc) from the template directory to
  * the project `root` directory, and return the absolute paths of the files
  @@ -154,6 +173,8 @@ export function copyBazelFiles(root: string, templateDir: string) {
  if (!existsSync(dest)) {
  if (!useYarn && name === 'WORKSPACE') {
  replaceYarnWithNpm(source, dest);
  + } else if (platform() === 'darwin' && name === '.bazelrc') {
  + disableSandbox(source, dest);
  } else {
  copyFileSync(source, dest);
  }
  