-
Notifications
You must be signed in to change notification settings - Fork 52
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
fix: omit duplicates from list of bundled functions #3795
base: main
Are you sure you want to change the base?
Conversation
@@ -21,7 +21,10 @@ const getRelativeFunctionMainFiles = async function ({ featureFlags, functionsSr | |||
|
|||
const zisiFeatureFlags = getZisiFeatureFlags(featureFlags) | |||
const functions = await listFunctions(functionsSrc, { featureFlags: zisiFeatureFlags }) | |||
return functions.map(({ mainFile }) => relative(functionsSrc, mainFile)) | |||
const dedupedFunctions = new Map(functions.map((func) => [func.name, func])) |
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.
Just wondering, any reason you are not going with Set
? Set ensures no duplicates exist by design :)
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 might have different functions with the same name. By passing an array of entries to Map
, we guarantee that the last function with the same name takes precedence, which is the order in which zip-it-and-ship-it outputs the files.
Does that answer the question?
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.
Yes, thanks for the explanation :)
@eduardoboucas What's the latest status of this PR? Should it be closed? |
Sorry, my bad. This fell between the cracks. I'm updating the branch and will merge this later today. |
Summary
When printing the list of bundled functions, Netlify Build uses zip-it-and-ship-it's
listFunctions
method, which includes functions that have not been bundled due to a naming conflict (e.g. when bothfunction.js
andfunction.ts
are found). Because of this, Netlify Build was incorrectly reporting that both functions were bundled, when in fact onlyfunction.js
was.This PR removes those duplicate functions from the list.
Fixes #3974.
A picture of a cute animal (not mandatory, but encouraged)