From 1e98d0f428fd72f0a700b0c096b0d1a9e717d7ec Mon Sep 17 00:00:00 2001
From: Joe Lim <xjlim@users.noreply.github.com>
Date: Mon, 2 Oct 2017 19:57:02 -0700
Subject: [PATCH] Watch for changes in `src/**/node_modules` (#3230)

* Allow the dev server to watch for changes in src/node_modules

* fix eslint error

* fix broken regex

* handle trailing slash edge case for file paths

Closes #2760
Fixes #3223
---
 packages/react-dev-utils/getProcessForPort.js          | 10 +++++++---
 .../react-scripts/config/webpackDevServer.config.js    |  8 +++++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/packages/react-dev-utils/getProcessForPort.js b/packages/react-dev-utils/getProcessForPort.js
index c91959a37..932f3e5bf 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 25b42d0de..a48a1fbc3 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');
 
@@ -72,8 +73,13 @@ 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(
+        `^(?!${path.normalize(paths.appSrc + '/')}).+[\\/]node_modules[\\/]`,
+        'g'
+      ),
     },
     // Enable HTTPS if the HTTPS environment variable is set to 'true'
     https: protocol === 'https',
-- 
GitLab