From 8bd08495b180a3d7f6dfff19e9a95e32da831387 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 15 Nov 2021 16:47:57 +0530 Subject: [PATCH] refactor: code --- lib/Server.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index d33c3f9463..0a7610d34f 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -447,6 +447,10 @@ class Server { const compilerWatchOptions = compilerOptions.watchOptions || {}; const getDefaultWatchOptions = (watchOptions = {}) => { + watchOptions = { + ...compilerWatchOptions, + ...watchOptions, + }; // duplicate the same massaging of options that watchpack performs // https://github.com/webpack/watchpack/blob/master/lib/DirectoryWatcher.js#L49 // this isn't an elegant solution, but we'll improve it in the future @@ -464,6 +468,10 @@ class Server { : // eslint-disable-next-line no-undefined undefined; + if (watchOptions.poll) { + delete watchOptions.poll; + } + const finalWatchOptions = { ignoreInitial: true, persistent: true, @@ -471,17 +479,12 @@ class Server { atomic: false, alwaysStat: true, ignorePermissionErrors: true, - ...compilerWatchOptions, ...watchOptions, ignored: watchOptions.ignored, usePolling, interval, }; - if (finalWatchOptions.poll) { - delete finalWatchOptions.poll; - } - return finalWatchOptions; };