From 35814645c0aac1280314697c8ac35530a4320270 Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Thu, 4 May 2017 10:19:33 -0700 Subject: [PATCH] worker-farm: pass explicit execArgv to workers Reviewed By: davidaurelio Differential Revision: D5002197 fbshipit-source-id: 8f556626321963c103d38ec9865110a39f1a5109 --- packages/metro-bundler/src/JSTransformer/index.js | 1 + packages/metro-bundler/src/worker-farm/lib/farm.js | 4 ++-- packages/metro-bundler/src/worker-farm/lib/fork.js | 3 ++- packages/metro-bundler/src/worker-farm/lib/index.js | 6 +++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/metro-bundler/src/JSTransformer/index.js b/packages/metro-bundler/src/JSTransformer/index.js index 081a0489..98a08c82 100644 --- a/packages/metro-bundler/src/JSTransformer/index.js +++ b/packages/metro-bundler/src/JSTransformer/index.js @@ -38,6 +38,7 @@ function makeFarm(worker, methods, timeout, maxConcurrentWorkers) { return workerFarm( { autoStart: true, + execArgv: [], maxConcurrentCallsPerWorker: 1, maxConcurrentWorkers, maxCallsPerWorker: MAX_CALLS_PER_WORKER, diff --git a/packages/metro-bundler/src/worker-farm/lib/farm.js b/packages/metro-bundler/src/worker-farm/lib/farm.js index 3bf82848..d9e2527a 100644 --- a/packages/metro-bundler/src/worker-farm/lib/farm.js +++ b/packages/metro-bundler/src/worker-farm/lib/farm.js @@ -27,7 +27,7 @@ const extend = require('xtend') , ProcessTerminatedError = require('errno').create('ProcessTerminatedError') , MaxConcurrentCallsError = require('errno').create('MaxConcurrentCallsError') -function Farm (options: {}, path: string) { +function Farm (options: {+execArgv: Array}, path: string) { this.options = extend(DEFAULT_OPTIONS, options) this.path = path this.activeCalls = 0 @@ -108,7 +108,7 @@ Farm.prototype.onExit = function (childId) { Farm.prototype.startChild = function () { this.childId++ - var forked = fork(this.path) + var forked = fork(this.path, {execArgv: this.options.execArgv}) , id = this.childId , c = { send : forked.send diff --git a/packages/metro-bundler/src/worker-farm/lib/fork.js b/packages/metro-bundler/src/worker-farm/lib/fork.js index a246df6b..e1b39877 100644 --- a/packages/metro-bundler/src/worker-farm/lib/fork.js +++ b/packages/metro-bundler/src/worker-farm/lib/fork.js @@ -14,10 +14,11 @@ const childProcess = require('child_process'); const childModule = require.resolve('./child/index'); -function fork(forkModule: string) { +function fork(forkModule: string, options: {|+execArgv: Array|}) { const child = childProcess.fork(childModule, { env: process.env, cwd: process.cwd(), + execArgv: options.execArgv, }); child.send({module: forkModule}); diff --git a/packages/metro-bundler/src/worker-farm/lib/index.js b/packages/metro-bundler/src/worker-farm/lib/index.js index 73bd6fa5..a5610145 100644 --- a/packages/metro-bundler/src/worker-farm/lib/index.js +++ b/packages/metro-bundler/src/worker-farm/lib/index.js @@ -14,7 +14,11 @@ const Farm = require('./farm') var farms = [] // keep record of farms so we can end() them if required -function farm(options: {}, path: string, methods: Array): {[name: string]: Function} { +function farm( + options: {+execArgv: Array}, + path: string, + methods: Array, +): {[name: string]: Function} { var f = new Farm(options, path) , api = f.setup(methods)