Azure/azure-functions-nodejs-library

Build compiler Esbuild support

Closed this issue · 2 comments

Investigative information

  • azure/functions Version: 4.4.0

Currently this libary got a problem, and that is that it can not be compiled with builders like esbuild/babel/webkit.

Example:
`
$ esbuild ./src/functions/example/index.js --bundle --platform=node --target=node20.12.2 --outfile=.build/index.js

X [ERROR] Could not resolve "@azure/functions-core"

../../node_modules/@azure/functions/dist/azure-functions.js:2544:25:
  2544 │ module.exports = require("@azure/functions-core");
       ╵                          ~~~~~~~~~~~~~~~~~~~~~~~

You can mark the path "@azure/functions-core" as external to exclude it from the bundle, which
will remove this error and leave the unresolved path in the bundle. You can also surround this
"require" call with a try/catch block to handle this failure at run-time instead of bundle-time.
`
Why do we even need a compiler?

Monorepo's got alot of libaries ( Terrabytes ), 99,99% of those have noting to do with the function.
A compiler is normally a way to solve this problem.
So running a compiler like esbuild on the js with the function, results in a js file, with the libaries that it needs in the Javascript file, and only those it needs to run in the function. it will result in a js file that is just a few Kb's.

Known workarounds

There is a workaround for the compiler to add "@azure/functions-core" as external libary.
It will compile without the "@azure/functions-core" libary then.
This will result in a successful compile.

but when deploying it to azure it will not show the functions.
So the "@azure/functions-core" is a important script that needs to be included if you want the script to work on azure functions.

but when deploying it to azure it will not show the functions.

Can you expand on this? For example, you could provide a sample app that hits this problem, or follow these instructions to share your app name and time of issue.

So the "@azure/functions-core" is a important script that needs to be included if you want the script to work on azure functions.

This is not true, I believe you're running into some other problem that we need to figure out. You should be listing "@azure/functions-core" as an external library

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.