-
Notifications
You must be signed in to change notification settings - Fork 71
feat!: update signature of zipFunctions
#6524
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
zipFunctions
zipFunctions
This pull request adds or modifies JavaScript ( |
@@ -71,11 +113,12 @@ export const zipFunctions = async function ( | |||
const logger = getLogger(systemLog, debug) | |||
const cache = new RuntimeCache() | |||
const featureFlags = getFlags(inputFeatureFlags) | |||
const srcFolders = resolveFunctionsDirectories(relativeSrcFolders) | |||
const bag = getFunctionsBag(input) | |||
const srcFolders = resolveFunctionsDirectories(bag.directories) |
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.
We use directories
to go find functions.
const internalFunctionsPath = internalSrcFolder && resolve(internalSrcFolder) | ||
|
||
const [paths] = await Promise.all([listFunctionsDirectories(srcFolders), fs.mkdir(destFolder, { recursive: true })]) | ||
const functions = await getFunctionsFromPaths(paths, { | ||
const functions = await getFunctionsFromPaths([...paths, ...bag.functions], { |
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.
And we use functions
to pass directly to getFunctionsFromPaths
, which filters the paths that can actually be functions.
This pull request adds or modifies JavaScript ( |
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.
LGTM
This pull request adds or modifies JavaScript ( |
This pull request adds or modifies JavaScript ( |
This pull request adds or modifies JavaScript ( |
This pull request adds or modifies JavaScript ( |
Summary
In #6481 we made it possible for
zipFunctions
to receive both directory and file paths. The idea is that we could accept both directories of functions and individual functions, interchangeably.This works for the most part, but becomes a bit challenging when the individual functions live in their own sub-directory.
For example, given the following tree:
If I pass
my-functions
tozipFunctions
, zip-it-and-ship-it will understand thatfunc1
is a function in a sub-directory and will handle it correctly, which means naming the functionfunc1
(notindex
) and understanding thatutil.js
is a supporting file and not an entry file for another function.This understanding breaks down if we pass
my-functions/func1/index.js
directly, because zip-it-and-ship-it has no way of knowing that the function is actually calledfunc1
, notindex
.So this PR updates the signature of
zipFunctions
to accept an object (which I've calledFunctionsBag
) with two properties that separate the input into:directories
: Paths that can contain multiple functions (which in the tree above would bemy-functions
)functions
: Paths that point to individual functions, whether they live in their own sub-directory or not (which in the tree above would bemy-functions/func-1
)zipFunctions
continues to accept a string or array of strings as before, but I marked this as a breaking change because we no longer accept specific files on those strings. This was the change introduced in #6481, and even though no part of our system is relying on that yet, it's technically a breaking change so I'm doing a major bump.Update
I'm rolling another breaking change into this PR by removing the
internalSrcFolder
parameter in favour of making the newFunctionsBag
object acceptuser
andgenerated
top-level properties.We currently have an issue where functions produced with the Frameworks API are not marked as generated (or internal, in zip-it-and-ship-it's terminology). This is because
internalSrcFolder
accepts one single directory, which is currently set by Netlify Build to.netlify/functions-internal
.With this change, Netlify Build sends an object that looks something like this:
A picture of a cute animal (not mandatory, but encouraged)
🐖