-
Notifications
You must be signed in to change notification settings - Fork 171
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
Support scoped variables for the parameter of an inline component. #4919
Merged
seanparsons
merged 4 commits into
master
from
feature/scoped-variables-inline-component
Feb 20, 2024
Merged
Support scoped variables for the parameter of an inline component. #4919
seanparsons
merged 4 commits into
master
from
feature/scoped-variables-inline-component
Feb 20, 2024
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
…ne component. - The result of `propertiesExposedByParams` is passed to `createLookupRender` in most of the call sites so that the parameters are supplied to the elements within arbitrary expressions. - Added `params` field to `JSExpressionOtherJavaScript` and `ArbitraryJSBlock`. - Added `propertiesExposedByParams` utility function. - Moved `parseParam`, `parseParams` and `parseBindingName` to `parser-printer-parsing.ts` so they can be called from the logic there as well. - `parseOtherJavaScript` now takes a `params` parameter to the `create` parameter. - `parseOtherJavaScript` parses out the params of single functions arbitrary blocks.
seanparsons
requested review from
gbalint,
Rheeseyb,
ruggi,
balazsbajorics,
liady and
bkrmendy
February 16, 2024 18:11
Job #10491: Bundle Size — 62.17MiB (~+0.01%).
Warning Bundle contains 58 duplicate packages – View duplicate packages Bundle metrics
Bundle size by type
View job #10491 report View feature/scoped-variables-inline-... branch activity View project dashboard |
Rheeseyb
approved these changes
Feb 20, 2024
balazsbajorics
approved these changes
Feb 20, 2024
liady
approved these changes
Feb 20, 2024
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.
Problem:
In the case where an inline component is used, for example:
The parameters to that function (in the above case
something
) aren't made available in the scoped variables for the body of the function.Fix:
Now we include the same parameter representation that is used in
UtopiaJSXComponent
in arbitrary blocks and expressions. During the canvas render, those values are additionally included when building the scoped variables by supplying them to thecreateLookupRender
function.In the process of doing this work, it was discovered that we were losing the destructured parameters from code when performing the Babel transformation. When attempting to parse the destructured parameters in the Babel AST this was the code that the transformer function would have access to:
This was due to the
es2015
Babel preset applying before any of the plugins run (which is where our code lives), which amongst other things includes a plugin that transforms any object destructuring. Even though the ES2015 standard itself includes support for native object destructuring. The fix for this was to switch the preset toes2016
and then fix all the tests as that change resulted in the transpiled JavaScript values to be more representative of the original JavaScript.Commit Details:
propertiesExposedByParams
is passed tocreateLookupRender
in most of the call sites so that the parameters are supplied to the elements within arbitrary expressions.params
field toJSExpressionOtherJavaScript
andArbitraryJSBlock
.propertiesExposedByParams
utility function.parseParam
,parseParams
andparseBindingName
toparser-printer-parsing.ts
so they can be called from the logic there as well.parseOtherJavaScript
now takes aparams
parameter to thecreate
parameter.parseOtherJavaScript
parses out the params of single functions arbitrary blocks.es2015
toes2016
.