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

feat(compiler): More tooling metadata #132

Merged
merged 1 commit into from
Mar 5, 2018
Merged

Conversation

rsalvador
Copy link
Contributor

Details

For tooling we need metadata location/doc info for all class properties and methods

Does this PR introduce a breaking change?

  • Yes
  • [x ] No

If yes, please describe the impact and migration path for existing applications:
Please check if your PR fulfills the following requirements:

Reminders ( please delete this section before submitting )


The PR fulfills these requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Title

LWC PR title follows conventional commit format and is automatically validated by our CI.

ex:
commit-type(optional scope): commit description. ( NOTE: space between column and the message )

Types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test, proposal.
Scope: The scope should be the name of the npm package affected (engine, compiler, wire-service, etc.)

@salesforce-best-lwc-internal
Copy link

Benchmark comparison

Base commit: af244cc | Target commit: 530e229

benchmark base(af244cc) target(530e229) trend
table-append-1k.benchmark:benchmark-table/append/1k 275.69 (± 4.36 ms) 277.44 (± 5.44 ms) 👌
table-clear-1k.benchmark:benchmark-table/clear/1k 14.71 (± 0.75 ms) 14.14 (± 0.53 ms) 👍
table-create-10k.benchmark:benchmark-table/create/10k 1525.13 (± 18.67 ms) 1560.03 (± 32.03 ms) 👎
table-create-1k.benchmark:benchmark-table/create/1k 167.31 (± 2.50 ms) 173.06 (± 6.69 ms) 👎
table-update-10th-1k.benchmark:benchmark-table/update-10th/1k 148.87 (± 3.23 ms) 151.34 (± 4.43 ms) 👌
tablecmp-append-1k.benchmark:benchmark-table-component/append/1k 351.15 (± 8.73 ms) 346.75 (± 10.35 ms) 👌
tablecmp-clear-1k.benchmark:benchmark-table/clear/1k 32.44 (± 1.46 ms) 34.04 (± 1.34 ms) 👎
tablecmp-create-10k.benchmark:benchmark-table-component/create/10k 2389.68 (± 23.45 ms) 2433.53 (± 34.63 ms) 👎
tablecmp-create-1k.benchmark:benchmark-table-component/create/1k 267.40 (± 5.39 ms) 264.80 (± 5.21 ms) 👌
tablecmp-update-10th-1k.benchmark:benchmark-table-component/update-10th/1k 142.52 (± 2.66 ms) 143.88 (± 3.99 ms) 👌

@rsalvador rsalvador force-pushed the rsalvador/metadata branch from 530e229 to acd72a2 Compare March 2, 2018 00:45
@salesforce-best-lwc-internal
Copy link

Benchmark comparison

Base commit: af244cc | Target commit: acd72a2

benchmark base(af244cc) target(acd72a2) trend
table-append-1k.benchmark:benchmark-table/append/1k 275.69 (± 4.36 ms) 268.80 (± 3.96 ms) 👍
table-clear-1k.benchmark:benchmark-table/clear/1k 14.71 (± 0.75 ms) 13.65 (± 0.55 ms) 👍
table-create-10k.benchmark:benchmark-table/create/10k 1525.13 (± 18.67 ms) 1572.50 (± 31.94 ms) 👎
table-create-1k.benchmark:benchmark-table/create/1k 167.31 (± 2.50 ms) 173.21 (± 7.35 ms) 👎
table-update-10th-1k.benchmark:benchmark-table/update-10th/1k 148.87 (± 3.23 ms) 151.18 (± 6.23 ms) 👌
tablecmp-append-1k.benchmark:benchmark-table-component/append/1k 351.15 (± 8.73 ms) 346.24 (± 9.24 ms) 👌
tablecmp-clear-1k.benchmark:benchmark-table/clear/1k 32.44 (± 1.46 ms) 35.80 (± 1.73 ms) 👎
tablecmp-create-10k.benchmark:benchmark-table-component/create/10k 2389.68 (± 23.45 ms) 2494.03 (± 24.80 ms) 👎
tablecmp-create-1k.benchmark:benchmark-table-component/create/1k 267.40 (± 5.39 ms) 266.92 (± 6.76 ms) 👌
tablecmp-update-10th-1k.benchmark:benchmark-table-component/update-10th/1k 142.52 (± 2.66 ms) 140.19 (± 5.31 ms) 👌

Copy link

@esalman-sfdc esalman-sfdc left a comment

Choose a reason for hiding this comment

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

Looking good overall. Have a question for Vince.

