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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

eduardoboucas
Copy link
Member

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.

Copy link

github-actions bot commented Jul 10, 2025

📊 Benchmark results

Comparing with 47a1a61

  • Dependency count: 1,082 (no change)
  • Package size: 288 MB (no change)
  • Number of ts-expect-error directives: 399 (no change)

@@ -524,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.

timeline: 'dev' | 'build'
}

export async function runNetlifyBuild(
Copy link
Member Author

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.

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

Successfully merging this pull request may close these issues.

1 participant