firebase-tools
firebase-tools copied to clipboard
fix(functions,emulators): loadTriggers() with top level await
Description
Context: ESM functions with firestore triggers
The expected behavior of loadTriggers() is to
try and require() the function entrypoint,
falling back to dynamic import() when node raises a ERR_REQUIRE_ESM error. But node may also raise an ERR_REQUIRE_ASYNC_MODULE error when the module has top level awaits
This commit simply makes it so ERR_REQUIRE_ASYNC_MODULE also falls back to import()
Scenarios Tested
Tested on our (private) repo
Let me know if tests need to be added/updated :)