Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build compiler Esbuild support #256

Closed
edgehero opened this issue May 13, 2024 · 2 comments
Closed

Build compiler Esbuild support #256

edgehero opened this issue May 13, 2024 · 2 comments

Comments

@edgehero
Copy link

edgehero commented May 13, 2024

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.

@ejizba
Copy link
Contributor

ejizba commented May 17, 2024

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

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants