Skip to content

fix: omit duplicate functions from list of bundled files #6535

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/build/src/plugins_core/functions/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ 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]))
const relativeMainFiles = [...dedupedFunctions.values()].map(({ mainFile }) => relative(functionsSrc, mainFile))
return relativeMainFiles
}

export const getUserAndInternalFunctions = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const handler = () => true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const handler = () => true
6 changes: 6 additions & 0 deletions packages/build/tests/core/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,12 @@ test('Bundles functions from the `.netlify/functions-internal` directory even if
t.snapshot(normalizeOutput(output))
})

test('Removes duplicate function names from the list of processed functions', async (t) => {
const output = await new Fixture('./fixtures/functions_duplicate_names').runWithBuild()
t.true(normalizeOutput(output).includes(`- function_one.js`))
t.false(normalizeOutput(output).includes(`- function_one.ts`))
})

test.serial('`rustTargetDirectory` is passed to zip-it-and-ship-it only when running in buildbot', async (t) => {
const runCount = 4
const mockZipFunctions = sinon.stub().resolves()
Expand Down
Loading