Skip to content

Commit e65904a

Browse files
committed
chore: only prevent interval be undefined
1 parent b272880 commit e65904a

3 files changed

Lines changed: 9 additions & 27 deletions

File tree

lib/Server.js

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -306,22 +306,6 @@ function useFn(route, fn) {
306306

307307
const DEFAULT_ALLOWED_PROTOCOLS = /^(file|.+-extension):/i;
308308

309-
/**
310-
* Removes properties with undefined values from an object.
311-
* Needed because chokidar v4 crashes when options are explicitly set to undefined.
312-
* @see https://github.com/paulmillr/chokidar/issues/1394
313-
* @template {Record<string, unknown>} T
314-
* @param {T} obj the object to filter
315-
* @returns {T} a new object without undefined values
316-
*/
317-
function removeUndefinedValues(obj) {
318-
return /** @type {T} */ (
319-
Object.fromEntries(
320-
Object.entries(obj).filter(([, value]) => typeof value !== "undefined"),
321-
)
322-
);
323-
}
324-
325309
/**
326310
* @typedef {object} BasicApplication
327311
* @property {typeof useFn} use
@@ -849,7 +833,7 @@ class Server {
849833

850834
const usePolling = getPolling();
851835
const interval = getInterval();
852-
const { poll: _poll, ...rest } = watchOptions;
836+
const { poll: _poll, interval: _interval, ...rest } = watchOptions;
853837

854838
return {
855839
ignoreInitial: true,
@@ -3205,11 +3189,7 @@ class Server {
32053189
watchFiles(watchPath, watchOptions = {}) {
32063190
const chokidar = require("chokidar");
32073191

3208-
// https://github.com/paulmillr/chokidar/issues/1394
3209-
const watcher = chokidar.watch(
3210-
watchPath,
3211-
removeUndefinedValues(watchOptions),
3212-
);
3192+
const watcher = chokidar.watch(watchPath, watchOptions);
32133193

32143194
// disabling refreshing on changing the content
32153195
if (this.options.liveReload) {

test/cli/__snapshots__/basic.test.js.snap.webpack5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ Options:
126126
--no-static-watch Does not watch for files in static content directory.
127127
--static-reset Clear all items provided in 'static' configuration. Allows to configure options for serving static files from directory (by default 'public' directory).
128128
--static-public-path-reset Clear all items provided in 'static.publicPath' configuration. The static files will be available in the browser under this public path.
129-
--watch-files <value...> Allows to configure list of globs/directories/files to watch for file changes.
130-
--watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes.
129+
--watch-files <value...> Allows to configure list of directories/files to watch for file changes.
130+
--watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of directories/files to watch for file changes.
131131
--no-web-socket-server Disallows to set web socket server and options.
132132
--web-socket-server-type <value> Allows to set web socket server and options (by default 'ws').
133133

test/e2e/__snapshots__/watch-files.test.js.snap.webpack5

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ exports[`watchFiles option should work with options {} should reload when file c
365365
"ignorePermissionErrors": true,
366366
"ignored": [],
367367
"interval": 100,
368-
"persistent": true,
368+
"persistent": undefined,
369369
"usePolling": true,
370370
}
371371
`;
@@ -376,7 +376,7 @@ exports[`watchFiles option should work with options {} should reload when file c
376376
"atomic": false,
377377
"awaitWriteFinish": false,
378378
"binaryInterval": 300,
379-
"followSymlinks": true,
379+
"followSymlinks": undefined,
380380
"ignoreInitial": true,
381381
"ignorePermissionErrors": true,
382382
"ignored": [],
@@ -404,6 +404,7 @@ exports[`watchFiles option should work with options {} should reload when file c
404404

405405
exports[`watchFiles option should work with options {} should reload when file content is changed 6`] = `
406406
{
407+
"alwaysStat": undefined,
407408
"atomic": false,
408409
"awaitWriteFinish": false,
409410
"binaryInterval": 300,
@@ -423,6 +424,7 @@ exports[`watchFiles option should work with options {} should reload when file c
423424
"atomic": false,
424425
"awaitWriteFinish": false,
425426
"binaryInterval": 300,
427+
"depth": undefined,
426428
"followSymlinks": false,
427429
"ignoreInitial": true,
428430
"ignorePermissionErrors": true,
@@ -441,7 +443,7 @@ exports[`watchFiles option should work with options {} should reload when file c
441443
"binaryInterval": 300,
442444
"followSymlinks": false,
443445
"ignoreInitial": true,
444-
"ignorePermissionErrors": false,
446+
"ignorePermissionErrors": undefined,
445447
"ignored": [],
446448
"interval": 100,
447449
"persistent": true,

0 commit comments

Comments
 (0)