Skip to content

feat: load generated functions from Netlify Build #7408

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

Merged
merged 11 commits into from
Jul 28, 2025
Prev Previous commit
Next Next commit
refactor: change directory computation
  • Loading branch information
eduardoboucas committed Jul 11, 2025
commit b0abce02f7e5fac7cea670d619a6364e76a06b5e
3 changes: 2 additions & 1 deletion src/lib/functions/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,11 @@ export class FunctionsRegistry {
return
}

const directory = directories.find((directory) => mainFile.startsWith(directory)) ?? srcDir
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super happy with this. For some context, directory contains the top-level functions directory where this specific function is found (not the sub-directory where a function may live). For example, for both netlify/functions/foo/index.js and netlify/functions/bar.js this value would be netlify/functions.

This value was undefined for any functions in generatedFunctions, because those functions don't typically live inside any of the regular function directories. So for those cases the right value to use is srcDir.

I think this is in need of some refactoring though, because I'm not sure why we need to keep track of the parent functions directory and not just the directory where the function lives.

I'm keeping this as is for now, where we're just adding srcDir as a fallback, to minimise the impact of this change, and then we'll revisit when possible.

const func = new NetlifyFunction({
blobsContext: this.blobsContext,
config: this.config,
directory: srcDir ?? directories.find((directory) => mainFile.startsWith(directory)),
directory,
mainFile,
name,
displayName,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy