fix(lambda): define dirname in handler bundle

This commit is contained in:
Miguel Ángel
2026-07-05 11:46:48 -07:00
committed by GitHub
parent b7dcb9e2a3
commit f999b40d73
2 changed files with 18 additions and 0 deletions
@@ -0,0 +1,14 @@
import { describe, expect, it } from "bun:test";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
describe("build-zip handler banner", () => {
it("defines CommonJS path globals for inlined CJS dependencies", () => {
const source = readFileSync(fileURLToPath(new URL("./build-zip.ts", import.meta.url)), "utf8");
expect(source).toContain('import { fileURLToPath as __hf_fileURLToPath } from "url";');
expect(source).toContain('import { dirname as __hf_dirname } from "path";');
expect(source).toContain("const __filename = __hf_fileURLToPath(import.meta.url);");
expect(source).toContain("const __dirname = __hf_dirname(__filename);");
});
});
+4
View File
@@ -252,6 +252,10 @@ async function bundleHandler(stagingDir: string): Promise<void> {
"// hyperframes-aws-lambda handler bundle",
'import { createRequire as __hf_createRequire } from "module";',
"const require = __hf_createRequire(import.meta.url);",
'import { fileURLToPath as __hf_fileURLToPath } from "url";',
'import { dirname as __hf_dirname } from "path";',
"const __filename = __hf_fileURLToPath(import.meta.url);",
"const __dirname = __hf_dirname(__filename);",
].join("\n"),
},
});