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

fix(babel-plugin-component): correct class member decorator validation #1122

Merged
merged 4 commits into from
Mar 20, 2019

Conversation

apapko
Copy link
Collaborator

@apapko apapko commented Mar 20, 2019

Details

Fixes #1113 - improve decorator validation logic.

Does this PR introduce a breaking change?

  • Yes
  • No

@apapko apapko requested a review from pmdartus March 20, 2019 01:03
@apapko apapko changed the title Apapko/decorator validation fix(babel-plugin-component): correct class member decorator validation Mar 20, 2019
@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 1f12803 | Target commit: 4e8b083

lwc-engine-benchmark

table-append-1k metric base(1f12803) target(4e8b083) trend
benchmark-table/append/1k duration 151.55 (±6.15 ms) 149.80 (±5.70 ms) -1.8ms (1.2%) 👌
table-clear-1k metric base(1f12803) target(4e8b083) trend
benchmark-table/clear/1k duration 10.35 (±0.75 ms) 10.30 (±0.50 ms) -0.1ms (0.5%) 👌
table-create-10k metric base(1f12803) target(4e8b083) trend
benchmark-table/create/10k duration 877.20 (±6.25 ms) 882.45 (±12.10 ms) +5.3ms (0.6%) 👎
table-create-1k metric base(1f12803) target(4e8b083) trend
benchmark-table/create/1k duration 116.65 (±2.15 ms) 117.85 (±2.90 ms) +1.2ms (1.0%) 👌
table-update-10th-1k metric base(1f12803) target(4e8b083) trend
benchmark-table/update-10th/1k duration 73.30 (±2.40 ms) 73.90 (±2.25 ms) +0.6ms (0.8%) 👌
tablecmp-append-1k metric base(1f12803) target(4e8b083) trend
benchmark-table-component/append/1k duration 222.05 (±8.85 ms) 220.90 (±10.80 ms) -1.2ms (0.5%) 👌
tablecmp-clear-1k metric base(1f12803) target(4e8b083) trend
benchmark-table-component/clear/1k duration 5.80 (±0.90 ms) 5.90 (±1.00 ms) +0.1ms (1.7%) 👌
tablecmp-create-10k metric base(1f12803) target(4e8b083) trend
benchmark-table-component/create/10k duration 1749.25 (±9.60 ms) 1756.65 (±9.85 ms) +7.4ms (0.4%) 👎
tablecmp-create-1k metric base(1f12803) target(4e8b083) trend
benchmark-table-component/create/1k duration 211.20 (±4.45 ms) 207.25 (±5.10 ms) -3.9ms (1.9%) 👌
tablecmp-update-10th-1k metric base(1f12803) target(4e8b083) trend
benchmark-table-component/update-10th/1k duration 66.45 (±4.70 ms) 67.05 (±5.00 ms) +0.6ms (0.9%) 👌
wc-append-1k metric base(1f12803) target(4e8b083) trend
benchmark-table-wc/append/1k duration 237.00 (±16.00 ms) 236.05 (±15.10 ms) -0.9ms (0.4%) 👌
wc-clear-1k metric base(1f12803) target(4e8b083) trend
benchmark-table-wc/clear/1k duration 10.45 (±1.80 ms) 10.35 (±1.50 ms) -0.1ms (1.0%) 👌
wc-create-10k metric base(1f12803) target(4e8b083) trend
benchmark-table-wc/create/10k duration 1866.80 (±15.85 ms) 1883.75 (±14.40 ms) +17.0ms (0.9%) 👎
wc-create-1k metric base(1f12803) target(4e8b083) trend
benchmark-table-wc/create/1k duration 224.50 (±6.95 ms) 220.65 (±6.05 ms) -3.8ms (1.7%) 👌
wc-update-10th-1k metric base(1f12803) target(4e8b083) trend
benchmark-table-wc/update-10th/1k duration 70.90 (±5.65 ms) 68.95 (±5.95 ms) -2.0ms (2.8%) 👌

Copy link
Member

@pmdartus pmdartus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for the trailing console.log, LGTM

@@ -145,6 +149,7 @@ module.exports = function validate(klass, decorators) {
}
});

//console.log('---> decorators: ', decorators);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//console.log('---> decorators: ', decorators);

const parentPath = path.parentPath;
const name = parentPath.get('key.name').node;

const associatedGetter = decorators.find(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain how this find operation was picking up class methods that were not decorated with @api?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was not. The filter logic resulted in a list of @api decorated setters and the find function was only looking at @api decorated getters. The issue was that we weren't cross referencing setter method name with the getter method name ( line 94 didn't check the current getter method name ).

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 1f12803 | Target commit: ca7f7b7

lwc-engine-benchmark

table-append-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table/append/1k duration 151.55 (±6.15 ms) 150.35 (±5.45 ms) -1.2ms (0.8%) 👌
table-clear-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table/clear/1k duration 10.35 (±0.75 ms) 10.60 (±0.50 ms) +0.2ms (2.4%) 👌
table-create-10k metric base(1f12803) target(ca7f7b7) trend
benchmark-table/create/10k duration 877.20 (±6.25 ms) 876.75 (±6.10 ms) -0.5ms (0.1%) 👌
table-create-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table/create/1k duration 116.65 (±2.15 ms) 118.45 (±2.10 ms) +1.8ms (1.5%) 👌
table-update-10th-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table/update-10th/1k duration 73.30 (±2.40 ms) 73.05 (±1.45 ms) -0.3ms (0.3%) 👌
tablecmp-append-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table-component/append/1k duration 222.05 (±8.85 ms) 223.85 (±9.30 ms) +1.8ms (0.8%) 👌
tablecmp-clear-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table-component/clear/1k duration 5.80 (±0.90 ms) 5.85 (±1.05 ms) +0.0ms (0.9%) 👌
tablecmp-create-10k metric base(1f12803) target(ca7f7b7) trend
benchmark-table-component/create/10k duration 1749.25 (±9.60 ms) 1745.65 (±12.15 ms) -3.6ms (0.2%) 👍
tablecmp-create-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table-component/create/1k duration 211.20 (±4.45 ms) 210.10 (±5.85 ms) -1.1ms (0.5%) 👌
tablecmp-update-10th-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table-component/update-10th/1k duration 66.45 (±4.70 ms) 65.60 (±4.05 ms) -0.9ms (1.3%) 👌
wc-append-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table-wc/append/1k duration 237.00 (±16.00 ms) 230.65 (±13.55 ms) -6.4ms (2.7%) 👌
wc-clear-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table-wc/clear/1k duration 10.45 (±1.80 ms) 10.95 (±1.25 ms) +0.5ms (4.8%) 👌
wc-create-10k metric base(1f12803) target(ca7f7b7) trend
benchmark-table-wc/create/10k duration 1866.80 (±15.85 ms) 1851.60 (±16.25 ms) -15.2ms (0.8%) 👍
wc-create-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table-wc/create/1k duration 224.50 (±6.95 ms) 219.15 (±6.40 ms) -5.3ms (2.4%) 👍
wc-update-10th-1k metric base(1f12803) target(ca7f7b7) trend
benchmark-table-wc/update-10th/1k duration 70.90 (±5.65 ms) 67.60 (±5.05 ms) -3.3ms (4.7%) 👍

@apapko apapko merged commit 22ec3d5 into master Mar 20, 2019
@apapko apapko deleted the apapko/decorator-validation branch March 20, 2019 15:58
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.

3 participants