mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-01 19:42:03 +00:00
fix(lambda): define dirname in handler bundle
This commit is contained in:
@@ -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);");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -252,6 +252,10 @@ async function bundleHandler(stagingDir: string): Promise<void> {
|
|||||||
"// hyperframes-aws-lambda handler bundle",
|
"// hyperframes-aws-lambda handler bundle",
|
||||||
'import { createRequire as __hf_createRequire } from "module";',
|
'import { createRequire as __hf_createRequire } from "module";',
|
||||||
"const require = __hf_createRequire(import.meta.url);",
|
"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"),
|
].join("\n"),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user