Skip to content

Commit 6283e34

Browse files
wjhsfnolanlawsonjhefferman-sfdc
authored
feat(ssr): enable @wire on getters/setters (#4986)
* fix(ssr): adjacent text in `<template>`s Co-Authored-By: Will Harney <62956339+wjhsf@users.noreply.github.com> Co-Authored-By: John Hefferman <jhefferman@salesforce.com> * test: fix expected failures * test(snapshots): add helpfuler message when error/expected swap * fix(ssr): support @wire-decorated getters/setters * chore: add test for edge case * test(ssr): add test for differently-wired getter/setter * Update packages/@lwc/ssr-compiler/src/compile-js/index.ts Co-authored-by: Nolan Lawson <nlawson@salesforce.com> * fix(ssr): use structured clone when converting wired getter to prop * test: add tests * chore: add comment --------- Co-authored-by: Nolan Lawson <nlawson@salesforce.com> Co-authored-by: John Hefferman <jhefferman@salesforce.com>
1 parent 71b929e commit 6283e34

File tree

32 files changed

+236
-10
lines changed

32 files changed

+236
-10
lines changed

packages/@lwc/engine-server/src/__tests__/fixtures/wire/collision/get-set/error.txt

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<x-wire>
2+
<template shadowrootmode="open">
3+
<div>
4+
Wired? set
5+
</div>
6+
</template>
7+
</x-wire>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const tagName = 'x-wire';
2+
export { default } from 'x/wire';
3+
export * from 'x/wire';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export class Adapter {
2+
constructor(dataCallback) {
3+
this.callback = dataCallback;
4+
}
5+
6+
connect() {}
7+
8+
update(cfg) {
9+
this.callback(cfg.value);
10+
}
11+
12+
disconnect() {}
13+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<div>Wired? {wired}</div>
3+
</template>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { wire, LightningElement } from 'lwc';
2+
import { Adapter } from 'x/adapter';
3+
export default class Test extends LightningElement {
4+
@wire(Adapter, { value: 'get' })
5+
get wired() {
6+
throw new Error('get wired!');
7+
}
8+
9+
@wire(Adapter, { value: 'set' })
10+
set wired(val) {
11+
throw new Error('set wired!');
12+
}
13+
}

packages/@lwc/engine-server/src/__tests__/fixtures/wire/collision/method-prop/error.txt

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<x-wire>
2+
<template shadowrootmode="open">
3+
propAndMethod
4+
</template>
5+
</x-wire>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const tagName = 'x-wire';
2+
export { default } from 'x/wire';
3+
export * from 'x/wire';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export class adapter {
2+
constructor(dataCallback) {
3+
this.dc = dataCallback;
4+
}
5+
6+
connect() {}
7+
8+
update(config) {
9+
this.dc(config.name);
10+
}
11+
12+
disconnect() {}
13+
}

0 commit comments

Comments
 (0)