This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
fix: detect a wider range of scheduled functions #1105
Merged
Merged
Conversation
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
⏱ Benchmark resultsComparing with 123e7e8 largeDepsEsbuild: 7.4s⬆️ 16.91% increase vs. 123e7e8
Legend
largeDepsNft: 35s
Legend
largeDepsZisi: 50.4s
Legend
|
scheduled functions which are reassigned or not directly exported are now detected
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.
Looks really good. I left some comments and questions, mostly related to the fact that traversing ASTs is tricky and we should go the extra mile to make sure stuff is easy to understand by our future selves!
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
eduardoboucas
approved these changes
Jun 9, 2022
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.
🚀
Skn0tt
pushed a commit
to netlify/build
that referenced
this pull request
May 21, 2024
…ship-it#1105) * fix: detect a wider range of scheduled functions scheduled functions which are reassigned or not directly exported are now detected * Update src/runtimes/node/parser/bindings.ts Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com> * Update src/runtimes/node/parser/exports.ts Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com> * Update src/runtimes/node/parser/exports.ts Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com> * Apply suggestions from code review Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com> * refactor: clean up code Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
scheduled functions which are reassigned or not directly exported are now detected
This PR extends the functionality of the detection for the in-source-config of scheduled functions.
2 cases were not supported previously:
schedule()
helper but assigned to a variableschedule(SCHEDULE, ...)
export const handler = schedule()
) but instead assigned to a variable which is exportedexport { handler }
To solve both of these cases I opted to collect all variable bindings and their current value (only in the root scope). This is done by iterating through all nodes and collecting all declarations of variables and all reassigns. This method is memoized so that multiple calls (at the moment maximum 2) won't result in duplicated work.
Now, when the cron pattern in the schedule helper (1) or the export (2) is encountered as an identifier instead of the expected value, the code now can resolve the identifier to its value using the binding-map.