Skip to content

Commit

Permalink
use new watchpack collectTimeInfoEntries
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Molinaro committed Nov 24, 2021
1 parent c66e4ce commit 8867bc1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
28 changes: 20 additions & 8 deletions lib/node/NodeWatchFileSystem.js
Expand Up @@ -68,6 +68,8 @@ class NodeWatchFileSystem {
if (callbackUndelayed) {
this.watcher.once("change", callbackUndelayed);
}

let fileMap, directoryMap;
this.watcher.once("aggregated", (changes, removals) => {
if (this.inputFileSystem && this.inputFileSystem.purge) {
const fs = this.inputFileSystem;
Expand All @@ -78,8 +80,10 @@ class NodeWatchFileSystem {
fs.purge(item);
}
}
const times = this.watcher.getTimeInfoEntries();
callback(null, times, times, changes, removals);
fileMap = new Map();
directoryMap = new Map();
this.watcher.collectTimeInfoEntries(fileMap, directoryMap);
callback(null, fileMap, directoryMap, changes, removals);
});

this.watcher.watch({ files, directories, missing, startTime });
Expand Down Expand Up @@ -120,18 +124,26 @@ class NodeWatchFileSystem {
return items;
},
getFileTimeInfoEntries: () => {
if (fileMap) return fileMap;
if (this.watcher) {
return this.watcher.getTimeInfoEntries();
} else {
return new Map();
this.watcher.collectTimeInfoEntries(
(fileMap = new Map()),
(directoryMap = new Map())
);
return fileMap;
}
return new Map();
},
getContextTimeInfoEntries: () => {
if (directoryMap) return directoryMap;
if (this.watcher) {
return this.watcher.getTimeInfoEntries();
} else {
return new Map();
this.watcher.collectTimeInfoEntries(
(fileMap = new Map()),
(directoryMap = new Map())
);
return directoryMap;
}
return new Map();
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -27,7 +27,7 @@
"schema-utils": "^3.1.0",
"tapable": "^2.1.1",
"terser-webpack-plugin": "^5.1.3",
"watchpack": "^2.2.0",
"watchpack": "^2.3.0",
"webpack-sources": "^3.2.2"
},
"peerDependenciesMeta": {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -6074,10 +6074,10 @@ wast-loader@^1.11.0:
dependencies:
wabt "1.0.0-nightly.20180421"

watchpack@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.2.0.tgz#47d78f5415fe550ecd740f99fe2882323a58b1ce"
integrity sha512-up4YAn/XHgZHIxFBVCdlMiWDj6WaLKpwVeGQk2I5thdYxF/KmF0aaz6TfJZ/hfl1h/XlcDr7k1KH7ThDagpFaA==
watchpack@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.3.0.tgz#a41bca3da6afaff31e92a433f4c856a0c25ea0c4"
integrity sha512-MnN0Q1OsvB/GGHETrFeZPQaOelWh/7O+EiFlj8sM9GPjtQkis7k01aAxrg/18kTfoIVcLL+haEVFlXDaSRwKRw==
dependencies:
glob-to-regexp "^0.4.1"
graceful-fs "^4.1.2"
Expand Down

0 comments on commit 8867bc1

Please sign in to comment.