{
output: {
metadata: {
decorators: [

Choose a reason for hiding this comment

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

classMembers section now seems to be the superSet of what 'decorator' section provided. @yungcheng do you think we should just delete the 'decorators' section and have consumers derive whatever they need from classMembers section or do you think that its needed to reduce processing overhead on consumer end? I understand that you'll need to move some of the extra metadata collected for @wire over for this but it may be good for consolidation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to have it separated because compiler already visited all decorators, why would we want consumers to do the similar thing again on class members? Also the usage is quite different, class member provides general information for intellisense, decorators are used for dependencies. However if we end up tightening things up with platform compiler and have all information in class member, then I am okay with deleting decorators since you would need to process class member on the server.

return {
Class(path, state) {
if (isComponentClass(path, state.componentBaseClassImports)) {
if (isDefaultExport(path)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

combine both check maybe?


state.file.metadata.classMembers = [];
const classBody = path.get('body');
classBody.get('body').forEach(path => {
Copy link
Contributor

Choose a reason for hiding this comment

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

classBody = path.get('body').get('body') maybe? seems to make more sense

@rsalvador rsalvador force-pushed the rsalvador/metadata branch from acd72a2 to 2f06bed Compare March 2, 2018 04:16
@salesforce-best-lwc-internal
Copy link

Benchmark comparison

Base commit: af244cc | Target commit: 2f06bed

benchmark base(af244cc) target(2f06bed) trend
table-append-1k.benchmark:benchmark-table/append/1k 275.69 (± 4.36 ms) 283.05 (± 12.38 ms) 👌
table-clear-1k.benchmark:benchmark-table/clear/1k 14.71 (± 0.75 ms) 13.52 (± 0.49 ms) 👍
table-create-10k.benchmark:benchmark-table/create/10k 1525.13 (± 18.67 ms) 1624.27 (± 56.81 ms) 👎
table-create-1k.benchmark:benchmark-table/create/1k 167.31 (± 2.50 ms) 165.29 (± 3.82 ms) 👌
table-update-10th-1k.benchmark:benchmark-table/update-10th/1k 148.87 (± 3.23 ms) 154.61 (± 11.35 ms) 👌
tablecmp-append-1k.benchmark:benchmark-table-component/append/1k 351.15 (± 8.73 ms) 350.70 (± 15.76 ms) 👌
tablecmp-clear-1k.benchmark:benchmark-table/clear/1k 32.44 (± 1.46 ms) 37.84 (± 3.78 ms) 👎
tablecmp-create-10k.benchmark:benchmark-table-component/create/10k 2389.68 (± 23.45 ms) 2539.13 (± 85.01 ms) 👎
tablecmp-create-1k.benchmark:benchmark-table-component/create/1k 267.40 (± 5.39 ms) 256.30 (± 5.72 ms) 👍
tablecmp-update-10th-1k.benchmark:benchmark-table-component/update-10th/1k 142.52 (± 2.66 ms) 148.57 (± 5.27 ms) 👎

@diervo
Copy link
Contributor

diervo commented Mar 2, 2018

I was debating with @pmdartus and maybe we want to move all of the metadata gathering to the Platform compiler instead?

We don't have to do it in 214, but as we add more metadata (and the shape will likely change) we are not sure where things will live... Food for tought.

@diervo diervo closed this Mar 2, 2018
@diervo diervo reopened this Mar 2, 2018
@rsalvador
Copy link
Contributor Author

We’ll need that metadata for the public vscode extension.

removeDecorators(decorators);
removeImportSpecifiers(decoratorImportSpecifiers);
Class(path, state) {
// don't remove decorators until metadata.js had the chance to visit the Class node
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eventually it would be good to split the compiler into 2 separate phases:

  1. validation + metadata collection
  2. AST transformation

@rsalvador rsalvador force-pushed the rsalvador/metadata branch from 2f06bed to 6927956 Compare March 5, 2018 16:12
@salesforce-best-lwc-internal
Copy link

Benchmark comparison

Base commit: dd91b7c | Target commit: 6927956

benchmark base(dd91b7c) target(6927956) trend
table-append-1k.benchmark:benchmark-table/append/1k 268.77 (± 3.13 ms) 280.70 (± 5.69 ms) 👎
table-clear-1k.benchmark:benchmark-table/clear/1k 13.44 (± 0.70 ms) 14.29 (± 0.74 ms) 👎
table-create-10k.benchmark:benchmark-table/create/10k 1503.42 (± 8.20 ms) 1523.52 (± 26.29 ms) 👎
table-create-1k.benchmark:benchmark-table/create/1k 161.71 (± 1.31 ms) 167.11 (± 2.27 ms) 👎
table-update-10th-1k.benchmark:benchmark-table/update-10th/1k 143.82 (± 3.80 ms) 147.19 (± 1.57 ms) 👎
tablecmp-append-1k.benchmark:benchmark-table-component/append/1k 342.19 (± 6.60 ms) 351.12 (± 11.60 ms) 👎
tablecmp-clear-1k.benchmark:benchmark-table/clear/1k 32.80 (± 1.28 ms) 34.78 (± 1.20 ms) 👎
tablecmp-create-10k.benchmark:benchmark-table-component/create/10k 2336.80 (± 31.41 ms) 2415.25 (± 30.14 ms) 👎
tablecmp-create-1k.benchmark:benchmark-table-component/create/1k 259.65 (± 2.80 ms) 286.37 (± 9.35 ms) 👎
tablecmp-update-10th-1k.benchmark:benchmark-table-component/update-10th/1k 140.01 (± 2.72 ms) 147.26 (± 4.38 ms) 👎

@rsalvador rsalvador merged commit 0514227 into master Mar 5, 2018
@rsalvador rsalvador deleted the rsalvador/metadata branch March 5, 2018 16:23
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