@@ -632,14 +632,10 @@ where
632
632
base_url,
633
633
} = rt_provider;
634
634
635
- let entrypoint = metadata
636
- . entrypoint
637
- . as_ref ( )
638
- . with_context ( || "could not find entrypoint from metadata" ) ?;
639
-
635
+ let entrypoint = metadata. entrypoint . as_ref ( ) ;
640
636
let main_module_url = match entrypoint {
641
- Entrypoint :: Key ( key) => base_url. join ( key) ?,
642
- Entrypoint :: ModuleCode ( _) => Url :: parse (
637
+ Some ( Entrypoint :: Key ( key) ) => base_url. join ( key) ?,
638
+ Some ( Entrypoint :: ModuleCode ( _) ) | None => Url :: parse (
643
639
maybe_entrypoint
644
640
. as_ref ( )
645
641
. with_context ( || "could not find entrypoint key" ) ?,
@@ -668,16 +664,25 @@ where
668
664
let ( fs, maybe_s3_fs) = build_file_system_fn ( if is_user_worker {
669
665
Arc :: new ( StaticFs :: new (
670
666
static_files,
671
- main_module_url
672
- . to_file_path ( )
673
- . map_err ( |_| {
674
- anyhow ! ( "failed to resolve base dir using main module url" )
675
- } )
676
- . and_then ( |it| {
677
- it. parent ( )
678
- . map ( Path :: to_path_buf)
679
- . with_context ( || "failed to determine parent directory" )
680
- } ) ?,
667
+ if matches ! ( entrypoint, Some ( Entrypoint :: ModuleCode ( _) ) | None )
668
+ && maybe_entrypoint. is_some ( )
669
+ {
670
+ // it is eszip from before v2
671
+ base_url
672
+ . to_file_path ( )
673
+ . map_err ( |_| anyhow ! ( "failed to resolve base url" ) ) ?
674
+ } else {
675
+ main_module_url
676
+ . to_file_path ( )
677
+ . map_err ( |_| {
678
+ anyhow ! ( "failed to resolve base dir using main module url" )
679
+ } )
680
+ . and_then ( |it| {
681
+ it. parent ( )
682
+ . map ( Path :: to_path_buf)
683
+ . with_context ( || "failed to determine parent directory" )
684
+ } ) ?
685
+ } ,
681
686
vfs_path,
682
687
vfs,
683
688
npm_snapshot,
@@ -993,10 +998,10 @@ where
993
998
994
999
let main_module_id = {
995
1000
match entrypoint {
996
- Entrypoint :: Key ( _) => {
1001
+ Some ( Entrypoint :: Key ( _) ) | None => {
997
1002
js_runtime. load_main_es_module ( & main_module_url) . await ?
998
1003
}
999
- Entrypoint :: ModuleCode ( module_code) => {
1004
+ Some ( Entrypoint :: ModuleCode ( module_code) ) => {
1000
1005
js_runtime
1001
1006
. load_main_es_module_from_code (
1002
1007
& main_module_url,
0 commit comments