-
Notifications
You must be signed in to change notification settings - Fork 365
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: determine duplicate function precedence based on extension #5623
Merged
khendrikse
merged 11 commits into
main
from
feat-461/set-function-precedence-based-on-extension
Apr 13, 2023
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4833341
fix: determine duplicate function precedence based on extension
khendrikse c614a22
Merge branch 'main' into feat-461/set-function-precedence-based-on-exβ¦
khendrikse c5a759a
test: add test for duplicate function precedence
khendrikse d881924
Merge branch 'main' into feat-461/set-function-precedence-based-on-exβ¦
khendrikse 6b14d25
feat: reverse functions array to keep function precedence
khendrikse e8c8856
Merge branch 'main' into feat-461/set-function-precedence-based-on-exβ¦
khendrikse b97dafe
feat: reverse functions array to keep function precedence
khendrikse 45e47d8
feat: reverse the way we pass sourcedirectories to match reversed order
khendrikse f0ce6a6
Merge branch 'main' into feat-461/set-function-precedence-based-on-exβ¦
khendrikse fce8949
Update src/lib/functions/registry.mjs
khendrikse 2c4ac94
Update src/lib/functions/registry.mjs
khendrikse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hmm, this feels unrelated to the extension precedence. Is this a separate problem you've identified?
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.
It is actually related. In zip-it-and-ship-it we have defined that the rightmost directory takes precedence. Since me reversing the array in this PR is mimicking ZISI behavior, it meant that we had to also use that same logic here in the CLI.
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.
But we're reversing the array of the functions that come out, not the list of directories going in?
(Sorry if I'm missing the point.)
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.
No worries! I'll try to explain it better.
Previously:
In the CLI we were passing the following to ZISI:
directories:
[user-func-dir, internal-func-dir]
This meant that zisi returns a list of functions with the following precedence:
user-func-dir/hello.ts
user-func-dir/hello.js
internal-func-dir/hello.js
This is because ZISI will let functions from the rightmost directory take precedence. (fun fact: we pass the internal folder first in netlify/build as well)
That wasn't a problem before in the CLI, as we'd register the first function we'd encounter (in this case
user-func-dir/hello.ts
), making the user function take precedence, just like we do innetlify/build
.Currently
To make sure we get the same precedence as ZISI passes on to us, I reversed the functions array we got from ZISI before we register functions. But to also make sure that user functions take precedence like they did before, and like they do because of the way we pass the internal-func folder first in
netlify/build
, I also had to change the way we pass the sourcedirectories.Otherwise we'd first register the
internal-func-dir/hello.js