From 97c7131d12f151d468650126f5d59b77948b34e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= <nison.mael@gmail.com> Date: Fri, 28 Sep 2018 17:21:58 +0200 Subject: [PATCH] Forwards args through thread-loader (#5157) * Forwards args through thread-loader * Comments & dev --- .../config/webpack.config.dev.js | 10 +++++++++ .../config/webpack.config.prod.js | 22 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 19dd958ff..2561ade86 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 6d6794b70..0defc5f44 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -277,7 +277,16 @@ 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: { + // 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, + }, + }, { // We need to use our own loader until `babel-loader` supports // customization @@ -332,7 +341,16 @@ 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: { + // 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, + }, + }, { loader: require.resolve('babel-loader'), options: { -- GitLab