Skip to content
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

Scoped variables show destructured parameters. #4882

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

seanparsons
Copy link
Contributor

Problem:
With code like the following in a component:

export function App({ style: { background } }) {

The destructured values aren't made available into the scoped variables menu.

Fix:
The main fixes needed for this to work were the following:

  • createComponentRendererComponent now uses propertiesExposedByParam to identify the properties that are brought into scope from the destructuring, which are added to the dictionary of scoped variables.
  • As a result of the above work, it was observed that applyPropsParamToPassedProps wasn't properly handled destructured fields that are renamed.

In the process of doing the above work I noticed that getVariablesInScope was looking for the first component it could find, not the targeted component. To perform the lookup findContainingComponent was implemented.

Commit Details:

  • Added propertiesExposedByParam utility function.
  • Added findContainingComponent utility function.
  • getVariablesInScope now finds the correct component and not just the first one.
  • Fixed applyPropsParamToPassedProps to correctly handle destructured values and repeated field usages.
  • createComponentRendererComponent includes values exposed by the props param when building spiedVariablesInScope.

- Added `propertiesExposedByParam` utility function.
- Added `findContainingComponent` utility function.
- `getVariablesInScope` now finds the correct component and not just the first one.
- Fixed `applyPropsParamToPassedProps` to correctly handle destructured values
  and repeated field usages.
- `createComponentRendererComponent` includes values exposed by the props param
  when building `spiedVariablesInScope`.
Copy link
Contributor

github-actions bot commented Feb 12, 2024

Try me

Copy link

relativeci bot commented Feb 12, 2024

Job #10393: Bundle Size — 61.74MiB (~+0.01%).

dcab6d0(current) vs d299c8d master#10389(baseline)

Warning

Bundle contains 57 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
Job #10393
     Baseline
Job #10389
Regression  Initial JS 34.78MiB(+0.01%) 34.78MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 22.05% 20.45%
No change  Chunks 28 28
No change  Assets 32 32
No change  Modules 4294 4294
No change  Duplicate Modules 493 493
No change  Duplicate Code 31.01% 31.01%
No change  Packages 455 455
No change  Duplicate Packages 57 57
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
Job #10393
     Baseline
Job #10389
Regression  JS 61.72MiB (~+0.01%) 61.72MiB
Improvement  HTML 11.37KiB (-0.32%) 11.41KiB

View job #10393 reportView feature/scoped-nested-parameters branch activityView project dashboard

Copy link
Contributor

github-actions bot commented Feb 12, 2024

Performance test results:
Highlight Regular (2%)

Highlight All Elements (-2%)

Selection (-1%)

De-Selection (1%)

Selection Change (6%)
Before: 61.6ms (54.3-72.7ms)
After: 65.6ms (57.2-85.3ms)

Scroll Canvas (20%)
Before: 3ms (2.4-9.2ms)
After: 3.6ms (2.8-8.8ms)

(Chart1)
(Chart2)

@seanparsons seanparsons merged commit 0d843a1 into master Feb 13, 2024
5 checks passed
@seanparsons seanparsons deleted the feature/scoped-nested-parameters branch February 13, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants