@lwc/template-compiler 9.0.4-alpha.2 → 9.1.1-alpha.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.
@@ -6,7 +6,7 @@
6
6
  Object.defineProperty(exports, '__esModule', { value: true });
7
7
 
8
8
  var errors = require('@lwc/errors');
9
- var path = require('path');
9
+ var path = require('node:path');
10
10
  var shared = require('@lwc/shared');
11
11
  var he = require('he');
12
12
  var acorn = require('acorn');
@@ -29,7 +29,6 @@ function _interopNamespaceDefault(e) {
29
29
  return Object.freeze(n);
30
30
  }
31
31
 
32
- var he__namespace = /*#__PURE__*/_interopNamespaceDefault(he);
33
32
  var astring__namespace = /*#__PURE__*/_interopNamespaceDefault(astring);
34
33
 
35
34
  /*
@@ -9267,52 +9266,46 @@ function isAttribute$1(node) {
9267
9266
  return node.type === 'Attribute';
9268
9267
  }
9269
9268
 
9270
- exports.LWCDirectiveDomMode = void 0;
9271
- (function (LWCDirectiveDomMode) {
9272
- LWCDirectiveDomMode["manual"] = "manual";
9273
- })(exports.LWCDirectiveDomMode || (exports.LWCDirectiveDomMode = {}));
9274
- exports.LWCDirectiveRenderMode = void 0;
9275
- (function (LWCDirectiveRenderMode) {
9276
- LWCDirectiveRenderMode["shadow"] = "shadow";
9277
- LWCDirectiveRenderMode["light"] = "light";
9278
- })(exports.LWCDirectiveRenderMode || (exports.LWCDirectiveRenderMode = {}));
9269
+ const LWCDirectiveDomMode = {
9270
+ manual: 'manual',
9271
+ };
9272
+ const LWCDirectiveRenderMode = {
9273
+ shadow: 'shadow',
9274
+ light: 'light',
9275
+ };
9279
9276
  /**
9280
9277
  * All supported special LWC tags, they should all begin with lwc:*
9281
9278
  */
9282
- exports.LwcTagName = void 0;
9283
- (function (LwcTagName) {
9284
- LwcTagName["Component"] = "lwc:component";
9285
- })(exports.LwcTagName || (exports.LwcTagName = {}));
9286
- exports.TemplateDirectiveName = void 0;
9287
- (function (TemplateDirectiveName) {
9288
- TemplateDirectiveName["If"] = "if:true";
9289
- TemplateDirectiveName["IfBlock"] = "lwc:if";
9290
- TemplateDirectiveName["ElseifBlock"] = "lwc:elseif";
9291
- TemplateDirectiveName["ElseBlock"] = "lwc:else";
9292
- TemplateDirectiveName["ForEach"] = "for:each";
9293
- TemplateDirectiveName["ForOf"] = "for:of";
9294
- TemplateDirectiveName["ScopedSlotFragment"] = "lwc:slot-data";
9295
- })(exports.TemplateDirectiveName || (exports.TemplateDirectiveName = {}));
9296
- exports.ElementDirectiveName = void 0;
9297
- (function (ElementDirectiveName) {
9298
- ElementDirectiveName["Dom"] = "lwc:dom";
9279
+ const LwcTagName = {
9280
+ Component: 'lwc:component',
9281
+ };
9282
+ const TemplateDirectiveName = {
9283
+ If: 'if:true',
9284
+ IfBlock: 'lwc:if',
9285
+ ElseifBlock: 'lwc:elseif',
9286
+ ElseBlock: 'lwc:else',
9287
+ ForEach: 'for:each',
9288
+ ForOf: 'for:of',
9289
+ ScopedSlotFragment: 'lwc:slot-data',
9290
+ };
9291
+ const ElementDirectiveName = {
9292
+ Dom: 'lwc:dom',
9299
9293
  // TODO [#3331]: remove usage of lwc:dynamic in 246
9300
- ElementDirectiveName["Dynamic"] = "lwc:dynamic";
9301
- ElementDirectiveName["Is"] = "lwc:is";
9302
- ElementDirectiveName["External"] = "lwc:external";
9303
- ElementDirectiveName["InnerHTML"] = "lwc:inner-html";
9304
- ElementDirectiveName["Ref"] = "lwc:ref";
9305
- ElementDirectiveName["SlotBind"] = "lwc:slot-bind";
9306
- ElementDirectiveName["SlotData"] = "lwc:slot-data";
9307
- ElementDirectiveName["Spread"] = "lwc:spread";
9308
- ElementDirectiveName["On"] = "lwc:on";
9309
- ElementDirectiveName["Key"] = "key";
9310
- })(exports.ElementDirectiveName || (exports.ElementDirectiveName = {}));
9311
- exports.RootDirectiveName = void 0;
9312
- (function (RootDirectiveName) {
9313
- RootDirectiveName["PreserveComments"] = "lwc:preserve-comments";
9314
- RootDirectiveName["RenderMode"] = "lwc:render-mode";
9315
- })(exports.RootDirectiveName || (exports.RootDirectiveName = {}));
9294
+ Dynamic: 'lwc:dynamic',
9295
+ Is: 'lwc:is',
9296
+ External: 'lwc:external',
9297
+ InnerHTML: 'lwc:inner-html',
9298
+ Ref: 'lwc:ref',
9299
+ SlotBind: 'lwc:slot-bind',
9300
+ SlotData: 'lwc:slot-data',
9301
+ Spread: 'lwc:spread',
9302
+ On: 'lwc:on',
9303
+ Key: 'key',
9304
+ };
9305
+ const RootDirectiveName = {
9306
+ PreserveComments: 'lwc:preserve-comments',
9307
+ RenderMode: 'lwc:render-mode',
9308
+ };
9316
9309
 
