MCPcopy
hub / github.com/webpack/webpack-dev-server / normalizeOptions

Method normalizeOptions

lib/Server.js:840–1468  ·  view source on GitHub ↗

* @private * @returns {Promise }

()

Source from the content-addressed store, hash-verified

838 * @returns {Promise<void>}
839 */
840 async normalizeOptions() {
841 const { options } = this;
842 const compilerOptions = this.getCompilerOptions();
843 const compilerWatchOptions = compilerOptions.watchOptions;
844 /**
845 * @param {WatchOptions & { aggregateTimeout?: number, ignored?: WatchOptions["ignored"], poll?: number | boolean }} watchOptions watch options
846 * @returns {WatchOptions} normalized watch options
847 */
848 const getWatchOptions = (watchOptions = {}) => {
849 const getPolling = () => {
850 if (typeof watchOptions.usePolling !== "undefined") {
851 return watchOptions.usePolling;
852 }
853
854 if (typeof watchOptions.poll !== "undefined") {
855 return Boolean(watchOptions.poll);
856 }
857
858 if (typeof compilerWatchOptions.poll !== "undefined") {
859 return Boolean(compilerWatchOptions.poll);
860 }
861
862 return false;
863 };
864 const getInterval = () => {
865 if (typeof watchOptions.interval !== "undefined") {
866 return watchOptions.interval;
867 }
868
869 if (typeof watchOptions.poll === "number") {
870 return watchOptions.poll;
871 }
872
873 if (typeof compilerWatchOptions.poll === "number") {
874 return compilerWatchOptions.poll;
875 }
876 };
877
878 const usePolling = getPolling();
879 const interval = getInterval();
880 const { poll: _poll, interval: _interval, ...rest } = watchOptions;
881
882 return {
883 ignoreInitial: true,
884 persistent: true,
885 followSymlinks: false,
886 atomic: false,
887 alwaysStat: true,
888 ignorePermissionErrors: true,
889 // Respect options from compiler watchOptions
890 usePolling,
891 ...(interval !== undefined ? { interval } : {}),
892 ...rest,
893 };
894 };
895 /**
896 * @param {(string | Static | undefined)=} optionsForStatic for static
897 * @returns {NormalizedStatic} normalized options for static

Callers 1

setupMethod · 0.95

Calls 4

getCompilerOptionsMethod · 0.95
findCacheDirMethod · 0.80
infoMethod · 0.80
readFileMethod · 0.80

Tested by

no test coverage detected