@@ -16,6 +16,7 @@ use deno_cache_dir::file_fetcher::NullBlobStore;
1616use deno_graph:: MediaType ;
1717use deno_graph:: Module ;
1818use deno_graph:: ModuleGraph ;
19+ use deno_graph:: Position ;
1920use deno_graph:: analysis:: ModuleAnalyzer ;
2021use deno_graph:: ast:: DefaultModuleAnalyzer ;
2122use deno_graph:: ast:: EsParser ;
@@ -339,10 +340,9 @@ impl DenoLoader {
339340 & mut self ,
340341 roots : Vec < String > ,
341342 ) -> Result < ( ) , anyhow:: Error > {
342- let cwd = self . workspace_factory . initial_cwd ( ) ;
343343 let roots = roots
344344 . into_iter ( )
345- . map ( |e| parse_entrypoint ( e , & cwd ) )
345+ . map ( |e| self . resolve_entrypoint ( e ) )
346346 . collect :: < Result < Vec < _ > , _ > > ( ) ?;
347347 let npm_package_info_provider = self
348348 . npm_installer_factory
@@ -441,9 +441,7 @@ impl DenoLoader {
441441 ) ?,
442442 ) ,
443443 None => {
444- let entrypoint =
445- parse_entrypoint ( specifier, self . workspace_factory . initial_cwd ( ) ) ?
446- . to_string ( ) ;
444+ let entrypoint = self . resolve_entrypoint ( specifier) ?. to_string ( ) ;
447445 (
448446 entrypoint,
449447 deno_path_util:: url_from_file_path (
@@ -599,6 +597,26 @@ impl DenoLoader {
599597 Ok ( Cow :: Borrowed ( source. as_bytes ( ) ) )
600598 }
601599 }
600+
601+ fn resolve_entrypoint (
602+ & self ,
603+ specifier : String ,
604+ ) -> Result < Url , anyhow:: Error > {
605+ let cwd = self . workspace_factory . initial_cwd ( ) ;
606+ if specifier. contains ( '\\' ) {
607+ return Ok ( deno_path_util:: url_from_file_path ( & resolve_absolute_path (
608+ specifier, cwd,
609+ ) ) ?) ;
610+ }
611+ let referrer = deno_path_util:: url_from_directory_path ( cwd) ?;
612+ Ok ( self . resolver . resolve (
613+ & specifier,
614+ & referrer,
615+ Position :: zeroed ( ) ,
616+ node_resolver:: ResolutionMode :: Import ,
617+ node_resolver:: NodeResolutionKind :: Execution ,
618+ ) ?)
619+ }
602620}
603621
604622fn create_module_response (
@@ -641,24 +659,6 @@ fn create_external_repsonse(url: &Url) -> JsValue {
641659 obj. into ( )
642660}
643661
644- fn parse_entrypoint (
645- entrypoint : String ,
646- cwd : & Path ,
647- ) -> Result < Url , anyhow:: Error > {
648- if entrypoint. starts_with ( "jsr:" )
649- || entrypoint. starts_with ( "https:" )
650- || entrypoint. starts_with ( "http:" )
651- || entrypoint. starts_with ( "file:" )
652- || entrypoint. starts_with ( "npm:" )
653- {
654- Ok ( Url :: parse ( & entrypoint) ?)
655- } else {
656- Ok ( deno_path_util:: url_from_file_path ( & resolve_absolute_path (
657- entrypoint, cwd,
658- ) ) ?)
659- }
660- }
661-
662662fn resolve_absolute_path ( path : String , cwd : & Path ) -> PathBuf {
663663 let path = sys_traits:: impls:: wasm_string_to_path ( path) ;
664664 cwd. join ( path)
0 commit comments