@lwc/ssr-compiler 8.16.0 → 8.16.2
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/index.cjs.js +18 -20
- package/dist/index.js +18 -20
- package/dist/transmogrify.d.ts +3 -3
- package/package.json +7 -7
- package/dist/optimizer.d.ts +0 -3
package/dist/index.cjs.js
CHANGED
|
@@ -25,21 +25,21 @@ var util = require('util');
|
|
|
25
25
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
26
26
|
*/
|
|
27
27
|
const EMIT_IDENT = estreeToolkit.builders.identifier('$$emit');
|
|
28
|
+
/** Function names that may be transmogrified. All should start with `__lwc`. */
|
|
28
29
|
// Rollup may rename variables to prevent shadowing. When it does, it uses the format `foo$0`, `foo$1`, etc.
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const isWithinFn = (pattern, nodePath) => {
|
|
30
|
+
const TRANSMOGRIFY_TARGET = /^__lwc(GenerateMarkup|GenerateSlottedContent|Tmpl)(?:\$\d+)?$/;
|
|
31
|
+
const isWithinFn = (nodePath) => {
|
|
32
32
|
const { node } = nodePath;
|
|
33
33
|
if (!node) {
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
36
|
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') &&
|
|
37
37
|
node.id &&
|
|
38
|
-
|
|
38
|
+
TRANSMOGRIFY_TARGET.test(node.id.name)) {
|
|
39
39
|
return true;
|
|
40
40
|
}
|
|
41
41
|
if (nodePath.parentPath) {
|
|
42
|
-
return isWithinFn(
|
|
42
|
+
return isWithinFn(nodePath.parentPath);
|
|
43
43
|
}
|
|
44
44
|
return false;
|
|
45
45
|
};
|
|
@@ -54,8 +54,7 @@ const visitors$2 = {
|
|
|
54
54
|
// Component authors might conceivably use async generator functions in their own code. Therefore,
|
|
55
55
|
// when traversing & transforming written+generated code, we need to disambiguate generated async
|
|
56
56
|
// generator functions from those that were written by the component author.
|
|
57
|
-
if (!isWithinFn(
|
|
58
|
-
!isWithinFn(TMPL_FN_PATTERN, path)) {
|
|
57
|
+
if (!isWithinFn(path)) {
|
|
59
58
|
return;
|
|
60
59
|
}
|
|
61
60
|
node.generator = false;
|
|
@@ -70,8 +69,7 @@ const visitors$2 = {
|
|
|
70
69
|
// Component authors might conceivably use generator functions within their own code. Therefore,
|
|
71
70
|
// when traversing & transforming written+generated code, we need to disambiguate generated yield
|
|
72
71
|
// expressions from those that were written by the component author.
|
|
73
|
-
if (!isWithinFn(
|
|
74
|
-
!isWithinFn(GEN_MARKUP_OR_GEN_SLOTTED_CONTENT_PATTERN, path)) {
|
|
72
|
+
if (!isWithinFn(path)) {
|
|
75
73
|
return;
|
|
76
74
|
}
|
|
77
75
|
if (node.delegate) {
|
|
@@ -130,7 +128,7 @@ const visitors$2 = {
|
|
|
130
128
|
* Is compiled into the following JavaScript, intended for execution during SSR & stripped down
|
|
131
129
|
* for the purposes of this example:
|
|
132
130
|
*
|
|
133
|
-
* async function*
|
|
131
|
+
* async function* __lwcTmpl(props, attrs, slottedContent, Cmp, instance) {
|
|
134
132
|
* yield '<div>foobar</div>';
|
|
135
133
|
* const childProps = {};
|
|
136
134
|
* const childAttrs = {};
|
|
@@ -139,7 +137,7 @@ const visitors$2 = {
|
|
|
139
137
|
*
|
|
140
138
|
* When transmogrified in async-mode, the above generated template function becomes the following:
|
|
141
139
|
*
|
|
142
|
-
* async function
|
|
140
|
+
* async function __lwcTmpl($$emit, props, attrs, slottedContent, Cmp, instance) {
|
|
143
141
|
* $$emit('<div>foobar</div>');
|
|
144
142
|
* const childProps = {};
|
|
145
143
|
* const childAttrs = {};
|
|
@@ -148,7 +146,7 @@ const visitors$2 = {
|
|
|
148
146
|
*
|
|
149
147
|
* When transmogrified in sync-mode, the template function becomes the following:
|
|
150
148
|
*
|
|
151
|
-
* function
|
|
149
|
+
* function __lwcTmpl($$emit, props, attrs, slottedContent, Cmp, instance) {
|
|
152
150
|
* $$emit('<div>foobar</div>');
|
|
153
151
|
* const childProps = {};
|
|
154
152
|
* const childAttrs = {};
|
|
@@ -745,7 +743,7 @@ const bGenerateMarkup = (esTemplate `
|
|
|
745
743
|
configurable: false,
|
|
746
744
|
enumerable: false,
|
|
747
745
|
writable: false,
|
|
748
|
-
value: async function*
|
|
746
|
+
value: async function* __lwcGenerateMarkup(
|
|
749
747
|
// The $$emit function is magically inserted here
|
|
750
748
|
tagName,
|
|
751
749
|
props,
|
|
@@ -849,7 +847,7 @@ function addGenerateMarkupFunction(program, state, tagName, filename) {
|
|
|
849
847
|
let exposeTemplateBlock = null;
|
|
850
848
|
if (!tmplExplicitImports) {
|
|
851
849
|
const defaultTmplPath = `./${node_path.parse(filename).name}.html`;
|
|
852
|
-
const tmplVar = estreeToolkit.builders.identifier('
|
|
850
|
+
const tmplVar = estreeToolkit.builders.identifier('__lwcTmpl');
|
|
853
851
|
program.body.unshift(bImportDeclaration({ default: tmplVar.name }, defaultTmplPath));
|
|
854
852
|
program.body.unshift(bImportDeclaration({ SYMBOL__DEFAULT_TEMPLATE: '__SYMBOL__DEFAULT_TEMPLATE' }));
|
|
855
853
|
exposeTemplateBlock = bExposeTemplate(tmplVar, classIdentifier);
|
|
@@ -1261,7 +1259,7 @@ ${ /* template */0}.stylesheetScopeToken = stylesheetScopeToken;
|
|
|
1261
1259
|
function addScopeTokenDeclarations(program, filename, namespace, componentName) {
|
|
1262
1260
|
const { scopeToken } = templateCompiler.generateScopeTokens(filename, namespace, componentName);
|
|
1263
1261
|
program.body.unshift(bStylesheetTokenDeclaration(builders.builders.literal(scopeToken)), bHasScopedStylesheetsDeclaration());
|
|
1264
|
-
program.body.push(...tmplAssignmentBlock(builders.builders.identifier('
|
|
1262
|
+
program.body.push(...tmplAssignmentBlock(builders.builders.identifier('__lwcTmpl')));
|
|
1265
1263
|
}
|
|
1266
1264
|
|
|
1267
1265
|
/*
|
|
@@ -1584,7 +1582,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1584
1582
|
*/
|
|
1585
1583
|
const bGenerateSlottedContent = (esTemplateWithYield `
|
|
1586
1584
|
const shadowSlottedContent = ${ /* hasShadowSlottedContent */estreeToolkit.is.literal}
|
|
1587
|
-
? async function*
|
|
1585
|
+
? async function* __lwcGenerateSlottedContent(contextfulParent) {
|
|
1588
1586
|
// The 'contextfulParent' variable is shadowed here so that a contextful relationship
|
|
1589
1587
|
// is established between components rendered in slotted content & the "parent"
|
|
1590
1588
|
// component that contains the <slot>.
|
|
@@ -1617,11 +1615,11 @@ const bGenerateSlottedContent = (esTemplateWithYield `
|
|
|
1617
1615
|
${ /* light DOM addLightContent statements */estreeToolkit.is.expressionStatement}
|
|
1618
1616
|
${ /* scoped slot addLightContent statements */estreeToolkit.is.expressionStatement}
|
|
1619
1617
|
`);
|
|
1620
|
-
// Note that this function name (`
|
|
1618
|
+
// Note that this function name (`__lwcGenerateSlottedContent`) does not need to be scoped even though
|
|
1621
1619
|
// it may be repeated multiple times in the same scope, because it's a function _expression_ rather
|
|
1622
1620
|
// than a function _declaration_, so it isn't available to be referenced anywhere.
|
|
1623
1621
|
const bAddSlottedContent = (esTemplate `
|
|
1624
|
-
addSlottedContent(${ /* slot name */estreeToolkit.is.expression} ?? "", async function*
|
|
1622
|
+
addSlottedContent(${ /* slot name */estreeToolkit.is.expression} ?? "", async function* __lwcGenerateSlottedContent(contextfulParent, ${
|
|
1625
1623
|
/* scoped slot data variable */ isNullableOf(estreeToolkit.is.identifier)}, slotAttributeValue) {
|
|
1626
1624
|
// FIXME: make validation work again
|
|
1627
1625
|
${ /* slot content */false}
|
|
@@ -2436,7 +2434,7 @@ function templateIrToEsTree(node, contextOpts) {
|
|
|
2436
2434
|
*/
|
|
2437
2435
|
// TODO [#4663]: Render mode mismatch between template and compiler should throw.
|
|
2438
2436
|
const bExportTemplate = (esTemplate `
|
|
2439
|
-
export default async function*
|
|
2437
|
+
export default async function* __lwcTmpl(
|
|
2440
2438
|
// This is where $$emit comes from
|
|
2441
2439
|
shadowSlottedContent,
|
|
2442
2440
|
lightSlottedContent,
|
|
@@ -2569,5 +2567,5 @@ function compileTemplateForSSR(src, filename, options, mode = shared.DEFAULT_SSR
|
|
|
2569
2567
|
|
|
2570
2568
|
exports.compileComponentForSSR = compileComponentForSSR;
|
|
2571
2569
|
exports.compileTemplateForSSR = compileTemplateForSSR;
|
|
2572
|
-
/** version: 8.16.
|
|
2570
|
+
/** version: 8.16.2 */
|
|
2573
2571
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.js
CHANGED
|
@@ -21,21 +21,21 @@ import { inspect } from 'util';
|
|
|
21
21
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
22
22
|
*/
|
|
23
23
|
const EMIT_IDENT = builders.identifier('$$emit');
|
|
24
|
+
/** Function names that may be transmogrified. All should start with `__lwc`. */
|
|
24
25
|
// Rollup may rename variables to prevent shadowing. When it does, it uses the format `foo$0`, `foo$1`, etc.
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const isWithinFn = (pattern, nodePath) => {
|
|
26
|
+
const TRANSMOGRIFY_TARGET = /^__lwc(GenerateMarkup|GenerateSlottedContent|Tmpl)(?:\$\d+)?$/;
|
|
27
|
+
const isWithinFn = (nodePath) => {
|
|
28
28
|
const { node } = nodePath;
|
|
29
29
|
if (!node) {
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
32
32
|
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') &&
|
|
33
33
|
node.id &&
|
|
34
|
-
|
|
34
|
+
TRANSMOGRIFY_TARGET.test(node.id.name)) {
|
|
35
35
|
return true;
|
|
36
36
|
}
|
|
37
37
|
if (nodePath.parentPath) {
|
|
38
|
-
return isWithinFn(
|
|
38
|
+
return isWithinFn(nodePath.parentPath);
|
|
39
39
|
}
|
|
40
40
|
return false;
|
|
41
41
|
};
|
|
@@ -50,8 +50,7 @@ const visitors$2 = {
|
|
|
50
50
|
// Component authors might conceivably use async generator functions in their own code. Therefore,
|
|
51
51
|
// when traversing & transforming written+generated code, we need to disambiguate generated async
|
|
52
52
|
// generator functions from those that were written by the component author.
|
|
53
|
-
if (!isWithinFn(
|
|
54
|
-
!isWithinFn(TMPL_FN_PATTERN, path)) {
|
|
53
|
+
if (!isWithinFn(path)) {
|
|
55
54
|
return;
|
|
56
55
|
}
|
|
57
56
|
node.generator = false;
|
|
@@ -66,8 +65,7 @@ const visitors$2 = {
|
|
|
66
65
|
// Component authors might conceivably use generator functions within their own code. Therefore,
|
|
67
66
|
// when traversing & transforming written+generated code, we need to disambiguate generated yield
|
|
68
67
|
// expressions from those that were written by the component author.
|
|
69
|
-
if (!isWithinFn(
|
|
70
|
-
!isWithinFn(GEN_MARKUP_OR_GEN_SLOTTED_CONTENT_PATTERN, path)) {
|
|
68
|
+
if (!isWithinFn(path)) {
|
|
71
69
|
return;
|
|
72
70
|
}
|
|
73
71
|
if (node.delegate) {
|
|
@@ -126,7 +124,7 @@ const visitors$2 = {
|
|
|
126
124
|
* Is compiled into the following JavaScript, intended for execution during SSR & stripped down
|
|
127
125
|
* for the purposes of this example:
|
|
128
126
|
*
|
|
129
|
-
* async function*
|
|
127
|
+
* async function* __lwcTmpl(props, attrs, slottedContent, Cmp, instance) {
|
|
130
128
|
* yield '<div>foobar</div>';
|
|
131
129
|
* const childProps = {};
|
|
132
130
|
* const childAttrs = {};
|
|
@@ -135,7 +133,7 @@ const visitors$2 = {
|
|
|
135
133
|
*
|
|
136
134
|
* When transmogrified in async-mode, the above generated template function becomes the following:
|
|
137
135
|
*
|
|
138
|
-
* async function
|
|
136
|
+
* async function __lwcTmpl($$emit, props, attrs, slottedContent, Cmp, instance) {
|
|
139
137
|
* $$emit('<div>foobar</div>');
|
|
140
138
|
* const childProps = {};
|
|
141
139
|
* const childAttrs = {};
|
|
@@ -144,7 +142,7 @@ const visitors$2 = {
|
|
|
144
142
|
*
|
|
145
143
|
* When transmogrified in sync-mode, the template function becomes the following:
|
|
146
144
|
*
|
|
147
|
-
* function
|
|
145
|
+
* function __lwcTmpl($$emit, props, attrs, slottedContent, Cmp, instance) {
|
|
148
146
|
* $$emit('<div>foobar</div>');
|
|
149
147
|
* const childProps = {};
|
|
150
148
|
* const childAttrs = {};
|
|
@@ -741,7 +739,7 @@ const bGenerateMarkup = (esTemplate `
|
|
|
741
739
|
configurable: false,
|
|
742
740
|
enumerable: false,
|
|
743
741
|
writable: false,
|
|
744
|
-
value: async function*
|
|
742
|
+
value: async function* __lwcGenerateMarkup(
|
|
745
743
|
// The $$emit function is magically inserted here
|
|
746
744
|
tagName,
|
|
747
745
|
props,
|
|
@@ -845,7 +843,7 @@ function addGenerateMarkupFunction(program, state, tagName, filename) {
|
|
|
845
843
|
let exposeTemplateBlock = null;
|
|
846
844
|
if (!tmplExplicitImports) {
|
|
847
845
|
const defaultTmplPath = `./${parse$1(filename).name}.html`;
|
|
848
|
-
const tmplVar = builders.identifier('
|
|
846
|
+
const tmplVar = builders.identifier('__lwcTmpl');
|
|
849
847
|
program.body.unshift(bImportDeclaration({ default: tmplVar.name }, defaultTmplPath));
|
|
850
848
|
program.body.unshift(bImportDeclaration({ SYMBOL__DEFAULT_TEMPLATE: '__SYMBOL__DEFAULT_TEMPLATE' }));
|
|
851
849
|
exposeTemplateBlock = bExposeTemplate(tmplVar, classIdentifier);
|
|
@@ -1257,7 +1255,7 @@ ${ /* template */0}.stylesheetScopeToken = stylesheetScopeToken;
|
|
|
1257
1255
|
function addScopeTokenDeclarations(program, filename, namespace, componentName) {
|
|
1258
1256
|
const { scopeToken } = generateScopeTokens(filename, namespace, componentName);
|
|
1259
1257
|
program.body.unshift(bStylesheetTokenDeclaration(builders$1.literal(scopeToken)), bHasScopedStylesheetsDeclaration());
|
|
1260
|
-
program.body.push(...tmplAssignmentBlock(builders$1.identifier('
|
|
1258
|
+
program.body.push(...tmplAssignmentBlock(builders$1.identifier('__lwcTmpl')));
|
|
1261
1259
|
}
|
|
1262
1260
|
|
|
1263
1261
|
/*
|
|
@@ -1580,7 +1578,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1580
1578
|
*/
|
|
1581
1579
|
const bGenerateSlottedContent = (esTemplateWithYield `
|
|
1582
1580
|
const shadowSlottedContent = ${ /* hasShadowSlottedContent */is.literal}
|
|
1583
|
-
? async function*
|
|
1581
|
+
? async function* __lwcGenerateSlottedContent(contextfulParent) {
|
|
1584
1582
|
// The 'contextfulParent' variable is shadowed here so that a contextful relationship
|
|
1585
1583
|
// is established between components rendered in slotted content & the "parent"
|
|
1586
1584
|
// component that contains the <slot>.
|
|
@@ -1613,11 +1611,11 @@ const bGenerateSlottedContent = (esTemplateWithYield `
|
|
|
1613
1611
|
${ /* light DOM addLightContent statements */is.expressionStatement}
|
|
1614
1612
|
${ /* scoped slot addLightContent statements */is.expressionStatement}
|
|
1615
1613
|
`);
|
|
1616
|
-
// Note that this function name (`
|
|
1614
|
+
// Note that this function name (`__lwcGenerateSlottedContent`) does not need to be scoped even though
|
|
1617
1615
|
// it may be repeated multiple times in the same scope, because it's a function _expression_ rather
|
|
1618
1616
|
// than a function _declaration_, so it isn't available to be referenced anywhere.
|
|
1619
1617
|
const bAddSlottedContent = (esTemplate `
|
|
1620
|
-
addSlottedContent(${ /* slot name */is.expression} ?? "", async function*
|
|
1618
|
+
addSlottedContent(${ /* slot name */is.expression} ?? "", async function* __lwcGenerateSlottedContent(contextfulParent, ${
|
|
1621
1619
|
/* scoped slot data variable */ isNullableOf(is.identifier)}, slotAttributeValue) {
|
|
1622
1620
|
// FIXME: make validation work again
|
|
1623
1621
|
${ /* slot content */false}
|
|
@@ -2432,7 +2430,7 @@ function templateIrToEsTree(node, contextOpts) {
|
|
|
2432
2430
|
*/
|
|
2433
2431
|
// TODO [#4663]: Render mode mismatch between template and compiler should throw.
|
|
2434
2432
|
const bExportTemplate = (esTemplate `
|
|
2435
|
-
export default async function*
|
|
2433
|
+
export default async function* __lwcTmpl(
|
|
2436
2434
|
// This is where $$emit comes from
|
|
2437
2435
|
shadowSlottedContent,
|
|
2438
2436
|
lightSlottedContent,
|
|
@@ -2564,5 +2562,5 @@ function compileTemplateForSSR(src, filename, options, mode = DEFAULT_SSR_MODE)
|
|
|
2564
2562
|
}
|
|
2565
2563
|
|
|
2566
2564
|
export { compileComponentForSSR, compileTemplateForSSR };
|
|
2567
|
-
/** version: 8.16.
|
|
2565
|
+
/** version: 8.16.2 */
|
|
2568
2566
|
//# sourceMappingURL=index.js.map
|
package/dist/transmogrify.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type Visitors = Parameters<typeof traverse<Node, TransmogrificationState>
|
|
|
18
18
|
* Is compiled into the following JavaScript, intended for execution during SSR & stripped down
|
|
19
19
|
* for the purposes of this example:
|
|
20
20
|
*
|
|
21
|
-
* async function*
|
|
21
|
+
* async function* __lwcTmpl(props, attrs, slottedContent, Cmp, instance) {
|
|
22
22
|
* yield '<div>foobar</div>';
|
|
23
23
|
* const childProps = {};
|
|
24
24
|
* const childAttrs = {};
|
|
@@ -27,7 +27,7 @@ export type Visitors = Parameters<typeof traverse<Node, TransmogrificationState>
|
|
|
27
27
|
*
|
|
28
28
|
* When transmogrified in async-mode, the above generated template function becomes the following:
|
|
29
29
|
*
|
|
30
|
-
* async function
|
|
30
|
+
* async function __lwcTmpl($$emit, props, attrs, slottedContent, Cmp, instance) {
|
|
31
31
|
* $$emit('<div>foobar</div>');
|
|
32
32
|
* const childProps = {};
|
|
33
33
|
* const childAttrs = {};
|
|
@@ -36,7 +36,7 @@ export type Visitors = Parameters<typeof traverse<Node, TransmogrificationState>
|
|
|
36
36
|
*
|
|
37
37
|
* When transmogrified in sync-mode, the template function becomes the following:
|
|
38
38
|
*
|
|
39
|
-
* function
|
|
39
|
+
* function __lwcTmpl($$emit, props, attrs, slottedContent, Cmp, instance) {
|
|
40
40
|
* $$emit('<div>foobar</div>');
|
|
41
41
|
* const childProps = {};
|
|
42
42
|
* const childAttrs = {};
|
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.16.
|
|
7
|
+
"version": "8.16.2",
|
|
8
8
|
"description": "Compile component for use during server-side rendering",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"compiler",
|
|
@@ -48,18 +48,18 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@babel/types": "7.26.
|
|
52
|
-
"@lwc/
|
|
53
|
-
"@lwc/
|
|
54
|
-
"@lwc/template-compiler": "8.16.
|
|
55
|
-
"acorn": "8.14.
|
|
51
|
+
"@babel/types": "7.26.10",
|
|
52
|
+
"@lwc/errors": "8.16.2",
|
|
53
|
+
"@lwc/shared": "8.16.2",
|
|
54
|
+
"@lwc/template-compiler": "8.16.2",
|
|
55
|
+
"acorn": "8.14.1",
|
|
56
56
|
"astring": "^1.9.0",
|
|
57
57
|
"estree-toolkit": "^1.7.8",
|
|
58
58
|
"immer": "^10.1.1",
|
|
59
59
|
"meriyah": "^5.0.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@lwc/babel-plugin-component": "8.16.
|
|
62
|
+
"@lwc/babel-plugin-component": "8.16.2",
|
|
63
63
|
"@types/estree": "^1.0.6"
|
|
64
64
|
}
|
|
65
65
|
}
|
package/dist/optimizer.d.ts
DELETED