-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ssr): only default-exported classes are LWC components @W-1731235…
…8@ (#4942) * fix(ssr): only default-exported classes are LWC components @W-17312358@ fixes #4398 * test(ssr): add fixture for `export default Component` * test(ssr): add test for component-like-but-not scenarios * test(ssr): use non-empty template to prove it works * test(ssr): test `export { Component as default }` * test(ssr): add more tests for exports * chore: ignore failing test
- Loading branch information
Showing
30 changed files
with
117 additions
and
10 deletions.
There are no files selected for viewing
Empty file.
4 changes: 4 additions & 0 deletions
4
...ages/@lwc/engine-server/src/__tests__/fixtures/exports/component-as-default/expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<x-cmp> | ||
<template shadowrootmode="open"> | ||
</template> | ||
</x-cmp> |
3 changes: 3 additions & 0 deletions
3
packages/@lwc/engine-server/src/__tests__/fixtures/exports/component-as-default/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const tagName = 'x-cmp'; | ||
export { default } from 'x/cmp'; | ||
export * from 'x/cmp'; |
3 changes: 3 additions & 0 deletions
3
.../engine-server/src/__tests__/fixtures/exports/component-as-default/modules/x/cmp/cmp.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
This template isn't actually used because `export {Component as default}` isn't recognized as an LWC component. | ||
</template> |
4 changes: 4 additions & 0 deletions
4
...wc/engine-server/src/__tests__/fixtures/exports/component-as-default/modules/x/cmp/cmp.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
class Component extends LightningElement {} | ||
export {Component as default} |
Empty file.
5 changes: 5 additions & 0 deletions
5
packages/@lwc/engine-server/src/__tests__/fixtures/exports/default-class-named/expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<x-cmp> | ||
<template shadowrootmode="open"> | ||
As the children proclaim, you only live once! | ||
</template> | ||
</x-cmp> |
3 changes: 3 additions & 0 deletions
3
packages/@lwc/engine-server/src/__tests__/fixtures/exports/default-class-named/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const tagName = 'x-cmp'; | ||
export { default } from 'x/cmp'; | ||
export * from 'x/cmp'; |
3 changes: 3 additions & 0 deletions
3
...c/engine-server/src/__tests__/fixtures/exports/default-class-named/modules/x/cmp/cmp.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
As the children proclaim, you only live once! | ||
</template> |
3 changes: 3 additions & 0 deletions
3
...lwc/engine-server/src/__tests__/fixtures/exports/default-class-named/modules/x/cmp/cmp.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Component extends LightningElement {} |
Empty file.
5 changes: 5 additions & 0 deletions
5
...ges/@lwc/engine-server/src/__tests__/fixtures/exports/default-class-unnamed/expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<x-cmp> | ||
<template shadowrootmode="open"> | ||
As the children proclaim, you only live once! | ||
</template> | ||
</x-cmp> |
3 changes: 3 additions & 0 deletions
3
packages/@lwc/engine-server/src/__tests__/fixtures/exports/default-class-unnamed/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const tagName = 'x-cmp'; | ||
export { default } from 'x/cmp'; | ||
export * from 'x/cmp'; |
3 changes: 3 additions & 0 deletions
3
...engine-server/src/__tests__/fixtures/exports/default-class-unnamed/modules/x/cmp/cmp.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
As the children proclaim, you only live once! | ||
</template> |
3 changes: 3 additions & 0 deletions
3
...c/engine-server/src/__tests__/fixtures/exports/default-class-unnamed/modules/x/cmp/cmp.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class extends LightningElement {} |
Empty file.
5 changes: 5 additions & 0 deletions
5
packages/@lwc/engine-server/src/__tests__/fixtures/exports/default-identifier/expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<x-cmp> | ||
<template shadowrootmode="open"> | ||
As the children proclaim, you only live once! | ||
</template> | ||
</x-cmp> |
3 changes: 3 additions & 0 deletions
3
packages/@lwc/engine-server/src/__tests__/fixtures/exports/default-identifier/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const tagName = 'x-cmp'; | ||
export { default } from 'x/cmp'; | ||
export * from 'x/cmp'; |
3 changes: 3 additions & 0 deletions
3
...wc/engine-server/src/__tests__/fixtures/exports/default-identifier/modules/x/cmp/cmp.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
As the children proclaim, you only live once! | ||
</template> |
4 changes: 4 additions & 0 deletions
4
...@lwc/engine-server/src/__tests__/fixtures/exports/default-identifier/modules/x/cmp/cmp.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
class Component extends LightningElement {} | ||
export default Component; |
Empty file.
5 changes: 5 additions & 0 deletions
5
packages/@lwc/engine-server/src/__tests__/fixtures/superclass/not-superclass/expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<x-component data-lwc-host-mutated="data-yolo" data-yolo> | ||
<template shadowrootmode="open"> | ||
yay ook ook ook | ||
</template> | ||
</x-component> |
3 changes: 3 additions & 0 deletions
3
packages/@lwc/engine-server/src/__tests__/fixtures/superclass/not-superclass/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const tagName = 'x-component'; | ||
export { default } from 'x/component'; | ||
export * from 'x/component'; |
3 changes: 3 additions & 0 deletions
3
...erver/src/__tests__/fixtures/superclass/not-superclass/modules/x/component/component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
{something} {data} | ||
</template> |
9 changes: 9 additions & 0 deletions
9
...-server/src/__tests__/fixtures/superclass/not-superclass/modules/x/component/component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { LightningElement } from 'lwc' | ||
import { FancyMixin } from 'x/mixinSuperclass' | ||
import { NotDefault } from 'x/notLwcClass' | ||
import Superless from 'x/superless' | ||
|
||
export default class extends FancyMixin(LightningElement) { | ||
something = new NotDefault().prop | ||
data = new Superless().method() | ||
} |
7 changes: 7 additions & 0 deletions
7
...__tests__/fixtures/superclass/not-superclass/modules/x/mixinSuperclass/mixinSuperclass.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const FancyMixin = Class => { | ||
return class extends Class { | ||
connectedCallback() { | ||
this.setAttribute('data-yolo', '') | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...ver/src/__tests__/fixtures/superclass/not-superclass/modules/x/notLwcClass/notLwcClass.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class NotLightningElement {} | ||
export class NotDefault extends NotLightningElement { | ||
prop = 'yay' | ||
} |
11 changes: 11 additions & 0 deletions
11
...-server/src/__tests__/fixtures/superclass/not-superclass/modules/x/superless/superless.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Base {} | ||
|
||
class NotExported extends Base { | ||
static value = 'ook ook ook' | ||
} | ||
|
||
export default class { | ||
method() { | ||
return NotExported.value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters