fix(watch): preserve ProcState::file_fetcher between restarts (#15466)

This commit changes "ProcState" to store "file_fetcher" field in an "Arc",
allowing it to be preserved between restarts and thus keeping the state
alive between the restarts. File watchers for "deno test" and "deno bench"
now reset "ProcState" between restarts.
This commit is contained in:
Nayeem Rahman 2023-01-10 15:28:10 +00:00 committed by GitHub
parent 0329bc69da
commit 71ea4ef274
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 126 additions and 42 deletions

View file

@ -72,7 +72,7 @@ pub struct GraphData {
impl GraphData {
/// Store data from `graph` into `self`.
pub fn add_graph(&mut self, graph: &ModuleGraph, reload: bool) {
pub fn add_graph(&mut self, graph: &ModuleGraph) {
for graph_import in &graph.imports {
for dep in graph_import.dependencies.values() {
for resolved in [&dep.maybe_code, &dep.maybe_type] {
@ -96,7 +96,7 @@ impl GraphData {
continue;
}
if !reload && self.modules.contains_key(specifier) {
if self.modules.contains_key(specifier) {
continue;
}
@ -470,7 +470,7 @@ impl GraphData {
impl From<&ModuleGraph> for GraphData {
fn from(graph: &ModuleGraph) -> Self {
let mut graph_data = GraphData::default();
graph_data.add_graph(graph, false);
graph_data.add_graph(graph);
graph_data
}
}
@ -542,7 +542,7 @@ pub async fn create_graph_and_maybe_check(
let check_js = ps.options.check_js();
let mut graph_data = GraphData::default();
graph_data.add_graph(&graph, false);
graph_data.add_graph(&graph);
graph_data
.check(
&graph.roots,