fix: for codebase bundle, use cjs exports instead

This commit is contained in:
Ruben Fiszel
2024-07-30 21:48:30 +02:00
parent 1a548f32a1
commit be8cedfe7f
2 changed files with 2 additions and 12 deletions
+1 -1
View File
@@ -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?;
};
+1 -11
View File
@@ -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}`);