solid-optimizer 1.0.0-next.6 → 1.0.0-next.7

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.
@@ -1,6 +1,7 @@
1
1
  import remapping from "@jridgewell/remapping";
2
2
  import MagicString from "magic-string";
3
3
  import { parseSync, rawTransferSupported, visitorKeys } from "oxc-parser";
4
+ import { parse, parseFragment, serialize } from "parse5";
4
5
  //#region src/ast.ts
5
6
  /**
6
7
  * Keys that only hold TypeScript types. Types never run, so no pass reads or rewrites them.
@@ -65,7 +66,7 @@ function collectParents(program) {
65
66
  * is several times faster to read. It is not in the options' type yet.
66
67
  */
67
68
  const RAW_TRANSFER = rawTransferSupported();
68
- function parse(filename, code) {
69
+ function parse$1(filename, code) {
69
70
  const options = {
70
71
  lang: getLanguage(filename),
71
72
  sourceType: "module",
@@ -993,7 +994,7 @@ function constantExports(program, options, scopes = analyzeScopes(program)) {
993
994
  //#endregion
994
995
  //#region src/jsx.ts
995
996
  function keptPiece(node) {
996
- const text = node.type === "JSXText" ? node : void 0;
997
+ const text = node.type === "JSXText" ? node.value : void 0;
997
998
  return {
998
999
  node,
999
1000
  text: void 0,
@@ -1008,27 +1009,39 @@ function splicePiece(s, node, children) {
1008
1009
  const first = children.at(0);
1009
1010
  const last = children.at(-1);
1010
1011
  if (!first || !last) return replacedPiece(node, "");
1011
- return {
1012
- node,
1013
- text: s.slice(first.start, last.end),
1014
- startText: first.type === "JSXText" ? first : void 0,
1015
- endText: last.type === "JSXText" ? last : void 0
1016
- };
1012
+ return replacedPiece(node, s.slice(first.start, last.end));
1017
1013
  }
1014
+ /**
1015
+ * A piece that writes `text`, JSX children as source, in place of `node`.
1016
+ *
1017
+ * The texts it starts and ends with are read from `text` itself, not from
1018
+ * the children it came from. A fold inside them in the same round can have
1019
+ * turned a child that was an element into text, such as an inner `<Show>`.
1020
+ * JSX text holds no `<`, `>`, `{`, or `}`, so the first and last of those
1021
+ * mark where the text ends.
1022
+ */
1018
1023
  function replacedPiece(node, text) {
1024
+ const start = text.search(/[<{]/);
1025
+ const end = Math.max(text.lastIndexOf(">"), text.lastIndexOf("}"));
1026
+ const startText = start === -1 ? text : text.slice(0, start);
1027
+ const endText = text.slice(end + 1);
1019
1028
  return {
1020
1029
  node,
1021
1030
  text,
1022
- startText: void 0,
1023
- endText: void 0
1031
+ startText: startText === "" ? void 0 : startText,
1032
+ endText: endText === "" ? void 0 : endText
1024
1033
  };
1025
1034
  }
1035
+ /** Whether JSX drops this text: whitespace that contains a line break. */
1036
+ function isDroppedText(text) {
1037
+ return /^\s*$/.test(text) && /[\r\n]/.test(text);
1038
+ }
1026
1039
  /**
1027
1040
  * Whether two texts render differently as one text node than apart.
1028
1041
  * Two texts that JSX drops, like line breaks and indentation, still drop together.
1029
1042
  */
1030
1043
  function mergeChangesText(before, after) {
1031
- return before !== void 0 && after !== void 0 && !(isFilteredText(before) && isFilteredText(after));
1044
+ return before !== void 0 && after !== void 0 && !(isDroppedText(before) && isDroppedText(after));
1032
1045
  }
1033
1046
  /**
1034
1047
  * Puts `{}` between two pieces that meet as text, on whichever side is replaced.
@@ -1689,16 +1702,10 @@ var Folder = class {
1689
1702
  primary: true
1690
1703
  };
1691
1704
  case "JSXElement":
1692
- case "JSXFragment": return {
1693
- kind: "jsx",
1694
- text: getText(this.context, value)
1695
- };
1705
+ case "JSXFragment": return this.foldedJSX(value);
1696
1706
  default:
1697
1707
  if (value.expression.type === "JSXEmptyExpression") return EMPTY;
1698
- if (value.expression.type === "JSXElement" || value.expression.type === "JSXFragment") return {
1699
- kind: "jsx",
1700
- text: getText(this.context, value.expression)
1701
- };
1708
+ if (value.expression.type === "JSXElement" || value.expression.type === "JSXFragment") return this.foldedJSX(value.expression);
1702
1709
  return {
1703
1710
  kind: "expression",
1704
1711
  text: getText(this.context, value.expression),
@@ -1706,6 +1713,23 @@ var Folder = class {
1706
1713
  };
1707
1714
  }
1708
1715
  }
1716
+ /**
1717
+ * What a JSX value renders, read after the folds of this round. A fold
1718
+ * inside it can have replaced it with an expression already, such as an
1719
+ * inner `<Show>` that became its string `fallback`.
1720
+ */
1721
+ foldedJSX(node) {
1722
+ const text = getText(this.context, node);
1723
+ if (text.startsWith("<")) return {
1724
+ kind: "jsx",
1725
+ text
1726
+ };
1727
+ return {
1728
+ kind: "expression",
1729
+ text,
1730
+ primary: false
1731
+ };
1732
+ }
1709
1733
  foldShow(element) {
1710
1734
  const when = this.attributeTruthiness(element, "when");
1711
1735
  if (when === void 0) return;
@@ -1888,7 +1912,7 @@ var Folder = class {
1888
1912
  const inTemplate = this.joinsParentTemplate(element);
1889
1913
  const loop = new SizeEstimator(this.context.code).jsx(element, inTemplate) + (declaration ? compactLength(this.context.code.slice(declaration.start, declaration.end)) : 0);
1890
1914
  const code = `const __so_rows__ = ${text};`;
1891
- const statement = parse(this.context.filename, code).body.at(0);
1915
+ const statement = parse$1(this.context.filename, code).body.at(0);
1892
1916
  const init = statement?.type === "VariableDeclaration" ? statement.declarations.at(0)?.init : void 0;
1893
1917
  if (init?.type !== "JSXFragment") return false;
1894
1918
  const estimator = new SizeEstimator(code);
@@ -2722,7 +2746,7 @@ function copySize(filename, header, copy, inTemplate, options, called, measured)
2722
2746
  for (let round = 0; round < 4; round += 1) {
2723
2747
  let changed = false;
2724
2748
  for (const pass of calls ? [fold, calls.inline] : [fold]) {
2725
- const program = parse(filename, code);
2749
+ const program = parse$1(filename, code);
2726
2750
  const s = new MagicString(code);
2727
2751
  depth += 1;
2728
2752
  let passChanged;
@@ -2748,7 +2772,7 @@ function copySize(filename, header, copy, inTemplate, options, called, measured)
2748
2772
  if (!changed) break;
2749
2773
  }
2750
2774
  if (measured) measured.code = code;
2751
- const wrapper = parse(filename, code).body.at(-1);
2775
+ const wrapper = parse$1(filename, code).body.at(-1);
2752
2776
  if (wrapper?.type !== "FunctionDeclaration" || !wrapper.body) return Number.POSITIVE_INFINITY;
2753
2777
  const estimator = new SizeEstimator(code);
2754
2778
  let size = 0;
@@ -3795,7 +3819,10 @@ var Inliner = class {
3795
3819
  const statements = [...snapshots];
3796
3820
  const first = component.statements.at(0);
3797
3821
  const last = component.statements.at(-1);
3798
- if (first && last) statements.push(copy.slice(first.start, last.end));
3822
+ if (first && last) {
3823
+ const text = copy.slice(first.start, last.end);
3824
+ statements.push(text.endsWith(";") ? text : `${text};`);
3825
+ }
3799
3826
  return {
3800
3827
  element,
3801
3828
  host,
@@ -3803,19 +3830,22 @@ var Inliner = class {
3803
3830
  root: copy.slice(component.root.start, component.root.end)
3804
3831
  };
3805
3832
  }
3833
+ /** Queues statements for a host. Each `return` gets its own, since their scopes can differ. */
3834
+ addToHost(found, texts) {
3835
+ const key = found.host.kind === "return" ? found.host.statement : found.fn;
3836
+ const entry = this.hosts.get(key) ?? {
3837
+ host: found.host,
3838
+ texts: []
3839
+ };
3840
+ entry.texts.push(...texts);
3841
+ this.hosts.set(key, entry);
3842
+ }
3806
3843
  /**
3807
3844
  * Writes a prepared copy over its call site.
3808
3845
  */
3809
3846
  commit(site) {
3810
3847
  this.context.s.overwrite(site.element.start, site.element.end, site.root);
3811
- if (site.host) {
3812
- const entry = this.hosts.get(site.host.fn) ?? {
3813
- host: site.host.host,
3814
- texts: []
3815
- };
3816
- entry.texts.push(...site.statements);
3817
- this.hosts.set(site.host.fn, entry);
3818
- }
3848
+ if (site.host) this.addToHost(site.host, site.statements);
3819
3849
  }
3820
3850
  /**
3821
3851
  * The context reads in a component's copy at `element` that a closed
@@ -3895,12 +3925,7 @@ var Inliner = class {
3895
3925
  const host = this.findHost(element);
3896
3926
  if (!host) continue;
3897
3927
  const name = this.freshName(`${provider.context.name.charAt(0).toLowerCase()}${provider.context.name.slice(1)}Value`);
3898
- const entry = this.hosts.get(host.fn) ?? {
3899
- host: host.host,
3900
- texts: []
3901
- };
3902
- entry.texts.push(`const ${name} = ${getText(this.context, provider.value)};`);
3903
- this.hosts.set(host.fn, entry);
3928
+ this.addToHost(host, [`const ${name} = ${getText(this.context, provider.value)};`]);
3904
3929
  this.context.s.overwrite(provider.value.start, provider.value.end, name);
3905
3930
  this.transparent.set(element, {
3906
3931
  provider,
@@ -4051,17 +4076,7 @@ var Inliner = class {
4051
4076
  }
4052
4077
  }
4053
4078
  splicedPiece(container, value) {
4054
- if (value.kind === "children") {
4055
- const first = value.children.at(0);
4056
- const last = value.children.at(-1);
4057
- if (!first || !last) return replacedPiece(container, "");
4058
- return {
4059
- node: container,
4060
- text: this.context.s.slice(first.start, last.end),
4061
- startText: first.type === "JSXText" ? first : void 0,
4062
- endText: last.type === "JSXText" ? last : void 0
4063
- };
4064
- }
4079
+ if (value.kind === "children") return splicePiece(this.context.s, container, value.children);
4065
4080
  return replacedPiece(container, value.text);
4066
4081
  }
4067
4082
  /**
@@ -4518,29 +4533,81 @@ const TRACKED_PROPS = /* @__PURE__ */ new Map([
4518
4533
  ["Repeat", "count"]
4519
4534
  ]);
4520
4535
  /**
4536
+ * Global constructors whose instances are never thenable or async iterable.
4537
+ */
4538
+ const SYNC_CONSTRUCTORS = /* @__PURE__ */ new Set([
4539
+ "Array",
4540
+ "Date",
4541
+ "Error",
4542
+ "Map",
4543
+ "RegExp",
4544
+ "Set",
4545
+ "URL",
4546
+ "URLSearchParams",
4547
+ "WeakMap",
4548
+ "WeakSet"
4549
+ ]);
4550
+ /**
4551
+ * Whether an object literal can have a `then` method or `Symbol.asyncIterator`,
4552
+ * its own or from a `__proto__` it sets.
4553
+ */
4554
+ function mayBeThenable(node) {
4555
+ for (const property of node.properties) {
4556
+ if (property.type === "SpreadElement" || property.computed) return true;
4557
+ const { key } = property;
4558
+ let name;
4559
+ if (key.type === "Identifier") name = key.name;
4560
+ else if ("value" in key) name = key.value;
4561
+ if (name === "then" || name === "__proto__") return true;
4562
+ }
4563
+ return false;
4564
+ }
4565
+ /**
4521
4566
  * Whether evaluating `node` always creates a new value, which reference
4522
- * equality never finds equal to the last one.
4567
+ * equality never finds equal to the last one. The value is never a promise
4568
+ * or an async iterable, which a memo waits for and an inlined read does not.
4569
+ * `isGlobal` tells whether a name is one the module does not declare.
4523
4570
  */
4524
- function isFresh(node) {
4571
+ function isFresh(node, isGlobal) {
4525
4572
  switch (node.type) {
4526
- case "ObjectExpression":
4527
4573
  case "ArrayExpression":
4528
4574
  case "ArrowFunctionExpression":
4529
4575
  case "FunctionExpression":
4530
- case "ClassExpression":
4531
- case "NewExpression":
4532
4576
  case "JSXElement":
4533
4577
  case "JSXFragment": return true;
4534
- case "ParenthesizedExpression": return isFresh(node.expression);
4535
- case "ConditionalExpression": return isFresh(node.consequent) && isFresh(node.alternate);
4578
+ case "ObjectExpression": return !mayBeThenable(node);
4579
+ case "NewExpression": return node.callee.type === "Identifier" && SYNC_CONSTRUCTORS.has(node.callee.name) && isGlobal(node.callee);
4580
+ case "ParenthesizedExpression": return isFresh(node.expression, isGlobal);
4581
+ case "ConditionalExpression": return isFresh(node.consequent, isGlobal) && isFresh(node.alternate, isGlobal);
4536
4582
  case "SequenceExpression": {
4537
4583
  const last = node.expressions.at(-1);
4538
- return last !== void 0 && isFresh(last);
4584
+ return last !== void 0 && isFresh(last, isGlobal);
4539
4585
  }
4540
4586
  default: return false;
4541
4587
  }
4542
4588
  }
4543
4589
  /**
4590
+ * Whether `node` evaluates to a value that is never a promise or an async
4591
+ * iterable. A memo waits for one of those, and an inlined read does not.
4592
+ */
4593
+ function isSync(node, isGlobal) {
4594
+ switch (node.type) {
4595
+ case "Literal":
4596
+ case "TemplateLiteral":
4597
+ case "UnaryExpression":
4598
+ case "UpdateExpression":
4599
+ case "BinaryExpression": return true;
4600
+ case "ParenthesizedExpression": return isSync(node.expression, isGlobal);
4601
+ case "ConditionalExpression": return isSync(node.consequent, isGlobal) && isSync(node.alternate, isGlobal);
4602
+ case "LogicalExpression": return isSync(node.left, isGlobal) && isSync(node.right, isGlobal);
4603
+ case "SequenceExpression": {
4604
+ const last = node.expressions.at(-1);
4605
+ return last !== void 0 && isSync(last, isGlobal);
4606
+ }
4607
+ default: return isFresh(node, isGlobal);
4608
+ }
4609
+ }
4610
+ /**
4544
4611
  * The text of an expression that always gives the same primitive: a literal
4545
4612
  * other than a regular expression, a template literal without expressions,
4546
4613
  * or a negated number.
@@ -4770,7 +4837,12 @@ var MemoInliner = class {
4770
4837
  } else {
4771
4838
  const constant = constantText(this.context, expression);
4772
4839
  if (constant !== void 0) return this.inlineConstant(declarator, binding, constant);
4773
- if (!alwaysNotifies && !isFresh(expression)) return;
4840
+ const isGlobal = (node) => this.context.scopes.references.get(node) === void 0;
4841
+ if (!alwaysNotifies && !isFresh(expression, isGlobal)) return;
4842
+ if (alwaysNotifies && !isSync(expression, isGlobal)) {
4843
+ this.reason = "memo-async";
4844
+ return;
4845
+ }
4774
4846
  }
4775
4847
  if (binding.references.length !== 1) {
4776
4848
  this.reason = "memo-reads";
@@ -4900,6 +4972,233 @@ function inlineMemos(context) {
4900
4972
  return inliner.changed;
4901
4973
  }
4902
4974
  //#endregion
4975
+ //#region src/nesting.ts
4976
+ const VOID_ELEMENTS = /* @__PURE__ */ new Set([
4977
+ "area",
4978
+ "base",
4979
+ "br",
4980
+ "col",
4981
+ "embed",
4982
+ "hr",
4983
+ "img",
4984
+ "input",
4985
+ "keygen",
4986
+ "link",
4987
+ "meta",
4988
+ "param",
4989
+ "source",
4990
+ "track",
4991
+ "wbr"
4992
+ ]);
4993
+ const SVG_ELEMENTS = /* @__PURE__ */ new Set([
4994
+ "altGlyph",
4995
+ "altGlyphDef",
4996
+ "altGlyphItem",
4997
+ "animate",
4998
+ "animateColor",
4999
+ "animateMotion",
5000
+ "animateTransform",
5001
+ "circle",
5002
+ "clipPath",
5003
+ "cursor",
5004
+ "defs",
5005
+ "desc",
5006
+ "ellipse",
5007
+ "feBlend",
5008
+ "feColorMatrix",
5009
+ "feComponentTransfer",
5010
+ "feComposite",
5011
+ "feConvolveMatrix",
5012
+ "feDiffuseLighting",
5013
+ "feDisplacementMap",
5014
+ "feDistantLight",
5015
+ "feDropShadow",
5016
+ "feFlood",
5017
+ "feFuncA",
5018
+ "feFuncB",
5019
+ "feFuncG",
5020
+ "feFuncR",
5021
+ "feGaussianBlur",
5022
+ "feImage",
5023
+ "feMerge",
5024
+ "feMergeNode",
5025
+ "feMorphology",
5026
+ "feOffset",
5027
+ "fePointLight",
5028
+ "feSpecularLighting",
5029
+ "feSpotLight",
5030
+ "feTile",
5031
+ "feTurbulence",
5032
+ "filter",
5033
+ "font",
5034
+ "foreignObject",
5035
+ "g",
5036
+ "glyph",
5037
+ "glyphRef",
5038
+ "hkern",
5039
+ "image",
5040
+ "line",
5041
+ "linearGradient",
5042
+ "marker",
5043
+ "mask",
5044
+ "metadata",
5045
+ "mpath",
5046
+ "path",
5047
+ "pattern",
5048
+ "polygon",
5049
+ "polyline",
5050
+ "radialGradient",
5051
+ "rect",
5052
+ "set",
5053
+ "stop",
5054
+ "switch",
5055
+ "symbol",
5056
+ "text",
5057
+ "textPath",
5058
+ "tref",
5059
+ "tspan",
5060
+ "use",
5061
+ "view",
5062
+ "vkern"
5063
+ ]);
5064
+ function findElement(parent, name) {
5065
+ for (const child of parent.childNodes) if (child.nodeName === name && "childNodes" in child) return child;
5066
+ throw new Error(`[solid-optimizer] no <${name}> in an empty document`);
5067
+ }
5068
+ let body;
5069
+ /** What a browser makes of `html` set as the body's `innerHTML`. */
5070
+ function parseAsBody(html) {
5071
+ body ??= findElement(findElement(parse("<!DOCTYPE html><html><body></body></html>"), "html"), "body");
5072
+ return serialize(parseFragment(body, html, {}));
5073
+ }
5074
+ /** The tag of an intrinsic element, or `undefined` for a component or a namespaced tag. */
5075
+ function readIntrinsicTag(element) {
5076
+ const name = element.openingElement.name;
5077
+ return name.type === "JSXIdentifier" && isIntrinsicTag(name.name) ? name.name : void 0;
5078
+ }
5079
+ /**
5080
+ * The template rooted at `element`. Elements inside fragments join it.
5081
+ * Elements in expression containers or under a component start their own.
5082
+ */
5083
+ function collectTemplate(element, tag) {
5084
+ const node = {
5085
+ element,
5086
+ tag,
5087
+ children: []
5088
+ };
5089
+ addTemplateChildren(node, element.children);
5090
+ return node;
5091
+ }
5092
+ function addTemplateChildren(node, children) {
5093
+ for (const child of children) if (child.type === "JSXFragment") addTemplateChildren(node, child.children);
5094
+ else if (child.type === "JSXElement") {
5095
+ const tag = readIntrinsicTag(child);
5096
+ if (tag !== void 0) node.children.push(collectTemplate(child, tag));
5097
+ }
5098
+ }
5099
+ /**
5100
+ * The tags of a template, without text or attributes. Elements not in
5101
+ * `included` are left out with what they hold.
5102
+ */
5103
+ function writeTags(node, included) {
5104
+ if (VOID_ELEMENTS.has(node.tag)) return `<${node.tag}>`;
5105
+ let inner = "";
5106
+ for (const child of node.children) if (included.has(child)) inner += writeTags(child, included);
5107
+ return `<${node.tag}>${inner}</${node.tag}>`;
5108
+ }
5109
+ /**
5110
+ * Table parts parse only inside a table, and SVG parts only inside an
5111
+ * `<svg>`, so a template rooted at one is checked inside one, as Solid
5112
+ * creates it.
5113
+ */
5114
+ function placeInContext(tag, html) {
5115
+ if (SVG_ELEMENTS.has(tag)) return `<svg>${html}</svg>`;
5116
+ switch (tag) {
5117
+ case "td":
5118
+ case "th": return `<table><tbody><tr>${html}</tr></tbody></table>`;
5119
+ case "tr": return `<table><tbody>${html}</tbody></table>`;
5120
+ case "col": return `<table><colgroup>${html}</colgroup></table>`;
5121
+ case "thead":
5122
+ case "tbody":
5123
+ case "tfoot":
5124
+ case "colgroup":
5125
+ case "caption": return `<table>${html}</table>`;
5126
+ default: return html;
5127
+ }
5128
+ }
5129
+ /** Whether a `<template>` in the template holds an element, which Solid rejects. */
5130
+ function hasTemplateContent(node, included) {
5131
+ for (const child of node.children) if (included.has(child) && (node.tag === "template" || hasTemplateContent(child, included))) return true;
5132
+ return false;
5133
+ }
5134
+ function isValidTemplate(root, included) {
5135
+ if (hasTemplateContent(root, included)) return false;
5136
+ const html = placeInContext(root.tag, writeTags(root, included));
5137
+ return parseAsBody(html).toLowerCase() === html.toLowerCase();
5138
+ }
5139
+ function collectAll(node, into) {
5140
+ into.add(node);
5141
+ for (const child of node.children) collectAll(child, into);
5142
+ return into;
5143
+ }
5144
+ /**
5145
+ * Wraps the elements that make `root`'s template parse differently, and
5146
+ * returns the wrapped elements, each the root of a template of its own.
5147
+ */
5148
+ function wrapInvalidElements(context, root) {
5149
+ if (isValidTemplate(root, collectAll(root, /* @__PURE__ */ new Set()))) return [];
5150
+ const included = /* @__PURE__ */ new Set([root]);
5151
+ if (!isValidTemplate(root, included)) return [];
5152
+ const wrapped = [];
5153
+ const pending = [];
5154
+ pushChildren(pending, root);
5155
+ for (let node = pending.pop(); node; node = pending.pop()) {
5156
+ included.add(node);
5157
+ if (!isValidTemplate(root, included)) {
5158
+ included.delete(node);
5159
+ context.s.prependRight(node.element.start, "{");
5160
+ context.s.appendLeft(node.element.end, "}");
5161
+ wrapped.push(node);
5162
+ continue;
5163
+ }
5164
+ pushChildren(pending, node);
5165
+ }
5166
+ return wrapped;
5167
+ }
5168
+ /** Pushes the children of `node` so that they pop in source order. */
5169
+ function pushChildren(pending, node) {
5170
+ for (let index = node.children.length - 1; index >= 0; index -= 1) pending.push(node.children[index]);
5171
+ }
5172
+ function repairNesting(context) {
5173
+ const roots = [];
5174
+ const visit = (node, inTemplate) => {
5175
+ if (node.type === "JSXElement") {
5176
+ const tag = readIntrinsicTag(node);
5177
+ if (tag !== void 0 && !inTemplate) roots.push(collectTemplate(node, tag));
5178
+ for (const child of node.children) visit(child, tag !== void 0);
5179
+ for (const attribute of node.openingElement.attributes) visit(attribute, false);
5180
+ return;
5181
+ }
5182
+ if (node.type === "JSXFragment") {
5183
+ for (const child of node.children) visit(child, inTemplate);
5184
+ return;
5185
+ }
5186
+ forEachChild(node, (child) => {
5187
+ visit(child, false);
5188
+ });
5189
+ };
5190
+ visit(context.program, false);
5191
+ let changed = false;
5192
+ for (let root = roots.pop(); root; root = roots.pop()) {
5193
+ const wrapped = wrapInvalidElements(context, root);
5194
+ if (wrapped.length > 0) {
5195
+ changed = true;
5196
+ roots.push(...wrapped);
5197
+ }
5198
+ }
5199
+ return changed;
5200
+ }
5201
+ //#endregion
4903
5202
  //#region src/conditional.ts
4904
5203
  /**
4905
5204
  * Rewrites each `<Show>` and `<Switch>` that can be lowered. One inside
@@ -5226,7 +5525,7 @@ function resolveOptions(options) {
5226
5525
  };
5227
5526
  }
5228
5527
  function parseCode(code, filename) {
5229
- const program = parse(filename, code);
5528
+ const program = parse$1(filename, code);
5230
5529
  return {
5231
5530
  code,
5232
5531
  program,
@@ -5307,6 +5606,13 @@ function compile(code, options = {}) {
5307
5606
  current = result.code;
5308
5607
  if (result.map !== void 0) maps.push(result.map);
5309
5608
  }
5609
+ if (current !== code) {
5610
+ const result = runPass(parsedCurrent(), filename, resolved, sourceMap, repairNesting, void 0);
5611
+ if (result) {
5612
+ current = result.code;
5613
+ if (result.map !== void 0) maps.push(result.map);
5614
+ }
5615
+ }
5310
5616
  const report = skipped ? { skipped } : {};
5311
5617
  if (maps.length === 0) return {
5312
5618
  code: current,
@@ -5326,7 +5632,7 @@ function compile(code, options = {}) {
5326
5632
  * Only `filename`, `importedConstants`, and `globalConstants` of the options are used.
5327
5633
  */
5328
5634
  function readModuleConstants(code, options = {}) {
5329
- const program = parse(options.filename ?? "input.jsx", code);
5635
+ const program = parse$1(options.filename ?? "input.jsx", code);
5330
5636
  const scopes = analyzeScopes(program);
5331
5637
  return {
5332
5638
  imports: namedImportSources(program, scopes),
@@ -5334,6 +5640,6 @@ function readModuleConstants(code, options = {}) {
5334
5640
  };
5335
5641
  }
5336
5642
  //#endregion
5337
- export { lookup as a, forEachChild as c, unwrap as d, analyzeScopes as i, isIntrinsicTag as l, readModuleConstants as n, scopeAt as o, CONTEXT_SAFE_PRIMITIVES as r, collectParents as s, compile as t, parse as u };
5643
+ export { lookup as a, forEachChild as c, unwrap as d, analyzeScopes as i, isIntrinsicTag as l, readModuleConstants as n, scopeAt as o, CONTEXT_SAFE_PRIMITIVES as r, collectParents as s, compile as t, parse$1 as u };
5338
5644
 
5339
- //# sourceMappingURL=compile-DnfP-Quf.mjs.map
5645
+ //# sourceMappingURL=compile-BuPR3pVT.mjs.map