9317
9310
  /*
9318
9311
  * Copyright (c) 2018, salesforce.com, inc.
@@ -9504,7 +9497,7 @@ const VALID_IF_MODIFIER = new Set(['true', 'false', 'strict-true']);
9504
9497
  const ITERATOR_RE = /^iterator:.*$/;
9505
9498
  const EVENT_HANDLER_RE = /^on/;
9506
9499
  const EVENT_HANDLER_NAME_RE = /^on[a-z][a-z0-9_]*$/;
9507
- const LWC_DIRECTIVE_SET = new Set(Object.values(exports.ElementDirectiveName));
9500
+ const LWC_DIRECTIVE_SET = new Set(Object.values(ElementDirectiveName));
9508
9501
  const ATTRIBUTE_NAME_CHAR = [
9509
9502
  ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-',
9510
9503
  '\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD',
@@ -9650,7 +9643,7 @@ class ParserCtx {
9650
9643
  this.siblingScopes = [];
9651
9644
  this.source = source;
9652
9645
  this.config = config;
9653
- this.renderMode = exports.LWCDirectiveRenderMode.shadow;
9646
+ this.renderMode = LWCDirectiveRenderMode.shadow;
9654
9647
  this.preserveComments = config.preserveHtmlComments;
9655
9648
  this.ecmaVersion = config.experimentalComplexExpressions
9656
9649
  ? TMPL_EXPR_ECMASCRIPT_EDITION
@@ -10063,7 +10056,7 @@ function cleanTextNode(value) {
10063
10056
  return str;
10064
10057
  }
10065
10058
  function decodeTextContent(source) {
10066
- return he__namespace.decode(source);
10059
+ return he.decode(source);
10067
10060
  }
10068
10061
 
10069
10062
  /*
@@ -10616,8 +10609,7 @@ function parseExpression(ctx, source, location, unquotedAttributeExpression) {
10616
10609
  }, errors.ParserDiagnostics.TEMPLATE_EXPRESSION_PARSING_ERROR, location, (err) => `Invalid expression ${source} - ${err.message}`);
10617
10610
  }
10618
10611
  function parseIdentifier(ctx, source, location) {
10619
- let isValid = true;
10620
- isValid = acorn.isIdentifierStart(source.charCodeAt(0));
10612
+ let isValid = acorn.isIdentifierStart(source.charCodeAt(0));
10621
10613
  for (let i = 1; i < source.length && isValid; i++) {
10622
10614
  isValid = acorn.isIdentifierChar(source.charCodeAt(i));
10623
10615
  }
@@ -11442,7 +11434,7 @@ function parseBaseElement(ctx, parsedAttr, parse5Elm, parent, parse5ElmLocation)
11442
11434
  // Check if the element tag is a valid custom element name and is not part of known standard
11443
11435
  // element name containing a dash.
11444
11436
  if (isCustomElementTag(tag)) {
11445
- if (parsedAttr.get(exports.ElementDirectiveName.External)) {
11437
+ if (parsedAttr.get(ElementDirectiveName.External)) {
11446
11438
  element$1 = externalComponent(tag, parse5ElmLocation);
11447
11439
  }
11448
11440
  else {
@@ -11467,7 +11459,7 @@ function parseBaseElement(ctx, parsedAttr, parse5Elm, parent, parse5ElmLocation)
11467
11459
  function parseLwcElement(ctx, parse5Elm, parsedAttr, parse5ElmLocation) {
11468
11460
  let lwcElementParser;
11469
11461
  switch (parse5Elm.tagName) {
11470
- case exports.LwcTagName.Component:
11462
+ case LwcTagName.Component:
11471
11463
  lwcElementParser = parseLwcComponent;
11472
11464
  break;
11473
11465
  default:
@@ -11480,7 +11472,7 @@ function parseLwcComponent(ctx, parse5Elm, parsedAttr, parse5ElmLocation) {
11480
11472
  ctx.throwAtLocation(errors.ParserDiagnostics.INVALID_OPTS_LWC_ENABLE_DYNAMIC_COMPONENTS, sourceLocation(parse5ElmLocation));
11481
11473
  }
11482
11474
  // <lwc:component> must be used with lwc:is directive
11483
- if (!parsedAttr.get(exports.ElementDirectiveName.Is)) {
11475
+ if (!parsedAttr.get(ElementDirectiveName.Is)) {
11484
11476
  ctx.throwAtLocation(errors.ParserDiagnostics.LWC_COMPONENT_TAG_WITHOUT_IS_DIRECTIVE, sourceLocation(parse5ElmLocation));
11485
11477
  }
11486
11478
  return lwcComponent(parse5Elm.tagName, parse5ElmLocation);
@@ -11755,21 +11747,21 @@ function applyRootLwcDirectives(ctx, parsedAttr, root) {
11755
11747
  applyLwcPreserveCommentsDirective(ctx, parsedAttr, root);
11756
11748
  }
11757
11749
  function applyLwcRenderModeDirective(ctx, parsedAttr, root) {
11758
- const lwcRenderModeAttribute = parsedAttr.pick(exports.RootDirectiveName.RenderMode);
11750
+ const lwcRenderModeAttribute = parsedAttr.pick(RootDirectiveName.RenderMode);
11759
11751
  if (!lwcRenderModeAttribute) {
11760
11752
  return;
11761
11753
  }
11762
11754
  const { value: renderDomAttr } = lwcRenderModeAttribute;
11763
11755
  if (!isStringLiteral(renderDomAttr) ||
11764
- (renderDomAttr.value !== exports.LWCDirectiveRenderMode.shadow &&
11765
- renderDomAttr.value !== exports.LWCDirectiveRenderMode.light)) {
11756
+ (renderDomAttr.value !== LWCDirectiveRenderMode.shadow &&
11757
+ renderDomAttr.value !== LWCDirectiveRenderMode.light)) {
11766
11758
  ctx.throwOnNode(errors.ParserDiagnostics.LWC_RENDER_MODE_INVALID_VALUE, root);
11767
11759
  }
11768
11760
  root.directives.push(renderModeDirective(renderDomAttr.value, lwcRenderModeAttribute.location));
11769
11761
  ctx.instrumentation?.incrementCounter(errors.CompilerMetrics.LWCRenderModeDirective);
11770
11762
  }
11771
11763
  function applyLwcPreserveCommentsDirective(ctx, parsedAttr, root) {
11772
- const lwcPreserveCommentAttribute = parsedAttr.pick(exports.RootDirectiveName.PreserveComments);
11764
+ const lwcPreserveCommentAttribute = parsedAttr.pick(RootDirectiveName.PreserveComments);
11773
11765
  if (!lwcPreserveCommentAttribute) {
11774
11766
  return;
11775
11767
  }
@@ -11802,15 +11794,15 @@ function applyLwcDirectives(ctx, parsedAttr, element) {
11802
11794
  ]);
11803
11795
  }
11804
11796
  // Should not allow render mode or preserve comments on non root nodes
11805
- if (parsedAttr.get(exports.RootDirectiveName.RenderMode)) {
11797
+ if (parsedAttr.get(RootDirectiveName.RenderMode)) {
11806
11798
  ctx.throwOnNode(errors.ParserDiagnostics.UNKNOWN_LWC_DIRECTIVE, element, [
11807
- exports.RootDirectiveName.RenderMode,
11799
+ RootDirectiveName.RenderMode,
11808
11800
  `<${element.name}>`,
11809
11801
  ]);
11810
11802
  }
11811
- if (parsedAttr.get(exports.RootDirectiveName.PreserveComments)) {
11803
+ if (parsedAttr.get(RootDirectiveName.PreserveComments)) {
11812
11804
  ctx.throwOnNode(errors.ParserDiagnostics.UNKNOWN_LWC_DIRECTIVE, element, [
11813
- exports.RootDirectiveName.PreserveComments,
11805
+ RootDirectiveName.PreserveComments,
11814
11806
  `<${element.name}>`,
11815
11807
  ]);
11816
11808
  }
@@ -11821,7 +11813,7 @@ function applyLwcDirectives(ctx, parsedAttr, element) {
11821
11813
  }
11822
11814
  function applyLwcSlotBindDirective(ctx, parsedAttr, element) {
11823
11815
  const { name: tag } = element;
11824
- const slotBindAttribute = parsedAttr.pick(exports.ElementDirectiveName.SlotBind);
11816
+ const slotBindAttribute = parsedAttr.pick(ElementDirectiveName.SlotBind);
11825
11817
  if (!slotBindAttribute) {
11826
11818
  return;
11827
11819
  }
@@ -11840,7 +11832,7 @@ function applyLwcSlotBindDirective(ctx, parsedAttr, element) {
11840
11832
  }
11841
11833
  function applyLwcSpreadDirective(ctx, parsedAttr, element) {
11842
11834
  const { name: tag } = element;
11843
- const lwcSpread = parsedAttr.pick(exports.ElementDirectiveName.Spread);
11835
+ const lwcSpread = parsedAttr.pick(ElementDirectiveName.Spread);
11844
11836
  if (!lwcSpread) {
11845
11837
  return;
11846
11838
  }
@@ -11852,7 +11844,7 @@ function applyLwcSpreadDirective(ctx, parsedAttr, element) {
11852
11844
  }
11853
11845
  function applyLwcOnDirective(ctx, parsedAttr, element) {
11854
11846
  const { name: tag } = element;
11855
- const lwcOn = parsedAttr.pick(exports.ElementDirectiveName.On);
11847
+ const lwcOn = parsedAttr.pick(ElementDirectiveName.On);
11856
11848
  if (!lwcOn) {
11857
11849
  return;
11858
11850
  }
@@ -11873,7 +11865,7 @@ function applyLwcOnDirective(ctx, parsedAttr, element) {
11873
11865
  element.directives.push(OnDirective(lwcOnValue, lwcOn.location));
11874
11866
  }
11875
11867
  function applyLwcExternalDirective(ctx, parsedAttr, element) {
11876
- const lwcExternalAttribute = parsedAttr.pick(exports.ElementDirectiveName.External);
11868
+ const lwcExternalAttribute = parsedAttr.pick(ElementDirectiveName.External);
11877
11869
  if (!lwcExternalAttribute) {
11878
11870
  return;
11879
11871
  }
@@ -11890,7 +11882,7 @@ function applyLwcExternalDirective(ctx, parsedAttr, element) {
11890
11882
  }
11891
11883
  function applyLwcDynamicDirective(ctx, parsedAttr, element) {
11892
11884
  const { name: tag } = element;
11893
- const lwcDynamicAttribute = parsedAttr.pick(exports.ElementDirectiveName.Dynamic);
11885
+ const lwcDynamicAttribute = parsedAttr.pick(ElementDirectiveName.Dynamic);
11894
11886
  if (!lwcDynamicAttribute) {
11895
11887
  return;
11896
11888
  }
@@ -11913,7 +11905,7 @@ function applyLwcDynamicDirective(ctx, parsedAttr, element) {
11913
11905
  }
11914
11906
  function applyLwcIsDirective(ctx, parsedAttr, element) {
11915
11907
  const { name: tag } = element;
11916
- const lwcIsAttribute = parsedAttr.pick(exports.ElementDirectiveName.Is);
11908
+ const lwcIsAttribute = parsedAttr.pick(ElementDirectiveName.Is);
11917
11909
  if (!lwcIsAttribute) {
11918
11910
  return;
11919
11911
  }
@@ -11934,7 +11926,7 @@ function applyLwcDomDirective(ctx, parsedAttr, element) {
11934
11926
  if (!lwcDomAttribute) {
11935
11927
  return;
11936
11928
  }
11937
- if (ctx.renderMode === exports.LWCDirectiveRenderMode.light) {
11929
+ if (ctx.renderMode === LWCDirectiveRenderMode.light) {
11938
11930
  ctx.throwOnNode(errors.ParserDiagnostics.LWC_DOM_INVALID_IN_LIGHT_DOM, element, [`<${tag}>`]);
11939
11931
  }
11940
11932
  if (isComponent(element)) {
@@ -11944,8 +11936,8 @@ function applyLwcDomDirective(ctx, parsedAttr, element) {
11944
11936
  ctx.throwOnNode(errors.ParserDiagnostics.LWC_DOM_INVALID_SLOT_ELEMENT, element);
11945
11937
  }
11946
11938
  const { value: lwcDomAttr } = lwcDomAttribute;
11947
- if (!isStringLiteral(lwcDomAttr) || lwcDomAttr.value !== exports.LWCDirectiveDomMode.manual) {
11948
- const possibleValues = Object.keys(exports.LWCDirectiveDomMode)
11939
+ if (!isStringLiteral(lwcDomAttr) || lwcDomAttr.value !== LWCDirectiveDomMode.manual) {
11940
+ const possibleValues = Object.keys(LWCDirectiveDomMode)
11949
11941
  .map((value) => `"${value}"`)
11950
11942
  .join(', or ');
11951
11943
  ctx.throwOnNode(errors.ParserDiagnostics.LWC_DOM_INVALID_VALUE, element, [possibleValues]);
@@ -11953,7 +11945,7 @@ function applyLwcDomDirective(ctx, parsedAttr, element) {
11953
11945
  element.directives.push(domDirective(lwcDomAttr.value, lwcDomAttribute.location));
11954
11946
  }
11955
11947
  function applyLwcInnerHtmlDirective(ctx, parsedAttr, element) {
11956
- const lwcInnerHtmlDirective = parsedAttr.pick(exports.ElementDirectiveName.InnerHTML);
11948
+ const lwcInnerHtmlDirective = parsedAttr.pick(ElementDirectiveName.InnerHTML);
11957
11949
  if (!lwcInnerHtmlDirective) {
11958
11950
  return;
11959
11951
  }
@@ -11976,7 +11968,7 @@ function applyLwcInnerHtmlDirective(ctx, parsedAttr, element) {
11976
11968
  element.directives.push(innerHTMLDirective(innerHTMLVal, lwcInnerHtmlDirective.location));
11977
11969
  }
11978
11970
  function applyRefDirective(ctx, parsedAttr, element) {
11979
- const lwcRefDirective = parsedAttr.pick(exports.ElementDirectiveName.Ref);
11971
+ const lwcRefDirective = parsedAttr.pick(ElementDirectiveName.Ref);
11980
11972
  if (!lwcRefDirective) {
11981
11973
  return;
11982
11974
  }
@@ -12047,7 +12039,7 @@ function parseForOf(ctx, _parse5Elm, parse5ElmLocation, parent, parsedAttr) {
12047
12039
  return node;
12048
12040
  }
12049
12041
  function parseScopedSlotFragment(ctx, parse5Elm, parse5ElmLocation, parent, parsedAttr) {
12050
- const slotDataAttr = parsedAttr.pick(exports.ElementDirectiveName.SlotData);
12042
+ const slotDataAttr = parsedAttr.pick(ElementDirectiveName.SlotData);
12051
12043
  if (!slotDataAttr) {
12052
12044
  return;
12053
12045
  }
@@ -12085,7 +12077,7 @@ function parseScopedSlotFragment(ctx, parse5Elm, parse5ElmLocation, parent, pars
12085
12077
  }
12086
12078
  function applyKey(ctx, parsedAttr, element) {
12087
12079
  const { name: tag } = element;
12088
- const keyAttribute = parsedAttr.pick(exports.ElementDirectiveName.Key);
12080
+ const keyAttribute = parsedAttr.pick(ElementDirectiveName.Key);
12089
12081
  if (keyAttribute) {
12090
12082
  if (!isExpression$1(keyAttribute.value)) {
12091
12083
  ctx.throwOnNode(errors.ParserDiagnostics.KEY_ATTRIBUTE_SHOULD_BE_EXPRESSION, keyAttribute);
@@ -12114,18 +12106,18 @@ function applyKey(ctx, parsedAttr, element) {
12114
12106
  ctx.throwOnNode(errors.ParserDiagnostics.MISSING_KEY_IN_ITERATOR, element, [tag]);
12115
12107
  }
12116
12108
  }
12117
- const RESTRICTED_DIRECTIVES_ON_SLOT = Object.values(exports.TemplateDirectiveName).join(', ');
12109
+ const RESTRICTED_DIRECTIVES_ON_SLOT = Object.values(TemplateDirectiveName).join(', ');
12118
12110
  const ALLOWED_SLOT_ATTRIBUTES = [
12119
- exports.ElementDirectiveName.Key,
12120
- exports.ElementDirectiveName.SlotBind,
12111
+ ElementDirectiveName.Key,
12112
+ ElementDirectiveName.SlotBind,
12121
12113
  'name',
12122
12114
  'slot',
12123
12115
  ];
12124
12116
  const ALLOWED_SLOT_ATTRIBUTES_SET = new Set(ALLOWED_SLOT_ATTRIBUTES);
12125
12117
  function parseSlot(ctx, parsedAttr, parse5ElmLocation) {
12126
12118
  const location = sourceLocation(parse5ElmLocation);
12127
- const isScopedSlot = !shared.isUndefined(parsedAttr.get(exports.ElementDirectiveName.SlotBind));
12128
- if (isScopedSlot && ctx.renderMode !== exports.LWCDirectiveRenderMode.light) {
12119
+ const isScopedSlot = !shared.isUndefined(parsedAttr.get(ElementDirectiveName.SlotBind));
12120
+ if (isScopedSlot && ctx.renderMode !== LWCDirectiveRenderMode.light) {
12129
12121
  ctx.throwAtLocation(errors.ParserDiagnostics.SCOPED_SLOT_BIND_IN_LIGHT_DOM_ONLY, location);
12130
12122
  }
12131
12123
  // Restrict specific template directives on <slot> element
@@ -12136,7 +12128,7 @@ function parseSlot(ctx, parsedAttr, parse5ElmLocation) {
12136
12128
  ]);
12137
12129
  }
12138
12130
  // Can't handle slots in applySlot because it would be too late for class and style attrs
12139
- if (ctx.renderMode === exports.LWCDirectiveRenderMode.light) {
12131
+ if (ctx.renderMode === LWCDirectiveRenderMode.light) {
12140
12132
  const invalidAttrs = parsedAttr
12141
12133
  .getAttributes()
12142
12134
  .filter(({ name }) => !ALLOWED_SLOT_ATTRIBUTES_SET.has(name))
@@ -12318,21 +12310,21 @@ function validateTemplate(ctx, parsedAttr, template, parse5ElmLocation) {
12318
12310
  if (!template.attrs.length) {
12319
12311
  ctx.throwAtLocation(errors.ParserDiagnostics.NO_DIRECTIVE_FOUND_ON_TEMPLATE, location);
12320
12312
  }
12321
- if (parsedAttr.get(exports.ElementDirectiveName.External)) {
12313
+ if (parsedAttr.get(ElementDirectiveName.External)) {
12322
12314
  ctx.throwAtLocation(errors.ParserDiagnostics.INVALID_LWC_EXTERNAL_ON_NON_CUSTOM_ELEMENT, location, ['<template>']);
12323
12315
  }
12324
- if (parsedAttr.get(exports.ElementDirectiveName.InnerHTML)) {
12316
+ if (parsedAttr.get(ElementDirectiveName.InnerHTML)) {
12325
12317
  ctx.throwAtLocation(errors.ParserDiagnostics.LWC_INNER_HTML_INVALID_ELEMENT, location, [
12326
12318
  '<template>',
12327
12319
  ]);
12328
12320
  }
12329
- if (parsedAttr.get(exports.ElementDirectiveName.Ref)) {
12321
+ if (parsedAttr.get(ElementDirectiveName.Ref)) {
12330
12322
  ctx.throwAtLocation(errors.ParserDiagnostics.LWC_REF_INVALID_ELEMENT, location, ['<template>']);
12331
12323
  }
12332
- if (parsedAttr.get(exports.ElementDirectiveName.Is)) {
12324
+ if (parsedAttr.get(ElementDirectiveName.Is)) {
12333
12325
  ctx.throwAtLocation(errors.ParserDiagnostics.LWC_IS_INVALID_ELEMENT, location, ['<template>']);
12334
12326
  }
12335
- if (parsedAttr.get(exports.ElementDirectiveName.On)) {
12327
+ if (parsedAttr.get(ElementDirectiveName.On)) {
12336
12328
  if (!ctx.config.enableLwcOn) {
12337
12329
  ctx.throwAtLocation(errors.ParserDiagnostics.INVALID_LWC_ON_OPTS, location, ['<template>']);
12338
12330
  }
@@ -12534,10 +12526,9 @@ function shouldAddCustomRenderer(element, state) {
12534
12526
  }
12535
12527
  const { attributes, directives } = element;
12536
12528
  if (directives.length) {
12537
- let directiveMatched = false;
12538
12529
  // If any directives require custom renderer
12539
- directiveMatched = directives.some((dir) => {
12540
- return state.crDirectives.has(exports.ElementDirectiveName[dir.name]);
12530
+ const directiveMatched = directives.some((dir) => {
12531
+ return state.crDirectives.has(ElementDirectiveName[dir.name]);
12541
12532
  });
12542
12533
  if (directiveMatched) {
12543
12534
  return true;
@@ -12609,7 +12600,7 @@ function shouldFlatten(codeGen, children) {
12609
12600
  // light DOM slots - backwards-compatible behavior uses flattening, new behavior uses fragments
12610
12601
  (!shared.isAPIFeatureEnabled(2 /* APIFeature.USE_FRAGMENTS_FOR_LIGHT_DOM_SLOTS */, codeGen.apiVersion) &&
