From 80de2176703e2a123c14cc868c7f89b8061b9cd9 Mon Sep 17 00:00:00 2001 From: Joe Lim Date: Mon, 2 Oct 2017 13:11:13 -0700 Subject: [PATCH 1/4] Allow the dev server to watch for changes in src/node_modules --- packages/react-scripts/config/webpackDevServer.config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpackDevServer.config.js b/packages/react-scripts/config/webpackDevServer.config.js index 25b42d0de8b..a1d3c34380b 100644 --- a/packages/react-scripts/config/webpackDevServer.config.js +++ b/packages/react-scripts/config/webpackDevServer.config.js @@ -72,8 +72,10 @@ module.exports = function(proxy, allowedHost) { quiet: true, // Reportedly, this avoids CPU overload on some systems. // https://github.com/facebookincubator/create-react-app/issues/293 + // src/node_modules is not ignored to support absolute imports + // https://github.com/facebookincubator/create-react-app/issues/1065 watchOptions: { - ignored: /node_modules/, + ignored: new RegExp(`^(?!${paths.appSrc})*[\\\/]node_modules[\\\/]`, 'g'), }, // Enable HTTPS if the HTTPS environment variable is set to 'true' https: protocol === 'https', From b0ef885f4a26da85da3819fd4fb34eb611fd18bd Mon Sep 17 00:00:00 2001 From: Joe Lim Date: Mon, 2 Oct 2017 13:28:43 -0700 Subject: [PATCH 2/4] fix eslint error --- packages/react-scripts/config/webpackDevServer.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpackDevServer.config.js b/packages/react-scripts/config/webpackDevServer.config.js index a1d3c34380b..4ee8f3abeec 100644 --- a/packages/react-scripts/config/webpackDevServer.config.js +++ b/packages/react-scripts/config/webpackDevServer.config.js @@ -75,7 +75,7 @@ module.exports = function(proxy, allowedHost) { // src/node_modules is not ignored to support absolute imports // https://github.com/facebookincubator/create-react-app/issues/1065 watchOptions: { - ignored: new RegExp(`^(?!${paths.appSrc})*[\\\/]node_modules[\\\/]`, 'g'), + ignored: new RegExp(`^(?!${paths.appSrc})*[\\/]node_modules[\\/]`, 'g'), }, // Enable HTTPS if the HTTPS environment variable is set to 'true' https: protocol === 'https', From eca7cf08f891c42e01d3bbab212de24a8051f162 Mon Sep 17 00:00:00 2001 From: Joe Lim Date: Mon, 2 Oct 2017 19:07:34 -0700 Subject: [PATCH 3/4] fix broken regex --- packages/react-scripts/config/webpackDevServer.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpackDevServer.config.js b/packages/react-scripts/config/webpackDevServer.config.js index 4ee8f3abeec..daf82e77f88 100644 --- a/packages/react-scripts/config/webpackDevServer.config.js +++ b/packages/react-scripts/config/webpackDevServer.config.js @@ -75,7 +75,7 @@ module.exports = function(proxy, allowedHost) { // src/node_modules is not ignored to support absolute imports // https://github.com/facebookincubator/create-react-app/issues/1065 watchOptions: { - ignored: new RegExp(`^(?!${paths.appSrc})*[\\/]node_modules[\\/]`, 'g'), + ignored: new RegExp(`^(?!${paths.appSrc}).+[\\/]node_modules[\\/]`, 'g'), }, // Enable HTTPS if the HTTPS environment variable is set to 'true' https: protocol === 'https', From 2d6875f3ef0c7ad3c056ba05a7a03e37ecb9eb58 Mon Sep 17 00:00:00 2001 From: Joe Lim Date: Mon, 2 Oct 2017 19:52:24 -0700 Subject: [PATCH 4/4] handle trailing slash edge case for file paths --- packages/react-dev-utils/getProcessForPort.js | 10 +++++++--- .../react-scripts/config/webpackDevServer.config.js | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/react-dev-utils/getProcessForPort.js b/packages/react-dev-utils/getProcessForPort.js index c91959a379c..932f3e5bf4d 100644 --- a/packages/react-dev-utils/getProcessForPort.js +++ b/packages/react-dev-utils/getProcessForPort.js @@ -46,7 +46,7 @@ function getProcessCommand(processId, processDirectory) { execOptions ); - command = command.replace(/\n$/, '') + command = command.replace(/\n$/, ''); if (isProcessAReactApp(command)) { const packageName = getPackageNameInDirectory(processDirectory); @@ -68,8 +68,12 @@ function getProcessForPort(port) { var processId = getProcessIdOnPort(port); var directory = getDirectoryOfProcessById(processId); var command = getProcessCommand(processId, directory); - return chalk.cyan(command) + chalk.grey(' (pid ' + processId + ')\n') + - chalk.blue(' in ') + chalk.cyan(directory); + return ( + chalk.cyan(command) + + chalk.grey(' (pid ' + processId + ')\n') + + chalk.blue(' in ') + + chalk.cyan(directory) + ); } catch (e) { return null; } diff --git a/packages/react-scripts/config/webpackDevServer.config.js b/packages/react-scripts/config/webpackDevServer.config.js index daf82e77f88..a48a1fbc3a6 100644 --- a/packages/react-scripts/config/webpackDevServer.config.js +++ b/packages/react-scripts/config/webpackDevServer.config.js @@ -10,6 +10,7 @@ const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware'); const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware'); +const path = require('path'); const config = require('./webpack.config.dev'); const paths = require('./paths'); @@ -75,7 +76,10 @@ module.exports = function(proxy, allowedHost) { // src/node_modules is not ignored to support absolute imports // https://github.com/facebookincubator/create-react-app/issues/1065 watchOptions: { - ignored: new RegExp(`^(?!${paths.appSrc}).+[\\/]node_modules[\\/]`, 'g'), + ignored: new RegExp( + `^(?!${path.normalize(paths.appSrc + '/')}).+[\\/]node_modules[\\/]`, + 'g' + ), }, // Enable HTTPS if the HTTPS environment variable is set to 'true' https: protocol === 'https',