From 4d67b7d1862dab269db41cbfce2ff0a88cbf8566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Fri, 28 Sep 2018 17:08:37 +0200 Subject: [PATCH 1/2] Forwards args through thread-loader --- .../react-scripts/config/webpack.config.prod.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 6d6794b70a0..2e4ad6abe8c 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -277,7 +277,12 @@ module.exports = { use: [ // This loader parallelizes code compilation, it is optional but // improves compile time on larger projects - require.resolve('thread-loader'), + { + loader: require.resolve('thread-loader'), + options: { + workerNodeArgs: process.execArgv, + }, + }, { // We need to use our own loader until `babel-loader` supports // customization @@ -332,7 +337,12 @@ module.exports = { use: [ // This loader parallelizes code compilation, it is optional but // improves compile time on larger projects - require.resolve('thread-loader'), + { + loader: require.resolve('thread-loader'), + options: { + workerNodeArgs: process.execArgv, + }, + }, { loader: require.resolve('babel-loader'), options: { From 926eaab1caa19a401404425d339f733083ad9f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Fri, 28 Sep 2018 17:21:00 +0200 Subject: [PATCH 2/2] Comments & dev --- packages/react-scripts/config/webpack.config.dev.js | 10 ++++++++++ packages/react-scripts/config/webpack.config.prod.js | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 19dd958ffb0..2561ade86dd 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -225,6 +225,11 @@ module.exports = { loader: require.resolve('thread-loader'), options: { poolTimeout: Infinity, // keep workers alive for more effective watch mode + // Forwards the process args (such as --require) to the child + // workers. Ensures that the worker operates in the same kind + // of environment than the current one (important in case a + // preloaded script modifies the env) + workerNodeArgs: process.execArgv, }, }, { @@ -284,6 +289,11 @@ module.exports = { loader: require.resolve('thread-loader'), options: { poolTimeout: Infinity, // keep workers alive for more effective watch mode + // Forwards the process args (such as --require) to the child + // workers. Ensures that the worker operates in the same kind + // of environment than the current one (important in case a + // preloaded script modifies the env) + workerNodeArgs: process.execArgv, }, }, { diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 2e4ad6abe8c..0defc5f44ab 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -280,6 +280,10 @@ module.exports = { { loader: require.resolve('thread-loader'), options: { + // Forwards the process args (such as --require) to the child + // workers. Ensures that the worker operates in the same kind + // of environment than the current one (important in case a + // preloaded script modifies the env) workerNodeArgs: process.execArgv, }, }, @@ -340,6 +344,10 @@ module.exports = { { loader: require.resolve('thread-loader'), options: { + // Forwards the process args (such as --require) to the child + // workers. Ensures that the worker operates in the same kind + // of environment than the current one (important in case a + // preloaded script modifies the env) workerNodeArgs: process.execArgv, }, },