Skip to content

Commit 6faaabb

Browse files
committed
Use await import instead of require for functions modules that contain top-level awaits
1 parent 9ed934d commit 6faaabb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/runtime/loader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ async function loadModule(functionsDir: string) {
4848
try {
4949
return require(path.resolve(absolutePath));
5050
} catch (e) {
51-
if (e.code === "ERR_REQUIRE_ESM") {
52-
// This is an ESM package!
51+
if (e.code === "ERR_REQUIRE_ESM" || e.code === "ERR_REQUIRE_ASYNC_MODULE") {
52+
// This is an ESM package, or one containing top-level awaits!
5353
const modulePath = require.resolve(absolutePath);
5454
// Resolve module path to file:// URL. Required for windows support.
5555
const moduleURL = url.pathToFileURL(modulePath).href;

0 commit comments

Comments
 (0)