Skip to content

Commit d1fcc2b

Browse files
Keen Yee Liaualxhub
Keen Yee Liau
authored andcommittedMay 7, 2019
fix(bazel): Directly spawn native Bazel binary (#30306)
Instead of launching a Node.js process that in turn spawns Bazel binary, the Builder could now directly spawn the native binary. This makes the bootup process slightly more efficient, and allows the Builder to control spawn options. This works with both Bazel and iBazel. PR Close #30306
1 parent fac0044 commit d1fcc2b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed
 

‎packages/bazel/src/builders/bazel.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/// <reference types='node'/>
1010

11-
import {fork} from 'child_process';
11+
import {spawn} from 'child_process';
1212
import {copyFileSync, existsSync, readdirSync, statSync, unlinkSync} from 'fs';
1313
import {dirname, join, normalize} from 'path';
1414

@@ -24,7 +24,7 @@ export function runBazel(
2424
projectDir = normalize(projectDir);
2525
binary = normalize(binary);
2626
return new Promise((resolve, reject) => {
27-
const buildProcess = fork(binary, [command, workspaceTarget, ...flags], {
27+
const buildProcess = spawn(binary, [command, workspaceTarget, ...flags], {
2828
cwd: projectDir,
2929
stdio: 'inherit',
3030
});
@@ -51,12 +51,12 @@ export function runBazel(
5151
*/
5252
export function checkInstallation(name: Executable, projectDir: string): string {
5353
projectDir = normalize(projectDir);
54-
const packageName = `@bazel/${name}/package.json`;
54+
const packageName = `@bazel/${name}`;
5555
try {
5656
const bazelPath = require.resolve(packageName, {
5757
paths: [projectDir],
5858
});
59-
return dirname(bazelPath);
59+
return require(bazelPath).getNativeBinary();
6060
} catch (error) {
6161
if (error.code === 'MODULE_NOT_FOUND') {
6262
throw new Error(

‎packages/bazel/src/builders/files/__dot__bazelrc.template

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ build --incompatible_strict_action_env
2323
run --incompatible_strict_action_env
2424
test --incompatible_strict_action_env
2525

26+
build --incompatible_bzl_disallow_load_after_statement=false
27+
2628
test --test_output=errors
2729

2830
# Use the Angular 6 compiler

‎packages/bazel/src/schematics/ng-add/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ function addDevDependenciesToPackageJson(options: Schema) {
4848

4949
const devDependencies: {[k: string]: string} = {
5050
'@angular/bazel': angularCoreVersion,
51-
'@bazel/bazel': '^0.24.0',
52-
'@bazel/ibazel': '^0.10.1',
51+
'@bazel/bazel': '^0.25.1',
52+
'@bazel/ibazel': '^0.10.2',
5353
'@bazel/karma': '0.27.12',
5454
'@bazel/typescript': '0.27.12',
5555
};

0 commit comments

Comments
 (0)
Please sign in to comment.