Conversation
This was referenced Mar 13, 2025
mofeiZ
commented
Mar 13, 2025
Comment on lines
+25
to
+32
| CompilerError.throwTodo({ | ||
| reason: `Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting`, | ||
| description: `Rewrite the reference to ${fnPath.node.id?.name ?? 'this function'} to not rely on hoisting to fix this issue`, | ||
| loc: fnPath.node.loc ?? null, | ||
| suggestions: null, | ||
| }); |
Contributor
Author
There was a problem hiding this comment.
#32598 replaces this bailout with special handling
mofeiZ
commented
Mar 13, 2025
| }); | ||
| } else { | ||
| fnPath.replaceWith(gatingExpression); | ||
| const gatingExpression = t.conditionalExpression( |
mofeiZ
commented
Mar 13, 2025
| parsedOptions[key] = parseTargetConfig(value); | ||
| break; | ||
| } | ||
| case 'gating': { |
Contributor
Author
There was a problem hiding this comment.
Moved gating config parsing to BabelPlugin entrypoint -- now it's unconditional and eager like the rest of our config parsing / validation. Previously, we only tried to parse gating if we had successful compilation events.
mofeiZ
commented
Mar 13, 2025
| return; | ||
| } | ||
|
|
||
| let gating: null | { |
Contributor
Author
There was a problem hiding this comment.
Changes in this file are all code movement.
- tryParseExternalFunction is moved to
parsePluginOptions, which runs before this function - collect
referencedBeforeDeclaredset here instead eagerly bailing out. This is to prepare for the next PR [compiler] Avoid bailouts when inserting gating #32598. (Also happy to merge these into a single changeset if that's easier to review)
poteto
approved these changes
Mar 13, 2025
Comment on lines
+24
to
+32
| if (referencedBeforeDeclaration) { | ||
| CompilerError.throwTodo({ | ||
| reason: `Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting`, | ||
| description: `Rewrite the reference to ${fnPath.node.id?.name ?? 'this function'} to not rely on hoisting to fix this issue`, | ||
| loc: fnPath.node.loc ?? null, | ||
| suggestions: null, | ||
| }); |
Contributor
There was a problem hiding this comment.
Small nit; what do you think about moving the throw to the callsite instead of having the boolean arg?
Contributor
Author
There was a problem hiding this comment.
#32511 replaces this throw, so this is very temporary
Some code movement for the next PR
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Some code movement for the next PR
Stack created with Sapling. Best reviewed with ReviewStack.