@lwc/ssr-compiler 8.12.7 → 8.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compile-js/index.d.ts +1 -1
- package/dist/index.cjs.js +66 -35
- package/dist/index.js +67 -36
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type CompilationMode } from '@lwc/shared';
|
|
1
2
|
import type { ComponentTransformOptions } from '../shared';
|
|
2
|
-
import type { CompilationMode } from '@lwc/shared';
|
|
3
3
|
export default function compileJS(src: string, filename: string, tagName: string, options: ComponentTransformOptions, compilationMode: CompilationMode): {
|
|
4
4
|
code: string;
|
|
5
5
|
};
|
package/dist/index.cjs.js
CHANGED
|
@@ -738,8 +738,9 @@ function bWireAdaptersPlumbing(adapters) {
|
|
|
738
738
|
*/
|
|
739
739
|
const bGenerateMarkup = (esTemplate `
|
|
740
740
|
// These variables may mix with component-authored variables, so should be reasonably unique
|
|
741
|
-
const
|
|
742
|
-
const
|
|
741
|
+
const __lwcSuperPublicProperties__ = Array.from(Object.getPrototypeOf(${ /* Component class */estreeToolkit.is.identifier})?.__lwcPublicProperties__?.values?.() ?? []);
|
|
742
|
+
const __lwcPublicProperties__ = new Set(${ /*public properties*/estreeToolkit.is.arrayExpression}.concat(__lwcSuperPublicProperties__));
|
|
743
|
+
const __lwcPrivateProperties__ = new Set(${ /*private properties*/estreeToolkit.is.arrayExpression});
|
|
743
744
|
|
|
744
745
|
async function* generateMarkup(
|
|
745
746
|
tagName,
|
|
@@ -755,7 +756,7 @@ const bGenerateMarkup = (esTemplate `
|
|
|
755
756
|
tagName = tagName ?? ${ /*component tag name*/estreeToolkit.is.literal};
|
|
756
757
|
attrs = attrs ?? Object.create(null);
|
|
757
758
|
props = props ?? Object.create(null);
|
|
758
|
-
const instance = new ${ /* Component class */
|
|
759
|
+
const instance = new ${ /* Component class */0}({
|
|
759
760
|
tagName: tagName.toUpperCase(),
|
|
760
761
|
});
|
|
761
762
|
|
|
@@ -777,12 +778,12 @@ const bGenerateMarkup = (esTemplate `
|
|
|
777
778
|
// If a render() function is defined on the class or any of its superclasses, then that takes priority.
|
|
778
779
|
// Next, if the class or any of its superclasses has an implicitly-associated template, then that takes
|
|
779
780
|
// second priority (e.g. a foo.html file alongside a foo.js file). Finally, there is a fallback empty template.
|
|
780
|
-
const tmplFn = instance.render?.() ?? ${ /*component class*/
|
|
781
|
+
const tmplFn = instance.render?.() ?? ${ /*component class*/0}[__SYMBOL__DEFAULT_TEMPLATE] ?? __fallbackTmpl;
|
|
781
782
|
yield \`<\${tagName}\`;
|
|
782
783
|
|
|
783
784
|
const hostHasScopedStylesheets =
|
|
784
785
|
tmplFn.hasScopedStylesheets ||
|
|
785
|
-
hasScopedStaticStylesheets(${ /*component class*/
|
|
786
|
+
hasScopedStaticStylesheets(${ /*component class*/0});
|
|
786
787
|
const hostScopeToken = hostHasScopedStylesheets ? tmplFn.stylesheetScopeToken + "-host" : undefined;
|
|
787
788
|
|
|
788
789
|
yield* __renderAttrs(instance, attrs, hostScopeToken, scopeToken);
|
|
@@ -791,12 +792,13 @@ const bGenerateMarkup = (esTemplate `
|
|
|
791
792
|
shadowSlottedContent,
|
|
792
793
|
lightSlottedContent,
|
|
793
794
|
scopedSlottedContent,
|
|
794
|
-
${ /*component class*/
|
|
795
|
+
${ /*component class*/0},
|
|
795
796
|
instance
|
|
796
797
|
);
|
|
797
798
|
yield \`</\${tagName}>\`;
|
|
798
799
|
}
|
|
799
|
-
${ /* component class */
|
|
800
|
+
${ /* component class */0}[__SYMBOL__GENERATE_MARKUP] = generateMarkup;
|
|
801
|
+
${ /* component class */0}.__lwcPublicProperties__ = __lwcPublicProperties__;
|
|
800
802
|
`);
|
|
801
803
|
const bExposeTemplate = (esTemplate `
|
|
802
804
|
if (${ /*template*/estreeToolkit.is.identifier}) {
|
|
@@ -846,7 +848,7 @@ function addGenerateMarkupFunction(program, state, tagName, filename) {
|
|
|
846
848
|
SYMBOL__SET_INTERNALS: '__SYMBOL__SET_INTERNALS',
|
|
847
849
|
establishContextfulRelationship: '__establishContextfulRelationship',
|
|
848
850
|
}));
|
|
849
|
-
program.body.push(...bGenerateMarkup(estreeToolkit.builders.arrayExpression(publicProperties.map(estreeToolkit.builders.literal)), estreeToolkit.builders.arrayExpression(privateProperties.map(estreeToolkit.builders.literal)), defaultTagName,
|
|
851
|
+
program.body.push(...bGenerateMarkup(classIdentifier, estreeToolkit.builders.arrayExpression(publicProperties.map(estreeToolkit.builders.literal)), estreeToolkit.builders.arrayExpression(privateProperties.map(estreeToolkit.builders.literal)), defaultTagName, connectWireAdapterCode));
|
|
850
852
|
if (exposeTemplateBlock) {
|
|
851
853
|
program.body.push(exposeTemplateBlock);
|
|
852
854
|
}
|
|
@@ -935,6 +937,19 @@ const visitors = {
|
|
|
935
937
|
node.id = estreeToolkit.builders.identifier('DefaultComponentName');
|
|
936
938
|
state.lwcClassName = 'DefaultComponentName';
|
|
937
939
|
}
|
|
940
|
+
// There's no builder for comment nodes :\
|
|
941
|
+
const lwcVersionComment = {
|
|
942
|
+
type: 'Block',
|
|
943
|
+
value: shared.LWC_VERSION_COMMENT,
|
|
944
|
+
};
|
|
945
|
+
// Add LWC version comment to end of class body
|
|
946
|
+
const { body } = node;
|
|
947
|
+
if (body.trailingComments) {
|
|
948
|
+
body.trailingComments.push(lwcVersionComment);
|
|
949
|
+
}
|
|
950
|
+
else {
|
|
951
|
+
body.trailingComments = [lwcVersionComment];
|
|
952
|
+
}
|
|
938
953
|
}
|
|
939
954
|
},
|
|
940
955
|
PropertyDefinition(path, state) {
|
|
@@ -1042,7 +1057,12 @@ const visitors = {
|
|
|
1042
1057
|
break;
|
|
1043
1058
|
}
|
|
1044
1059
|
},
|
|
1045
|
-
Super(path,
|
|
1060
|
+
Super(path, state) {
|
|
1061
|
+
// If we mutate any super calls that are piped through this compiler, then we'll be
|
|
1062
|
+
// inadvertently mutating things like Wire adapters.
|
|
1063
|
+
if (!state.isLWC) {
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1046
1066
|
const parentFn = path.getFunctionParent();
|
|
1047
1067
|
if (parentFn &&
|
|
1048
1068
|
parentFn.parentPath?.node?.type === 'MethodDefinition' &&
|
|
@@ -1121,7 +1141,11 @@ function compileJS(src, filename, tagName, options, compilationMode) {
|
|
|
1121
1141
|
ast = transmogrify(ast, compilationMode);
|
|
1122
1142
|
}
|
|
1123
1143
|
return {
|
|
1124
|
-
code: astring.generate(ast, {
|
|
1144
|
+
code: astring.generate(ast, {
|
|
1145
|
+
// The AST generated by meriyah doesn't seem to include comments,
|
|
1146
|
+
// so this just preserves the LWC version comment we added
|
|
1147
|
+
comments: true,
|
|
1148
|
+
}),
|
|
1125
1149
|
};
|
|
1126
1150
|
}
|
|
1127
1151
|
|
|
@@ -1657,24 +1681,31 @@ const bYieldFromChildGenerator = (esTemplateWithYield `
|
|
|
1657
1681
|
Slotted content is inserted here.
|
|
1658
1682
|
Note that the slotted content will be stored in variables named
|
|
1659
1683
|
`shadowSlottedContent`/`lightSlottedContentMap / scopedSlottedContentMap` which are used below
|
|
1660
|
-
|
|
1684
|
+
when the child's generateMarkup function is invoked.
|
|
1661
1685
|
*/
|
|
1662
1686
|
estreeToolkit.is.statement}
|
|
1663
1687
|
|
|
1664
1688
|
const scopeToken = hasScopedStylesheets ? stylesheetScopeToken : undefined;
|
|
1665
|
-
const
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1689
|
+
const generateMarkup = ${ /* Component */estreeToolkit.is.identifier}[__SYMBOL__GENERATE_MARKUP];
|
|
1690
|
+
const tagName = ${ /* tag name */estreeToolkit.is.literal};
|
|
1691
|
+
|
|
1692
|
+
if (generateMarkup) {
|
|
1693
|
+
yield* generateMarkup(
|
|
1694
|
+
tagName,
|
|
1695
|
+
childProps,
|
|
1696
|
+
childAttrs,
|
|
1697
|
+
shadowSlottedContent,
|
|
1698
|
+
lightSlottedContentMap,
|
|
1699
|
+
scopedSlottedContentMap,
|
|
1700
|
+
instance,
|
|
1701
|
+
scopeToken,
|
|
1702
|
+
contextfulParent
|
|
1703
|
+
);
|
|
1704
|
+
} else {
|
|
1705
|
+
yield \`<\${tagName}>\`;
|
|
1706
|
+
yield* __fallbackTmpl(shadowSlottedContent, lightSlottedContentMap, scopedSlottedContentMap, ${ /* Component */3}, instance)
|
|
1707
|
+
yield \`</\${tagName}>\`;
|
|
1708
|
+
}
|
|
1678
1709
|
}
|
|
1679
1710
|
`);
|
|
1680
1711
|
const Component = function Component(node, cxt) {
|
|
@@ -1684,6 +1715,7 @@ const Component = function Component(node, cxt) {
|
|
|
1684
1715
|
cxt.import({ default: childComponentLocalName }, importPath);
|
|
1685
1716
|
cxt.import({
|
|
1686
1717
|
SYMBOL__GENERATE_MARKUP: '__SYMBOL__GENERATE_MARKUP',
|
|
1718
|
+
fallbackTmpl: '__fallbackTmpl',
|
|
1687
1719
|
});
|
|
1688
1720
|
const childTagName = node.name;
|
|
1689
1721
|
return [
|
|
@@ -2038,11 +2070,12 @@ const ForOf = function ForEach(node, cxt) {
|
|
|
2038
2070
|
const LegacyIf = function If(node, cxt) {
|
|
2039
2071
|
const { modifier: trueOrFalseAsStr, condition, children } = node;
|
|
2040
2072
|
const trueOrFalse = trueOrFalseAsStr === 'true';
|
|
2041
|
-
|
|
2042
|
-
|
|
2073
|
+
const test = trueOrFalse
|
|
2074
|
+
? expressionIrToEs(condition, cxt)
|
|
2075
|
+
: estreeToolkit.builders.unaryExpression('!', expressionIrToEs(condition, cxt));
|
|
2043
2076
|
const childStatements = irChildrenToEs(children, cxt);
|
|
2044
2077
|
const block = estreeToolkit.builders.blockStatement(optimizeAdjacentYieldStmts(childStatements));
|
|
2045
|
-
return [estreeToolkit.builders.ifStatement(
|
|
2078
|
+
return [estreeToolkit.builders.ifStatement(test, block)];
|
|
2046
2079
|
};
|
|
2047
2080
|
|
|
2048
2081
|
/*
|
|
@@ -2369,17 +2402,15 @@ function compileTemplate(src, filename, options, compilationMode) {
|
|
|
2369
2402
|
experimentalDynamicDirective: options.experimentalDynamicDirective,
|
|
2370
2403
|
});
|
|
2371
2404
|
if (!root || warnings.length) {
|
|
2372
|
-
let fatal = !root;
|
|
2373
2405
|
for (const warning of warnings) {
|
|
2374
2406
|
// eslint-disable-next-line no-console
|
|
2375
2407
|
console.error('Cannot compile:', warning.message);
|
|
2376
|
-
if (warning.level === errors.DiagnosticLevel.Fatal ||
|
|
2377
|
-
warning.level === errors.DiagnosticLevel.Error) {
|
|
2378
|
-
fatal = true;
|
|
2379
|
-
}
|
|
2380
2408
|
}
|
|
2381
|
-
//
|
|
2382
|
-
|
|
2409
|
+
// The legacy SSR implementation would not bail from compilation even if a
|
|
2410
|
+
// DiagnosticLevel.Fatal error was encountered. It would only fail if the
|
|
2411
|
+
// template parser failed to return a root node. That behavior is duplicated
|
|
2412
|
+
// here.
|
|
2413
|
+
if (!root) {
|
|
2383
2414
|
throw new Error('Template compilation failure; see warnings in the console.');
|
|
2384
2415
|
}
|
|
2385
2416
|
}
|
|
@@ -2422,5 +2453,5 @@ function compileTemplateForSSR(src, filename, options, mode = shared.DEFAULT_SSR
|
|
|
2422
2453
|
|
|
2423
2454
|
exports.compileComponentForSSR = compileComponentForSSR;
|
|
2424
2455
|
exports.compileTemplateForSSR = compileTemplateForSSR;
|
|
2425
|
-
/** version: 8.
|
|
2456
|
+
/** version: 8.13.0 */
|
|
2426
2457
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2025 Salesforce, Inc.
|
|
3
3
|
*/
|
|
4
|
-
import { normalizeStyleAttributeValue, StringReplace, StringTrim, entries, isUndefined, HTML_NAMESPACE, isVoidElement, isBooleanAttribute,
|
|
4
|
+
import { LWC_VERSION_COMMENT, normalizeStyleAttributeValue, StringReplace, StringTrim, entries, isUndefined, HTML_NAMESPACE, isVoidElement, isBooleanAttribute, DEFAULT_SSR_MODE, generateCustomElementTagName } from '@lwc/shared';
|
|
5
5
|
import { generate } from 'astring';
|
|
6
6
|
import { builders, traverse, is } from 'estree-toolkit';
|
|
7
7
|
import { parseModule } from 'meriyah';
|
|
8
|
-
import { generateCompilerError, DecoratorErrors
|
|
8
|
+
import { generateCompilerError, DecoratorErrors } from '@lwc/errors';
|
|
9
9
|
import { produce } from 'immer';
|
|
10
10
|
import { parse as parse$1 } from 'node:path';
|
|
11
11
|
import { parse } from 'acorn';
|
|
@@ -734,8 +734,9 @@ function bWireAdaptersPlumbing(adapters) {
|
|
|
734
734
|
*/
|
|
735
735
|
const bGenerateMarkup = (esTemplate `
|
|
736
736
|
// These variables may mix with component-authored variables, so should be reasonably unique
|
|
737
|
-
const
|
|
738
|
-
const
|
|
737
|
+
const __lwcSuperPublicProperties__ = Array.from(Object.getPrototypeOf(${ /* Component class */is.identifier})?.__lwcPublicProperties__?.values?.() ?? []);
|
|
738
|
+
const __lwcPublicProperties__ = new Set(${ /*public properties*/is.arrayExpression}.concat(__lwcSuperPublicProperties__));
|
|
739
|
+
const __lwcPrivateProperties__ = new Set(${ /*private properties*/is.arrayExpression});
|
|
739
740
|
|
|
740
741
|
async function* generateMarkup(
|
|
741
742
|
tagName,
|
|
@@ -751,7 +752,7 @@ const bGenerateMarkup = (esTemplate `
|
|
|
751
752
|
tagName = tagName ?? ${ /*component tag name*/is.literal};
|
|
752
753
|
attrs = attrs ?? Object.create(null);
|
|
753
754
|
props = props ?? Object.create(null);
|
|
754
|
-
const instance = new ${ /* Component class */
|
|
755
|
+
const instance = new ${ /* Component class */0}({
|
|
755
756
|
tagName: tagName.toUpperCase(),
|
|
756
757
|
});
|
|
757
758
|
|
|
@@ -773,12 +774,12 @@ const bGenerateMarkup = (esTemplate `
|
|
|
773
774
|
// If a render() function is defined on the class or any of its superclasses, then that takes priority.
|
|
774
775
|
// Next, if the class or any of its superclasses has an implicitly-associated template, then that takes
|
|
775
776
|
// second priority (e.g. a foo.html file alongside a foo.js file). Finally, there is a fallback empty template.
|
|
776
|
-
const tmplFn = instance.render?.() ?? ${ /*component class*/
|
|
777
|
+
const tmplFn = instance.render?.() ?? ${ /*component class*/0}[__SYMBOL__DEFAULT_TEMPLATE] ?? __fallbackTmpl;
|
|
777
778
|
yield \`<\${tagName}\`;
|
|
778
779
|
|
|
779
780
|
const hostHasScopedStylesheets =
|
|
780
781
|
tmplFn.hasScopedStylesheets ||
|
|
781
|
-
hasScopedStaticStylesheets(${ /*component class*/
|
|
782
|
+
hasScopedStaticStylesheets(${ /*component class*/0});
|
|
782
783
|
const hostScopeToken = hostHasScopedStylesheets ? tmplFn.stylesheetScopeToken + "-host" : undefined;
|
|
783
784
|
|
|
784
785
|
yield* __renderAttrs(instance, attrs, hostScopeToken, scopeToken);
|
|
@@ -787,12 +788,13 @@ const bGenerateMarkup = (esTemplate `
|
|
|
787
788
|
shadowSlottedContent,
|
|
788
789
|
lightSlottedContent,
|
|
789
790
|
scopedSlottedContent,
|
|
790
|
-
${ /*component class*/
|
|
791
|
+
${ /*component class*/0},
|
|
791
792
|
instance
|
|
792
793
|
);
|
|
793
794
|
yield \`</\${tagName}>\`;
|
|
794
795
|
}
|
|
795
|
-
${ /* component class */
|
|
796
|
+
${ /* component class */0}[__SYMBOL__GENERATE_MARKUP] = generateMarkup;
|
|
797
|
+
${ /* component class */0}.__lwcPublicProperties__ = __lwcPublicProperties__;
|
|
796
798
|
`);
|
|
797
799
|
const bExposeTemplate = (esTemplate `
|
|
798
800
|
if (${ /*template*/is.identifier}) {
|
|
@@ -842,7 +844,7 @@ function addGenerateMarkupFunction(program, state, tagName, filename) {
|
|
|
842
844
|
SYMBOL__SET_INTERNALS: '__SYMBOL__SET_INTERNALS',
|
|
843
845
|
establishContextfulRelationship: '__establishContextfulRelationship',
|
|
844
846
|
}));
|
|
845
|
-
program.body.push(...bGenerateMarkup(builders.arrayExpression(publicProperties.map(builders.literal)), builders.arrayExpression(privateProperties.map(builders.literal)), defaultTagName,
|
|
847
|
+
program.body.push(...bGenerateMarkup(classIdentifier, builders.arrayExpression(publicProperties.map(builders.literal)), builders.arrayExpression(privateProperties.map(builders.literal)), defaultTagName, connectWireAdapterCode));
|
|
846
848
|
if (exposeTemplateBlock) {
|
|
847
849
|
program.body.push(exposeTemplateBlock);
|
|
848
850
|
}
|
|
@@ -931,6 +933,19 @@ const visitors = {
|
|
|
931
933
|
node.id = builders.identifier('DefaultComponentName');
|
|
932
934
|
state.lwcClassName = 'DefaultComponentName';
|
|
933
935
|
}
|
|
936
|
+
// There's no builder for comment nodes :\
|
|
937
|
+
const lwcVersionComment = {
|
|
938
|
+
type: 'Block',
|
|
939
|
+
value: LWC_VERSION_COMMENT,
|
|
940
|
+
};
|
|
941
|
+
// Add LWC version comment to end of class body
|
|
942
|
+
const { body } = node;
|
|
943
|
+
if (body.trailingComments) {
|
|
944
|
+
body.trailingComments.push(lwcVersionComment);
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
body.trailingComments = [lwcVersionComment];
|
|
948
|
+
}
|
|
934
949
|
}
|
|
935
950
|
},
|
|
936
951
|
PropertyDefinition(path, state) {
|
|
@@ -1038,7 +1053,12 @@ const visitors = {
|
|
|
1038
1053
|
break;
|
|
1039
1054
|
}
|
|
1040
1055
|
},
|
|
1041
|
-
Super(path,
|
|
1056
|
+
Super(path, state) {
|
|
1057
|
+
// If we mutate any super calls that are piped through this compiler, then we'll be
|
|
1058
|
+
// inadvertently mutating things like Wire adapters.
|
|
1059
|
+
if (!state.isLWC) {
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1042
1062
|
const parentFn = path.getFunctionParent();
|
|
1043
1063
|
if (parentFn &&
|
|
1044
1064
|
parentFn.parentPath?.node?.type === 'MethodDefinition' &&
|
|
@@ -1117,7 +1137,11 @@ function compileJS(src, filename, tagName, options, compilationMode) {
|
|
|
1117
1137
|
ast = transmogrify(ast, compilationMode);
|
|
1118
1138
|
}
|
|
1119
1139
|
return {
|
|
1120
|
-
code: generate(ast, {
|
|
1140
|
+
code: generate(ast, {
|
|
1141
|
+
// The AST generated by meriyah doesn't seem to include comments,
|
|
1142
|
+
// so this just preserves the LWC version comment we added
|
|
1143
|
+
comments: true,
|
|
1144
|
+
}),
|
|
1121
1145
|
};
|
|
1122
1146
|
}
|
|
1123
1147
|
|
|
@@ -1653,24 +1677,31 @@ const bYieldFromChildGenerator = (esTemplateWithYield `
|
|
|
1653
1677
|
Slotted content is inserted here.
|
|
1654
1678
|
Note that the slotted content will be stored in variables named
|
|
1655
1679
|
`shadowSlottedContent`/`lightSlottedContentMap / scopedSlottedContentMap` which are used below
|
|
1656
|
-
|
|
1680
|
+
when the child's generateMarkup function is invoked.
|
|
1657
1681
|
*/
|
|
1658
1682
|
is.statement}
|
|
1659
1683
|
|
|
1660
1684
|
const scopeToken = hasScopedStylesheets ? stylesheetScopeToken : undefined;
|
|
1661
|
-
const
|
|
1685
|
+
const generateMarkup = ${ /* Component */is.identifier}[__SYMBOL__GENERATE_MARKUP];
|
|
1686
|
+
const tagName = ${ /* tag name */is.literal};
|
|
1662
1687
|
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1688
|
+
if (generateMarkup) {
|
|
1689
|
+
yield* generateMarkup(
|
|
1690
|
+
tagName,
|
|
1691
|
+
childProps,
|
|
1692
|
+
childAttrs,
|
|
1693
|
+
shadowSlottedContent,
|
|
1694
|
+
lightSlottedContentMap,
|
|
1695
|
+
scopedSlottedContentMap,
|
|
1696
|
+
instance,
|
|
1697
|
+
scopeToken,
|
|
1698
|
+
contextfulParent
|
|
1699
|
+
);
|
|
1700
|
+
} else {
|
|
1701
|
+
yield \`<\${tagName}>\`;
|
|
1702
|
+
yield* __fallbackTmpl(shadowSlottedContent, lightSlottedContentMap, scopedSlottedContentMap, ${ /* Component */3}, instance)
|
|
1703
|
+
yield \`</\${tagName}>\`;
|
|
1704
|
+
}
|
|
1674
1705
|
}
|
|
1675
1706
|
`);
|
|
1676
1707
|
const Component = function Component(node, cxt) {
|
|
@@ -1680,6 +1711,7 @@ const Component = function Component(node, cxt) {
|
|
|
1680
1711
|
cxt.import({ default: childComponentLocalName }, importPath);
|
|
1681
1712
|
cxt.import({
|
|
1682
1713
|
SYMBOL__GENERATE_MARKUP: '__SYMBOL__GENERATE_MARKUP',
|
|
1714
|
+
fallbackTmpl: '__fallbackTmpl',
|
|
1683
1715
|
});
|
|
1684
1716
|
const childTagName = node.name;
|
|
1685
1717
|
return [
|
|
@@ -2034,11 +2066,12 @@ const ForOf = function ForEach(node, cxt) {
|
|
|
2034
2066
|
const LegacyIf = function If(node, cxt) {
|
|
2035
2067
|
const { modifier: trueOrFalseAsStr, condition, children } = node;
|
|
2036
2068
|
const trueOrFalse = trueOrFalseAsStr === 'true';
|
|
2037
|
-
|
|
2038
|
-
|
|
2069
|
+
const test = trueOrFalse
|
|
2070
|
+
? expressionIrToEs(condition, cxt)
|
|
2071
|
+
: builders.unaryExpression('!', expressionIrToEs(condition, cxt));
|
|
2039
2072
|
const childStatements = irChildrenToEs(children, cxt);
|
|
2040
2073
|
const block = builders.blockStatement(optimizeAdjacentYieldStmts(childStatements));
|
|
2041
|
-
return [builders.ifStatement(
|
|
2074
|
+
return [builders.ifStatement(test, block)];
|
|
2042
2075
|
};
|
|
2043
2076
|
|
|
2044
2077
|
/*
|
|
@@ -2365,17 +2398,15 @@ function compileTemplate(src, filename, options, compilationMode) {
|
|
|
2365
2398
|
experimentalDynamicDirective: options.experimentalDynamicDirective,
|
|
2366
2399
|
});
|
|
2367
2400
|
if (!root || warnings.length) {
|
|
2368
|
-
let fatal = !root;
|
|
2369
2401
|
for (const warning of warnings) {
|
|
2370
2402
|
// eslint-disable-next-line no-console
|
|
2371
2403
|
console.error('Cannot compile:', warning.message);
|
|
2372
|
-
if (warning.level === DiagnosticLevel.Fatal ||
|
|
2373
|
-
warning.level === DiagnosticLevel.Error) {
|
|
2374
|
-
fatal = true;
|
|
2375
|
-
}
|
|
2376
2404
|
}
|
|
2377
|
-
//
|
|
2378
|
-
|
|
2405
|
+
// The legacy SSR implementation would not bail from compilation even if a
|
|
2406
|
+
// DiagnosticLevel.Fatal error was encountered. It would only fail if the
|
|
2407
|
+
// template parser failed to return a root node. That behavior is duplicated
|
|
2408
|
+
// here.
|
|
2409
|
+
if (!root) {
|
|
2379
2410
|
throw new Error('Template compilation failure; see warnings in the console.');
|
|
2380
2411
|
}
|
|
2381
2412
|
}
|
|
@@ -2417,5 +2448,5 @@ function compileTemplateForSSR(src, filename, options, mode = DEFAULT_SSR_MODE)
|
|
|
2417
2448
|
}
|
|
2418
2449
|
|
|
2419
2450
|
export { compileComponentForSSR, compileTemplateForSSR };
|
|
2420
|
-
/** version: 8.
|
|
2451
|
+
/** version: 8.13.0 */
|
|
2421
2452
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
|
|
5
5
|
],
|
|
6
6
|
"name": "@lwc/ssr-compiler",
|
|
7
|
-
"version": "8.
|
|
7
|
+
"version": "8.13.0",
|
|
8
8
|
"description": "Compile component for use during server-side rendering",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"compiler",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@babel/types": "7.26.7",
|
|
52
|
-
"@lwc/shared": "8.
|
|
53
|
-
"@lwc/errors": "8.
|
|
54
|
-
"@lwc/template-compiler": "8.
|
|
52
|
+
"@lwc/shared": "8.13.0",
|
|
53
|
+
"@lwc/errors": "8.13.0",
|
|
54
|
+
"@lwc/template-compiler": "8.13.0",
|
|
55
55
|
"acorn": "8.14.0",
|
|
56
56
|
"astring": "^1.9.0",
|
|
57
57
|
"estree-toolkit": "^1.7.8",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"meriyah": "^5.0.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@lwc/babel-plugin-component": "8.
|
|
62
|
+
"@lwc/babel-plugin-component": "8.13.0",
|
|
63
63
|
"@types/estree": "^1.0.6"
|
|
64
64
|
}
|
|
65
65
|
}
|