-
Notifications
You must be signed in to change notification settings - Fork 394
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(ssr): enable @wire
on getters/setters
#4986
Conversation
Co-Authored-By: Will Harney <[email protected]> Co-Authored-By: John Hefferman <[email protected]>
@wire
on getters/setters
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.
Some minor quibbles but looks good overall
packages/@lwc/engine-server/src/__tests__/fixtures/wire/get-set/modules/x/wire/wire.js
Show resolved
Hide resolved
export default class Wire extends LightningElement { | ||
@wire(adapter, { name: 'getterOnly' }) | ||
get getterOnly() { | ||
throw new Error('get getterOnly should not be called'); |
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.
This component would be a good test case for integration-karma
as well. engine-dom
presumably works the same way.
node.static | ||
); | ||
methodAsProp.decorators = decorators; | ||
path.replaceWith(methodAsProp); |
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.
Two things:
- We should clone the
node.key
andnode.decorators
for safety (or useimmer
). - This is a bit janky because, in the case of e.g.
getterWithSetter
, it replaces the getter but not the setter. So you end up with:
getterWithSetter;
set getterWithSetter(v) {
throw new Error("set getterWithSetter should not be called");
}
...when we could just have getterWithSetter;
alone.
Unfortunately solving this could require backtracing to find the corresponding setter/getter (since the @wire
may be declared on the second one). Maybe we could use an enter
/leave
function, or do a pre-traversal traverse
that merely notes with method declarations are @wire
-decorated.
); | ||
methodAsProp.decorators = decorators; | ||
path.replaceWith(methodAsProp); | ||
return; |
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.
It looks like we're missing a catalogWireAdapters()
here. Presumably a test would fail if we needed to validate the wire ID/config?
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.
We don't need to catalog getter/setters, because they're not going to exist. The cataloging gets done by the PropertyDefinition
visitor when we visit the newly-created node.
Fixes #4828. |
Co-authored-by: Nolan Lawson <[email protected]>
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.
Details
Copying the behavior of
engine-server
, the implementations of the getters/setters are ignored and they're treated just as props.Does this pull request introduce a breaking change?
Does this pull request introduce an observable change?
GUS work item