@lwc/ssr-compiler 8.1.3 → 8.3.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/index.js CHANGED
@@ -7,6 +7,7 @@ import { parseModule } from 'meriyah';
7
7
  import { AriaPropNameToAttrNameMap, reservedKeywords, normalizeStyleAttribute, isVoidElement, HTML_NAMESPACE, StringReplace, StringTrim } from '@lwc/shared';
8
8
  import { parse } from 'acorn';
9
9
  import { produce } from 'immer';
10
+ import { basename } from 'node:path';
10
11
  import { generateScopeTokens, toPropertyName, kebabcaseToCamelcase, parse as parse$1 } from '@lwc/template-compiler';
11
12
  import { builders as builders$1 } from 'estree-toolkit/dist/builders';
12
13
  import { inspect } from 'util';
@@ -70,19 +71,29 @@ function catalogTmplImport(path, state) {
70
71
  * SPDX-License-Identifier: MIT
71
72
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
72
73
  */
74
+ /** Placeholder value to use to opt out of validation. */
75
+ const NO_VALIDATION = false;
73
76
  const PLACEHOLDER_PREFIX = `__ESTEMPLATE_${Math.random().toString().slice(2)}_PLACEHOLDER__`;
77
+ const getReplacementNode = (state, placeholderId, nodeType) => {
78
+ const key = Number(placeholderId.slice(PLACEHOLDER_PREFIX.length));
79
+ const nodeCount = state.replacementNodes.length;
80
+ if (key >= nodeCount) {
81
+ throw new Error(`Cannot use index ${key} when only ${nodeCount} values have been provided.`);
82
+ }
83
+ const validateReplacement = state.placeholderToValidator.get(key);
84
+ const replacementNode = state.replacementNodes[key];
85
+ if (validateReplacement &&
86
+ !(Array.isArray(replacementNode)
87
+ ? replacementNode.every(validateReplacement)
88
+ : validateReplacement(replacementNode))) {
89
+ throw new Error(`Validation failed for templated node of type ${nodeType}`);
90
+ }
91
+ return replacementNode;
92
+ };
74
93
  const visitors$1 = {
75
94
  Identifier(path, state) {
76
95
  if (path.node?.name.startsWith(PLACEHOLDER_PREFIX)) {
77
- const key = path.node.name.slice(PLACEHOLDER_PREFIX.length);
78
- const validateReplacement = state.placeholderToValidator.get(key);
79
- const replacementNode = state.replacementNodes[key];
80
- if (validateReplacement &&
81
- !(Array.isArray(replacementNode)
82
- ? replacementNode.every(validateReplacement)
83
- : validateReplacement(replacementNode))) {
84
- throw new Error(`Validation failed for templated node of type ${path.node.type}`);
85
- }
96
+ const replacementNode = getReplacementNode(state, path.node.name, path.node.type);
86
97
  if (replacementNode === null) {
87
98
  path.remove();
88
99
  }
@@ -91,7 +102,7 @@ const visitors$1 = {
91
102
  path.remove();
92
103
  }
93
104
  else {
94
- if (path.parentPath.node.type === 'ExpressionStatement') {
105
+ if (path.parentPath?.node?.type === 'ExpressionStatement') {
95
106
  path.parentPath.replaceWithMultiple(replacementNode);
96
107
  }
97
108
  else {
@@ -107,27 +118,34 @@ const visitors$1 = {
107
118
  Literal(path, state) {
108
119
  if (typeof path.node?.value === 'string' &&
109
120
  path.node.value.startsWith(PLACEHOLDER_PREFIX)) {
110
- const key = path.node.value.slice(PLACEHOLDER_PREFIX.length);
111
- const validateReplacement = state.placeholderToValidator.get(key);
112
- const replacementNode = state.replacementNodes[key];
113
- if (validateReplacement && !validateReplacement(replacementNode)) {
114
- throw new Error(`Validation failed for templated node of type ${path.node.type}`);
115
- }
121
+ // A literal can only be replaced with a single node
122
+ const replacementNode = getReplacementNode(state, path.node.value, path.node.type);
116
123
  path.replaceWith(replacementNode);
117
124
  }
118
125
  },
119
126
  };
120
- function esTemplateImpl(javascriptSegments, validatorFns, wrap, unwrap) {
127
+ function esTemplateImpl(javascriptSegments, validators, wrap, unwrap) {
121
128
  let placeholderCount = 0;
122
129
  let parsableCode = javascriptSegments[0];
123
- validatorFns.reverse();
124
130
  const placeholderToValidator = new Map();
125
- for (const segment of javascriptSegments.slice(1)) {
126
- const validatorFn = validatorFns.pop();
127
- if (validatorFn) {
128
- placeholderToValidator.set(placeholderCount.toString(), validatorFn);
131
+ for (let i = 1; i < javascriptSegments.length; i += 1) {
132
+ const segment = javascriptSegments[i];
133
+ const validator = validators[i - 1]; // always one less value than strings in template literals
134
+ if (typeof validator === 'function' || validator === NO_VALIDATION) {
135
+ // Template slot will be filled by a *new* argument passed to the generated function
136
+ if (validator !== NO_VALIDATION) {
137
+ placeholderToValidator.set(placeholderCount, validator);
138
+ }
139
+ parsableCode += `${PLACEHOLDER_PREFIX}${placeholderCount}`;
140
+ placeholderCount += 1;
141
+ }
142
+ else {
143
+ // Template slot uses a *previously defined* argument passed to the generated function
144
+ if (validator >= placeholderCount) {
145
+ throw new Error(`Reference to argument ${validator} at index ${i} cannot be used. Only ${placeholderCount - 1} arguments have been defined.`);
146
+ }
147
+ parsableCode += `${PLACEHOLDER_PREFIX}${validator}`;
129
148
  }
130
- parsableCode += `${PLACEHOLDER_PREFIX}${placeholderCount++}`;
131
149
  parsableCode += segment;
132
150
  }
133
151
  if (wrap) {
@@ -159,16 +177,30 @@ function esTemplateImpl(javascriptSegments, validatorFns, wrap, unwrap) {
159
177
  placeholderToValidator,
160
178
  replacementNodes,
161
179
  }));
162
- return unwrap ? unwrap(result) : result;
180
+ return (unwrap ? unwrap(result) : result);
163
181
  };
164
182
  }
165
- function esTemplate(javascriptSegments, ...validatorFns) {
166
- return esTemplateImpl(javascriptSegments, validatorFns);
183
+ /**
184
+ * Template literal tag that generates a builder function. Like estree's `builders`, but for more
185
+ * complex structures. The template values should be estree `is` validators or a back reference to
186
+ * a previous slot (to re-use the referenced value).
187
+ *
188
+ * To have the generated function return a particular node type, the generic comes _after_ the
189
+ * template literal. Kinda weird, but it's necessary to infer the types of the template values.
190
+ * (If it were at the start, we'd need to explicitly provide _all_ type params. Tedious!)
191
+ * @example
192
+ * const bSum = esTemplate`(${is.identifier}, ${is.identifier}) => ${0} + ${1}`<EsArrowFunctionExpression>
193
+ * const sumFuncNode = bSum(b.identifier('a'), b.identifier('b'))
194
+ * // `sumFuncNode` is an AST node representing `(a, b) => a + b`
195
+ */
196
+ function esTemplate(javascriptSegments, ...Validators) {
197
+ return esTemplateImpl(javascriptSegments, Validators);
167
198
  }
168
- function esTemplateWithYield(javascriptSegments, ...validatorFns) {
199
+ /** Similar to {@linkcode esTemplate}, but supports `yield` expressions. */
200
+ function esTemplateWithYield(javascriptSegments, ...validators) {
169
201
  const wrap = (code) => `function* placeholder() {${code}}`;
170
202
  const unwrap = (node) => node.body.body.length === 1 ? node.body.body[0] : node.body.body;
171
- return esTemplateImpl(javascriptSegments, validatorFns, wrap, unwrap);
203
+ return esTemplateImpl(javascriptSegments, validators, wrap, unwrap);
172
204
  }
173
205
 
174
206
  /*
@@ -177,12 +209,12 @@ function esTemplateWithYield(javascriptSegments, ...validatorFns) {
177
209
  * SPDX-License-Identifier: MIT
178
210
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
179
211
  */
180
- const bDefaultStyleImport = esTemplate `
212
+ const bDefaultStyleImport = (esTemplate `
181
213
  import defaultStylesheets from '${is.literal}';
182
- `;
183
- const bDefaultScopedStyleImport = esTemplate `
214
+ `);
215
+ const bDefaultScopedStyleImport = (esTemplate `
184
216
  import defaultScopedStylesheets from '${is.literal}';
185
- `;
217
+ `);
186
218
  function catalogStyleImport(path, state) {
187
219
  const specifier = path.node.specifiers[0];
188
220
  if (typeof path.node.source.value !== 'string' ||
@@ -220,14 +252,20 @@ function catalogStaticStylesheets(ids, state) {
220
252
  * SPDX-License-Identifier: MIT
221
253
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
222
254
  */
223
- const isStringLiteral = (node) => is.literal(node) && typeof node.value === 'string';
224
- const isIdentOrRenderCall = (node) => is.identifier(node) ||
225
- (is.callExpression(node) &&
226
- is.memberExpression(node.callee) &&
227
- is.identifier(node.callee.property) &&
228
- node.callee.property.name === 'render');
255
+ const isStringLiteral = (node) => {
256
+ return is.literal(node) && typeof node.value === 'string';
257
+ };
258
+ /** Returns `true` if the node is an identifier or `<something>.render()`. */
259
+ const isIdentOrRenderCall = (node) => {
260
+ return (is.identifier(node) ||
261
+ (is.callExpression(node) &&
262
+ is.memberExpression(node.callee) &&
263
+ is.identifier(node.callee.property) &&
264
+ node.callee.property.name === 'render'));
265
+ };
266
+ /** Extends a validator to return `true` if the node is `null`. */
229
267
  function isNullableOf(validator) {
230
- return (node) => node === null || (validator && validator(node));
268
+ return (node) => node === null || validator(node);
231
269
  }
232
270
 
233
271
  /*
@@ -236,9 +274,9 @@ function isNullableOf(validator) {
236
274
  * SPDX-License-Identifier: MIT
237
275
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
238
276
  */
239
- const bImportDeclaration = esTemplate `
277
+ const bImportDeclaration = (esTemplate `
240
278
  import ${is.identifier} from "${isStringLiteral}";
241
- `;
279
+ `);
242
280
 
243
281
  /*
244
282
  * Copyright (c) 2024, salesforce.com, inc.
@@ -246,31 +284,40 @@ const bImportDeclaration = esTemplate `
246
284
  * SPDX-License-Identifier: MIT
247
285
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
248
286
  */
249
- const bGenerateMarkup = esTemplate `
287
+ const bGenerateMarkup = (esTemplate `
250
288
  export async function* generateMarkup(tagName, props, attrs, slotted) {
251
289
  attrs = attrs ?? {};
252
290
  ${isNullableOf(is.expressionStatement)};
253
291
  const instance = new ${is.identifier}({
254
292
  tagName: tagName.toUpperCase(),
255
293
  });
256
- instance.__internal__setState(props, __REFLECTED_PROPS__, attrs);
294
+ instance[__SYMBOL__SET_INTERNALS](props, __REFLECTED_PROPS__, attrs);
257
295
  instance.isConnected = true;
258
- instance.connectedCallback?.();
296
+ if (instance.connectedCallback) {
297
+ __mutationTracker.enable(instance);
298
+ instance.connectedCallback();
299
+ __mutationTracker.disable(instance);
300
+ }
259
301
  const tmplFn = ${isIdentOrRenderCall} ?? __fallbackTmpl;
260
302
  yield \`<\${tagName}\`;
261
303
  yield tmplFn.stylesheetScopeTokenHostClass ?? '';
262
- yield *__renderAttrs(attrs)
304
+ yield* __renderAttrs(instance, attrs)
263
305
  yield '>';
264
- yield* tmplFn(props, attrs, slotted, ${is.identifier}, instance);
306
+ yield* tmplFn(props, attrs, slotted, ${1}, instance);
265
307
  yield \`</\${tagName}>\`;
266
308
  }
267
- `;
268
- const bInsertFallbackTmplImport = esTemplate `
269
- import { fallbackTmpl as __fallbackTmpl, renderAttrs as __renderAttrs } from '@lwc/ssr-runtime';
270
- `;
271
- const bCreateReflectedPropArr = esTemplate `
309
+ `);
310
+ const bInsertFallbackTmplImport = (esTemplate `
311
+ import {
312
+ fallbackTmpl as __fallbackTmpl,
313
+ mutationTracker as __mutationTracker,
314
+ renderAttrs as __renderAttrs,
315
+ SYMBOL__SET_INTERNALS as __SYMBOL__SET_INTERNALS,
316
+ } from '@lwc/ssr-runtime';
317
+ `);
318
+ const bCreateReflectedPropArr = (esTemplate `
272
319
  const __REFLECTED_PROPS__ = ${is.arrayExpression};
273
- `;
320
+ `);
274
321
  function bReflectedAttrsObj(reflectedPropNames) {
275
322
  // This will build getter properties for each reflected property. It'll look
276
323
  // something like this:
@@ -281,9 +328,16 @@ function bReflectedAttrsObj(reflectedPropNames) {
281
328
  //
282
329
  // The props object will be kept up-to-date with any new values set on the corresponding
283
330
  // property name in the component instance.
284
- const reflectedAttrGetters = reflectedPropNames.map((propName) => builders.property('get', builders.literal(AriaPropNameToAttrNameMap[propName]), builders.functionExpression(null, [], builders.blockStatement([
285
- builders.returnStatement(builders.memberExpression(builders.identifier('props'), builders.identifier(propName))),
286
- ]))));
331
+ const reflectedAttrAccessors = [];
332
+ for (const propName of reflectedPropNames) {
333
+ reflectedAttrAccessors.push(builders.property('get', builders.literal(AriaPropNameToAttrNameMap[propName]), builders.functionExpression(null, [], builders.blockStatement([
334
+ builders.returnStatement(builders.callExpression(builders.identifier('String'), [
335
+ builders.memberExpression(builders.identifier('props'), builders.identifier(propName)),
336
+ ])),
337
+ ]))), builders.property('set', builders.literal(AriaPropNameToAttrNameMap[propName]), builders.functionExpression(null, [builders.identifier('val')], builders.blockStatement([
338
+ builders.expressionStatement(builders.assignmentExpression('=', builders.memberExpression(builders.identifier('props'), builders.identifier(propName)), builders.identifier('val'))),
339
+ ]))));
340
+ }
287
341
  // This mutates the `attrs` object, adding the reflected aria attributes that have been
288
342
  // detected. Example:
289
343
  //
@@ -293,7 +347,7 @@ function bReflectedAttrsObj(reflectedPropNames) {
293
347
  // return props.ariaChecked;
294
348
  // }
295
349
  // }
296
- return builders.expressionStatement(builders.assignmentExpression('=', builders.identifier('attrs'), builders.objectExpression([builders.spreadElement(builders.identifier('attrs')), ...reflectedAttrGetters])));
350
+ return builders.expressionStatement(builders.assignmentExpression('=', builders.identifier('attrs'), builders.objectExpression([builders.spreadElement(builders.identifier('attrs')), ...reflectedAttrAccessors])));
297
351
  }
298
352
  /**
299
353
  * This builds a generator function `generateMarkup` and adds it to the component JS's
@@ -314,7 +368,7 @@ function addGenerateMarkupExport(program, state, filename) {
314
368
  ? builders.callExpression(builders.memberExpression(builders.identifier('instance'), builders.identifier('render')), [])
315
369
  : builders.identifier('tmpl');
316
370
  if (!tmplExplicitImports) {
317
- const defaultTmplPath = filename.replace(/\.js$/, '.html');
371
+ const defaultTmplPath = `./${basename(filename, 'js')}html`;
318
372
  program.body.unshift(bImportDeclaration(builders.identifier('tmpl'), builders.literal(defaultTmplPath)));
319
373
  }
320
374
  let attrsAugmentation = null;
@@ -324,7 +378,7 @@ function addGenerateMarkupExport(program, state, filename) {
324
378
  const reflectedPropArr = builders.arrayExpression([...state.reflectedPropsInPlay].map((propName) => builders.literal(propName)));
325
379
  program.body.unshift(bInsertFallbackTmplImport());
326
380
  program.body.push(bCreateReflectedPropArr(reflectedPropArr));
327
- program.body.push(bGenerateMarkup(attrsAugmentation, classIdentifier, renderCall, classIdentifier));
381
+ program.body.push(bGenerateMarkup(attrsAugmentation, classIdentifier, renderCall));
328
382
  }
329
383
 
330
384
  /*
@@ -442,7 +496,7 @@ function compileJS(src, filename) {
442
496
  // file in question is likely not an LWC. With this v1 implementation,
443
497
  // we'll just return the original source.
444
498
  return {
445
- code: src,
499
+ code: generate(ast, {}),
446
500
  };
447
501
  }
448
502
  if (state.cssExplicitImports || state.staticStylesheetIds) {
@@ -454,27 +508,1199 @@ function compileJS(src, filename) {
454
508
  };
455
509
  }
456
510
 
457
- const bStylesheetTokenDeclaration = esTemplate `
511
+ /**
512
+ * Copyright (c) 2024 Salesforce, Inc.
513
+ */
514
+ /*
515
+ * Copyright (c) 2024, Salesforce, Inc.
516
+ * All rights reserved.
517
+ * SPDX-License-Identifier: MIT
518
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
519
+ */
520
+
521
+ /*
522
+ * Copyright (c) 2018, salesforce.com, inc.
523
+ * All rights reserved.
524
+ * SPDX-License-Identifier: MIT
525
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
526
+ */
527
+ var DiagnosticLevel;
528
+ (function (DiagnosticLevel) {
529
+ /** Unexpected error, parsing error, bundling error */
530
+ DiagnosticLevel[DiagnosticLevel["Fatal"] = 0] = "Fatal";
531
+ /** Linting error with error level, invalid external reference, invalid import, invalid transform */
532
+ DiagnosticLevel[DiagnosticLevel["Error"] = 1] = "Error";
533
+ /** Linting error with warning level, usage of an API to be deprecated */
534
+ DiagnosticLevel[DiagnosticLevel["Warning"] = 2] = "Warning";
535
+ /** Logging messages */
536
+ DiagnosticLevel[DiagnosticLevel["Log"] = 3] = "Log";
537
+ })(DiagnosticLevel || (DiagnosticLevel = {}));
538
+
539
+ /*
540
+ * Copyright (c) 2024, Salesforce, Inc.
541
+ * All rights reserved.
542
+ * SPDX-License-Identifier: MIT
543
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
544
+ */
545
+ /*
546
+ * For the next available error code, reference (and update!) the value in ./index.ts
547
+ */
548
+ ({
549
+ code: 1001,
550
+ message: 'Unexpected compilation error: {0}',
551
+ level: DiagnosticLevel.Error,
552
+ url: '',
553
+ });
554
+ ({
555
+ INVALID_COMPAT_PROPERTY: {
556
+ code: 1013,
557
+ message: 'Expected a boolean for outputConfig.compat, received "{0}".',
558
+ level: DiagnosticLevel.Error,
559
+ url: '',
560
+ },
561
+ INVALID_ENV_ENTRY_VALUE: {
562
+ code: 1014,
563
+ message: 'Expected a string for outputConfig.env["{0}"], received "{1}".',
564
+ level: DiagnosticLevel.Error,
565
+ url: '',
566
+ },
567
+ INVALID_ENV_PROPERTY: {
568
+ code: 1015,
569
+ message: 'Expected an object for outputConfig.env, received "{0}".',
570
+ level: DiagnosticLevel.Error,
571
+ url: '',
572
+ },
573
+ INVALID_FILES_PROPERTY: {
574
+ code: 1016,
575
+ message: 'Expected an object with files to be compiled.',
576
+ level: DiagnosticLevel.Error,
577
+ url: '',
578
+ },
579
+ INVALID_NAME_PROPERTY: {
580
+ code: 1018,
581
+ message: 'Expected a string for name, received "{0}".',
582
+ level: DiagnosticLevel.Error,
583
+ url: '',
584
+ },
585
+ INVALID_NAMESPACE_PROPERTY: {
586
+ code: 1019,
587
+ message: 'Expected a string for namespace, received "{0}".',
588
+ level: DiagnosticLevel.Error,
589
+ url: '',
590
+ },
591
+ INVALID_SOURCEMAP_PROPERTY: {
592
+ code: 1021,
593
+ message: 'Expected a boolean value or \'inline\' for outputConfig.sourcemap, received "{0}".',
594
+ level: DiagnosticLevel.Error,
595
+ url: '',
596
+ },
597
+ MISSING_OPTIONS_OBJECT: {
598
+ code: 1023,
599
+ message: 'Expected options object, received "{0}".',
600
+ level: DiagnosticLevel.Error,
601
+ url: '',
602
+ },
603
+ UNEXPECTED_FILE_CONTENT: {
604
+ code: 1024,
605
+ message: 'Unexpected file content for "{0}". Expected a string, received "{1}".',
606
+ level: DiagnosticLevel.Error,
607
+ url: '',
608
+ },
609
+ UNKNOWN_ENV_ENTRY_KEY: {
610
+ code: 1025,
611
+ message: 'Unknown entry "{0}" in outputConfig.env.',
612
+ level: DiagnosticLevel.Error,
613
+ url: '',
614
+ },
615
+ });
616
+ ({
617
+ MODULE_RESOLUTION_ERROR: {
618
+ code: 1002,
619
+ message: 'Error in module resolution: {0}',
620
+ level: DiagnosticLevel.Warning,
621
+ url: '',
622
+ },
623
+ IMPORTEE_RESOLUTION_FAILED: {
624
+ code: 1010,
625
+ message: 'Failed to resolve entry for module "{0}".',
626
+ level: DiagnosticLevel.Error,
627
+ url: '',
628
+ },
629
+ IMPORTEE_RESOLUTION_FROM_IMPORTER_FAILED: {
630
+ code: 1011,
631
+ message: 'Failed to resolve import "{0}" from "{1}". Please add "{2}" file to the component folder.',
632
+ level: DiagnosticLevel.Error,
633
+ url: '',
634
+ },
635
+ NONEXISTENT_FILE: {
636
+ code: 1004,
637
+ message: 'No such file {0}',
638
+ level: DiagnosticLevel.Error,
639
+ url: '',
640
+ },
641
+ FOLDER_NAME_STARTS_WITH_CAPITAL_LETTER: {
642
+ code: 1116,
643
+ message: 'Illegal folder name "{0}". The folder name must start with a lowercase character: "{1}".',
644
+ level: DiagnosticLevel.Error,
645
+ url: '',
646
+ },
647
+ FOLDER_AND_FILE_NAME_CASE_MISMATCH: {
648
+ code: 1117,
649
+ message: 'Failed to resolve "{0}". The file name must case match the component folder name "{1}".',
650
+ level: DiagnosticLevel.Error,
651
+ url: '',
652
+ },
653
+ IMPORT_AND_FILE_NAME_CASE_MISMATCH: {
654
+ code: 1118,
655
+ message: 'Failed to resolve "{0}" from "{1}". Did you mean "{2}"?',
656
+ level: DiagnosticLevel.Error,
657
+ url: '',
658
+ },
659
+ RELATIVE_DYNAMIC_IMPORT: {
660
+ code: 1120,
661
+ message: 'Illegal usage of the dynamic import syntax with a relative path.',
662
+ level: DiagnosticLevel.Error,
663
+ url: '',
664
+ },
665
+ });
666
+ ({
667
+ CSS_TRANSFORMER_ERROR: {
668
+ code: 1009,
669
+ message: '{0}',
670
+ level: DiagnosticLevel.Error,
671
+ url: '',
672
+ },
673
+ CSS_IN_HTML_ERROR: {
674
+ code: 1026,
675
+ message: 'An error occurred parsing inline CSS. {0}',
676
+ level: DiagnosticLevel.Error,
677
+ url: '',
678
+ },
679
+ HTML_TRANSFORMER_ERROR: {
680
+ code: 1008,
681
+ message: '{0}',
682
+ level: DiagnosticLevel.Error,
683
+ url: '',
684
+ },
685
+ INVALID_ID: {
686
+ code: 1027,
687
+ message: 'Expect a string for id. Received {0}',
688
+ level: DiagnosticLevel.Error,
689
+ url: '',
690
+ },
691
+ INVALID_SOURCE: {
692
+ code: 1006,
693
+ message: 'Expect a string for source. Received {0}',
694
+ level: DiagnosticLevel.Error,
695
+ url: '',
696
+ },
697
+ JS_TRANSFORMER_ERROR: {
698
+ code: 1007,
699
+ message: '{0}',
700
+ level: DiagnosticLevel.Error,
701
+ url: '',
702
+ },
703
+ NO_AVAILABLE_TRANSFORMER: {
704
+ code: 1005,
705
+ message: 'No available transformer for "{0}"',
706
+ level: DiagnosticLevel.Error,
707
+ url: '',
708
+ },
709
+ JS_TRANSFORMER_DECORATOR_ERROR: {
710
+ code: 1198,
711
+ message: 'Decorators like @api, @track, and @wire are only supported in LightningElement classes. {0}',
712
+ level: DiagnosticLevel.Error,
713
+ url: '',
714
+ },
715
+ });
716
+
717
+ /*
718
+ * Copyright (c) 2024, Salesforce, Inc.
719
+ * All rights reserved.
720
+ * SPDX-License-Identifier: MIT
721
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
722
+ */
723
+ /*
724
+ * For the next available error code, reference (and update!) the value in ./index.ts
725
+ */
726
+ ({
727
+ INVALID_DYNAMIC_IMPORT_SOURCE_STRICT: {
728
+ code: 1121,
729
+ message: 'Invalid import. The argument "{0}" must be a stringLiteral for dynamic imports when strict mode is enabled.',
730
+ url: '',
731
+ level: DiagnosticLevel.Error,
732
+ },
733
+ });
734
+ ({
735
+ ADAPTER_SHOULD_BE_FIRST_PARAMETER: {
736
+ code: 1092,
737
+ message: '@wire expects an adapter as first parameter. @wire(adapter: WireAdapter, config?: any).',
738
+ level: DiagnosticLevel.Error,
739
+ url: '',
740
+ },
741
+ API_AND_TRACK_DECORATOR_CONFLICT: {
742
+ code: 1093,
743
+ message: '@api method or property cannot be used with @track',
744
+ level: DiagnosticLevel.Error,
745
+ url: '',
746
+ },
747
+ CONFIG_OBJECT_SHOULD_BE_SECOND_PARAMETER: {
748
+ code: 1094,
749
+ message: '@wire expects a configuration object expression as second parameter.',
750
+ level: DiagnosticLevel.Error,
751
+ url: '',
752
+ },
753
+ CONFLICT_WITH_ANOTHER_DECORATOR: {
754
+ code: 1095,
755
+ message: '@wire method or property cannot be used with @{0}',
756
+ level: DiagnosticLevel.Error,
757
+ url: '',
758
+ },
759
+ DUPLICATE_API_PROPERTY: {
760
+ code: 1096,
761
+ message: 'Duplicate @api property "{0}".',
762
+ level: DiagnosticLevel.Error,
763
+ url: '',
764
+ },
765
+ FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER: {
766
+ code: 1097,
767
+ message: '@wire expects a function identifier as first parameter.',
768
+ level: DiagnosticLevel.Error,
769
+ url: '',
770
+ },
771
+ IMPORTED_FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER: {
772
+ code: 1098,
773
+ message: '@wire expects a function identifier to be imported as first parameter.',
774
+ level: DiagnosticLevel.Error,
775
+ url: '',
776
+ },
777
+ INVALID_BOOLEAN_PUBLIC_PROPERTY: {
778
+ code: 1099,
779
+ message: 'Boolean public property must default to false.',
780
+ level: DiagnosticLevel.Error,
781
+ url: '',
782
+ },
783
+ INVALID_DECORATOR: {
784
+ code: 1100,
785
+ message: 'Invalid decorator usage. Supported decorators ({0}) should be imported from "{1}"',
786
+ level: DiagnosticLevel.Error,
787
+ url: '',
788
+ },
789
+ INVALID_DECORATOR_TYPE: {
790
+ code: 1101,
791
+ message: 'Invalid property of field type',
792
+ level: DiagnosticLevel.Error,
793
+ url: '',
794
+ },
795
+ INVALID_DECORATOR_WITH_NAME: {
796
+ code: 1102,
797
+ message: 'Invalid \'{0}\' decorator usage. Supported decorators ({1}) should be imported from "{2}"',
798
+ level: DiagnosticLevel.Error,
799
+ url: '',
800
+ },
801
+ IS_NOT_CLASS_PROPERTY_OR_CLASS_METHOD: {
802
+ code: 1103,
803
+ message: '"@{0}" can only be applied on class properties',
804
+ level: DiagnosticLevel.Error,
805
+ url: '',
806
+ },
807
+ IS_NOT_DECORATOR: {
808
+ code: 1104,
809
+ message: '"{0}" can only be used as a class decorator',
810
+ level: DiagnosticLevel.Error,
811
+ url: '',
812
+ },
813
+ ONE_WIRE_DECORATOR_ALLOWED: {
814
+ code: 1105,
815
+ message: 'Method or property can only have 1 @wire decorator',
816
+ level: DiagnosticLevel.Error,
817
+ url: '',
818
+ },
819
+ PROPERTY_CANNOT_BE_COMPUTED: {
820
+ code: 1106,
821
+ message: '@api cannot be applied to a computed property, getter, setter or method.',
822
+ level: DiagnosticLevel.Error,
823
+ url: '',
824
+ },
825
+ PROPERTY_NAME_CANNOT_START_WITH_DATA: {
826
+ code: 1107,
827
+ message: 'Invalid property name "{0}". Properties starting with "data" are reserved attributes.',
828
+ level: DiagnosticLevel.Error,
829
+ url: '',
830
+ },
831
+ PROPERTY_NAME_CANNOT_START_WITH_ON: {
832
+ code: 1108,
833
+ message: 'Invalid property name "{0}". Properties starting with "on" are reserved for event handlers.',
834
+ level: DiagnosticLevel.Error,
835
+ url: '',
836
+ },
837
+ PROPERTY_NAME_IS_AMBIGUOUS: {
838
+ code: 1109,
839
+ message: 'Ambiguous attribute name "{0}". "{0}" will never be called from template because its corresponding property is camel cased. Consider renaming to "{1}".',
840
+ level: DiagnosticLevel.Error,
841
+ url: '',
842
+ },
843
+ PROPERTY_NAME_IS_RESERVED: {
844
+ code: 1110,
845
+ message: 'Invalid property name "{0}". "{0}" is a reserved attribute.',
846
+ level: DiagnosticLevel.Error,
847
+ url: '',
848
+ },
849
+ PROPERTY_NAME_PART_IS_RESERVED: {
850
+ code: 1111,
851
+ message: 'Invalid property name "{0}". "part" is a future reserved attribute for web components.',
852
+ level: DiagnosticLevel.Error,
853
+ url: '',
854
+ },
855
+ SINGLE_DECORATOR_ON_SETTER_GETTER_PAIR: {
856
+ code: 1112,
857
+ message: '@api get {0} and @api set {0} detected in class declaration. Only one of the two needs to be decorated with @api.',
858
+ level: DiagnosticLevel.Error,
859
+ url: '',
860
+ },
861
+ TRACK_ONLY_ALLOWED_ON_CLASS_PROPERTIES: {
862
+ code: 1113,
863
+ message: '@track decorator can only be applied to class properties.',
864
+ level: DiagnosticLevel.Error,
865
+ url: '',
866
+ },
867
+ WIRE_ADAPTER_SHOULD_BE_IMPORTED: {
868
+ code: 1119,
869
+ message: 'Failed to resolve @wire adapter "{0}". Ensure it is imported.',
870
+ level: DiagnosticLevel.Error,
871
+ url: '',
872
+ },
873
+ FUNCTION_IDENTIFIER_CANNOT_HAVE_COMPUTED_PROPS: {
874
+ code: 1131,
875
+ message: '@wire identifier cannot contain computed properties',
876
+ level: DiagnosticLevel.Error,
877
+ url: '',
878
+ },
879
+ FUNCTION_IDENTIFIER_CANNOT_HAVE_NESTED_MEMBER_EXRESSIONS: {
880
+ code: 1132,
881
+ message: '@wire identifier cannot contain nested member expressions',
882
+ level: DiagnosticLevel.Error,
883
+ url: '',
884
+ },
885
+ COMPUTED_PROPERTY_CANNOT_BE_TEMPLATE_LITERAL: {
886
+ code: 1199,
887
+ message: 'Cannot use a template literal as a computed property key. Instead, use a string or extract the value to a constant.',
888
+ level: DiagnosticLevel.Error,
889
+ url: '',
890
+ },
891
+ COMPUTED_PROPERTY_MUST_BE_CONSTANT_OR_LITERAL: {
892
+ code: 1200,
893
+ message: 'Computed property in @wire config must be a constant or primitive literal.',
894
+ level: DiagnosticLevel.Error,
895
+ url: '',
896
+ },
897
+ });
898
+
899
+ /*
900
+ * Copyright (c) 2024, Salesforce, Inc.
901
+ * All rights reserved.
902
+ * SPDX-License-Identifier: MIT
903
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
904
+ */
905
+ /*
906
+ * For the next available error code, reference (and update!) the value in ./index.ts
907
+ */
908
+ ({
909
+ INVALID_TEMPLATE: {
910
+ code: 1003,
911
+ message: 'Invalid template',
912
+ level: DiagnosticLevel.Error,
913
+ url: '',
914
+ },
915
+ OPTIONS_MUST_BE_OBJECT: {
916
+ code: 1028,
917
+ message: 'Compiler options must be an object',
918
+ level: DiagnosticLevel.Error,
919
+ url: '',
920
+ },
921
+ UNKNOWN_IF_MODIFIER: {
922
+ code: 1029,
923
+ message: 'Unknown if modifier {0}',
924
+ level: DiagnosticLevel.Error,
925
+ url: '',
926
+ },
927
+ UNKNOWN_OPTION_PROPERTY: {
928
+ code: 1030,
929
+ message: 'Unknown option property {0}',
930
+ level: DiagnosticLevel.Error,
931
+ url: '',
932
+ },
933
+ DUPLICATE_ELEMENT_ENTRY: {
934
+ code: 1150,
935
+ message: 'customRendererConfig contains duplicate entry for {0} element tag',
936
+ level: DiagnosticLevel.Error,
937
+ url: '',
938
+ },
939
+ CUSTOM_ELEMENT_TAG_DISALLOWED: {
940
+ code: 1151,
941
+ message: 'customRendererConfig should not contain a custom element tag, but found {0}',
942
+ level: DiagnosticLevel.Error,
943
+ url: '',
944
+ },
945
+ });
946
+ ({
947
+ AMBIGUOUS_ATTRIBUTE_VALUE: {
948
+ code: 1034,
949
+ message: 'Ambiguous attribute value {0}. ' +
950
+ 'If you want to make it a valid identifier you should remove the surrounding quotes {1}. ' +
951
+ 'If you want to make it a string you should escape it {2}.',
952
+ level: DiagnosticLevel.Error,
953
+ url: '',
954
+ },
955
+ AMBIGUOUS_ATTRIBUTE_VALUE_STRING: {
956
+ code: 1035,
957
+ message: 'Ambiguous attribute value {0}. If you want to make it a string you should escape it {1}',
958
+ level: DiagnosticLevel.Error,
959
+ url: '',
960
+ },
961
+ BOOLEAN_ATTRIBUTE_FALSE: {
962
+ code: 1036,
963
+ message: 'To not set a boolean attribute, try <{0}> instead of <{0} {1}="{2}">. ' +
964
+ 'To represent a false value, the attribute has to be omitted altogether.',
965
+ level: DiagnosticLevel.Error,
966
+ url: '',
967
+ },
968
+ BOOLEAN_ATTRIBUTE_TRUE: {
969
+ code: 1037,
970
+ message: 'To set a boolean attributes, try <{0} {1}> instead of <{0} {1}="{2}">. ' +
971
+ 'If the attribute is present, its value must either be the empty string ' +
972
+ "or a value that is an ASCII case -insensitive match for the attribute's canonical name " +
973
+ 'with no leading or trailing whitespace.',
974
+ level: DiagnosticLevel.Error,
975
+ url: '',
976
+ },
977
+ COMPUTED_PROPERTY_ACCESS_NOT_ALLOWED: {
978
+ code: 1038,
979
+ message: "Template expression doesn't allow computed property access",
980
+ level: DiagnosticLevel.Error,
981
+ url: '',
982
+ },
983
+ DIRECTIVE_SHOULD_BE_EXPRESSION: {
984
+ code: 1039,
985
+ message: '{0} directive is expected to be an expression',
986
+ level: DiagnosticLevel.Error,
987
+ url: '',
988
+ },
989
+ INVALID_ID_ATTRIBUTE: {
990
+ code: 1040,
991
+ message: 'Invalid id value "{0}". Id values must not contain any whitespace.',
992
+ level: DiagnosticLevel.Error,
993
+ url: '',
994
+ },
995
+ INVALID_STATIC_ID_IN_ITERATION: {
996
+ code: 1041,
997
+ message: 'Static id values are not allowed in iterators. Id values must be unique within a template and must therefore be computed with an expression.',
998
+ level: DiagnosticLevel.Warning,
999
+ url: '',
1000
+ },
1001
+ DUPLICATE_ID_FOUND: {
1002
+ code: 1042,
1003
+ message: 'Duplicate id value "{0}" detected. Id values must be unique within a template.',
1004
+ level: DiagnosticLevel.Error,
1005
+ url: '',
1006
+ },
1007
+ EVENT_HANDLER_SHOULD_BE_EXPRESSION: {
1008
+ code: 1043,
1009
+ message: 'Event handler should be an expression',
1010
+ level: DiagnosticLevel.Error,
1011
+ url: '',
1012
+ },
1013
+ FOR_EACH_AND_FOR_ITEM_DIRECTIVES_SHOULD_BE_TOGETHER: {
1014
+ code: 1044,
1015
+ message: 'for:each and for:item directives should be associated together.',
1016
+ level: DiagnosticLevel.Error,
1017
+ url: '',
1018
+ },
1019
+ FOR_EACH_DIRECTIVE_SHOULD_BE_EXPRESSION: {
1020
+ code: 1045,
1021
+ message: 'for:each directive is expected to be a expression.',
1022
+ level: DiagnosticLevel.Error,
1023
+ url: '',
1024
+ },
1025
+ FOR_INDEX_DIRECTIVE_SHOULD_BE_STRING: {
1026
+ code: 1046,
1027
+ message: 'for:index directive is expected to be a string.',
1028
+ level: DiagnosticLevel.Error,
1029
+ url: '',
1030
+ },
1031
+ FOR_ITEM_DIRECTIVE_SHOULD_BE_STRING: {
1032
+ code: 1047,
1033
+ message: 'for:item directive is expected to be a string.',
1034
+ level: DiagnosticLevel.Error,
1035
+ url: '',
1036
+ },
1037
+ FORBIDDEN_IFRAME_SRCDOC_ATTRIBUTE: {
1038
+ code: 1048,
1039
+ message: 'srcdoc attribute is disallowed on <iframe> for security reasons',
1040
+ level: DiagnosticLevel.Error,
1041
+ url: '',
1042
+ },
1043
+ FORBIDDEN_SVG_NAMESPACE_IN_TEMPLATE: {
1044
+ code: 1049,
1045
+ message: "Forbidden svg namespace tag found in template: '<{0}>' tag is not allowed within <svg>",
1046
+ level: DiagnosticLevel.Error,
1047
+ url: '',
1048
+ },
1049
+ FORBIDDEN_MATHML_NAMESPACE_IN_TEMPLATE: {
1050
+ code: 1050,
1051
+ message: "Forbidden MathML namespace tag found in template: '<{0}>' tag is not allowed within <math>",
1052
+ level: DiagnosticLevel.Error,
1053
+ url: '',
1054
+ },
1055
+ FORBIDDEN_TAG_ON_TEMPLATE: {
1056
+ code: 1051,
1057
+ message: "Forbidden tag found in template: '<{0}>' tag is not allowed.",
1058
+ level: DiagnosticLevel.Error,
1059
+ url: '',
1060
+ },
1061
+ GENERIC_PARSING_ERROR: {
1062
+ code: 1052,
1063
+ message: 'Error parsing attribute: {0}',
1064
+ level: DiagnosticLevel.Error,
1065
+ url: '',
1066
+ },
1067
+ IDENTIFIER_PARSING_ERROR: {
1068
+ code: 1053,
1069
+ message: 'Error parsing identifier: {0}',
1070
+ level: DiagnosticLevel.Error,
1071
+ url: '',
1072
+ },
1073
+ IF_DIRECTIVE_SHOULD_BE_EXPRESSION: {
1074
+ code: 1054,
1075
+ message: 'If directive should be an expression',
1076
+ level: DiagnosticLevel.Error,
1077
+ url: '',
1078
+ },
1079
+ INVALID_ATTRIBUTE_CASE: {
1080
+ code: 1055,
1081
+ message: '{0} is not valid attribute for {1}. All attributes name should be all lowercase.',
1082
+ level: DiagnosticLevel.Error,
1083
+ url: '',
1084
+ },
1085
+ INVALID_EVENT_NAME: {
1086
+ code: 1056,
1087
+ message: 'Invalid event type "{0}". Event type must begin with a lower-case alphabetic character and contain only lower-case alphabetic characters, underscores, and numeric characters',
1088
+ level: DiagnosticLevel.Error,
1089
+ url: '',
1090
+ },
1091
+ INVALID_HTML_ATTRIBUTE: {
1092
+ code: 1057,
1093
+ message: '{0} is not valid attribute for {1}. For more information refer to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/{1}',
1094
+ level: DiagnosticLevel.Warning,
1095
+ url: '',
1096
+ },
1097
+ INVALID_HTML_SYNTAX: {
1098
+ code: 1058,
1099
+ message: 'Invalid HTML syntax: {0}. For more information, ' +
1100
+ 'please visit https://html.spec.whatwg.org/multipage/parsing.html#parse-error-{0}',
1101
+ level: DiagnosticLevel.Error,
1102
+ url: '',
1103
+ },
1104
+ INVALID_IDENTIFIER: {
1105
+ code: 1059,
1106
+ message: '{0} is not a valid identifier',
1107
+ level: DiagnosticLevel.Error,
1108
+ url: '',
1109
+ },
1110
+ INVALID_NODE: {
1111
+ code: 1060,
1112
+ message: "Template expression doesn't allow {0}",
1113
+ level: DiagnosticLevel.Error,
1114
+ url: '',
1115
+ },
1116
+ INVALID_TABINDEX_ATTRIBUTE: {
1117
+ code: 1061,
1118
+ message: 'The attribute "tabindex" can only be set to "0" or "-1".',
1119
+ level: DiagnosticLevel.Error,
1120
+ url: '',
1121
+ },
1122
+ DEPRECATED_IS_ATTRIBUTE_CANNOT_BE_EXPRESSION: {
1123
+ code: 1062,
1124
+ message: '"is" attribute value can\'t be an expression',
1125
+ level: DiagnosticLevel.Error,
1126
+ url: '',
1127
+ },
1128
+ IS_ATTRIBUTE_NOT_SUPPORTED: {
1129
+ code: 1063,
1130
+ message: '"is" attribute is disallowed',
1131
+ level: DiagnosticLevel.Error,
1132
+ url: '',
1133
+ },
1134
+ KEY_ATTRIBUTE_SHOULD_BE_EXPRESSION: {
1135
+ code: 1064,
1136
+ message: 'Key attribute value should be an expression',
1137
+ level: DiagnosticLevel.Error,
1138
+ url: '',
1139
+ },
1140
+ KEY_SHOULDNT_REFERENCE_FOR_EACH_INDEX: {
1141
+ code: 1065,
1142
+ message: 'Invalid key value for element <{0}>. Key cannot reference for:each index {1}',
1143
+ level: DiagnosticLevel.Error,
1144
+ url: '',
1145
+ },
1146
+ KEY_SHOULDNT_REFERENCE_ITERATOR_INDEX: {
1147
+ code: 1066,
1148
+ message: 'Invalid key value for element <{0}>. Key cannot reference iterator index',
1149
+ level: DiagnosticLevel.Error,
1150
+ url: '',
1151
+ },
1152
+ MISSING_KEY_IN_ITERATOR: {
1153
+ code: 1071,
1154
+ message: 'Missing key for element <{0}> inside of iterator. Elements within iterators must have a unique, computed key value.',
1155
+ level: DiagnosticLevel.Error,
1156
+ url: '',
1157
+ },
1158
+ MISSING_ROOT_TEMPLATE_TAG: {
1159
+ code: 1072,
1160
+ message: 'Missing root template tag',
1161
+ level: DiagnosticLevel.Error,
1162
+ url: '',
1163
+ },
1164
+ MODIFYING_ITERATORS_NOT_ALLOWED: {
1165
+ code: 1073,
1166
+ message: "Template expression doesn't allow to modify iterators",
1167
+ level: DiagnosticLevel.Error,
1168
+ url: '',
1169
+ },
1170
+ MULTIPLE_EXPRESSIONS: {
1171
+ code: 1074,
1172
+ message: 'Multiple expressions found',
1173
+ level: DiagnosticLevel.Error,
1174
+ url: '',
1175
+ },
1176
+ MULTIPLE_ROOTS_FOUND: {
1177
+ code: 1075,
1178
+ message: 'Multiple roots found',
1179
+ level: DiagnosticLevel.Error,
1180
+ url: '',
1181
+ },
1182
+ NAME_ON_SLOT_CANNOT_BE_EXPRESSION: {
1183
+ code: 1076,
1184
+ message: "Name attribute on slot tag can't be an expression.",
1185
+ level: DiagnosticLevel.Error,
1186
+ url: '',
1187
+ },
1188
+ NO_DIRECTIVE_FOUND_ON_TEMPLATE: {
1189
+ code: 1077,
1190
+ message: 'Invalid template tag. A directive is expected to be associated with the template tag.',
1191
+ level: DiagnosticLevel.Error,
1192
+ url: '',
1193
+ },
1194
+ NO_MATCHING_CLOSING_TAGS: {
1195
+ code: 1078,
1196
+ message: '<{0}> has no matching closing tag.',
1197
+ level: DiagnosticLevel.Error,
1198
+ url: '',
1199
+ },
1200
+ ROOT_TAG_SHOULD_BE_TEMPLATE: {
1201
+ code: 1079,
1202
+ message: 'Expected root tag to be template, found {0}',
1203
+ level: DiagnosticLevel.Error,
1204
+ url: '',
1205
+ },
1206
+ ROOT_TEMPLATE_HAS_UNKNOWN_ATTRIBUTES: {
1207
+ code: 1080,
1208
+ message: 'Root template has unknown or disallowed attributes: {0}',
1209
+ level: DiagnosticLevel.Error,
1210
+ url: '',
1211
+ },
1212
+ // TODO [#3100]: Update message to point to external documentation once available.
1213
+ SLOT_TAG_CANNOT_HAVE_DIRECTIVES: {
1214
+ code: 1082,
1215
+ message: "<slot> tag can't be associated with {0} template directives.",
1216
+ level: DiagnosticLevel.Error,
1217
+ url: '',
1218
+ },
1219
+ TEMPLATE_EXPRESSION_PARSING_ERROR: {
1220
+ code: 1083,
1221
+ message: 'Error parsing template expression: {0}',
1222
+ level: DiagnosticLevel.Error,
1223
+ url: '',
1224
+ },
1225
+ UNEXPECTED_IF_MODIFIER: {
1226
+ code: 1084,
1227
+ message: 'Unexpected if modifier {0}',
1228
+ level: DiagnosticLevel.Error,
1229
+ url: '',
1230
+ },
1231
+ LWC_DOM_INVALID_VALUE: {
1232
+ code: 1085,
1233
+ message: 'Invalid value for "lwc:dom". \'lwc:dom\' can only be set to {0}',
1234
+ level: DiagnosticLevel.Error,
1235
+ url: '',
1236
+ },
1237
+ LWC_DOM_INVALID_CONTENTS: {
1238
+ code: 1086,
1239
+ message: 'Invalid contents for element with "lwc:dom". Element must be empty',
1240
+ level: DiagnosticLevel.Error,
1241
+ url: '',
1242
+ },
1243
+ LWC_DOM_INVALID_CUSTOM_ELEMENT: {
1244
+ code: 1087,
1245
+ message: 'Invalid directive "lwc:dom" on element {0}. "lwc:dom" cannot be added to a custom element',
1246
+ level: DiagnosticLevel.Error,
1247
+ url: '',
1248
+ },
1249
+ LWC_DOM_INVALID_SLOT_ELEMENT: {
1250
+ code: 1088,
1251
+ message: 'Invalid directive "lwc:dom" on <slot>.. "lwc:dom" cannot be added to a <slot>',
1252
+ level: DiagnosticLevel.Error,
1253
+ url: '',
1254
+ },
1255
+ STYLE_TAG_NOT_ALLOWED_IN_TEMPLATE: {
1256
+ code: 1122,
1257
+ message: "The <style> element is disallowed inside the template. Please add css rules into '.css' file of your component bundle.",
1258
+ level: DiagnosticLevel.Error,
1259
+ url: '',
1260
+ },
1261
+ UNKNOWN_HTML_TAG_IN_TEMPLATE: {
1262
+ code: 1123,
1263
+ message: "Unknown html tag '<{0}>'. For more information refer to https://developer.mozilla.org/en-US/docs/Web/HTML/Element and https://developer.mozilla.org/en-US/docs/Web/SVG/Element",
1264
+ level: DiagnosticLevel.Warning,
1265
+ url: '',
1266
+ },
1267
+ ATTRIBUTE_NAME_STARTS_WITH_INVALID_CHARACTER: {
1268
+ code: 1124,
1269
+ message: '{0} is not valid attribute for {1}. Attribute name must start with an underscore, dollar sign, or an optional hyphen character followed by an alphabetic character.',
1270
+ level: DiagnosticLevel.Error,
1271
+ url: '',
1272
+ },
1273
+ ATTRIBUTE_NAME_MUST_END_WITH_ALPHA_NUMERIC_CHARACTER: {
1274
+ code: 1125,
1275
+ message: '{0} is not valid attribute for {1}. Attribute name must end with alpha-numeric character.',
1276
+ level: DiagnosticLevel.Error,
1277
+ url: '',
1278
+ },
1279
+ UNKNOWN_LWC_DIRECTIVE: {
1280
+ code: 1127,
1281
+ message: 'Invalid directive "{0}" on element {1}.',
1282
+ level: DiagnosticLevel.Error,
1283
+ url: '',
1284
+ },
1285
+ INVALID_OPTS_LWC_DYNAMIC: {
1286
+ code: 1128,
1287
+ message: 'Invalid lwc:dynamic usage. The LWC dynamic directive must be enabled in order to use this feature.',
1288
+ level: DiagnosticLevel.Error,
1289
+ url: '',
1290
+ },
1291
+ INVALID_LWC_DYNAMIC_ON_NATIVE_ELEMENT: {
1292
+ code: 1129,
1293
+ message: 'Invalid lwc:dynamic usage on element "{0}". This directive can only be used in a custom element.',
1294
+ level: DiagnosticLevel.Error,
1295
+ url: '',
1296
+ },
1297
+ INVALID_LWC_DYNAMIC_LITERAL_PROP: {
1298
+ code: 1130,
1299
+ message: 'Invalid lwc:dynamic usage on element "{0}". The directive binding must be an expression.',
1300
+ level: DiagnosticLevel.Error,
1301
+ url: '',
1302
+ },
1303
+ LWC_RENDER_MODE_INVALID_VALUE: {
1304
+ code: 1133,
1305
+ message: 'Invalid value for "lwc:render-mode". \'lwc:render-mode\' can only be set to "shadow", or "light"',
1306
+ level: DiagnosticLevel.Error,
1307
+ url: '',
1308
+ },
1309
+ LWC_LIGHT_SLOT_INVALID_ATTRIBUTES: {
1310
+ code: 1134,
1311
+ message: "Invalid attribute(s) '{0}' on slot. Slots in Light DOM templates (which have 'lwc:render-mode' directive) can only have [{1}] attributes",
1312
+ level: DiagnosticLevel.Error,
1313
+ url: '',
1314
+ },
1315
+ LWC_DOM_INVALID_IN_LIGHT_DOM: {
1316
+ code: 1135,
1317
+ message: "Invalid directive 'lwc:dom' on element {0}. 'lwc:dom' is not necessary in Light DOM components.",
1318
+ level: DiagnosticLevel.Error,
1319
+ url: '',
1320
+ },
1321
+ INVALID_FOR_EACH_WITH_ITERATOR: {
1322
+ code: 1136,
1323
+ message: "Invalid usage for 'for:each' and '{0}' directives on the same element.",
1324
+ level: DiagnosticLevel.Error,
1325
+ url: '',
1326
+ },
1327
+ NO_DUPLICATE_SLOTS: {
1328
+ code: 1137,
1329
+ message: 'Invalid duplicate slot ({0}).',
1330
+ level: DiagnosticLevel.Warning,
1331
+ url: '',
1332
+ },
1333
+ NO_SLOTS_IN_ITERATOR: {
1334
+ code: 1138,
1335
+ message: 'Invalid slot ({0}). A slot cannot appear inside of an iterator.',
1336
+ level: DiagnosticLevel.Warning,
1337
+ url: '',
1338
+ },
1339
+ LWC_LIGHT_SLOT_INVALID_EVENT_LISTENER: {
1340
+ code: 1139,
1341
+ message: "Invalid event listener '{0}' on slot. Slots in Light DOM templates cannot have event listeners.",
1342
+ level: DiagnosticLevel.Error,
1343
+ url: '',
1344
+ },
1345
+ LWC_INNER_HTML_INVALID_CUSTOM_ELEMENT: {
1346
+ code: 1140,
1347
+ message: 'Invalid lwc:inner-html usage on element "{0}". The directive can\'t be used on a custom element or special LWC managed elements denoted with lwc:*.',
1348
+ level: DiagnosticLevel.Error,
1349
+ url: '',
1350
+ },
1351
+ LWC_INNER_HTML_INVALID_ELEMENT: {
1352
+ code: 1141,
1353
+ message: 'Invalid lwc:inner-html usage on element "{0}". The directive can\'t be used on a slot or a template element.',
1354
+ level: DiagnosticLevel.Error,
1355
+ url: '',
1356
+ },
1357
+ LWC_INNER_HTML_INVALID_CONTENTS: {
1358
+ code: 1142,
1359
+ message: 'Invalid lwc:inner-html usage on element "{0}". The directive can\'t be used on an element with content.',
1360
+ level: DiagnosticLevel.Error,
1361
+ url: '',
1362
+ },
1363
+ LWC_INNER_HTML_INVALID_VALUE: {
1364
+ code: 1143,
1365
+ message: 'Invalid lwc:inner-html usage on element "{0}". The directive binding can only be an expression or a string.',
1366
+ level: DiagnosticLevel.Error,
1367
+ url: '',
1368
+ },
1369
+ INVALID_HTML_RECOVERY: {
1370
+ code: 1144,
1371
+ message: 'Invalid HTML detected, "<{0}>" was automatically inserted within "<{1}>"; the compiled template may not match the template source.',
1372
+ level: DiagnosticLevel.Warning,
1373
+ url: '',
1374
+ },
1375
+ INVALID_TEMPLATE_ATTRIBUTE: {
1376
+ code: 1145,
1377
+ message: 'Invalid attributes detected on template. The following attributes are not supported on template tags in LWC: {0}. For more information, ' +
1378
+ 'please visit https://sfdc.co/template-directives',
1379
+ level: DiagnosticLevel.Warning,
1380
+ url: '',
1381
+ },
1382
+ PRESERVE_COMMENTS_MUST_BE_BOOLEAN: {
1383
+ code: 1146,
1384
+ message: 'lwc:preserve-comments must be a boolean attribute.',
1385
+ level: DiagnosticLevel.Error,
1386
+ url: '',
1387
+ },
1388
+ DUPLICATE_ATTR_PROP_TRANSFORM: {
1389
+ code: 1147,
1390
+ message: 'Found multiple HTML attributes mapping to the same JavaScript property. "{0}" and "{1}" both map to "{2}".',
1391
+ level: DiagnosticLevel.Warning,
1392
+ url: '',
1393
+ },
1394
+ INVALID_HTML_SYNTAX_WARNING: {
1395
+ code: 1148,
1396
+ message: 'Invalid HTML syntax: {0}. This will not be supported in future versions of LWC. For more information, ' +
1397
+ 'please visit https://html.spec.whatwg.org/multipage/parsing.html#parse-error-{0}',
1398
+ level: DiagnosticLevel.Warning,
1399
+ url: '',
1400
+ },
1401
+ KEY_SHOULD_BE_IN_ITERATION: {
1402
+ code: 1149,
1403
+ message: 'Invalid key attribute on element <{0}>. The key attribute should be applied to an element with for:each or iterator:*, or to a direct child of a <template> element with for:each or iterator:*. This key will be ignored, and may throw an error in future versions of LWC.',
1404
+ level: DiagnosticLevel.Warning,
1405
+ url: '',
1406
+ },
1407
+ INVALID_TEMPLATE_WARNING: {
1408
+ code: 1153,
1409
+ message: 'Non-root template elements must contain valid LWC template directive attributes. Otherwise, the template and its children will be ignored. ' +
1410
+ 'For more information please visit https://sfdc.co/template-directives',
1411
+ level: DiagnosticLevel.Warning,
1412
+ url: '',
1413
+ },
1414
+ INVALID_LWC_SPREAD_LITERAL_PROP: {
1415
+ code: 1155,
1416
+ message: 'Invalid lwc:spread usage on element "{0}". The directive binding must be an expression.',
1417
+ level: DiagnosticLevel.Error,
1418
+ url: '',
1419
+ },
1420
+ LWC_REF_INVALID_ELEMENT: {
1421
+ code: 1156,
1422
+ message: 'Invalid lwc:ref usage on element "{0}". The directive can\'t be used on a slot or a template element.',
1423
+ level: DiagnosticLevel.Error,
1424
+ url: '',
1425
+ },
1426
+ LWC_REF_INVALID_VALUE: {
1427
+ code: 1157,
1428
+ message: 'Invalid lwc:ref usage on element "{0}". The directive binding must be a non-empty string.',
1429
+ level: DiagnosticLevel.Error,
1430
+ url: '',
1431
+ },
1432
+ LWC_REF_INVALID_LOCATION_INSIDE_ITERATION: {
1433
+ code: 1158,
1434
+ message: 'Invalid lwc:ref usage on element "{0}". lwc:ref cannot be used inside for:each or an iterator.',
1435
+ level: DiagnosticLevel.Error,
1436
+ url: '',
1437
+ },
1438
+ IF_BLOCK_DIRECTIVE_SHOULD_BE_EXPRESSION: {
1439
+ code: 1159,
1440
+ message: 'lwc:if directive value should be an expression',
1441
+ level: DiagnosticLevel.Error,
1442
+ url: '',
1443
+ },
1444
+ ELSEIF_BLOCK_DIRECTIVE_SHOULD_BE_EXPRESSION: {
1445
+ code: 1160,
1446
+ message: 'lwc:elseif directive value should be an expression',
1447
+ level: DiagnosticLevel.Error,
1448
+ url: '',
1449
+ },
1450
+ ELSE_BLOCK_DIRECTIVE_CANNOT_HAVE_VALUE: {
1451
+ code: 1161,
1452
+ message: 'lwc:else directive cannot have a value',
1453
+ level: DiagnosticLevel.Error,
1454
+ url: '',
1455
+ },
1456
+ INVALID_IF_BLOCK_DIRECTIVE_WITH_CONDITIONAL: {
1457
+ code: 1162,
1458
+ message: "Invalid usage of 'lwc:if' and '{0}' directives on the same element.",
1459
+ level: DiagnosticLevel.Error,
1460
+ url: '',
1461
+ },
1462
+ INVALID_ELSEIF_BLOCK_DIRECTIVE_WITH_CONDITIONAL: {
1463
+ code: 1163,
1464
+ message: "Invalid usage of 'lwc:elseif' and '{0}' directives on the same element.",
1465
+ level: DiagnosticLevel.Error,
1466
+ url: '',
1467
+ },
1468
+ INVALID_ELSE_BLOCK_DIRECTIVE_WITH_CONDITIONAL: {
1469
+ code: 1164,
1470
+ message: "Invalid usage of 'lwc:else' and '{0}' directives on the same element.",
1471
+ level: DiagnosticLevel.Error,
1472
+ url: '',
1473
+ },
1474
+ LWC_IF_SCOPE_NOT_FOUND: {
1475
+ code: 1165,
1476
+ message: "'{0}' directive must be used immediately after an element with 'lwc:if' or 'lwc:elseif'. No such element found.",
1477
+ level: DiagnosticLevel.Error,
1478
+ url: '',
1479
+ },
1480
+ LWC_IF_CANNOT_BE_USED_WITH_IF_DIRECTIVE: {
1481
+ code: 1166,
1482
+ message: "'{0}' directive cannot be used with 'lwc:if', 'lwc:elseif', or 'lwc:else directives on the same element.",
1483
+ level: DiagnosticLevel.Error,
1484
+ url: '',
1485
+ },
1486
+ SCOPED_SLOT_BIND_IN_LIGHT_DOM_ONLY: {
1487
+ code: 1169,
1488
+ message: 'Invalid lwc:slot-bind usage on <slot> element. Scoped slots usage is allowed in Light DOM templates only.',
1489
+ level: DiagnosticLevel.Error,
1490
+ url: '',
1491
+ },
1492
+ INVALID_LWC_SLOT_BIND_LITERAL_PROP: {
1493
+ code: 1170,
1494
+ message: 'Invalid lwc:slot-bind usage on element {0}. The directive binding must be an expression.',
1495
+ level: DiagnosticLevel.Error,
1496
+ url: '',
1497
+ },
1498
+ INVALID_LWC_SLOT_BIND_NON_SLOT_ELEMENT: {
1499
+ code: 1171,
1500
+ message: 'Invalid lwc:slot-bind usage on element {0}. The directive can be used on a <slot> element only.',
1501
+ level: DiagnosticLevel.Error,
1502
+ url: '',
1503
+ },
1504
+ NO_DUPLICATE_SCOPED_SLOT: {
1505
+ code: 1172,
1506
+ message: 'Invalid duplicate scoped slots ({0})',
1507
+ level: DiagnosticLevel.Error,
1508
+ url: '',
1509
+ },
1510
+ NO_MIXED_SLOT_TYPES: {
1511
+ code: 1173,
1512
+ message: 'Mixing slot types disallowed for same ({0}) slot.',
1513
+ level: DiagnosticLevel.Error,
1514
+ url: '',
1515
+ },
1516
+ SLOT_DATA_VALUE_SHOULD_BE_STRING: {
1517
+ code: 1174,
1518
+ message: 'lwc:slot-data attribute value is expected to be a string.',
1519
+ level: DiagnosticLevel.Error,
1520
+ url: '',
1521
+ },
1522
+ SCOPED_SLOT_DATA_ON_TEMPLATE_ONLY: {
1523
+ code: 1176,
1524
+ message: 'lwc:slot-data directive can be used on <template> elements only.',
1525
+ level: DiagnosticLevel.Error,
1526
+ url: '',
1527
+ },
1528
+ NON_ELEMENT_SCOPED_SLOT_CONTENT: {
1529
+ code: 1177,
1530
+ message: '<template> tag with lwc:slot-data directive cannot contain a comment or text node as a direct child.',
1531
+ level: DiagnosticLevel.Error,
1532
+ url: '',
1533
+ },
1534
+ INVALID_PARENT_OF_LWC_SLOT_DATA: {
1535
+ code: 1178,
1536
+ message: '<template> tag with lwc:slot-data directive must be the direct child of a custom element.',
1537
+ level: DiagnosticLevel.Error,
1538
+ url: '',
1539
+ },
1540
+ SCOPED_SLOTDATA_CANNOT_BE_COMBINED_WITH_OTHER_DIRECTIVE: {
1541
+ code: 1179,
1542
+ message: 'lwc:slot-data directive cannot be combined with other directives on the same <template> tag.',
1543
+ level: DiagnosticLevel.Error,
1544
+ url: '',
1545
+ },
1546
+ INVALID_LWC_EXTERNAL_ON_NON_CUSTOM_ELEMENT: {
1547
+ code: 1180,
1548
+ message: 'Invalid lwc:external directive usage: {0}. This directive can only be used on custom elements.',
1549
+ level: DiagnosticLevel.Error,
1550
+ url: '',
1551
+ },
1552
+ INVALID_LWC_EXTERNAL_VALUE: {
1553
+ code: 1181,
1554
+ message: 'Invalid lwc:external directive usage: {0}. This directive is a boolean attribute and should not have a value.',
1555
+ level: DiagnosticLevel.Error,
1556
+ url: '',
1557
+ },
1558
+ SINGLE_IF_DIRECTIVE_ALLOWED: {
1559
+ code: 1182,
1560
+ message: `Multiple if: directives found on '{0}'. Only one if: directive is allowed; the rest are ignored.`,
1561
+ level: DiagnosticLevel.Warning,
1562
+ url: '',
1563
+ },
1564
+ LWC_COMPONENT_TAG_WITHOUT_IS_DIRECTIVE: {
1565
+ code: 1183,
1566
+ message: `<lwc:component> must have an 'lwc:is' attribute.`,
1567
+ level: DiagnosticLevel.Error,
1568
+ url: '',
1569
+ },
1570
+ UNSUPPORTED_LWC_TAG_NAME: {
1571
+ code: 1184,
1572
+ message: '{0} is not a special LWC tag name and will be treated as an HTML element.',
1573
+ level: DiagnosticLevel.Warning,
1574
+ url: '',
1575
+ },
1576
+ INVALID_LWC_IS_DIRECTIVE_VALUE: {
1577
+ code: 1185,
1578
+ message: 'Invalid lwc:is usage for value {0}. The value assigned to lwc:is must be an expression.',
1579
+ level: DiagnosticLevel.Error,
1580
+ url: '',
1581
+ },
1582
+ LWC_IS_INVALID_ELEMENT: {
1583
+ code: 1186,
1584
+ message: 'Invalid lwc:is usage for element {0}. The directive can only be used with <lwc:component>',
1585
+ level: DiagnosticLevel.Error,
1586
+ url: '',
1587
+ },
1588
+ DEPRECATED_LWC_DYNAMIC_ATTRIBUTE: {
1589
+ code: 1187,
1590
+ message: `The lwc:dynamic directive is deprecated and will be removed in a future release. Please use lwc:is instead.`,
1591
+ level: DiagnosticLevel.Warning,
1592
+ url: '',
1593
+ },
1594
+ INVALID_OPTS_LWC_ENABLE_DYNAMIC_COMPONENTS: {
1595
+ code: 1188,
1596
+ message: 'Invalid dynamic components usage, lwc:component and lwc:is can only be used when dynamic components have been enabled.',
1597
+ level: DiagnosticLevel.Error,
1598
+ url: '',
1599
+ },
1600
+ // TODO [#3370]: remove this error if template expressions is removed
1601
+ INVALID_EXPR_ARROW_FN_PARAM: {
1602
+ code: 1189,
1603
+ message: "Template expression doesn't allow {0} in arrow function params.",
1604
+ level: DiagnosticLevel.Error,
1605
+ url: '',
1606
+ },
1607
+ // TODO [#3370]: remove this error if template expressions is removed
1608
+ INVALID_EXPR_STATEMENTS_PROHIBITED: {
1609
+ code: 1190,
1610
+ message: 'Statements are disallowed in template expressions.',
1611
+ level: DiagnosticLevel.Error,
1612
+ url: '',
1613
+ },
1614
+ // TODO [#3370]: remove this error if template expressions is removed
1615
+ INVALID_EXPR_MUTATION_OUTSIDE_ARROW: {
1616
+ code: 1191,
1617
+ message: 'Field mutations are only permitted within arrow functions.',
1618
+ level: DiagnosticLevel.Error,
1619
+ url: '',
1620
+ },
1621
+ // TODO [#3370]: remove this error if template expressions is removed
1622
+ INVALID_EXPR_DELETE_OP: {
1623
+ code: 1192,
1624
+ message: 'Use of the delete operator is prohibited within template expressions.',
1625
+ level: DiagnosticLevel.Error,
1626
+ url: '',
1627
+ },
1628
+ // TODO [#3370]: remove this error if template expressions is removed
1629
+ INVALID_EXPR_ARROW_FN_BODY: {
1630
+ code: 1193,
1631
+ message: 'The body of arrow functions in template expressions must be an expression.',
1632
+ level: DiagnosticLevel.Error,
1633
+ url: '',
1634
+ },
1635
+ // TODO [#3370]: remove this error if template expressions is removed
1636
+ INVALID_EXPR_ARROW_FN_KIND: {
1637
+ code: 1194,
1638
+ message: 'Arrow functions in template expressions cannot be {0}.',
1639
+ level: DiagnosticLevel.Error,
1640
+ url: '',
1641
+ },
1642
+ // TODO [#3370]: remove this error if template expressions is removed
1643
+ INVALID_EXPR_EARLY_STAGE_FEATURE: {
1644
+ code: 1195,
1645
+ message: 'Early-stage JS features are disallowed in template expressions.',
1646
+ level: DiagnosticLevel.Error,
1647
+ url: '',
1648
+ },
1649
+ // TODO [#3370]: remove this error if template expressions is removed
1650
+ INVALID_EXPR_PROHIBITED_NODE_TYPE: {
1651
+ code: 1196,
1652
+ message: 'Use of {0} is disallowed within template expressions.',
1653
+ level: DiagnosticLevel.Error,
1654
+ url: '',
1655
+ },
1656
+ // TODO [#3370]: remove this error if template expressions is removed
1657
+ INVALID_EXPR_COMMENTS_DISALLOWED: {
1658
+ code: 1197,
1659
+ message: 'Use of comments is disallowed within template expressions.',
1660
+ level: DiagnosticLevel.Error,
1661
+ url: '',
1662
+ },
1663
+ });
1664
+
1665
+ /**
1666
+ * Pattern modeled after @lwc/engine-core's reporting.ts system
1667
+ */
1668
+ var CompilerMetrics;
1669
+ (function (CompilerMetrics) {
1670
+ CompilerMetrics["LWCDynamicDirective"] = "lwc-dynamic-directive";
1671
+ CompilerMetrics["LWCRenderModeDirective"] = "lwc-render-mode-directive";
1672
+ CompilerMetrics["LWCSpreadDirective"] = "lwc-spread-directive";
1673
+ CompilerMetrics["DynamicImportTransform"] = "dynamic-import-transform";
1674
+ })(CompilerMetrics || (CompilerMetrics = {}));
1675
+ /** version: 8.3.0 */
1676
+
1677
+ /*
1678
+ * Copyright (c) 2024, Salesforce, Inc.
1679
+ * All rights reserved.
1680
+ * SPDX-License-Identifier: MIT
1681
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1682
+ */
1683
+ const bStylesheetTokenDeclaration = (esTemplate `
458
1684
  const stylesheetScopeToken = '${is.literal}';
459
- `;
1685
+ `);
460
1686
  const bAdditionalDeclarations = [
461
- esTemplate `
1687
+ (esTemplate `
462
1688
  const hasScopedStylesheets = defaultScopedStylesheets && defaultScopedStylesheets.length > 0;
463
- `,
464
- esTemplate `
1689
+ `),
1690
+ (esTemplate `
465
1691
  const stylesheetScopeTokenClass = hasScopedStylesheets ? \` class="\${stylesheetScopeToken}"\` : '';
466
- `,
467
- esTemplate `
1692
+ `),
1693
+ (esTemplate `
468
1694
  const stylesheetScopeTokenHostClass = hasScopedStylesheets ? \` class="\${stylesheetScopeToken}-host"\` : '';
469
- `,
470
- esTemplate `
1695
+ `),
1696
+ (esTemplate `
471
1697
  const stylesheetScopeTokenClassPrefix = hasScopedStylesheets ? (stylesheetScopeToken + ' ') : '';
472
- `,
1698
+ `),
473
1699
  ];
474
1700
  // Scope tokens are associated with a given template. This is assigned here so that it can be used in `generateMarkup`.
475
- const tmplAssignmentBlock = esTemplate `
1701
+ const tmplAssignmentBlock = (esTemplate `
476
1702
  ${is.identifier}.stylesheetScopeTokenHostClass = stylesheetScopeTokenHostClass;
477
- `;
1703
+ `);
478
1704
  function addScopeTokenDeclarations(program, filename, namespace, componentName) {
479
1705
  const { scopeToken } = generateScopeTokens(filename, namespace, componentName);
480
1706
  program.body.unshift(bStylesheetTokenDeclaration(builders$1.literal(scopeToken)), ...bAdditionalDeclarations.map((declaration) => declaration()));
@@ -487,9 +1713,9 @@ function addScopeTokenDeclarations(program, filename, namespace, componentName)
487
1713
  * SPDX-License-Identifier: MIT
488
1714
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
489
1715
  */
490
- const bImportHtmlEscape = esTemplate `
1716
+ const bImportHtmlEscape = (esTemplate `
491
1717
  import { htmlEscape } from '@lwc/shared';
492
- `;
1718
+ `);
493
1719
  const importHtmlEscapeKey = 'import:htmlEscape';
494
1720
  // This is a mostly-correct regular expression will only match if the entire string
495
1721
  // provided is a valid ECMAScript identifier. Its imperfections lie in the fact that
@@ -548,8 +1774,8 @@ const Comment = function Comment(node, cxt) {
548
1774
  * SPDX-License-Identifier: MIT
549
1775
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
550
1776
  */
551
- function getRootMemberExpression$1(node) {
552
- return node.object.type === 'MemberExpression' ? getRootMemberExpression$1(node.object) : node;
1777
+ function getRootMemberExpression$2(node) {
1778
+ return node.object.type === 'MemberExpression' ? getRootMemberExpression$2(node.object) : node;
553
1779
  }
554
1780
  function expressionIrToEs(node, cxt) {
555
1781
  if (node.type === 'Identifier') {
@@ -560,7 +1786,7 @@ function expressionIrToEs(node, cxt) {
560
1786
  }
561
1787
  else if (node.type === 'MemberExpression') {
562
1788
  const nodeClone = structuredClone(node);
563
- const rootMemberExpr = getRootMemberExpression$1(nodeClone);
1789
+ const rootMemberExpr = getRootMemberExpression$2(nodeClone);
564
1790
  if (!cxt.isLocalVar(rootMemberExpr.object.name)) {
565
1791
  rootMemberExpr.object = builders.memberExpression(builders.identifier('instance'), rootMemberExpr.object);
566
1792
  }
@@ -575,14 +1801,16 @@ function expressionIrToEs(node, cxt) {
575
1801
  * SPDX-License-Identifier: MIT
576
1802
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
577
1803
  */
578
- const bYieldFromChildGenerator = esTemplateWithYield `
1804
+ const bYieldFromChildGenerator = (esTemplateWithYield `
579
1805
  {
580
1806
  const childProps = ${is.objectExpression};
581
1807
  const childAttrs = ${is.objectExpression};
582
- const childSlottedContentGenerators = {};
583
- yield* ${is.identifier}(${is.literal}, childProps, childAttrs, childSlottedContentGenerators);
1808
+ async function* childSlottedContentGenerator() {
1809
+ ${is.statement}
1810
+ };
1811
+ yield* ${is.identifier}(${is.literal}, childProps, childAttrs, childSlottedContentGenerator);
584
1812
  }
585
- `;
1813
+ `);
586
1814
  const bImportGenerateMarkup = (localName, importPath) => builders.importDeclaration([builders.importSpecifier(builders.identifier('generateMarkup'), builders.identifier(localName))], builders.literal(importPath));
587
1815
  function getChildAttrsOrProps(attrs, cxt) {
588
1816
  const objectAttrsOrProps = attrs.map((attr) => {
@@ -627,7 +1855,7 @@ const Component = function Component(node, cxt) {
627
1855
  const childTagName = node.name;
628
1856
  const attributes = [...node.attributes, ...reflectAriaPropsAsAttrs(node.properties)];
629
1857
  return [
630
- bYieldFromChildGenerator(getChildAttrsOrProps(node.properties, cxt), getChildAttrsOrProps(attributes, cxt), builders.identifier(childGeneratorLocalName), builders.literal(childTagName)),
1858
+ bYieldFromChildGenerator(getChildAttrsOrProps(node.properties, cxt), getChildAttrsOrProps(attributes, cxt), optimizeAdjacentYieldStmts(irChildrenToEs(node.children, cxt)), builders.identifier(childGeneratorLocalName), builders.literal(childTagName)),
631
1859
  ];
632
1860
  };
633
1861
 
@@ -638,7 +1866,7 @@ const Component = function Component(node, cxt) {
638
1866
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
639
1867
  */
640
1868
  const bYield$1 = (expr) => builders.expressionStatement(builders.yieldExpression(expr));
641
- const bConditionalLiveYield = esTemplateWithYield `
1869
+ const bConditionalLiveYield = (esTemplateWithYield `
642
1870
  {
643
1871
  const prefix = (${ /* isClass */is.literal} && stylesheetScopeTokenClassPrefix) || '';
644
1872
  const attrOrPropValue = ${is.expression};
@@ -650,13 +1878,13 @@ const bConditionalLiveYield = esTemplateWithYield `
650
1878
  }
651
1879
  }
652
1880
  }
653
- `;
654
- const bStringLiteralYield = esTemplateWithYield `
1881
+ `);
1882
+ const bStringLiteralYield = (esTemplateWithYield `
655
1883
  {
656
1884
  const prefix = (${ /* isClass */is.literal} && stylesheetScopeTokenClassPrefix) || '';
657
1885
  yield ' ' + ${is.literal} + '="' + prefix + "${is.literal}" + '"'
658
1886
  }
659
- `;
1887
+ `);
660
1888
  function yieldAttrOrPropLiteralValue(name, valueNode, isClass) {
661
1889
  const { value, type } = valueNode;
662
1890
  if (typeof value === 'string') {
@@ -704,6 +1932,7 @@ function reorderAttributes(attrs, props) {
704
1932
  return [classAttr, styleAttr, ...boringAttrs, ...props, slotAttr].filter((el) => el !== null);
705
1933
  }
706
1934
  const Element = function Element(node, cxt) {
1935
+ const innerHtmlDirective = node.type === 'Element' && node.directives.find((dir) => dir.name === 'InnerHTML');
707
1936
  const attrsAndProps = reorderAttributes(node.attributes, node.properties);
708
1937
  let hasClassAttribute = false;
709
1938
  const yieldAttrsAndProps = attrsAndProps.flatMap((attr) => {
@@ -724,13 +1953,27 @@ const Element = function Element(node, cxt) {
724
1953
  if (isVoidElement(node.name, HTML_NAMESPACE)) {
725
1954
  return [bYield$1(builders.literal(`<${node.name}`)), ...yieldAttrsAndProps, bYield$1(builders.literal(`>`))];
726
1955
  }
1956
+ let childContent;
1957
+ // An element can have children or lwc:inner-html, but not both
1958
+ // If it has both, the template compiler will throw an error before reaching here
1959
+ if (node.children.length) {
1960
+ childContent = irChildrenToEs(node.children, cxt);
1961
+ }
1962
+ else if (innerHtmlDirective) {
1963
+ const value = innerHtmlDirective.value;
1964
+ const unsanitizedHtmlExpression = value.type === 'Literal' ? builders.literal(value.value) : expressionIrToEs(value, cxt);
1965
+ childContent = [bYield$1(unsanitizedHtmlExpression)];
1966
+ }
1967
+ else {
1968
+ childContent = [];
1969
+ }
727
1970
  return [
728
1971
  bYield$1(builders.literal(`<${node.name}`)),
729
1972
  // If we haven't already prefixed the scope token to an existing class, add an explicit class here
730
1973
  ...(hasClassAttribute ? [] : [bYield$1(builders.identifier('stylesheetScopeTokenClass'))]),
731
1974
  ...yieldAttrsAndProps,
732
1975
  bYield$1(builders.literal(`>`)),
733
- ...irChildrenToEs(node.children, cxt),
1976
+ ...childContent,
734
1977
  bYield$1(builders.literal(`</${node.name}>`)),
735
1978
  ].filter(Boolean);
736
1979
  };
@@ -741,18 +1984,18 @@ const Element = function Element(node, cxt) {
741
1984
  * SPDX-License-Identifier: MIT
742
1985
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
743
1986
  */
744
- function getRootMemberExpression(node) {
745
- return node.object.type === 'MemberExpression' ? getRootMemberExpression(node.object) : node;
1987
+ function getRootMemberExpression$1(node) {
1988
+ return node.object.type === 'MemberExpression' ? getRootMemberExpression$1(node.object) : node;
746
1989
  }
747
- function getRootIdentifier(node) {
748
- const rootMemberExpression = getRootMemberExpression(node);
1990
+ function getRootIdentifier$1(node) {
1991
+ const rootMemberExpression = getRootMemberExpression$1(node);
749
1992
  return is.identifier(rootMemberExpression?.object) ? rootMemberExpression.object : null;
750
1993
  }
751
- const bForOfYieldFrom = esTemplate `
1994
+ const bForOfYieldFrom$1 = (esTemplate `
752
1995
  for (let [${is.identifier}, ${is.identifier}] of Object.entries(${is.expression} ?? {})) {
753
1996
  ${is.statement};
754
1997
  }
755
- `;
1998
+ `);
756
1999
  const ForEach = function ForEach(node, cxt) {
757
2000
  const forItemId = node.item.name;
758
2001
  const forIndexId = node.index?.name ?? '__unused__';
@@ -762,14 +2005,55 @@ const ForEach = function ForEach(node, cxt) {
762
2005
  });
763
2006
  cxt.popLocalVars();
764
2007
  const expression = node.expression;
2008
+ const scopeReferencedId = is.memberExpression(expression)
2009
+ ? getRootIdentifier$1(expression)
2010
+ : null;
2011
+ const iterable = cxt.isLocalVar(scopeReferencedId?.name)
2012
+ ? node.expression
2013
+ : builders.memberExpression(builders.identifier('instance'), node.expression);
2014
+ return [
2015
+ bForOfYieldFrom$1(builders.identifier(forIndexId), builders.identifier(forItemId), iterable, optimizeAdjacentYieldStmts(forEachStatements)),
2016
+ ];
2017
+ };
2018
+
2019
+ /*
2020
+ * Copyright (c) 2024, salesforce.com, inc.
2021
+ * All rights reserved.
2022
+ * SPDX-License-Identifier: MIT
2023
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2024
+ */
2025
+ function getRootMemberExpression(node) {
2026
+ return node.object.type === 'MemberExpression' ? getRootMemberExpression(node.object) : node;
2027
+ }
2028
+ function getRootIdentifier(node) {
2029
+ const rootMemberExpression = getRootMemberExpression(node);
2030
+ return is.identifier(rootMemberExpression?.object) ? rootMemberExpression.object : null;
2031
+ }
2032
+ const bForOfYieldFrom = (esTemplate `
2033
+ for (let ${is.identifier} of toIteratorDirective(${is.expression} ?? [])) {
2034
+ ${is.statement};
2035
+ }
2036
+ `);
2037
+ const bToIteratorDirectiveImport = (esTemplate `
2038
+ import { toIteratorDirective } from '@lwc/ssr-runtime';
2039
+ `);
2040
+ const ForOf = function ForEach(node, cxt) {
2041
+ const id = node.iterator.name;
2042
+ cxt.pushLocalVars([id]);
2043
+ const forEachStatements = node.children.flatMap((childNode) => {
2044
+ return irToEs(childNode, cxt);
2045
+ });
2046
+ cxt.popLocalVars();
2047
+ const expression = node.expression;
765
2048
  const scopeReferencedId = is.memberExpression(expression)
766
2049
  ? getRootIdentifier(expression)
767
2050
  : null;
768
2051
  const iterable = cxt.isLocalVar(scopeReferencedId?.name)
769
2052
  ? node.expression
770
2053
  : builders.memberExpression(builders.identifier('instance'), node.expression);
2054
+ cxt.hoist(bToIteratorDirectiveImport(), 'toIteratorDirective');
771
2055
  return [
772
- bForOfYieldFrom(builders.identifier(forIndexId), builders.identifier(forItemId), iterable, optimizeAdjacentYieldStmts(forEachStatements)),
2056
+ bForOfYieldFrom(builders.identifier(id), iterable, optimizeAdjacentYieldStmts(forEachStatements)),
773
2057
  ];
774
2058
  };
775
2059
 
@@ -779,32 +2063,86 @@ const ForEach = function ForEach(node, cxt) {
779
2063
  * SPDX-License-Identifier: MIT
780
2064
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
781
2065
  */
782
- function bBlockStatement(childNodes, cxt) {
783
- return builders.blockStatement(optimizeAdjacentYieldStmts(childNodes.flatMap((childNode) => irToEs(childNode, cxt))));
2066
+ function bYieldComment(text = '') {
2067
+ return builders.expressionStatement(builders.yieldExpression(builders.literal(`<!--${text}-->`)));
2068
+ }
2069
+ function bBlockStatement(childNodes, cxt, insertComments) {
2070
+ let statements = childNodes.flatMap((childNode) => irToEs(childNode, cxt));
2071
+ if (insertComments)
2072
+ statements = [bYieldComment(), ...statements, bYieldComment()];
2073
+ return builders.blockStatement(optimizeAdjacentYieldStmts(statements));
784
2074
  }
785
2075
  const If = function If(node, cxt) {
786
2076
  const { modifier: trueOrFalseAsStr, condition, children } = node;
787
2077
  const trueOrFalse = trueOrFalseAsStr === 'true';
788
2078
  const comparison = builders.binaryExpression('===', builders.literal(trueOrFalse), expressionIrToEs(condition, cxt));
789
- return [builders.ifStatement(comparison, bBlockStatement(children, cxt))];
2079
+ return [builders.ifStatement(comparison, bBlockStatement(children, cxt, false))];
790
2080
  };
791
2081
  function bIfStatement(ifElseIfNode, cxt) {
792
2082
  const { children, condition, else: elseNode } = ifElseIfNode;
793
2083
  let elseBlock = null;
794
2084
  if (elseNode) {
795
2085
  if (elseNode.type === 'ElseBlock') {
796
- elseBlock = bBlockStatement(elseNode.children, cxt);
2086
+ elseBlock = bBlockStatement(elseNode.children, cxt, true);
797
2087
  }
798
2088
  else {
799
2089
  elseBlock = bIfStatement(elseNode, cxt);
800
2090
  }
801
2091
  }
802
- return builders.ifStatement(expressionIrToEs(condition, cxt), bBlockStatement(children, cxt), elseBlock);
2092
+ return builders.ifStatement(expressionIrToEs(condition, cxt), bBlockStatement(children, cxt, true), elseBlock);
803
2093
  }
804
2094
  const IfBlock = function IfBlock(node, cxt) {
805
2095
  return [bIfStatement(node, cxt)];
806
2096
  };
807
2097
 
2098
+ /*
2099
+ * Copyright (c) 2024, salesforce.com, inc.
2100
+ * All rights reserved.
2101
+ * SPDX-License-Identifier: MIT
2102
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2103
+ */
2104
+ const bConditionalSlot = (esTemplateWithYield `
2105
+ if (isLightDom) {
2106
+ // start bookend HTML comment
2107
+ yield '<!---->';
2108
+
2109
+ const generator = slottedContent[${ /* slotName */is.expression} ?? ""];
2110
+ if (generator) {
2111
+ yield* generator();
2112
+ } else {
2113
+ // If we're in this else block, then the generator _must_ have yielded
2114
+ // something. It's impossible for a slottedContent["foo"] to exist
2115
+ // without the generator yielding at least a text node / element.
2116
+ // FIXME: how does this work with comments and lwc:preserve-comments?
2117
+ // TODO: default/fallback slot content
2118
+ ${ /* slot fallback content */is.statement}
2119
+ }
2120
+
2121
+ // end bookend HTML comment
2122
+ yield '<!---->';
2123
+ } else {
2124
+ ${ /* slot element AST */is.statement}
2125
+ }
2126
+ `);
2127
+ const Slot = function Slot(node, ctx) {
2128
+ const nameAttrValue = node.attributes.find((attr) => attr.name === 'name')?.value;
2129
+ let slotName;
2130
+ if (!nameAttrValue) {
2131
+ slotName = builders.literal('');
2132
+ }
2133
+ else if (nameAttrValue.type === 'Literal') {
2134
+ const name = typeof nameAttrValue.value === 'string' ? nameAttrValue.value : '';
2135
+ slotName = builders.literal(name);
2136
+ }
2137
+ else {
2138
+ slotName = builders.memberExpression(builders.literal('instance'), nameAttrValue);
2139
+ }
2140
+ // FIXME: avoid serializing the slot's children twice
2141
+ const slotAst = Element(node, ctx);
2142
+ const slotChildren = irChildrenToEs(node.children, ctx);
2143
+ return [bConditionalSlot(slotName, slotChildren, slotAst)];
2144
+ };
2145
+
808
2146
  /*
809
2147
  * Copyright (c) 2024, salesforce.com, inc.
810
2148
  * All rights reserved.
@@ -812,16 +2150,16 @@ const IfBlock = function IfBlock(node, cxt) {
812
2150
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
813
2151
  */
814
2152
  const bYield = (expr) => builders.expressionStatement(builders.yieldExpression(expr));
815
- const bYieldEscapedString = esTemplateWithYield `
2153
+ const bYieldEscapedString = (esTemplateWithYield `
816
2154
  const ${is.identifier} = ${is.expression};
817
- if (typeof ${is.identifier} === 'string') {
818
- yield (${is.literal} && ${is.identifier} === '') ? '\\u200D' : htmlEscape(${is.identifier});
819
- } else if (typeof ${is.identifier} === 'number') {
820
- yield ${is.identifier}.toString();
2155
+ if (typeof ${0} === 'string') {
2156
+ yield (${is.literal} && ${0} === '') ? '\\u200D' : htmlEscape(${0});
2157
+ } else if (typeof ${0} === 'number') {
2158
+ yield ${0}.toString();
821
2159
  } else {
822
- yield htmlEscape((${is.identifier} ?? '').toString());
2160
+ yield ${0} ? htmlEscape(${0}.toString()) : '\\u200D';
823
2161
  }
824
- `;
2162
+ `);
825
2163
  function isLiteral(node) {
826
2164
  return node.type === 'Literal';
827
2165
  }
@@ -834,7 +2172,7 @@ const Text = function Text(node, cxt) {
834
2172
  const valueToYield = expressionIrToEs(node.value, cxt);
835
2173
  cxt.hoist(bImportHtmlEscape(), importHtmlEscapeKey);
836
2174
  const tempVariable = builders.identifier(cxt.getUniqueVar());
837
- return bYieldEscapedString(tempVariable, valueToYield, tempVariable, isIsolatedTextNode, tempVariable, tempVariable, tempVariable, tempVariable, tempVariable);
2175
+ return bYieldEscapedString(tempVariable, valueToYield, isIsolatedTextNode);
838
2176
  };
839
2177
 
840
2178
  /*
@@ -900,20 +2238,28 @@ function createNewContext(templateOptions) {
900
2238
  const Root = function Root(node, cxt) {
901
2239
  return irChildrenToEs(node.children, cxt);
902
2240
  };
903
- const transformers = {
904
- Comment: Comment,
905
- Component: Component,
906
- Root: Root,
907
- Text: Text,
908
- Element: Element,
909
- ExternalComponent: Element,
910
- ForEach: ForEach,
911
- If: If,
912
- IfBlock: IfBlock,
913
- };
914
2241
  const defaultTransformer = (node) => {
915
2242
  throw new Error(`Unimplemented IR node: ${inspect(node)}`);
916
2243
  };
2244
+ const transformers = {
2245
+ Comment,
2246
+ Component,
2247
+ Element,
2248
+ ExternalComponent: Element,
2249
+ ForEach,
2250
+ ForOf,
2251
+ If,
2252
+ IfBlock,
2253
+ Root,
2254
+ Text,
2255
+ // lwc:elseif cannot exist without an lwc:if (IfBlock); this gets handled by that transformer
2256
+ ElseifBlock: defaultTransformer,
2257
+ // lwc:elseif cannot exist without an lwc:elseif (IfBlock); this gets handled by that transformer
2258
+ ElseBlock: defaultTransformer,
2259
+ ScopedSlotFragment: defaultTransformer,
2260
+ Slot,
2261
+ Lwc: defaultTransformer,
2262
+ };
917
2263
  function irChildrenToEs(children, cxt) {
918
2264
  const result = children.flatMap((child, idx) => {
919
2265
  cxt.prevSibling = children[idx - 1];
@@ -925,7 +2271,10 @@ function irChildrenToEs(children, cxt) {
925
2271
  return result;
926
2272
  }
927
2273
  function irToEs(node, cxt) {
928
- const transformer = transformers[node.type] ?? defaultTransformer;
2274
+ if ('directives' in node && node.directives.some((d) => d.name === 'Dynamic')) {
2275
+ throw new Error('The lwc:dynamic directive is not supported for SSR. Use <lwc:component> instead.');
2276
+ }
2277
+ const transformer = transformers[node.type];
929
2278
  return transformer(node, cxt);
930
2279
  }
931
2280
  function templateIrToEsTree(node, contextOpts) {
@@ -943,13 +2292,14 @@ function templateIrToEsTree(node, contextOpts) {
943
2292
  * SPDX-License-Identifier: MIT
944
2293
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
945
2294
  */
946
- const isBool = (node) => is.literal(node) && typeof node.value === 'boolean';
947
- const bStyleValidationImport = esTemplate `
2295
+ const bStyleValidationImport = (esTemplate `
948
2296
  import { validateStyleTextContents } from '@lwc/ssr-runtime';
949
- `;
950
- const bExportTemplate = esTemplate `
951
- export default async function* tmpl(props, attrs, slotted, Cmp, instance) {
952
- if (!${isBool} && Cmp.renderMode !== 'light') {
2297
+ `);
2298
+ // TODO [#4663]: Render mode mismatch between template and compiler should throw.
2299
+ const bExportTemplate = (esTemplate `
2300
+ export default async function* tmpl(props, attrs, slottedContent, Cmp, instance) {
2301
+ const isLightDom = Cmp.renderMode === 'light';
2302
+ if (!isLightDom) {
953
2303
  yield \`<template shadowrootmode="open"\${Cmp.delegatesFocus ? ' shadowrootdelegatesfocus' : ''}>\`
954
2304
  }
955
2305
 
@@ -971,29 +2321,54 @@ const bExportTemplate = esTemplate `
971
2321
 
972
2322
  ${is.statement};
973
2323
 
974
- if (!${isBool} && Cmp.renderMode !== 'light') {
2324
+ if (!isLightDom) {
975
2325
  yield '</template>';
976
2326
  }
2327
+
2328
+ if (slottedContent) {
2329
+ yield* slottedContent();
2330
+ }
977
2331
  }
978
- `;
2332
+ `);
979
2333
  function compileTemplate(src, filename, options) {
980
- const { root, warnings } = parse$1(src);
2334
+ const { root, warnings } = parse$1(src, {
2335
+ // `options` is from @lwc/compiler, and may have flags that @lwc/template-compiler doesn't
2336
+ // know about, so we must explicitly extract the relevant props.
2337
+ name: options.name,
2338
+ namespace: options.namespace,
2339
+ customRendererConfig: options.customRendererConfig,
2340
+ experimentalComputedMemberExpression: options.experimentalComputedMemberExpression,
2341
+ experimentalComplexExpressions: options.experimentalComplexExpressions,
2342
+ enableDynamicComponents: options.enableDynamicComponents,
2343
+ preserveHtmlComments: options.preserveHtmlComments,
2344
+ enableStaticContentOptimization: options.enableStaticContentOptimization,
2345
+ instrumentation: options.instrumentation,
2346
+ apiVersion: options.apiVersion,
2347
+ disableSyntheticShadowSupport: options.disableSyntheticShadowSupport,
2348
+ // TODO [#3331]: remove usage of lwc:dynamic in 246
2349
+ experimentalDynamicDirective: options.experimentalDynamicDirective,
2350
+ });
981
2351
  if (!root || warnings.length) {
2352
+ let fatal = !root;
982
2353
  for (const warning of warnings) {
983
2354
  // eslint-disable-next-line no-console
984
2355
  console.error('Cannot compile:', warning.message);
2356
+ if (warning.level === DiagnosticLevel.Fatal ||
2357
+ warning.level === DiagnosticLevel.Error) {
2358
+ fatal = true;
2359
+ }
2360
+ }
2361
+ // || !root is just used here to make TypeScript happy
2362
+ if (fatal || !root) {
2363
+ throw new Error('Template compilation failure; see warnings in the console.');
985
2364
  }
986
- throw new Error('Template compilation failure; see warnings in the console.');
987
2365
  }
988
- const tmplRenderMode = root.directives.find((directive) => directive.name === 'RenderMode')?.value?.value ??
989
- 'shadow';
990
- const astShadowModeBool = tmplRenderMode === 'light' ? builders.literal(true) : builders.literal(false);
991
2366
  const preserveComments = !!root.directives.find((directive) => directive.name === 'PreserveComments')?.value?.value;
992
2367
  const { hoisted, statements } = templateIrToEsTree(root, { preserveComments });
993
2368
  const moduleBody = [
994
2369
  ...hoisted,
995
2370
  bStyleValidationImport(),
996
- bExportTemplate(astShadowModeBool, optimizeAdjacentYieldStmts(statements), astShadowModeBool),
2371
+ bExportTemplate(optimizeAdjacentYieldStmts(statements)),
997
2372
  ];
998
2373
  const program = builders.program(moduleBody, 'module');
999
2374
  addScopeTokenDeclarations(program, filename, options.namespace, options.name);
@@ -1020,5 +2395,5 @@ function compileTemplateForSSR(src, filename, options) {
1020
2395
  }
1021
2396
 
1022
2397
  export { compileComponentForSSR, compileTemplateForSSR };
1023
- /** version: 8.1.3 */
2398
+ /** version: 8.3.0 */
1024
2399
  //# sourceMappingURL=index.js.map