You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the JavaScript world, there are two ways to import/export modules: CommonJS (default for node) and ES Modules (default for JavaScript).
The default for Azure Functions is to support exported functions in the CommonJS format, as follows:
module.exports=asyncfunction(context,req){context.log('JavaScript HTTP trigger function processed a request.');context.res={status: 200};};
We also now support ES Modules in preview, as follows:
exportconsthttpTrigger=asyncfunction(context,req){context.log('JavaScript HTTP trigger function processed a request.');context.res={status: 200};};
Currently, the only way we support ESM is if the file ends with the .mjs extension. However, we also want to respect the type property of package.json files, as described in this issue in the node worker. To fully support this, we need to support .cjs extension files as well, as described here.
This issue on the host side is to automatically detect index.cjs files as the scriptFile for node functions, in addition to the existing index.js and index.mjs.
Describe the solution you'd like
The Host automatically detects index.cjs files as the scriptFile for node functions, if index.js and index.mjs are not present. Implementation in #8205
The text was updated successfully, but these errors were encountered:
What problem would the feature you're requesting solve? Please describe.
This issue is implemented in #8205
In the JavaScript world, there are two ways to import/export modules: CommonJS (default for node) and ES Modules (default for JavaScript).
The default for Azure Functions is to support exported functions in the CommonJS format, as follows:
We also now support ES Modules in preview, as follows:
Currently, the only way we support ESM is if the file ends with the
.mjs
extension. However, we also want to respect thetype
property ofpackage.json
files, as described in this issue in the node worker. To fully support this, we need to support.cjs
extension files as well, as described here.This issue on the host side is to automatically detect
index.cjs
files as thescriptFile
for node functions, in addition to the existingindex.js
andindex.mjs
.Describe the solution you'd like
The Host automatically detects
index.cjs
files as thescriptFile
for node functions, ifindex.js
andindex.mjs
are not present. Implementation in #8205The text was updated successfully, but these errors were encountered: