Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<x-cmp>
<template shadowrootmode="open">
<h1>
hello
</h1>
</template>
</x-cmp>
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';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<h1>hello</h1>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { LightningElement } from 'lwc';

const privateFields = undefined;
const publicFields = undefined;
const stylesheetScopeToken = undefined;
const hasScopedStylesheets = undefined;
const defaultScopedStylesheets = undefined;

export default class extends LightningElement {
connectedCallback() {
// just use the variables to avoid them being tree-shaken
Object.assign(
{},
{
privateFields,
publicFields,
stylesheetScopeToken,
hasScopedStylesheets,
defaultScopedStylesheets,
}
);
}
}
12 changes: 9 additions & 3 deletions packages/@lwc/ssr-compiler/src/compile-js/generate-markup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import type { Program, Statement, IfStatement } from 'estree';
import type { ComponentMetaState } from './types';

const bGenerateMarkup = esTemplate`
const publicFields = new Set(${/*public fields*/ is.arrayExpression});
const privateFields = new Set(${/*private fields*/ is.arrayExpression});
// These variables may mix with component-authored variables, so should be reasonably unique
const __lwcPublicFields__ = new Set(${/*public fields*/ is.arrayExpression});
const __lwcPrivateFields__ = new Set(${/*private fields*/ is.arrayExpression});

async function* generateMarkup(
tagName,
Expand All @@ -38,7 +39,12 @@ const bGenerateMarkup = esTemplate`
__establishContextfulRelationship(contextfulParent, instance);
${/*connect wire*/ is.statement}

instance[__SYMBOL__SET_INTERNALS](props, attrs, publicFields, privateFields);
instance[__SYMBOL__SET_INTERNALS](
props,
attrs,
__lwcPublicFields__,
__lwcPrivateFields__,
);
instance.isConnected = true;
if (instance.connectedCallback) {
__mutationTracker.enable(instance);
Expand Down