Skip to content

Commit ae9b6e3

Browse files
authored
fix: runtime created with the old eszip cannot reference static files properly in some cases (#579)
1 parent 6db5cb5 commit ae9b6e3

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

crates/base/src/runtime/mod.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,11 +687,29 @@ where
687687
)
688688
};
689689

690+
let static_files = if is_some_entry_point {
691+
let entrypoint_path = main_module_url
692+
.to_file_path()
693+
.map_err(|_| anyhow!("failed to convert entrypoint to path"))?;
694+
let static_root_path = entrypoint_path
695+
.parent()
696+
.ok_or_else(|| anyhow!("could not resolve parent of entrypoint"))?
697+
.to_path_buf();
698+
699+
metadata
700+
.static_assets_lookup(static_root_path)
701+
.into_iter()
702+
.chain(static_files.into_iter())
703+
.collect()
704+
} else {
705+
static_files
706+
};
707+
690708
let (fs, s3_fs) = build_file_system_fn(if is_user_worker {
691709
Arc::new(StaticFs::new(
692710
static_files,
693711
if matches!(entrypoint, Some(Entrypoint::ModuleCode(_)) | None)
694-
&& maybe_entrypoint.is_some()
712+
&& is_some_entry_point
695713
{
696714
// it is eszip from before v2
697715
base_url

0 commit comments

Comments
 (0)