-
Notifications
You must be signed in to change notification settings - Fork 47k
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
[compiler] Infer deps configuration #31616
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
inferEffectDependencies: z | ||
.nullable( | ||
z.array( | ||
z.object({ | ||
module: z.string(), | ||
imported: z.string(), | ||
numRequiredArgs: z.number(), | ||
}), | ||
), | ||
) |
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.
tiny nit (feel free to ignore), it would be nice to make this consistent with other external function config options by using the ExternalFunctionSchema
type.
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.
ohhh nice!
module: 'react', | ||
imported: 'useSpecialEffect', | ||
numRequiredArgs: 2, |
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.
Nit: could we change this import to be not from react
? It would be great to be able to evaluate all fixture tests, and adding an unknown import from react
might mean monkey patching react
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.
Instead of test-fixture specific defaults, could we also add a default value to testComplexConfigDefaults
so that playground users can use @inferEffectDependencies
?
() => new Map<string, number>(), | ||
); | ||
moduleTargets.set(effectTarget.imported, effectTarget.numRequiredArgs); | ||
autodepFnConfigs.set(effectTarget.module, moduleTargets); |
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.
tiny nit: is this line needed (since we already have getOrInsertWith`)?
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 it is not :)
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.
Nice, let's go!!
Adds a way to configure how we insert deps for experimental purposes. ``` [ { module: 'react', imported: 'useEffect', numRequiredArgs: 1, }, { module: 'MyExperimentalEffectHooks', imported: 'useExperimentalEffect', numRequiredArgs: 2, }, ] ``` would insert dependencies for calls of `useEffect` imported from `react` if they have 1 argument and calls of useExperimentalEffect` from `MyExperimentalEffectHooks` if they have 2 arguments. The pushed dep array is appended to the arg list. DiffTrain build for [2a9f4c0](facebook@2a9f4c0)
Adds a way to configure how we insert deps for experimental purposes. ``` [ { module: 'react', imported: 'useEffect', numRequiredArgs: 1, }, { module: 'MyExperimentalEffectHooks', imported: 'useExperimentalEffect', numRequiredArgs: 2, }, ] ``` would insert dependencies for calls of `useEffect` imported from `react` if they have 1 argument and calls of useExperimentalEffect` from `MyExperimentalEffectHooks` if they have 2 arguments. The pushed dep array is appended to the arg list. DiffTrain build for [2a9f4c0](facebook@2a9f4c0)
Adds a way to configure how we insert deps for experimental purposes.
would insert dependencies for calls of
useEffect
imported fromreact
if they have 1 argument and calls of useExperimentalEffectfrom
MyExperimentalEffectHooks` if they have 2 arguments. The pushed dep array is appended to the arg list.