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

chore: simplify style dedupe config #5271

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
18 changes: 11 additions & 7 deletions packages/@lwc/ssr-runtime/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,26 @@ interface ComponentWithGenerateMarkup extends LightningElementConstructor {

export class RenderContext {
styleDedupeIsEnabled: boolean;
stylesheetToId = new WeakMap<Stylesheet, string>();
styleDedupePrefix: string;
stylesheetToId = new WeakMap<Stylesheet, string>();
nextId = 0;

constructor(styleDedupePrefix: string, styleDedupeIsEnabled: boolean) {
this.styleDedupeIsEnabled = styleDedupeIsEnabled;
this.styleDedupePrefix = styleDedupePrefix;
constructor(styleDedupe: string | boolean) {
if (styleDedupe || styleDedupe === '') {
this.styleDedupePrefix = styleDedupe && '';
this.styleDedupeIsEnabled = true;
} else {
this.styleDedupePrefix = '';
this.styleDedupeIsEnabled = false;
}
}
}

export async function serverSideRenderComponent(
tagName: string,
Component: ComponentWithGenerateMarkup,
props: Properties = {},
styleDedupePrefix = '',
styleDedupeIsEnabled = false,
styleDedupe: string | boolean = '',
mode: CompilationMode = DEFAULT_SSR_MODE
): Promise<string> {
if (typeof tagName !== 'string') {
Expand All @@ -222,7 +226,7 @@ export async function serverSideRenderComponent(
markup += segment;
};

emit.cxt = new RenderContext(styleDedupePrefix, styleDedupeIsEnabled);
emit.cxt = new RenderContext(styleDedupe);

if (!generateMarkup) {
// If a non-component is accidentally provided, render an empty template
Expand Down
Loading