-
Notifications
You must be signed in to change notification settings - Fork 412
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
base: main
Are you sure you want to change the base?
Conversation
📊 Benchmark resultsComparing with 47a1a61
|
@@ -524,10 +539,11 @@ export class FunctionsRegistry { | |||
return | |||
} | |||
|
|||
const directory = directories.find((directory) => mainFile.startsWith(directory)) ?? srcDir |
There was a problem hiding this comment.
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.
timeline: 'dev' | 'build' | ||
} | ||
|
||
export async function runNetlifyBuild( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main change here is to add two overloads to this function such that when we call it with timeline: "dev"
we get the return value correctly typed to the result of running the dev timeline, and the same for build
.
Summary
Loads functions generated by the new
functions.generate
util added in netlify/build#6487 and netlify/build#6525.It depends on netlify/build#6539, so tests will fail until that lands.