improve codebase bundle js import

This commit is contained in:
Ruben Fiszel
2025-11-28 13:58:36 +00:00
parent e724249299
commit 118c2ab035
+9 -11
View File
@@ -612,13 +612,15 @@ struct PulledCodebase {
}
async fn pull_codebase(w_id: &str, id: &str, job_dir: &str) -> Result<PulledCodebase> {
let path = windmill_common::s3_helpers::bundle(&w_id, &id);
let CodebaseInfo { is_tar, is_esm } = id_to_codebase_info(id);
let bun_cache_path = format!(
"{}/{}",
"{}/{}.{}",
windmill_common::worker::ROOT_CACHE_NOMOUNT_DIR,
path
path,
if is_tar { "tar" } else { "js" }
);
let CodebaseInfo { is_tar, is_esm } = id_to_codebase_info(id);
let dst = format!(
"{job_dir}/{}",
if is_tar { "codebase.tar" } else { "main.js" }
@@ -639,9 +641,10 @@ async fn pull_codebase(w_id: &str, id: &str, job_dir: &str) -> Result<PulledCode
&& object_store.is_none()
{
let bun_cache_path = format!(
"{}/{}",
"{}/{}.{}",
*windmill_common::worker::ROOT_STANDALONE_BUNDLE_DIR,
path
path,
if is_tar { "tar" } else { "js" }
);
if std::fs::metadata(&bun_cache_path).is_ok() {
tracing::info!("loading {bun_cache_path} from standalone bundle cache");
@@ -1095,14 +1098,9 @@ pub async fn handle_bun_job(
"".to_string()
};
let codebase_import = if format == BundleFormat::Esm {
" with { type: 'js' }"
} else {
""
};
let wrapper_content = format!(
r#"
import * as Main from "{main_import}"{codebase_import};
import * as Main from "{main_import}";
import * as fs from "fs/promises";