diff --git a/backend/windmill-worker/src/bun_executor.rs b/backend/windmill-worker/src/bun_executor.rs index b3090ac3d9..cec1e28e6c 100644 --- a/backend/windmill-worker/src/bun_executor.rs +++ b/backend/windmill-worker/src/bun_executor.rs @@ -718,7 +718,7 @@ pub async fn handle_bun_job( if !codebase.is_some() && !has_bundle_cache { let _ = write_file(job_dir, "main.ts", inner_content).await?; - } else if !annotation.native_mode { + } else if !annotation.native_mode && codebase.is_none() { let _ = write_file(job_dir, "package.json", r#"{ "type": "module" }"#).await?; }; diff --git a/cli/script.ts b/cli/script.ts index cdeb5bd708..9faf461495 100644 --- a/cli/script.ts +++ b/cli/script.ts @@ -157,22 +157,12 @@ export async function handleFile( log.info(`Starting building the bundle for ${path}`); const out = await esbuild.build({ entryPoints: [path], - format: "esm", + format: "cjs", bundle: true, write: false, platform: "node", packages: "bundle", target: "node20.15.1", - banner: { - js: ` - import { createRequire } from 'module'; - import { dirname } from 'path'; - import { fileURLToPath } from 'url'; - - const require = createRequire(import.meta.url); - const __filename = fileURLToPath(import.meta.url); - const __dirname = dirname(__filename);`, - }, }); bundleContent = out.outputFiles[0].text; log.info(`Finished building the bundle for ${path}`);