12611
12602
  isSlot(child) &&
12612
- codeGen.renderMode === exports.LWCDirectiveRenderMode.light) ||
12603
+ codeGen.renderMode === LWCDirectiveRenderMode.light) ||
12613
12604
  // If node is only a control flow node and does not map to a stand alone element.
12614
12605
  // Search children to determine if it should be flattened.
12615
12606
  (isIf(child) && shouldFlatten(codeGen, child.children)));
@@ -12642,7 +12633,7 @@ function generateTemplateMetadata(codeGen) {
12642
12633
  metadataExpressions.push(expressionStatement(slotsMetadata));
12643
12634
  }
12644
12635
  // ignore when shadow because we don't want to modify template unnecessarily
12645
- if (codeGen.renderMode === exports.LWCDirectiveRenderMode.light) {
12636
+ if (codeGen.renderMode === LWCDirectiveRenderMode.light) {
12646
12637
  const renderModeMetadata = assignmentExpression('=', memberExpression(identifier(TEMPLATE_FUNCTION_NAME), identifier('renderMode')), literal$1('light'));
12647
12638
  metadataExpressions.push(expressionStatement(renderModeMetadata));
12648
12639
  }
@@ -13368,7 +13359,7 @@ class CodeGen {
13368
13359
  }
13369
13360
  this.renderMode =
13370
13361
  root.directives.find(isRenderModeDirective)?.value.value ??
13371
- exports.LWCDirectiveRenderMode.shadow;
13362
+ LWCDirectiveRenderMode.shadow;
13372
13363
  this.preserveComments =
13373
13364
  root.directives.find(isPreserveCommentsDirective)?.value.value ??
13374
13365
  state.config.preserveHtmlComments;
@@ -13377,7 +13368,7 @@ class CodeGen {
13377
13368
  this.state = state;
13378
13369
  this.apiVersion = shared.getAPIVersionFromNumber(state.config.apiVersion);
13379
13370
  this.isSyntheticShadow =
13380
- this.renderMode !== exports.LWCDirectiveRenderMode.light &&
13371
+ this.renderMode !== LWCDirectiveRenderMode.light &&
13381
13372
  !this.state.config.disableSyntheticShadowSupport;
13382
13373
  }
13383
13374
  generateKey() {
@@ -13771,7 +13762,7 @@ class CodeGen {
13771
13762
  // then static IDs/IDrefs/fragment refs will be rendered directly into HTML strings.
13772
13763
  const needsScoping = this.isSyntheticShadow && (isIdOrIdRef || isScopedFragmentRef);
13773
13764
  if (isExpression$1(value) || isSvgHref || needsScoping) {
13774
- let partToken = '';
13765
+ let partToken;
13775
13766
  if (name === 'style') {
13776
13767
  partToken = `${"s" /* STATIC_PART_TOKEN_ID.STYLE */}${partId}`;
13777
13768
  databag.push(property$1(identifier('style'), this.bindExpression(value)));
@@ -14572,6 +14563,12 @@ function compile(source, filename, config) {
14572
14563
  };
14573
14564
  }
14574
14565
 
14566
+ exports.ElementDirectiveName = ElementDirectiveName;
14567
+ exports.LWCDirectiveDomMode = LWCDirectiveDomMode;
14568
+ exports.LWCDirectiveRenderMode = LWCDirectiveRenderMode;
14569
+ exports.LwcTagName = LwcTagName;
14570
+ exports.RootDirectiveName = RootDirectiveName;
14571
+ exports.TemplateDirectiveName = TemplateDirectiveName;
14575
14572
  exports.bindExpression = bindExpression;
14576
14573
  exports.compile = compile;
14577
14574
  exports.default = compile;
@@ -14579,5 +14576,5 @@ exports.generateScopeTokens = generateScopeTokens;
14579
14576
  exports.kebabcaseToCamelcase = kebabcaseToCamelcase;
14580
14577
  exports.parse = parse;
14581
14578
  exports.toPropertyName = toPropertyName;
14582
- /** version: 9.0.4-alpha.2 */
14583
- //# sourceMappingURL=index.cjs.js.map
14579
+ /** version: 9.1.1-alpha.0 */
14580
+ //# sourceMappingURL=index.cjs.map
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { Config } from './config';
2
2
  import type { TemplateCompileResult, TemplateParseResult } from './shared/types';
3
3
  export * from './shared/types';
4
- export { CustomRendererConfig, CustomRendererElementConfig } from './shared/renderer-hooks';
5
- export { Config } from './config';
4
+ export type { CustomRendererConfig, CustomRendererElementConfig } from './shared/renderer-hooks';
5
+ export type { Config } from './config';
6
6
  export { toPropertyName } from './shared/utils';
7
7
  export { kebabcaseToCamelcase } from './shared/naming';
8
8
  export { generateScopeTokens } from './scopeTokens';
package/dist/index.js CHANGED
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) 2026 Salesforce, Inc.
3
3
  */
4
4
  import { invariant, TemplateErrors, generateCompilerError, CompilerError, normalizeToDiagnostic, generateCompilerDiagnostic, ParserDiagnostics, DiagnosticLevel, CompilerMetrics } from '@lwc/errors';
5
- import path from 'path';
5
+ import path from 'node:path';
6
6
  import { StringCharAt, hasOwnProperty, getAPIVersionFromNumber, HTML_NAMESPACE, AriaAttrNameToPropNameMap, fromEntries, ArrayFrom, SPECIAL_PROPERTY_ATTRIBUTE_MAPPING, isAPIFeatureEnabled, minApiVersion, ID_REFERENCING_ATTRIBUTES_SET, SVG_NAMESPACE, isBooleanAttribute, isGlobalHtmlAttribute, isAriaAttribute, isVoidElement, MATHML_NAMESPACE, isNull, isUndefined, IMPORTANT_FLAG, isArray, ArrayEvery, ArraySome, normalizeStyleAttributeValue, htmlEscape, parseStyleText, LWC_VERSION_COMMENT } from '@lwc/shared';
7
- import * as he from 'he';
7
+ import he from 'he';
8
8
  import { parseExpressionAt, isIdentifierStart, isIdentifierChar } from 'acorn';
9
9
  import * as astring from 'astring';
10
10
 
@@ -9243,52 +9243,46 @@ function isAttribute$1(node) {
9243
9243
  return node.type === 'Attribute';
9244
9244
  }
9245
9245
 
9246
- var LWCDirectiveDomMode;
9247
- (function (LWCDirectiveDomMode) {
9248
- LWCDirectiveDomMode["manual"] = "manual";
9249
- })(LWCDirectiveDomMode || (LWCDirectiveDomMode = {}));
9250
- var LWCDirectiveRenderMode;
9251
- (function (LWCDirectiveRenderMode) {
9252
- LWCDirectiveRenderMode["shadow"] = "shadow";
9253
- LWCDirectiveRenderMode["light"] = "light";
9254
- })(LWCDirectiveRenderMode || (LWCDirectiveRenderMode = {}));
9246
+ const LWCDirectiveDomMode = {
9247
+ manual: 'manual',
9248
+ };
9249
+ const LWCDirectiveRenderMode = {
9250
+ shadow: 'shadow',
9251
+ light: 'light',
9252
+ };
9255
9253
  /**
9256
9254
  * All supported special LWC tags, they should all begin with lwc:*
9257
9255
  */
9258
- var LwcTagName;
9259
- (function (LwcTagName) {
9260
- LwcTagName["Component"] = "lwc:component";
9261
- })(LwcTagName || (LwcTagName = {}));
9262
- var TemplateDirectiveName;
9263
- (function (TemplateDirectiveName) {
9264
- TemplateDirectiveName["If"] = "if:true";
9265
- TemplateDirectiveName["IfBlock"] = "lwc:if";
9266
- TemplateDirectiveName["ElseifBlock"] = "lwc:elseif";
9267
- TemplateDirectiveName["ElseBlock"] = "lwc:else";
9268
- TemplateDirectiveName["ForEach"] = "for:each";
9269
- TemplateDirectiveName["ForOf"] = "for:of";
9270
- TemplateDirectiveName["ScopedSlotFragment"] = "lwc:slot-data";
9271
- })(TemplateDirectiveName || (TemplateDirectiveName = {}));
9272
- var ElementDirectiveName;
9273
- (function (ElementDirectiveName) {
9274
- ElementDirectiveName["Dom"] = "lwc:dom";
9256
+ const LwcTagName = {
9257
+ Component: 'lwc:component',
9258
+ };
9259
+ const TemplateDirectiveName = {
9260
+ If: 'if:true',
9261
+ IfBlock: 'lwc:if',
9262
+ ElseifBlock: 'lwc:elseif',
9263
+ ElseBlock: 'lwc:else',
9264
+ ForEach: 'for:each',
9265
+ ForOf: 'for:of',
9266
+ ScopedSlotFragment: 'lwc:slot-data',
9267
+ };
9268
+ const ElementDirectiveName = {
9269
+ Dom: 'lwc:dom',
9275
9270
  // TODO [#3331]: remove usage of lwc:dynamic in 246
9276
- ElementDirectiveName["Dynamic"] = "lwc:dynamic";
9277
- ElementDirectiveName["Is"] = "lwc:is";
9278
- ElementDirectiveName["External"] = "lwc:external";
9279
- ElementDirectiveName["InnerHTML"] = "lwc:inner-html";
9280
- ElementDirectiveName["Ref"] = "lwc:ref";
9281
- ElementDirectiveName["SlotBind"] = "lwc:slot-bind";
9282
- ElementDirectiveName["SlotData"] = "lwc:slot-data";
9283
- ElementDirectiveName["Spread"] = "lwc:spread";
9284
- ElementDirectiveName["On"] = "lwc:on";
9285
- ElementDirectiveName["Key"] = "key";
9286
- })(ElementDirectiveName || (ElementDirectiveName = {}));
9287
- var RootDirectiveName;
9288
- (function (RootDirectiveName) {
9289
- RootDirectiveName["PreserveComments"] = "lwc:preserve-comments";
9290
- RootDirectiveName["RenderMode"] = "lwc:render-mode";
9291
- })(RootDirectiveName || (RootDirectiveName = {}));
9271
+ Dynamic: 'lwc:dynamic',
9272
+ Is: 'lwc:is',
9273
+ External: 'lwc:external',
9274
+ InnerHTML: 'lwc:inner-html',
9275
+ Ref: 'lwc:ref',
9276
+ SlotBind: 'lwc:slot-bind',
9277
+ SlotData: 'lwc:slot-data',
9278
+ Spread: 'lwc:spread',
9279
+ On: 'lwc:on',
9280
+ Key: 'key',
9281
+ };
9282
+ const RootDirectiveName = {
9283
+ PreserveComments: 'lwc:preserve-comments',
9284
+ RenderMode: 'lwc:render-mode',
9285
+ };
9292
9286
 
9293
9287
  /*
9294
9288
  * Copyright (c) 2018, salesforce.com, inc.
@@ -10592,8 +10586,7 @@ function parseExpression(ctx, source, location, unquotedAttributeExpression) {
10592
10586
  }, ParserDiagnostics.TEMPLATE_EXPRESSION_PARSING_ERROR, location, (err) => `Invalid expression ${source} - ${err.message}`);
10593
10587
  }
10594
10588
  function parseIdentifier(ctx, source, location) {
10595
- let isValid = true;
10596
- isValid = isIdentifierStart(source.charCodeAt(0));
10589
+ let isValid = isIdentifierStart(source.charCodeAt(0));
10597
10590
  for (let i = 1; i < source.length && isValid; i++) {
10598
10591
  isValid = isIdentifierChar(source.charCodeAt(i));
10599
10592
  }
@@ -12510,9 +12503,8 @@ function shouldAddCustomRenderer(element, state) {
12510
12503
  }
12511
12504
  const { attributes, directives } = element;
12512
12505
  if (directives.length) {
12513
- let directiveMatched = false;
12514
12506
  // If any directives require custom renderer
12515
- directiveMatched = directives.some((dir) => {
12507
+ const directiveMatched = directives.some((dir) => {
12516
12508
  return state.crDirectives.has(ElementDirectiveName[dir.name]);
12517
12509
  });
12518
12510
  if (directiveMatched) {
@@ -13747,7 +13739,7 @@ class CodeGen {
13747
13739
  // then static IDs/IDrefs/fragment refs will be rendered directly into HTML strings.
13748
13740
  const needsScoping = this.isSyntheticShadow && (isIdOrIdRef || isScopedFragmentRef);
13749
13741
  if (isExpression$1(value) || isSvgHref || needsScoping) {
13750
- let partToken = '';
13742
+ let partToken;
13751
13743
  if (name === 'style') {
13752
13744
  partToken = `${"s" /* STATIC_PART_TOKEN_ID.STYLE */}${partId}`;
13753
13745
  databag.push(property$1(identifier('style'), this.bindExpression(value)));
@@ -14549,5 +14541,5 @@ function compile(source, filename, config) {
14549
14541
  }
14550
14542
 
14551
14543
  export { ElementDirectiveName, LWCDirectiveDomMode, LWCDirectiveRenderMode, LwcTagName, RootDirectiveName, TemplateDirectiveName, bindExpression, compile, compile as default, generateScopeTokens, kebabcaseToCamelcase, parse, toPropertyName };
14552
- /** version: 9.0.4-alpha.2 */
14544
+ /** version: 9.1.1-alpha.0 */
14553
14545
  //# sourceMappingURL=index.js.map
@@ -8,13 +8,15 @@ export interface TemplateCompileResult extends TemplateParseResult {
8
8
  code: string;
9
9
  cssScopeTokens: string[];
10
10
  }
11
- export declare enum LWCDirectiveDomMode {
12
- manual = "manual"
13
- }
14
- export declare enum LWCDirectiveRenderMode {
15
- shadow = "shadow",
16
- light = "light"
17
- }
11
+ export declare const LWCDirectiveDomMode: {
12
+ readonly manual: "manual";
13
+ };
14
+ export type LWCDirectiveDomMode = (typeof LWCDirectiveDomMode)[keyof typeof LWCDirectiveDomMode];
15
+ export declare const LWCDirectiveRenderMode: {
16
+ readonly shadow: "shadow";
17
+ readonly light: "light";
18
+ };
19
+ export type LWCDirectiveRenderMode = (typeof LWCDirectiveRenderMode)[keyof typeof LWCDirectiveRenderMode];
18
20
  export interface BaseNode {
19
21
  type: string;
20
22
  location: SourceLocation;
@@ -159,24 +161,25 @@ export interface LwcComponent extends BaseLwcElement<'lwc:component'> {
159
161
  /**
160
162
  * All supported special LWC tags, they should all begin with lwc:*
161
163
  */
162
- export declare enum LwcTagName {
163
- Component = "lwc:component"
164
- }
164
+ export declare const LwcTagName: {
165
+ readonly Component: "lwc:component";
166
+ };
167
+ export type LwcTagName = (typeof LwcTagName)[keyof typeof LwcTagName];
165
168
  export type BaseElement = Element | ExternalComponent | Component | Slot | LwcComponent;
166
169
  export interface Root extends BaseParentNode {
167
170
  type: 'Root';
168
171
  location: ElementSourceLocation;
169
172
  directives: RootDirective[];
170
173
  }
171
- export declare enum TemplateDirectiveName {
172
- If = "if:true",
173
- IfBlock = "lwc:if",
174
- ElseifBlock = "lwc:elseif",
175
- ElseBlock = "lwc:else",
176
- ForEach = "for:each",
177
- ForOf = "for:of",
178
- ScopedSlotFragment = "lwc:slot-data"
179
- }
174
+ export declare const TemplateDirectiveName: {
175
+ readonly If: "if:true";
176
+ readonly IfBlock: "lwc:if";
177
+ readonly ElseifBlock: "lwc:elseif";
178
+ readonly ElseBlock: "lwc:else";
179
+ readonly ForEach: "for:each";
180
+ readonly ForOf: "for:of";
181
+ readonly ScopedSlotFragment: "lwc:slot-data";
182
+ };
180
183
  interface DirectiveParentNode<T extends keyof typeof TemplateDirectiveName> extends BaseParentNode {
181
184
  directiveLocation: SourceLocation;
182
185
  type: T;
@@ -227,22 +230,22 @@ export type ForBlock = ForEach | ForOf;
227
230
  export type ParentNode = Root | ForBlock | If | IfBlock | ElseifBlock | ElseBlock | BaseElement | ScopedSlotFragment;
228
231
  export type ChildNode = ForBlock | If | IfBlock | ElseifBlock | ElseBlock | BaseElement | Comment | Text | ScopedSlotFragment;
229
232
  export type Node = Root | ForBlock | If | IfBlock | ElseifBlock | ElseBlock | BaseElement | Comment | Text | ScopedSlotFragment;
230
- export declare enum ElementDirectiveName {
231
- Dom = "lwc:dom",
232
- Dynamic = "lwc:dynamic",
233
- Is = "lwc:is",
234
- External = "lwc:external",
235
- InnerHTML = "lwc:inner-html",
236
- Ref = "lwc:ref",
237
- SlotBind = "lwc:slot-bind",
238
- SlotData = "lwc:slot-data",
239
- Spread = "lwc:spread",
240
- On = "lwc:on",
241
- Key = "key"
242
- }
243
- export declare enum RootDirectiveName {
244
- PreserveComments = "lwc:preserve-comments",
245
- RenderMode = "lwc:render-mode"
246
- }
233
+ export declare const ElementDirectiveName: {
234
+ readonly Dom: "lwc:dom";
235
+ readonly Dynamic: "lwc:dynamic";
236
+ readonly Is: "lwc:is";
237
+ readonly External: "lwc:external";
238
+ readonly InnerHTML: "lwc:inner-html";
239
+ readonly Ref: "lwc:ref";
240
+ readonly SlotBind: "lwc:slot-bind";
241
+ readonly SlotData: "lwc:slot-data";
242
+ readonly Spread: "lwc:spread";
243
+ readonly On: "lwc:on";
244
+ readonly Key: "key";
245
+ };
246
+ export declare const RootDirectiveName: {
247
+ readonly PreserveComments: "lwc:preserve-comments";
248
+ readonly RenderMode: "lwc:render-mode";
249
+ };
247
250
  export {};
248
251
  //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
5
5
  ],
6
6
  "name": "@lwc/template-compiler",
7
- "version": "9.0.4-alpha.2",
7
+ "version": "9.1.1-alpha.0",
8
8
  "description": "Template compiler package",
9
9
  "keywords": [
10
10
  "lwc"
@@ -19,17 +19,22 @@
19
19
  "url": "https://github.com/salesforce/lwc/issues"
20
20
  },
21
21
  "license": "MIT",
22
+ "type": "module",
22
23
  "publishConfig": {
23
24
  "access": "public"
24
25
  },
26
+ "engines": {
27
+ "node": ">=16.6.0"
28
+ },
25
29
  "volta": {
26
30
  "extends": "../../../package.json"
27
31
  },
28
- "main": "dist/index.cjs.js",
32
+ "main": "dist/index.js",
29
33
  "module": "dist/index.js",
30
34
  "types": "dist/index.d.ts",
31
35
  "files": [
32
36
  "dist/**/*.js",
37
+ "dist/**/*.cjs",
33
38
  "dist/**/*.d.ts"
34
39
  ],
35
40
  "scripts": {
@@ -46,8 +51,8 @@
46
51
  }
47
52
  },
48
53
  "dependencies": {
49
- "@lwc/errors": "9.0.4-alpha.2",
50
- "@lwc/shared": "9.0.4-alpha.2",
54
+ "@lwc/errors": "9.1.1-alpha.0",
55
+ "@lwc/shared": "9.1.1-alpha.0",
51
56
  "acorn": "~8.16.0",
52
57
  "astring": "~1.9.0",
53
58
  "he": "~1.2.0"