Skip to content

Commit 1e98d0f

Browse files
xjlimTimer
authored andcommitted
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
1 parent c003583 commit 1e98d0f

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/react-dev-utils/getProcessForPort.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function getProcessCommand(processId, processDirectory) {
4646
execOptions
4747
);
4848

49-
command = command.replace(/\n$/, '')
49+
command = command.replace(/\n$/, '');
5050

5151
if (isProcessAReactApp(command)) {
5252
const packageName = getPackageNameInDirectory(processDirectory);
@@ -68,8 +68,12 @@ function getProcessForPort(port) {
6868
var processId = getProcessIdOnPort(port);
6969
var directory = getDirectoryOfProcessById(processId);
7070
var command = getProcessCommand(processId, directory);
71-
return chalk.cyan(command) + chalk.grey(' (pid ' + processId + ')\n') +
72-
chalk.blue(' in ') + chalk.cyan(directory);
71+
return (
72+
chalk.cyan(command) +
73+
chalk.grey(' (pid ' + processId + ')\n') +
74+
chalk.blue(' in ') +
75+
chalk.cyan(directory)
76+
);
7377
} catch (e) {
7478
return null;
7579
}

packages/react-scripts/config/webpackDevServer.config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
1212
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
13+
const path = require('path');
1314
const config = require('./webpack.config.dev');
1415
const paths = require('./paths');
1516

@@ -72,8 +73,13 @@ module.exports = function(proxy, allowedHost) {
7273
quiet: true,
7374
// Reportedly, this avoids CPU overload on some systems.
7475
// https://github.com/facebookincubator/create-react-app/issues/293
76+
// src/node_modules is not ignored to support absolute imports
77+
// https://github.com/facebookincubator/create-react-app/issues/1065
7578
watchOptions: {
76-
ignored: /node_modules/,
79+
ignored: new RegExp(
80+
`^(?!${path.normalize(paths.appSrc + '/')}).+[\\/]node_modules[\\/]`,
81+
'g'
82+
),
7783
},
7884
// Enable HTTPS if the HTTPS environment variable is set to 'true'
7985
https: protocol === 'https',

0 commit comments

Comments
 (0)