diff --git a/cli/proc_state.rs b/cli/proc_state.rs index bdd57da980ea16..5a95d85b7cd3ca 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -49,7 +49,6 @@ use deno_graph::create_graph; use deno_graph::source::CacheInfo; use deno_graph::source::LoadFuture; use deno_graph::source::Loader; -use deno_graph::source::ResolveResponse; use deno_graph::ModuleKind; use deno_graph::Resolved; use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel; @@ -293,41 +292,11 @@ impl ProcState { dynamic_permissions: Permissions, reload_on_watch: bool, ) -> Result<(), AnyError> { - let maybe_resolver: Option<&dyn deno_graph::source::Resolver> = - if let Some(resolver) = &self.maybe_resolver { - Some(resolver.as_ref()) - } else { - None - }; - - // NOTE(@bartlomieju): - // Even though `roots` are fully resolved at this point, we are going - // to resolve them through `maybe_resolver` to get module kind for the graph - // or default to ESM. - // - // One might argue that this is a code smell, and I would agree. However - // due to flux in "Node compatibility" it's not clear where it should be - // decided what `ModuleKind` is decided for root specifier. - let roots: Vec<(deno_core::url::Url, deno_graph::ModuleKind)> = roots + let roots = roots .into_iter() - .map(|r| { - if let Some(resolver) = &maybe_resolver { - let response = - resolver.resolve(r.as_str(), &Url::parse("unused:").unwrap()); - // TODO(bartlomieju): this should be implemented in `deno_graph` - match response { - ResolveResponse::CommonJs(_) => (r, ModuleKind::CommonJs), - ResolveResponse::Err(_) => unreachable!(), - _ => (r, ModuleKind::Esm), - } - } else { - (r, ModuleKind::Esm) - } - }) - .collect(); + .map(|s| (s, ModuleKind::Esm)) + .collect::>(); - // TODO(bartlomieju): this is very make-shift, is there an existing API - // that we could include it like with "maybe_imports"? if !reload_on_watch { let graph_data = self.graph_data.read(); if self.options.type_check_mode() == TypeCheckMode::None @@ -350,6 +319,12 @@ impl ProcState { ); let maybe_locker = as_maybe_locker(self.lockfile.clone()); let maybe_imports = self.options.to_maybe_imports()?; + let maybe_resolver: Option<&dyn deno_graph::source::Resolver> = + if let Some(resolver) = &self.maybe_resolver { + Some(resolver.as_ref()) + } else { + None + }; struct ProcStateLoader<'a> { inner: &'a mut cache::FetchCacher,