babel-plugin-jsx-dom-expressions 0.29.16 → 0.30.3

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +528 -119
  3. package/package.json +4 -3
package/README.md CHANGED
@@ -20,7 +20,7 @@ This library uses a heuristic whether to dynamic wrap expressions based on if th
20
20
  ```jsx
21
21
  const view = ({ item }) => {
22
22
  const itemId = item.id;
23
- <tr class={itemId === selected() ? "danger" : ""}>
23
+ return <tr class={itemId === selected() ? "danger" : ""}>
24
24
  <td class="col-md-1">{itemId}</td>
25
25
  <td class="col-md-4">
26
26
  <a onclick={e => select(item, e)}>{item.label}</a>
package/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  var SyntaxJSX = require('@babel/plugin-syntax-jsx');
4
4
  var t = require('@babel/types');
5
5
  var helperModuleImports = require('@babel/helper-module-imports');
6
+ var htmlEntities = require('html-entities');
6
7
 
7
8
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
9
 
@@ -29,24 +30,8 @@ function _interopNamespace(e) {
29
30
  var SyntaxJSX__default = /*#__PURE__*/_interopDefaultLegacy(SyntaxJSX);
30
31
  var t__namespace = /*#__PURE__*/_interopNamespace(t);
31
32
 
32
- var config = {
33
- moduleName: "dom",
34
- generate: "dom",
35
- hydratable: false,
36
- delegateEvents: true,
37
- delegatedEvents: [],
38
- builtIns: [],
39
- requireImportSource: false,
40
- wrapConditionals: true,
41
- contextToCustomElements: false,
42
- staticMarker: "@once",
43
- effectWrapper: "effect",
44
- memoWrapper: "memo"
45
- };
46
-
47
33
  const booleans = [
48
34
  "allowfullscreen",
49
- "allowpaymentrequest",
50
35
  "async",
51
36
  "autofocus",
52
37
  "autoplay",
@@ -56,8 +41,8 @@ const booleans = [
56
41
  "disabled",
57
42
  "formnovalidate",
58
43
  "hidden",
44
+ "indeterminate",
59
45
  "ismap",
60
- "itemscope",
61
46
  "loop",
62
47
  "multiple",
63
48
  "muted",
@@ -69,13 +54,12 @@ const booleans = [
69
54
  "required",
70
55
  "reversed",
71
56
  "seamless",
72
- "selected",
73
- "truespeed"
57
+ "selected"
74
58
  ];
75
59
 
76
60
  const BooleanAttributes = new Set(booleans);
77
61
 
78
- const Properties = new Set(["className", "indeterminate", "value", "readOnly", ...booleans]);
62
+ const Properties = new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
79
63
 
80
64
  const ChildProperties = new Set(["innerHTML", "textContent", "innerText", "children"]);
81
65
 
@@ -87,6 +71,10 @@ const Aliases = {
87
71
 
88
72
  const PropAliases = {
89
73
  class: "className",
74
+ formnovalidate: "formNoValidate",
75
+ ismap: "isMap",
76
+ nomodule: "noModule",
77
+ playsinline: "playsInline",
90
78
  readonly: "readOnly"
91
79
  };
92
80
 
@@ -232,12 +220,16 @@ const reservedNameSpaces = new Set([
232
220
  "attr"
233
221
  ]);
234
222
 
223
+ function getConfig(path) {
224
+ return path.hub.file.metadata.config;
225
+ }
226
+
235
227
  function registerImportMethod(path, name) {
236
228
  const imports =
237
229
  path.scope.getProgramParent().data.imports ||
238
230
  (path.scope.getProgramParent().data.imports = new Set());
239
231
  if (!imports.has(name)) {
240
- helperModuleImports.addNamed(path, name, config.moduleName, {
232
+ helperModuleImports.addNamed(path, name, getConfig(path).moduleName, {
241
233
  nameHint: `_$${name}`
242
234
  });
243
235
  imports.add(name);
@@ -279,6 +271,7 @@ function isComponent(tagName) {
279
271
  }
280
272
 
281
273
  function isDynamic(path, { checkMember, checkTags, checkCallExpressions = true, native }) {
274
+ const config = getConfig(path);
282
275
  if (config.generate === "ssr" && native) {
283
276
  checkMember = false;
284
277
  checkCallExpressions = false;
@@ -337,12 +330,11 @@ function getStaticExpression(path) {
337
330
  }
338
331
 
339
332
  // remove unnecessary JSX Text nodes
340
- function filterChildren(children, loose) {
333
+ function filterChildren(children) {
341
334
  return children.filter(
342
335
  ({ node: child }) =>
343
336
  !(t__namespace.isJSXExpressionContainer(child) && t__namespace.isJSXEmptyExpression(child.expression)) &&
344
- (!t__namespace.isJSXText(child) ||
345
- (loose ? !/^[\r\n]\s*$/.test(child.extra.raw) : !/^\s*$/.test(child.extra.raw)))
337
+ (!t__namespace.isJSXText(child) || !/^[\r\n]\s*$/.test(child.extra.raw))
346
338
  );
347
339
  }
348
340
 
@@ -377,7 +369,31 @@ function toPropertyName(name) {
377
369
  return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
378
370
  }
379
371
 
372
+ function wrappedByText(list, startIndex) {
373
+ let index = startIndex,
374
+ wrapped;
375
+ while (--index >= 0) {
376
+ const node = list[index];
377
+ if (!node) continue;
378
+ if (node.text) {
379
+ wrapped = true;
380
+ break;
381
+ }
382
+ if (node.id) return false;
383
+ }
384
+ if (!wrapped) return false;
385
+ index = startIndex;
386
+ while (++index < list.length) {
387
+ const node = list[index];
388
+ if (!node) continue;
389
+ if (node.text) return true;
390
+ if (node.id) return false;
391
+ }
392
+ return false;
393
+ }
394
+
380
395
  function transformCondition(path, deep) {
396
+ const config = getConfig(path);
381
397
  const expr = path.node;
382
398
  if (config.memoWrapper) {
383
399
  registerImportMethod(path, config.memoWrapper);
@@ -496,8 +512,9 @@ function escapeHTML(s, attr) {
496
512
  return left < s.length ? out + s.substring(left) : out;
497
513
  }
498
514
 
499
- function transformElement$1(path, info) {
515
+ function transformElement$2(path, info) {
500
516
  let tagName = getTagName(path.node),
517
+ config = getConfig(path),
501
518
  wrapSVG = info.topLevel && tagName != "svg" && SVGElements.has(tagName),
502
519
  voidTag = VoidElements.indexOf(tagName) > -1,
503
520
  results = {
@@ -512,13 +529,13 @@ function transformElement$1(path, info) {
512
529
  if (tagName === "html" && config.hydratable) results.skipTemplate = true;
513
530
  if (wrapSVG) results.template = "<svg>" + results.template;
514
531
  if (!info.skipId) results.id = path.scope.generateUidIdentifier("el$");
515
- transformAttributes$1(path, results);
532
+ transformAttributes$2(path, results);
516
533
  if (config.contextToCustomElements && (tagName === "slot" || tagName.indexOf("-") > -1)) {
517
534
  contextToCustomElement(path, results);
518
535
  }
519
536
  results.template += ">";
520
537
  if (!voidTag) {
521
- transformChildren$1(path, results);
538
+ transformChildren$2(path, results, config);
522
539
  results.template += `</${tagName}>`;
523
540
  }
524
541
  if (info.topLevel && config.hydratable && results.hasHydratableEvent) {
@@ -531,7 +548,7 @@ function transformElement$1(path, info) {
531
548
  return results;
532
549
  }
533
550
 
534
- function setAttr$1(path, elem, name, value, { isSVG, dynamic, prevId, isCE }) {
551
+ function setAttr$2(path, elem, name, value, { isSVG, dynamic, prevId, isCE }) {
535
552
  // pull out namespace
536
553
  let parts, namespace;
537
554
  if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
@@ -627,7 +644,7 @@ function detectResolvableEventHandler(attribute, handler) {
627
644
  return t__namespace.isFunction(handler);
628
645
  }
629
646
 
630
- function transformAttributes$1(path, results) {
647
+ function transformAttributes$2(path, results) {
631
648
  let elem = results.id,
632
649
  hasHydratableEvent = false,
633
650
  children,
@@ -636,7 +653,8 @@ function transformAttributes$1(path, results) {
636
653
  tagName = getTagName(path.node),
637
654
  isSVG = SVGElements.has(tagName),
638
655
  isCE = tagName.includes("-"),
639
- hasChildren = path.node.children.length > 0;
656
+ hasChildren = path.node.children.length > 0,
657
+ config = getConfig(path);
640
658
 
641
659
  // preprocess styles
642
660
  const styleAttribute = attributes.find(
@@ -775,7 +793,9 @@ function transformAttributes$1(path, results) {
775
793
  isDynamic(attribute.get("argument"), {
776
794
  checkMember: true
777
795
  })
778
- ? t__namespace.arrowFunctionExpression([], node.argument)
796
+ ? t__namespace.isCallExpression(node.argument) && !node.argument.arguments.length
797
+ ? node.argument.callee
798
+ : t__namespace.arrowFunctionExpression([], node.argument)
779
799
  : node.argument,
780
800
  t__namespace.booleanLiteral(isSVG),
781
801
  t__namespace.booleanLiteral(hasChildren)
@@ -806,7 +826,19 @@ function transformAttributes$1(path, results) {
806
826
  !(t__namespace.isStringLiteral(value.expression) || t__namespace.isNumericLiteral(value.expression)))
807
827
  ) {
808
828
  if (key === "ref") {
809
- if (t__namespace.isLVal(value.expression)) {
829
+ // Normalize expressions for non-null and type-as
830
+ while (
831
+ t__namespace.isTSNonNullExpression(value.expression) ||
832
+ t__namespace.isTSAsExpression(value.expression)
833
+ ) {
834
+ value.expression = value.expression.expression;
835
+ }
836
+ let binding,
837
+ isFunction =
838
+ t__namespace.isIdentifier(value.expression) &&
839
+ (binding = path.scope.getBinding(value.expression.name)) &&
840
+ binding.kind === "const";
841
+ if (!isFunction && t__namespace.isLVal(value.expression)) {
810
842
  const refIdentifier = path.scope.generateUidIdentifier("_ref$");
811
843
  results.exprs.unshift(
812
844
  t__namespace.variableDeclaration("const", [
@@ -824,7 +856,7 @@ function transformAttributes$1(path, results) {
824
856
  )
825
857
  )
826
858
  );
827
- } else if (t__namespace.isFunction(value.expression)) {
859
+ } else if (isFunction || t__namespace.isFunction(value.expression)) {
828
860
  results.exprs.unshift(
829
861
  t__namespace.expressionStatement(t__namespace.callExpression(value.expression, [elem]))
830
862
  );
@@ -992,7 +1024,7 @@ function transformAttributes$1(path, results) {
992
1024
  results.dynamics.push({ elem: nextElem, key, value: value.expression, isSVG, isCE });
993
1025
  } else {
994
1026
  results.exprs.push(
995
- t__namespace.expressionStatement(setAttr$1(attribute, elem, key, value.expression, { isSVG, isCE }))
1027
+ t__namespace.expressionStatement(setAttr$2(attribute, elem, key, value.expression, { isSVG, isCE }))
996
1028
  );
997
1029
  }
998
1030
  } else {
@@ -1004,7 +1036,7 @@ function transformAttributes$1(path, results) {
1004
1036
  key = Aliases[key] || key;
1005
1037
  if (value && ChildProperties.has(key)) {
1006
1038
  results.exprs.push(
1007
- t__namespace.expressionStatement(setAttr$1(attribute, elem, key, value, { isSVG, isCE }))
1039
+ t__namespace.expressionStatement(setAttr$2(attribute, elem, key, value, { isSVG, isCE }))
1008
1040
  );
1009
1041
  } else {
1010
1042
  !isSVG && (key = key.toLowerCase());
@@ -1020,41 +1052,17 @@ function transformAttributes$1(path, results) {
1020
1052
  results.hasHydratableEvent = results.hasHydratableEvent || hasHydratableEvent;
1021
1053
  }
1022
1054
 
1023
- function wrappedByText(list, startIndex) {
1024
- let index = startIndex,
1025
- wrapped;
1026
- while (--index >= 0) {
1027
- const node = list[index];
1028
- if (!node) continue;
1029
- if (node.text) {
1030
- wrapped = true;
1031
- break;
1032
- }
1033
- if (node.id) return false;
1034
- }
1035
- if (!wrapped) return false;
1036
- index = startIndex;
1037
- while (++index < list.length) {
1038
- const node = list[index];
1039
- if (!node) continue;
1040
- if (node.text) return true;
1041
- if (node.id) return false;
1042
- }
1043
- return false;
1044
- }
1045
-
1046
- function transformChildren$1(path, results) {
1047
- const { hydratable } = config;
1055
+ function transformChildren$2(path, results, config) {
1048
1056
  let tempPath = results.id && results.id.name,
1049
1057
  tagName = getTagName(path.node),
1050
1058
  nextPlaceholder,
1051
1059
  i = 0;
1052
- const filteredChildren = filterChildren(path.get("children"), true),
1060
+ const filteredChildren = filterChildren(path.get("children")),
1053
1061
  childNodes = filteredChildren
1054
1062
  .map(
1055
1063
  (child, index) =>
1056
1064
  transformNode(child, {
1057
- skipId: !results.id || !detectExpressions(filteredChildren, index)
1065
+ skipId: !results.id || !detectExpressions(filteredChildren, index, config)
1058
1066
  })
1059
1067
  // combine adjacent textNodes
1060
1068
  )
@@ -1071,7 +1079,7 @@ function transformChildren$1(path, results) {
1071
1079
  if (!child) return;
1072
1080
  results.template += child.template;
1073
1081
  if (child.id) {
1074
- if (hydratable && tagName === "html") {
1082
+ if (config.hydratable && tagName === "html") {
1075
1083
  registerImportMethod(path, "getNextMatch");
1076
1084
  }
1077
1085
  const walk = t__namespace.memberExpression(
@@ -1081,7 +1089,7 @@ function transformChildren$1(path, results) {
1081
1089
  results.decl.push(
1082
1090
  t__namespace.variableDeclarator(
1083
1091
  child.id,
1084
- hydratable && tagName === "html"
1092
+ config.hydratable && tagName === "html"
1085
1093
  ? t__namespace.callExpression(t__namespace.identifier("_$getNextMatch"), [
1086
1094
  walk,
1087
1095
  t__namespace.stringLiteral(child.tagName)
@@ -1099,7 +1107,7 @@ function transformChildren$1(path, results) {
1099
1107
  } else if (child.exprs.length) {
1100
1108
  registerImportMethod(path, "insert");
1101
1109
  const multi = checkLength(filteredChildren),
1102
- markers = hydratable && multi;
1110
+ markers = config.hydratable && multi;
1103
1111
  // boxed by textNodes
1104
1112
  if (markers || wrappedByText(childNodes, index)) {
1105
1113
  let exprId, contentId;
@@ -1127,7 +1135,7 @@ function transformChildren$1(path, results) {
1127
1135
  t__namespace.callExpression(t__namespace.identifier("_$insert"), [
1128
1136
  results.id,
1129
1137
  child.exprs[0],
1130
- nextChild(childNodes, index) || t__namespace.nullLiteral()
1138
+ nextChild$1(childNodes, index) || t__namespace.nullLiteral()
1131
1139
  ])
1132
1140
  )
1133
1141
  );
@@ -1136,7 +1144,7 @@ function transformChildren$1(path, results) {
1136
1144
  t__namespace.expressionStatement(
1137
1145
  t__namespace.callExpression(
1138
1146
  t__namespace.identifier("_$insert"),
1139
- hydratable
1147
+ config.hydratable
1140
1148
  ? [
1141
1149
  results.id,
1142
1150
  child.exprs[0],
@@ -1165,7 +1173,8 @@ function transformChildren$1(path, results) {
1165
1173
  }
1166
1174
 
1167
1175
  function createPlaceholder(path, results, tempPath, i, char) {
1168
- const exprId = path.scope.generateUidIdentifier("el$");
1176
+ const exprId = path.scope.generateUidIdentifier("el$"),
1177
+ config = getConfig(path);
1169
1178
  let contentId;
1170
1179
  results.template += `<!${char}>`;
1171
1180
  if (config.hydratable && char === "/") {
@@ -1192,12 +1201,12 @@ function createPlaceholder(path, results, tempPath, i, char) {
1192
1201
  return [exprId, contentId];
1193
1202
  }
1194
1203
 
1195
- function nextChild(children, index) {
1196
- return children[index + 1] && (children[index + 1].id || nextChild(children, index + 1));
1204
+ function nextChild$1(children, index) {
1205
+ return children[index + 1] && (children[index + 1].id || nextChild$1(children, index + 1));
1197
1206
  }
1198
1207
 
1199
1208
  // reduce unnecessary refs
1200
- function detectExpressions(children, index) {
1209
+ function detectExpressions(children, index, config) {
1201
1210
  if (children[index - 1]) {
1202
1211
  const node = children[index - 1].node;
1203
1212
  if (
@@ -1233,8 +1242,8 @@ function detectExpressions(children, index) {
1233
1242
  )
1234
1243
  )
1235
1244
  return true;
1236
- const nextChildren = filterChildren(children[i].get("children"), true);
1237
- if (nextChildren.length) if (detectExpressions(nextChildren, 0)) return true;
1245
+ const nextChildren = filterChildren(children[i].get("children"));
1246
+ if (nextChildren.length) if (detectExpressions(nextChildren, 0, config)) return true;
1238
1247
  }
1239
1248
  }
1240
1249
  }
@@ -1252,7 +1261,8 @@ function contextToCustomElement(path, results) {
1252
1261
  );
1253
1262
  }
1254
1263
 
1255
- function createTemplate$1(path, result, wrap) {
1264
+ function createTemplate$2(path, result, wrap) {
1265
+ const config = getConfig(path);
1256
1266
  if (result.id) {
1257
1267
  registerTemplate(path, result);
1258
1268
  if (
@@ -1267,7 +1277,7 @@ function createTemplate$1(path, result, wrap) {
1267
1277
  t__namespace.blockStatement([
1268
1278
  result.decl,
1269
1279
  ...result.exprs.concat(
1270
- wrapDynamics(path, result.dynamics) || [],
1280
+ wrapDynamics$1(path, result.dynamics) || [],
1271
1281
  result.postExprs || []
1272
1282
  ),
1273
1283
  t__namespace.returnStatement(result.id)
@@ -1306,7 +1316,7 @@ function appendTemplates$1(path, templates) {
1306
1316
  }
1307
1317
 
1308
1318
  function registerTemplate(path, results) {
1309
- const { hydratable } = config;
1319
+ const { hydratable } = getConfig(path);
1310
1320
  let decl;
1311
1321
  if (results.template.length) {
1312
1322
  let templateDef, templateId;
@@ -1340,8 +1350,9 @@ function registerTemplate(path, results) {
1340
1350
  results.decl = t__namespace.variableDeclaration("const", results.decl);
1341
1351
  }
1342
1352
 
1343
- function wrapDynamics(path, dynamics) {
1353
+ function wrapDynamics$1(path, dynamics) {
1344
1354
  if (!dynamics.length) return;
1355
+ const config = getConfig(path);
1345
1356
  registerImportMethod(path, config.effectWrapper);
1346
1357
 
1347
1358
  const effectWrapperId = `_$${config.effectWrapper}`;
@@ -1356,7 +1367,7 @@ function wrapDynamics(path, dynamics) {
1356
1367
  t__namespace.callExpression(t__namespace.identifier(effectWrapperId), [
1357
1368
  t__namespace.arrowFunctionExpression(
1358
1369
  prevValue ? [prevValue] : [],
1359
- setAttr$1(path, dynamics[0].elem, dynamics[0].key, dynamics[0].value, {
1370
+ setAttr$2(path, dynamics[0].elem, dynamics[0].key, dynamics[0].value, {
1360
1371
  isSVG: dynamics[0].isSVG,
1361
1372
  isCE: dynamics[0].isCE,
1362
1373
  dynamic: true,
@@ -1381,7 +1392,7 @@ function wrapDynamics(path, dynamics) {
1381
1392
  t__namespace.assignmentExpression(
1382
1393
  "=",
1383
1394
  prev,
1384
- setAttr$1(path, elem, key, identifier, { isSVG, isCE, dynamic: true, prevId: prev })
1395
+ setAttr$2(path, elem, key, identifier, { isSVG, isCE, dynamic: true, prevId: prev })
1385
1396
  )
1386
1397
  )
1387
1398
  );
@@ -1391,7 +1402,7 @@ function wrapDynamics(path, dynamics) {
1391
1402
  t__namespace.logicalExpression(
1392
1403
  "&&",
1393
1404
  t__namespace.binaryExpression("!==", identifier, t__namespace.memberExpression(prevId, identifier)),
1394
- setAttr$1(
1405
+ setAttr$2(
1395
1406
  path,
1396
1407
  elem,
1397
1408
  key,
@@ -1428,8 +1439,9 @@ function appendToTemplate(template, value) {
1428
1439
  if (array && array.length) template.push.apply(template, array);
1429
1440
  }
1430
1441
 
1431
- function transformElement(path, info) {
1442
+ function transformElement$1(path, info) {
1432
1443
  let tagName = getTagName(path.node),
1444
+ config = getConfig(path),
1433
1445
  voidTag = VoidElements.indexOf(tagName) > -1,
1434
1446
  results = {
1435
1447
  template: [`<${tagName}`],
@@ -1443,10 +1455,10 @@ function transformElement(path, info) {
1443
1455
  results.template.push("");
1444
1456
  results.templateValues.push(t__namespace.callExpression(t__namespace.identifier("_$ssrHydrationKey"), []));
1445
1457
  }
1446
- transformAttributes(path, results);
1458
+ transformAttributes$1(path, results);
1447
1459
  appendToTemplate(results.template, ">");
1448
1460
  if (!voidTag) {
1449
- transformChildren(path, results);
1461
+ transformChildren$1(path, results, config);
1450
1462
  appendToTemplate(results.template, `</${tagName}>`);
1451
1463
  }
1452
1464
  return results;
@@ -1458,12 +1470,11 @@ function toAttribute(key, isSVG) {
1458
1470
  return key;
1459
1471
  }
1460
1472
 
1461
- function setAttr(results, name, value, isSVG) {
1473
+ function setAttr$1(results, name, value, isSVG) {
1462
1474
  // strip out namespaces for now, everything at this point is an attribute
1463
1475
  let parts;
1464
1476
  if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
1465
1477
  name = parts[1];
1466
- parts[0];
1467
1478
  }
1468
1479
 
1469
1480
  name = toAttribute(name, isSVG);
@@ -1543,7 +1554,7 @@ function transformToObject(attrName, attributes, selectedAttributes) {
1543
1554
  }
1544
1555
  }
1545
1556
 
1546
- function transformAttributes(path, results) {
1557
+ function transformAttributes$1(path, results) {
1547
1558
  let children;
1548
1559
  const tagName = getTagName(path.node),
1549
1560
  isSVG = SVGElements.has(tagName),
@@ -1615,7 +1626,9 @@ function transformAttributes(path, results) {
1615
1626
  checkMember: true,
1616
1627
  native: true
1617
1628
  })
1618
- ? t__namespace.arrowFunctionExpression([], node.argument)
1629
+ ? t__namespace.isCallExpression(node.argument) && !node.argument.arguments.length
1630
+ ? node.argument.callee
1631
+ : t__namespace.arrowFunctionExpression([], node.argument)
1619
1632
  : node.argument,
1620
1633
  t__namespace.booleanLiteral(isSVG),
1621
1634
  t__namespace.booleanLiteral(hasChildren)
@@ -1732,7 +1745,7 @@ function transformAttributes(path, results) {
1732
1745
  doEscape ? escapeExpression(path, value.expression, true) : value.expression
1733
1746
  );
1734
1747
  else if (doEscape) value.expression = escapeExpression(path, value.expression, true);
1735
- setAttr(results, key, value.expression, isSVG);
1748
+ setAttr$1(results, key, value.expression, isSVG);
1736
1749
  }
1737
1750
  } else {
1738
1751
  if (key === "$ServerOnly") return;
@@ -1778,10 +1791,9 @@ function transformClasslistObject(path, expr, values, quasis) {
1778
1791
  });
1779
1792
  }
1780
1793
 
1781
- function transformChildren(path, results) {
1782
- const { hydratable } = config,
1783
- doNotEscape = path.doNotEscape;
1784
- const filteredChildren = filterChildren(path.get("children"), true);
1794
+ function transformChildren$1(path, results, { hydratable }) {
1795
+ const doNotEscape = path.doNotEscape;
1796
+ const filteredChildren = filterChildren(path.get("children"));
1785
1797
  filteredChildren.forEach(node => {
1786
1798
  const child = transformNode(node, { doNotEscape });
1787
1799
  appendToTemplate(results.template, child.template);
@@ -1806,7 +1818,7 @@ function transformChildren(path, results) {
1806
1818
  });
1807
1819
  }
1808
1820
 
1809
- function createTemplate(path, result) {
1821
+ function createTemplate$1(path, result) {
1810
1822
  if (!result.template) {
1811
1823
  return result.exprs[0];
1812
1824
  }
@@ -1852,11 +1864,342 @@ function appendTemplates(path, templates) {
1852
1864
  path.node.body.unshift(t__namespace.variableDeclaration("const", declarators));
1853
1865
  }
1854
1866
 
1867
+ function transformElement(path, info) {
1868
+ let tagName = getTagName(path.node),
1869
+ results = {
1870
+ id: path.scope.generateUidIdentifier("el$"),
1871
+ decl: [],
1872
+ exprs: [],
1873
+ dynamics: [],
1874
+ postExprs: [],
1875
+ tagName
1876
+ };
1877
+
1878
+ registerImportMethod(path, "createElement");
1879
+ results.decl.push(
1880
+ t__namespace.variableDeclarator(
1881
+ results.id,
1882
+ t__namespace.callExpression(t__namespace.identifier("_$createElement"), [t__namespace.stringLiteral(tagName)])
1883
+ )
1884
+ );
1885
+
1886
+ transformAttributes(path, results);
1887
+ transformChildren(path, results);
1888
+
1889
+ return results;
1890
+ }
1891
+
1892
+ function transformAttributes(path, results) {
1893
+ let children;
1894
+ const elem = results.id,
1895
+ spread = t__namespace.identifier("_$spread"),
1896
+ hasChildren = path.node.children.length > 0,
1897
+ config = getConfig(path);
1898
+
1899
+ path
1900
+ .get("openingElement")
1901
+ .get("attributes")
1902
+ .forEach(attribute => {
1903
+ const node = attribute.node;
1904
+ if (t__namespace.isJSXSpreadAttribute(node)) {
1905
+ registerImportMethod(attribute, "spread");
1906
+ results.exprs.push(
1907
+ t__namespace.expressionStatement(
1908
+ t__namespace.callExpression(spread, [
1909
+ elem,
1910
+ isDynamic(attribute.get("argument"), {
1911
+ checkMember: true
1912
+ })
1913
+ ? t__namespace.isCallExpression(node.argument) && !node.argument.arguments.length
1914
+ ? node.argument.callee
1915
+ : t__namespace.arrowFunctionExpression([], node.argument)
1916
+ : node.argument,
1917
+ t__namespace.booleanLiteral(hasChildren)
1918
+ ])
1919
+ )
1920
+ );
1921
+ return;
1922
+ }
1923
+
1924
+ let value = node.value,
1925
+ key = t__namespace.isJSXNamespacedName(node.name)
1926
+ ? `${node.name.namespace.name}:${node.name.name.name}`
1927
+ : node.name.name,
1928
+ reservedNameSpace = t__namespace.isJSXNamespacedName(node.name) && node.name.namespace.name === "use";
1929
+ if (
1930
+ t__namespace.isJSXNamespacedName(node.name) &&
1931
+ reservedNameSpace &&
1932
+ !t__namespace.isJSXExpressionContainer(value)
1933
+ ) {
1934
+ node.value = value = t__namespace.JSXExpressionContainer(value || t__namespace.JSXEmptyExpression());
1935
+ }
1936
+ if (t__namespace.isJSXExpressionContainer(value)) {
1937
+ if (key === "ref") {
1938
+ // Normalize expressions for non-null and type-as
1939
+ while (
1940
+ t__namespace.isTSNonNullExpression(value.expression) ||
1941
+ t__namespace.isTSAsExpression(value.expression)
1942
+ ) {
1943
+ value.expression = value.expression.expression;
1944
+ }
1945
+ if (t__namespace.isLVal(value.expression)) {
1946
+ const refIdentifier = path.scope.generateUidIdentifier("_ref$");
1947
+ results.exprs.unshift(
1948
+ t__namespace.variableDeclaration("const", [
1949
+ t__namespace.variableDeclarator(refIdentifier, value.expression)
1950
+ ]),
1951
+ t__namespace.expressionStatement(
1952
+ t__namespace.conditionalExpression(
1953
+ t__namespace.binaryExpression(
1954
+ "===",
1955
+ t__namespace.unaryExpression("typeof", refIdentifier),
1956
+ t__namespace.stringLiteral("function")
1957
+ ),
1958
+ t__namespace.callExpression(refIdentifier, [elem]),
1959
+ t__namespace.assignmentExpression("=", value.expression, elem)
1960
+ )
1961
+ )
1962
+ );
1963
+ } else if (t__namespace.isFunction(value.expression)) {
1964
+ results.exprs.unshift(
1965
+ t__namespace.expressionStatement(t__namespace.callExpression(value.expression, [elem]))
1966
+ );
1967
+ } else if (t__namespace.isCallExpression(value.expression)) {
1968
+ const refIdentifier = path.scope.generateUidIdentifier("_ref$");
1969
+ results.exprs.unshift(
1970
+ t__namespace.variableDeclaration("const", [
1971
+ t__namespace.variableDeclarator(refIdentifier, value.expression)
1972
+ ]),
1973
+ t__namespace.expressionStatement(
1974
+ t__namespace.logicalExpression(
1975
+ "&&",
1976
+ t__namespace.binaryExpression(
1977
+ "===",
1978
+ t__namespace.unaryExpression("typeof", refIdentifier),
1979
+ t__namespace.stringLiteral("function")
1980
+ ),
1981
+ t__namespace.callExpression(refIdentifier, [elem])
1982
+ )
1983
+ )
1984
+ );
1985
+ }
1986
+ } else if (key.startsWith("use:")) {
1987
+ results.exprs.unshift(
1988
+ t__namespace.expressionStatement(
1989
+ t__namespace.callExpression(t__namespace.identifier(node.name.name.name), [
1990
+ elem,
1991
+ t__namespace.arrowFunctionExpression(
1992
+ [],
1993
+ t__namespace.isJSXEmptyExpression(value.expression)
1994
+ ? t__namespace.booleanLiteral(true)
1995
+ : value.expression
1996
+ )
1997
+ ])
1998
+ )
1999
+ );
2000
+ } else if (key === "children") {
2001
+ children = value;
2002
+ } else if (
2003
+ config.effectWrapper &&
2004
+ isDynamic(attribute.get("value").get("expression"), {
2005
+ checkMember: true
2006
+ })
2007
+ ) {
2008
+ results.dynamics.push({ elem, key, value: value.expression });
2009
+ } else {
2010
+ results.exprs.push(
2011
+ t__namespace.expressionStatement(setAttr(attribute, elem, key, value.expression))
2012
+ );
2013
+ }
2014
+ } else {
2015
+ results.exprs.push(t__namespace.expressionStatement(setAttr(attribute, elem, key, value)));
2016
+ }
2017
+ });
2018
+ if (!hasChildren && children) {
2019
+ path.node.children.push(children);
2020
+ }
2021
+ }
2022
+
2023
+ function setAttr(path, elem, name, value, { prevId } = {}) {
2024
+ registerImportMethod(path, "setProp");
2025
+ if (!value) value = t__namespace.booleanLiteral(true);
2026
+ return t__namespace.callExpression(
2027
+ t__namespace.identifier("_$setProp"),
2028
+ prevId ? [elem, t__namespace.stringLiteral(name), value, prevId] : [elem, t__namespace.stringLiteral(name), value]
2029
+ );
2030
+ }
2031
+
2032
+ function transformChildren(path, results) {
2033
+ const filteredChildren = filterChildren(path.get("children")),
2034
+ multi = checkLength(filteredChildren),
2035
+ childNodes = filteredChildren.map(transformNode).reduce((memo, child) => {
2036
+ if (!child) return memo;
2037
+ const i = memo.length;
2038
+ if (child.text && i && memo[i - 1].text) {
2039
+ memo[i - 1].template += child.template;
2040
+ } else memo.push(child);
2041
+ return memo;
2042
+ }, []);
2043
+
2044
+ const appends = [];
2045
+ childNodes.forEach((child, index) => {
2046
+ if (!child) return;
2047
+ if (child.id) {
2048
+ registerImportMethod(path, "insertNode");
2049
+ let insert = child.id;
2050
+ if (child.text) {
2051
+ registerImportMethod(path, "createTextNode");
2052
+ if (multi) {
2053
+ results.decl.push(
2054
+ t__namespace.variableDeclarator(
2055
+ child.id,
2056
+ t__namespace.callExpression(t__namespace.identifier("_$createTextNode"), [
2057
+ t__namespace.stringLiteral(htmlEntities.decode(child.template))
2058
+ ])
2059
+ )
2060
+ );
2061
+ } else
2062
+ insert = t__namespace.callExpression(t__namespace.identifier("_$createTextNode"), [
2063
+ t__namespace.stringLiteral(htmlEntities.decode(child.template))
2064
+ ]);
2065
+ }
2066
+ appends.push(
2067
+ t__namespace.expressionStatement(t__namespace.callExpression(t__namespace.identifier("_$insertNode"), [results.id, insert]))
2068
+ );
2069
+ results.decl.push(...child.decl);
2070
+ results.exprs.push(...child.exprs);
2071
+ results.dynamics.push(...child.dynamics);
2072
+ } else if (child.exprs.length) {
2073
+ registerImportMethod(path, "insert");
2074
+ if (multi) {
2075
+ results.exprs.push(
2076
+ t__namespace.expressionStatement(
2077
+ t__namespace.callExpression(t__namespace.identifier("_$insert"), [
2078
+ results.id,
2079
+ child.exprs[0],
2080
+ nextChild(childNodes, index) || t__namespace.nullLiteral()
2081
+ ])
2082
+ )
2083
+ );
2084
+ } else {
2085
+ results.exprs.push(
2086
+ t__namespace.expressionStatement(
2087
+ t__namespace.callExpression(t__namespace.identifier("_$insert"), [results.id, child.exprs[0]])
2088
+ )
2089
+ );
2090
+ }
2091
+ }
2092
+ });
2093
+ results.exprs.unshift(...appends);
2094
+ }
2095
+
2096
+ function nextChild(children, index) {
2097
+ return children[index + 1] && (children[index + 1].id || nextChild(children, index + 1));
2098
+ }
2099
+
2100
+ function createTemplate(path, result, wrap) {
2101
+ const config = getConfig(path);
2102
+ if (result.id) {
2103
+ result.decl = t__namespace.variableDeclaration("const", result.decl);
2104
+ if (
2105
+ !(result.exprs.length || result.dynamics.length || result.postExprs.length) &&
2106
+ result.decl.declarations.length === 1
2107
+ ) {
2108
+ return result.decl.declarations[0].init;
2109
+ } else {
2110
+ return t__namespace.callExpression(
2111
+ t__namespace.arrowFunctionExpression(
2112
+ [],
2113
+ t__namespace.blockStatement([
2114
+ result.decl,
2115
+ ...result.exprs.concat(
2116
+ wrapDynamics(path, result.dynamics) || [],
2117
+ result.postExprs || []
2118
+ ),
2119
+ t__namespace.returnStatement(result.id)
2120
+ ])
2121
+ ),
2122
+ []
2123
+ );
2124
+ }
2125
+ }
2126
+ if (wrap && result.dynamic && config.memoWrapper) {
2127
+ registerImportMethod(path, config.memoWrapper);
2128
+ return t__namespace.callExpression(t__namespace.identifier(`_$${config.memoWrapper}`), [result.exprs[0]]);
2129
+ }
2130
+ return result.exprs[0];
2131
+ }
2132
+
2133
+ function wrapDynamics(path, dynamics) {
2134
+ if (!dynamics.length) return;
2135
+ const config = getConfig(path);
2136
+ registerImportMethod(path, config.effectWrapper);
2137
+
2138
+ const effectWrapperId = `_$${config.effectWrapper}`;
2139
+
2140
+ if (dynamics.length === 1) {
2141
+ const prevValue = t__namespace.identifier("_$p");
2142
+
2143
+ return t__namespace.expressionStatement(
2144
+ t__namespace.callExpression(t__namespace.identifier(effectWrapperId), [
2145
+ t__namespace.arrowFunctionExpression(
2146
+ [prevValue],
2147
+ setAttr(path, dynamics[0].elem, dynamics[0].key, dynamics[0].value, {
2148
+ dynamic: true,
2149
+ prevId: prevValue
2150
+ })
2151
+ )
2152
+ ])
2153
+ );
2154
+ }
2155
+ const decls = [],
2156
+ statements = [],
2157
+ identifiers = [],
2158
+ prevId = t__namespace.identifier("_p$");
2159
+ dynamics.forEach(({ elem, key, value }) => {
2160
+ const identifier = path.scope.generateUidIdentifier("v$");
2161
+ identifiers.push(identifier);
2162
+ decls.push(t__namespace.variableDeclarator(identifier, value));
2163
+ const prev = t__namespace.memberExpression(prevId, identifier);
2164
+ statements.push(
2165
+ t__namespace.expressionStatement(
2166
+ t__namespace.logicalExpression(
2167
+ "&&",
2168
+ t__namespace.binaryExpression("!==", identifier, t__namespace.memberExpression(prevId, identifier)),
2169
+ t__namespace.assignmentExpression("=", t__namespace.memberExpression(prevId, identifier), setAttr(
2170
+ path,
2171
+ elem,
2172
+ key,
2173
+ identifier,
2174
+ { dynamic: true, prevId: prev }
2175
+ ))
2176
+ )
2177
+ )
2178
+ );
2179
+ });
2180
+
2181
+ return t__namespace.expressionStatement(
2182
+ t__namespace.callExpression(t__namespace.identifier(effectWrapperId), [
2183
+ t__namespace.arrowFunctionExpression(
2184
+ [prevId],
2185
+ t__namespace.blockStatement([
2186
+ t__namespace.variableDeclaration("const", decls),
2187
+ ...statements,
2188
+ t__namespace.returnStatement(prevId)
2189
+ ])
2190
+ ),
2191
+ t__namespace.objectExpression(identifiers.map(id => t__namespace.objectProperty(id, t__namespace.identifier("undefined"))))
2192
+ ])
2193
+ );
2194
+ }
2195
+
1855
2196
  function transformComponent(path) {
1856
- let props = [],
2197
+ let exprs = [],
2198
+ config = getConfig(path),
2199
+ tagName = getTagName(path.node),
2200
+ props = [],
1857
2201
  runningObject = [],
1858
- exprs = [],
1859
- tagName = getTagName(path.node);
2202
+ hasChildren = path.node.children.length > 0;
1860
2203
 
1861
2204
  if (config.builtIns.indexOf(tagName) > -1 && !path.scope.hasBinding(tagName)) {
1862
2205
  registerImportMethod(path, tagName);
@@ -1873,17 +2216,38 @@ function transformComponent(path) {
1873
2216
  props.push(t__namespace.objectExpression(runningObject));
1874
2217
  runningObject = [];
1875
2218
  }
1876
- props.push(node.argument);
2219
+ props.push(
2220
+ isDynamic(attribute.get("argument"), {
2221
+ checkMember: true
2222
+ })
2223
+ ? t__namespace.isCallExpression(node.argument) && !node.argument.arguments.length
2224
+ ? node.argument.callee
2225
+ : t__namespace.arrowFunctionExpression([], node.argument)
2226
+ : node.argument
2227
+ );
1877
2228
  } else {
1878
2229
  const value = node.value || t__namespace.booleanLiteral(true),
1879
2230
  key = t__namespace.isJSXNamespacedName(node.name)
1880
2231
  ? `${node.name.namespace.name}:${node.name.name.name}`
1881
2232
  : node.name.name,
1882
2233
  wrapName = t__namespace.isValidIdentifier(key) ? t__namespace.identifier : t__namespace.stringLiteral;
2234
+ if (hasChildren && key === "children") return;
1883
2235
  if (t__namespace.isJSXExpressionContainer(value))
1884
2236
  if (key === "ref") {
1885
2237
  if (config.generate === "ssr") return;
1886
- if (t__namespace.isLVal(value.expression)) {
2238
+ // Normalize expressions for non-null and type-as
2239
+ while (
2240
+ t__namespace.isTSNonNullExpression(value.expression) ||
2241
+ t__namespace.isTSAsExpression(value.expression)
2242
+ ) {
2243
+ value.expression = value.expression.expression;
2244
+ }
2245
+ let binding,
2246
+ isFunction =
2247
+ t__namespace.isIdentifier(value.expression) &&
2248
+ (binding = path.scope.getBinding(value.expression.name)) &&
2249
+ binding.kind === "const";
2250
+ if (!isFunction && t__namespace.isLVal(value.expression)) {
1887
2251
  const refIdentifier = path.scope.generateUidIdentifier("_ref$");
1888
2252
  runningObject.push(
1889
2253
  t__namespace.objectMethod(
@@ -1908,7 +2272,7 @@ function transformComponent(path) {
1908
2272
  ])
1909
2273
  )
1910
2274
  );
1911
- } else if (t__namespace.isFunction(value.expression)) {
2275
+ } else if (isFunction || t__namespace.isFunction(value.expression)) {
1912
2276
  runningObject.push(t__namespace.objectProperty(t__namespace.identifier("ref"), value.expression));
1913
2277
  } else if (t__namespace.isCallExpression(value.expression)) {
1914
2278
  const refIdentifier = path.scope.generateUidIdentifier("_ref$");
@@ -1967,7 +2331,7 @@ function transformComponent(path) {
1967
2331
  }
1968
2332
  });
1969
2333
 
1970
- const childResult = transformComponentChildren(path.get("children"));
2334
+ const childResult = transformComponentChildren(path.get("children"), config);
1971
2335
  if (childResult && childResult[0]) {
1972
2336
  if (childResult[1]) {
1973
2337
  const body =
@@ -2007,24 +2371,31 @@ function transformComponent(path) {
2007
2371
  return { exprs, template: "", component: true };
2008
2372
  }
2009
2373
 
2010
- function transformComponentChildren(children) {
2011
- const createTemplate$2 = config.generate === "ssr" ? createTemplate : createTemplate$1,
2374
+ function transformComponentChildren(children, config) {
2375
+ const createTemplate$3 =
2376
+ config.generate === "universal"
2377
+ ? createTemplate
2378
+ : config.generate === "ssr"
2379
+ ? createTemplate$1
2380
+ : createTemplate$2,
2012
2381
  filteredChildren = filterChildren(children);
2013
2382
  if (!filteredChildren.length) return;
2014
2383
  let dynamic = false;
2015
2384
 
2016
- let transformedChildren = filteredChildren.map(path => {
2385
+ let transformedChildren = filteredChildren.reduce((memo, path) => {
2017
2386
  if (t__namespace.isJSXText(path.node)) {
2018
- return t__namespace.stringLiteral(trimWhitespace(path.node.extra.rawValue));
2387
+ const v = htmlEntities.decode(trimWhitespace(path.node.extra.raw));
2388
+ if (v.length) memo.push(t__namespace.stringLiteral(v));
2019
2389
  } else {
2020
2390
  const child = transformNode(path, {
2021
2391
  topLevel: true,
2022
2392
  componentChild: true
2023
2393
  });
2024
2394
  dynamic = dynamic || child.dynamic;
2025
- return createTemplate$2(path, child, filteredChildren.length > 1);
2395
+ memo.push(createTemplate$3(path, child, filteredChildren.length > 1));
2026
2396
  }
2027
- });
2397
+ return memo;
2398
+ }, []);
2028
2399
 
2029
2400
  if (filteredChildren.length === 1) {
2030
2401
  transformedChildren = transformedChildren[0];
@@ -2048,20 +2419,30 @@ function transformComponentChildren(children) {
2048
2419
  return [transformedChildren, dynamic];
2049
2420
  }
2050
2421
 
2051
- function transformFragmentChildren(children, results) {
2052
- const createTemplate$2 = config.generate === "ssr" ? createTemplate : createTemplate$1,
2422
+ function transformFragmentChildren(children, results, config) {
2423
+ const createTemplate$3 =
2424
+ config.generate === "universal"
2425
+ ? createTemplate
2426
+ : config.generate === "ssr"
2427
+ ? createTemplate$1
2428
+ : createTemplate$2,
2053
2429
  filteredChildren = filterChildren(children),
2054
2430
  singleChild = filteredChildren.length === 1,
2055
- childNodes = filteredChildren.map(path => {
2056
- if (t__namespace.isJSXText(path.node)) return t__namespace.stringLiteral(trimWhitespace(path.node.extra.raw));
2057
- const child = transformNode(path, { topLevel: true, fragmentChild: true });
2058
- return createTemplate$2(path, child, !singleChild);
2059
- });
2431
+ childNodes = filteredChildren.reduce((memo, path) => {
2432
+ if (t__namespace.isJSXText(path.node)) {
2433
+ const v = htmlEntities.decode(trimWhitespace(path.node.extra.raw));
2434
+ if (v.length) memo.push(t__namespace.stringLiteral(v));
2435
+ } else {
2436
+ const child = transformNode(path, { topLevel: true, fragmentChild: true });
2437
+ memo.push(createTemplate$3(path, child, !singleChild));
2438
+ }
2439
+ return memo;
2440
+ }, []);
2060
2441
  results.exprs.push(singleChild ? childNodes[0] : t__namespace.arrayExpression(childNodes));
2061
2442
  }
2062
2443
 
2063
- function transformJSX(path, { opts }) {
2064
- Object.assign(config, opts);
2444
+ function transformJSX(path) {
2445
+ const config = getConfig(path);
2065
2446
  const replace = transformThis(path);
2066
2447
  const result = transformNode(
2067
2448
  path,
@@ -2071,7 +2452,12 @@ function transformJSX(path, { opts }) {
2071
2452
  topLevel: true
2072
2453
  }
2073
2454
  );
2074
- const template = config.generate === "ssr" ? createTemplate : createTemplate$1;
2455
+ const template =
2456
+ config.generate === "universal"
2457
+ ? createTemplate
2458
+ : config.generate === "ssr"
2459
+ ? createTemplate$1
2460
+ : createTemplate$2;
2075
2461
  path.replaceWith(replace(template(path, result, false)));
2076
2462
  }
2077
2463
 
@@ -2099,16 +2485,22 @@ function transformThis(path) {
2099
2485
  }
2100
2486
 
2101
2487
  function transformNode(path, info = {}) {
2488
+ const config = getConfig(path);
2102
2489
  const node = path.node;
2103
2490
  let staticValue;
2104
2491
  if (t__namespace.isJSXElement(node)) {
2105
2492
  let tagName = getTagName(node);
2106
2493
  if (isComponent(tagName)) return transformComponent(path);
2107
- const element = config.generate === "ssr" ? transformElement : transformElement$1;
2494
+ const element =
2495
+ config.generate === "universal"
2496
+ ? transformElement
2497
+ : config.generate === "ssr"
2498
+ ? transformElement$1
2499
+ : transformElement$2;
2108
2500
  return element(path, info);
2109
2501
  } else if (t__namespace.isJSXFragment(node)) {
2110
2502
  let results = { template: "", decl: [], exprs: [], dynamics: [] };
2111
- transformFragmentChildren(path.get("children"), results);
2503
+ transformFragmentChildren(path.get("children"), results, config);
2112
2504
  return results;
2113
2505
  } else if (t__namespace.isJSXText(node) || (staticValue = getStaticExpression(path))) {
2114
2506
  const text =
@@ -2187,6 +2579,7 @@ function transformNode(path, info = {}) {
2187
2579
 
2188
2580
  // add to the top/bottom of the module.
2189
2581
  var postprocess = path => {
2582
+ const config = getConfig(path);
2190
2583
  if (path.scope.data.events) {
2191
2584
  registerImportMethod(path, "delegateEvents");
2192
2585
  path.node.body.push(
@@ -2203,7 +2596,23 @@ var postprocess = path => {
2203
2596
  }
2204
2597
  };
2205
2598
 
2206
- var preprocess = path => {
2599
+ var config = {
2600
+ moduleName: "dom",
2601
+ generate: "dom",
2602
+ hydratable: false,
2603
+ delegateEvents: true,
2604
+ delegatedEvents: [],
2605
+ builtIns: [],
2606
+ requireImportSource: false,
2607
+ wrapConditionals: true,
2608
+ contextToCustomElements: false,
2609
+ staticMarker: "@once",
2610
+ effectWrapper: "effect",
2611
+ memoWrapper: "memo"
2612
+ };
2613
+
2614
+ var preprocess = (path, { opts }) => {
2615
+ path.hub.file.metadata.config = Object.assign({}, config, opts);
2207
2616
  const lib = config.requireImportSource;
2208
2617
  if (lib) {
2209
2618
  const comments = path.hub.file.ast.comments;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "babel-plugin-jsx-dom-expressions",
3
3
  "description": "A JSX to DOM plugin that wraps expressions for fine grained change detection",
4
- "version": "0.29.16",
4
+ "version": "0.30.3",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -20,7 +20,8 @@
20
20
  "dependencies": {
21
21
  "@babel/helper-module-imports": "^7.10.4",
22
22
  "@babel/plugin-syntax-jsx": "^7.10.4",
23
- "@babel/types": "^7.11.5"
23
+ "@babel/types": "^7.11.5",
24
+ "html-entities": "2.3.2"
24
25
  },
25
- "gitHead": "394e9b0081d5c6221a406ed18b4cd22329a32cc3"
26
+ "gitHead": "4eb94a2d860cb1b1fa09cce9b47c52e72f2e6648"
26
27
  }