@rolldown-plugin/solid 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -11,7 +11,6 @@ interface Options$1 {
11
11
  onlyRemoveTypeImports?: boolean;
12
12
  optimizeConstEnums?: boolean;
13
13
  rewriteImportExtensions?: boolean;
14
- allExtensions?: boolean;
15
14
  isTSX?: boolean;
16
15
  }
17
16
  //#endregion
package/dist/index.mjs CHANGED
@@ -147,7 +147,7 @@ function checkLength(children) {
147
147
  }
148
148
  function trimWhitespace(text) {
149
149
  text = text.replace(/\r/g, "");
150
- if (/\n/g.test(text)) text = text.split("\n").map((t$1, i) => i ? t$1.replace(/^\s*/g, "") : t$1).filter((s) => !/^\s*$/.test(s)).join(" ");
150
+ if (/\n/g.test(text)) text = text.split("\n").map((t, i) => i ? t.replace(/^\s*/g, "") : t).filter((s) => !/^\s*$/.test(s)).join(" ");
151
151
  return text.replace(/\s+/g, " ");
152
152
  }
153
153
  function toEventName(name) {
@@ -589,30 +589,29 @@ const voidElements = [
589
589
  "track",
590
590
  "wbr"
591
591
  ];
592
- var VoidElements_default = voidElements;
593
592
 
594
593
  //#endregion
595
594
  //#region src/babel-plugin-jsx-dom-expressions/babel-plugin-jsx-dom-expressions/ssr/template.ts
596
595
  function createTemplate$2(path, result) {
597
596
  if (!result.template) return result.exprs[0];
598
- let template$1, id;
599
- if (!Array.isArray(result.template)) template$1 = t.stringLiteral(result.template);
600
- else if (result.template.length === 1) template$1 = t.stringLiteral(result.template[0]);
597
+ let template, id;
598
+ if (!Array.isArray(result.template)) template = t.stringLiteral(result.template);
599
+ else if (result.template.length === 1) template = t.stringLiteral(result.template[0]);
601
600
  else {
602
601
  const strings = result.template.map((tmpl) => t.stringLiteral(tmpl));
603
- template$1 = t.arrayExpression(strings);
602
+ template = t.arrayExpression(strings);
604
603
  }
605
604
  const templates = path.scope.getProgramParent().data.templates || (path.scope.getProgramParent().data.templates = []);
606
605
  const found = templates.find((tmp) => {
607
- if (t.isArrayExpression(tmp.template) && t.isArrayExpression(template$1)) return tmp.template.elements.every((el, i) => template$1.elements[i] && el.value === template$1.elements[i].value);
608
- return tmp.template.value === template$1.value;
606
+ if (t.isArrayExpression(tmp.template) && t.isArrayExpression(template)) return tmp.template.elements.every((el, i) => template.elements[i] && el.value === template.elements[i].value);
607
+ return tmp.template.value === template.value;
609
608
  });
610
609
  if (!found) {
611
610
  id = path.scope.generateUidIdentifier("tmpl$");
612
611
  templates.push({
613
612
  id,
614
- template: template$1,
615
- templateWithClosingTags: template$1,
613
+ template,
614
+ templateWithClosingTags: template,
616
615
  renderer: "ssr"
617
616
  });
618
617
  } else id = found.id;
@@ -623,19 +622,19 @@ function createTemplate$2(path, result) {
623
622
  return t.callExpression(registerImportMethod(path, "ssr"), Array.isArray(result.template) && result.template.length > 1 ? [id, ...result.templateValues] : [id]);
624
623
  }
625
624
  function appendTemplates$1(path, templates) {
626
- const declarators = templates.map((template$1) => {
627
- return t.variableDeclarator(template$1.id, template$1.template);
625
+ const declarators = templates.map((template) => {
626
+ return t.variableDeclarator(template.id, template.template);
628
627
  });
629
628
  path.node.body.unshift(t.variableDeclaration("var", declarators));
630
629
  }
631
630
 
632
631
  //#endregion
633
632
  //#region src/babel-plugin-jsx-dom-expressions/babel-plugin-jsx-dom-expressions/ssr/element.ts
634
- function appendToTemplate(template$1, value) {
633
+ function appendToTemplate(template, value) {
635
634
  let array;
636
635
  if (Array.isArray(value)) [value, ...array] = value;
637
- template$1[template$1.length - 1] += value;
638
- if (array && array.length) template$1.push.apply(template$1, array);
636
+ template[template.length - 1] += value;
637
+ if (array && array.length) template.push.apply(template, array);
639
638
  }
640
639
  function transformElement$3(path, info) {
641
640
  const config = getConfig(path);
@@ -645,7 +644,7 @@ function transformElement$3(path, info) {
645
644
  ...info,
646
645
  ...config
647
646
  });
648
- const voidTag = VoidElements_default.indexOf(tagName) > -1, results = {
647
+ const voidTag = voidElements.indexOf(tagName) > -1, results = {
649
648
  template: [`<${tagName}`],
650
649
  templateValues: [],
651
650
  declarations: [],
@@ -897,14 +896,14 @@ function transformChildren$2(path, results, { hydratable }) {
897
896
  const multi = checkLength(filteredChildren), markers = hydratable && multi;
898
897
  filteredChildren.forEach((node) => {
899
898
  if (t.isJSXElement(node.node) && getTagName(node.node) === "head") {
900
- const child$1 = transformNode(node, {
899
+ const child = transformNode(node, {
901
900
  doNotEscape,
902
901
  hydratable: false
903
902
  });
904
903
  registerImportMethod(path, "NoHydration");
905
904
  registerImportMethod(path, "createComponent");
906
905
  results.template.push("");
907
- results.templateValues.push(t.callExpression(t.identifier("_$createComponent"), [t.identifier("_$NoHydration"), t.objectExpression([t.objectMethod("get", t.identifier("children"), [], t.blockStatement([t.returnStatement(createTemplate$2(path, child$1))]))])]));
906
+ results.templateValues.push(t.callExpression(t.identifier("_$createComponent"), [t.identifier("_$NoHydration"), t.objectExpression([t.objectMethod("get", t.identifier("children"), [], t.blockStatement([t.returnStatement(createTemplate$2(path, child))]))])]));
908
907
  return;
909
908
  }
910
909
  const child = transformNode(node, { doNotEscape });
@@ -927,15 +926,15 @@ function transformChildren$2(path, results, { hydratable }) {
927
926
  }
928
927
  function createElement(path, { topLevel, hydratable }) {
929
928
  const tagName = getTagName(path.node), config = getConfig(path), attributes = normalizeAttributes(path), doNotEscape = path.doNotEscape;
930
- const filteredChildren = filterChildren(path.get("children")), multi = checkLength(filteredChildren), markers = hydratable && multi, childNodes = filteredChildren.reduce((memo, path$1) => {
931
- if (t.isJSXText(path$1.node)) {
932
- const v$1 = decode(trimWhitespace(path$1.node.extra.raw));
933
- if (v$1.length) memo.push(t.stringLiteral(v$1));
929
+ const filteredChildren = filterChildren(path.get("children")), multi = checkLength(filteredChildren), markers = hydratable && multi, childNodes = filteredChildren.reduce((memo, path) => {
930
+ if (t.isJSXText(path.node)) {
931
+ const v = decode(trimWhitespace(path.node.extra.raw));
932
+ if (v.length) memo.push(t.stringLiteral(v));
934
933
  } else {
935
- const child = transformNode(path$1);
934
+ const child = transformNode(path);
936
935
  if (markers && child.exprs.length && !child.spreadElement) memo.push(t.stringLiteral("<!--$-->"));
937
- if (child.exprs.length && !doNotEscape && !child.spreadElement) child.exprs[0] = escapeExpression(path$1, child.exprs[0]);
938
- memo.push(getCreateTemplate(config, path$1, child)(path$1, child, true));
936
+ if (child.exprs.length && !doNotEscape && !child.spreadElement) child.exprs[0] = escapeExpression(path, child.exprs[0]);
937
+ memo.push(getCreateTemplate(config, path, child)(path, child, true));
939
938
  if (markers && child.exprs.length && !child.spreadElement) memo.push(t.stringLiteral("<!--/-->"));
940
939
  }
941
940
  return memo;
@@ -1269,10 +1268,10 @@ function transformComponentChildren(children, config) {
1269
1268
  let pathNodes = [];
1270
1269
  let transformedChildren = filteredChildren.reduce((memo, path) => {
1271
1270
  if (t.isJSXText(path.node)) {
1272
- const v$1 = decode(trimWhitespace(path.node.extra.raw));
1273
- if (v$1.length) {
1271
+ const v = decode(trimWhitespace(path.node.extra.raw));
1272
+ if (v.length) {
1274
1273
  pathNodes.push(path.node);
1275
- memo.push(t.stringLiteral(v$1));
1274
+ memo.push(t.stringLiteral(v));
1276
1275
  }
1277
1276
  } else {
1278
1277
  const child = transformNode(path, {
@@ -1305,8 +1304,8 @@ function transformComponentChildren(children, config) {
1305
1304
  function transformFragmentChildren(children, results, config) {
1306
1305
  const childNodes = filterChildren(children).reduce((memo, path) => {
1307
1306
  if (t.isJSXText(path.node)) {
1308
- const v$1 = decode(trimWhitespace(path.node.extra.raw));
1309
- if (v$1.length) memo.push(t.stringLiteral(v$1));
1307
+ const v = decode(trimWhitespace(path.node.extra.raw));
1308
+ if (v.length) memo.push(t.stringLiteral(v));
1310
1309
  } else {
1311
1310
  const child = transformNode(path, {
1312
1311
  topLevel: true,
@@ -1330,10 +1329,10 @@ function transformJSX(path, state) {
1330
1329
  topLevel: true,
1331
1330
  lastElement: true
1332
1331
  });
1333
- const template$1 = getCreateTemplate(config, path, result);
1334
- path.replaceWith(replace(template$1(path, result, false)));
1335
- path.traverse({ enter(path$1) {
1336
- if (path$1.node.leadingComments && path$1.node.leadingComments[0] && path$1.node.leadingComments[0].value.trim() === config.staticMarker) path$1.node.leadingComments.shift();
1332
+ const template = getCreateTemplate(config, path, result);
1333
+ path.replaceWith(replace(template(path, result, false)));
1334
+ path.traverse({ enter(path) {
1335
+ if (path.node.leadingComments && path.node.leadingComments[0] && path.node.leadingComments[0].value.trim() === config.staticMarker) path.node.leadingComments.shift();
1337
1336
  } });
1338
1337
  }
1339
1338
  function getTargetFunctionParent(path, parent) {
@@ -1345,20 +1344,20 @@ function transformThis(path) {
1345
1344
  const parent = path.scope.getFunctionParent();
1346
1345
  let thisId;
1347
1346
  path.traverse({
1348
- ThisExpression(path$1) {
1349
- if (getTargetFunctionParent(path$1, parent) === parent) {
1350
- thisId || (thisId = path$1.scope.generateUidIdentifier("self$"));
1351
- path$1.replaceWith(thisId);
1347
+ ThisExpression(path) {
1348
+ if (getTargetFunctionParent(path, parent) === parent) {
1349
+ thisId || (thisId = path.scope.generateUidIdentifier("self$"));
1350
+ path.replaceWith(thisId);
1352
1351
  }
1353
1352
  },
1354
- JSXElement(path$1) {
1355
- let source = path$1.get("openingElement").get("name");
1353
+ JSXElement(path) {
1354
+ let source = path.get("openingElement").get("name");
1356
1355
  while (source.isJSXMemberExpression()) source = source.get("object");
1357
1356
  if (source.isJSXIdentifier() && source.node.name === "this") {
1358
- if (getTargetFunctionParent(path$1, parent) === parent) {
1359
- thisId || (thisId = path$1.scope.generateUidIdentifier("self$"));
1357
+ if (getTargetFunctionParent(path, parent) === parent) {
1358
+ thisId || (thisId = path.scope.generateUidIdentifier("self$"));
1360
1359
  source.replaceWith(t.jsxIdentifier(thisId.name));
1361
- if (path$1.node.closingElement) path$1.node.closingElement.name = path$1.node.openingElement.name;
1360
+ if (path.node.closingElement) path.node.closingElement.name = path.node.openingElement.name;
1362
1361
  }
1363
1362
  }
1364
1363
  }
@@ -1568,7 +1567,7 @@ const alwaysClose = [
1568
1567
  "fieldset"
1569
1568
  ];
1570
1569
  function transformElement(path, info) {
1571
- let tagName = getTagName(path.node), config = getConfig(path), wrapSVG = info.topLevel && tagName != "svg" && SVGElements.has(tagName), voidTag = VoidElements_default.indexOf(tagName) > -1, isCustomElement = tagName.indexOf("-") > -1 || path.get("openingElement").get("attributes").some((a) => a.node?.name?.name === "is" || a.name?.name === "is"), isImportNode = (tagName === "img" || tagName === "iframe") && path.get("openingElement").get("attributes").some((a) => a.node.name?.name === "loading"), results = {
1570
+ let tagName = getTagName(path.node), config = getConfig(path), wrapSVG = info.topLevel && tagName != "svg" && SVGElements.has(tagName), voidTag = voidElements.indexOf(tagName) > -1, isCustomElement = tagName.indexOf("-") > -1 || path.get("openingElement").get("attributes").some((a) => a.node?.name?.name === "is" || a.name?.name === "is"), isImportNode = (tagName === "img" || tagName === "iframe") && path.get("openingElement").get("attributes").some((a) => a.node.name?.name === "loading"), results = {
1572
1571
  template: `<${tagName}`,
1573
1572
  templateWithClosingTags: `<${tagName}`,
1574
1573
  declarations: [],
@@ -1748,10 +1747,10 @@ function transformAttributes(path, results) {
1748
1747
  const properties = value.properties;
1749
1748
  const propertiesNode = node.get("expression").get("properties");
1750
1749
  const toRemoveProperty = [];
1751
- for (let i$1 = 0; i$1 < properties.length; i$1++) {
1752
- const property = properties[i$1];
1750
+ for (let i = 0; i < properties.length; i++) {
1751
+ const property = properties[i];
1753
1752
  if (property.computed) {
1754
- const r = propertiesNode[i$1].get("value").evaluate();
1753
+ const r = propertiesNode[i].get("value").evaluate();
1755
1754
  if (r.confident && (typeof r.value === "string" || typeof r.value === "number")) property.value = t.inherits(t.stringLiteral(`${r.value}`), property.value);
1756
1755
  continue;
1757
1756
  }
@@ -1762,7 +1761,7 @@ function transformAttributes(path, results) {
1762
1761
  toRemoveProperty.push(property);
1763
1762
  } else if (t.isIdentifier(property.value) && property.value.name === "undefined" || t.isNullLiteral(property.value)) toRemoveProperty.push(property);
1764
1763
  else {
1765
- const r = propertiesNode[i$1].get("value").evaluate();
1764
+ const r = propertiesNode[i].get("value").evaluate();
1766
1765
  if (r.confident && (typeof r.value === "string" || typeof r.value === "number")) {
1767
1766
  inlinedStyle += `${key}:${r.value};`;
1768
1767
  toRemoveProperty.push(property);
@@ -1775,8 +1774,8 @@ function transformAttributes(path, results) {
1775
1774
  }
1776
1775
  }
1777
1776
  if (inlinedStyle !== "") {
1778
- const styleAttribute$1 = t.jsxAttribute(t.jsxIdentifier("style"), t.stringLiteral(inlinedStyle.replace(/;$/, "")));
1779
- path.get("openingElement").node.attributes.push(styleAttribute$1);
1777
+ const styleAttribute = t.jsxAttribute(t.jsxIdentifier("style"), t.stringLiteral(inlinedStyle.replace(/;$/, "")));
1778
+ path.get("openingElement").node.attributes.push(styleAttribute);
1780
1779
  }
1781
1780
  }
1782
1781
  const styleAttribute = path.get("openingElement").get("attributes").find((a) => a.node.name && a.node.name.name === "style" && t.isJSXExpressionContainer(a.node.value) && t.isObjectExpression(a.node.value.expression) && !a.node.value.expression.properties.some((p) => t.isSpreadElement(p)));
@@ -1825,9 +1824,9 @@ function transformAttributes(path, results) {
1825
1824
  }
1826
1825
  path.get("openingElement").set("attributes", attributes.map((a) => a.node));
1827
1826
  let needsSpacing = true;
1828
- function inlineAttributeOnTemplate(isSVG$1, key, results$1, value) {
1829
- !isSVG$1 && (key = key.toLowerCase());
1830
- results$1.template += `${needsSpacing ? " " : ""}${key}`;
1827
+ function inlineAttributeOnTemplate(isSVG, key, results, value) {
1828
+ !isSVG && (key = key.toLowerCase());
1829
+ results.template += `${needsSpacing ? " " : ""}${key}`;
1831
1830
  if (!value) {
1832
1831
  needsSpacing = true;
1833
1832
  return;
@@ -1841,7 +1840,7 @@ function transformAttributes(path, results) {
1841
1840
  }
1842
1841
  if (!text.length) {
1843
1842
  needsSpacing = true;
1844
- results$1.template += ``;
1843
+ results.template += ``;
1845
1844
  return;
1846
1845
  }
1847
1846
  for (let i = 0, len = text.length; i < len; i++) {
@@ -1850,10 +1849,10 @@ function transformAttributes(path, results) {
1850
1849
  }
1851
1850
  if (needsQuoting) {
1852
1851
  needsSpacing = false;
1853
- results$1.template += `="${escapeHTML(text, true)}"`;
1852
+ results.template += `="${escapeHTML(text, true)}"`;
1854
1853
  } else {
1855
1854
  needsSpacing = true;
1856
- results$1.template += `=${escapeHTML(text, true)}`;
1855
+ results.template += `=${escapeHTML(text, true)}`;
1857
1856
  }
1858
1857
  }
1859
1858
  path.get("openingElement").get("attributes").forEach((attribute) => {
@@ -2036,10 +2035,10 @@ function transformChildren(path, results, config) {
2036
2035
  skipId: !results.id || !detectExpressions(filteredChildren, index, config)
2037
2036
  });
2038
2037
  if (!transformed) return memo;
2039
- const i$1 = memo.length;
2040
- if (transformed.text && i$1 && memo[i$1 - 1].text) {
2041
- memo[i$1 - 1].template += transformed.template;
2042
- memo[i$1 - 1].templateWithClosingTags += transformed.templateWithClosingTags || transformed.template;
2038
+ const i = memo.length;
2039
+ if (transformed.text && i && memo[i - 1].text) {
2040
+ memo[i - 1].template += transformed.template;
2041
+ memo[i - 1].templateWithClosingTags += transformed.templateWithClosingTags || transformed.template;
2043
2042
  } else memo.push(transformed);
2044
2043
  return memo;
2045
2044
  }, []);
@@ -2202,16 +2201,16 @@ function createTemplate(path, result, wrap) {
2202
2201
  return result.exprs[0];
2203
2202
  }
2204
2203
  function appendTemplates(path, templates) {
2205
- const declarators = templates.map((template$1) => {
2204
+ const declarators = templates.map((template) => {
2206
2205
  const tmpl = {
2207
- cooked: template$1.template,
2208
- raw: escapeStringForTemplate(template$1.template)
2206
+ cooked: template.template,
2207
+ raw: escapeStringForTemplate(template.template)
2209
2208
  };
2210
- const shouldUseImportNode = template$1.isCE || template$1.isImportNode;
2211
- const isMathML = /^<(math|annotation|annotation-xml|maction|math|merror|mfrac|mi|mmultiscripts|mn|mo|mover|mpadded|mphantom|mprescripts|mroot|mrow|ms|mspace|msqrt|mstyle|msub|msubsup|msup|mtable|mtd|mtext|mtr|munder|munderover|semantics|menclose|mfenced)(\s|>)/.test(template$1.template);
2212
- return t.variableDeclarator(template$1.id, t.addComment(t.callExpression(registerImportMethod(path, "template", getRendererConfig(path, "dom").moduleName), [t.templateLiteral([t.templateElement(tmpl, true)], [])].concat(template$1.isSVG || shouldUseImportNode || isMathML ? [
2209
+ const shouldUseImportNode = template.isCE || template.isImportNode;
2210
+ const isMathML = /^<(math|annotation|annotation-xml|maction|math|merror|mfrac|mi|mmultiscripts|mn|mo|mover|mpadded|mphantom|mprescripts|mroot|mrow|ms|mspace|msqrt|mstyle|msub|msubsup|msup|mtable|mtd|mtext|mtr|munder|munderover|semantics|menclose|mfenced)(\s|>)/.test(template.template);
2211
+ return t.variableDeclarator(template.id, t.addComment(t.callExpression(registerImportMethod(path, "template", getRendererConfig(path, "dom").moduleName), [t.templateLiteral([t.templateElement(tmpl, true)], [])].concat(template.isSVG || shouldUseImportNode || isMathML ? [
2213
2212
  t.booleanLiteral(!!shouldUseImportNode),
2214
- t.booleanLiteral(template$1.isSVG),
2213
+ t.booleanLiteral(template.isSVG),
2215
2214
  t.booleanLiteral(isMathML)
2216
2215
  ] : [])), "leading", "#__PURE__"));
2217
2216
  });
@@ -2224,7 +2223,7 @@ function registerTemplate(path, results) {
2224
2223
  let templateDef, templateId;
2225
2224
  if (!results.skipTemplate) {
2226
2225
  const templates = path.scope.getProgramParent().data.templates || (path.scope.getProgramParent().data.templates = []);
2227
- if (templateDef = templates.find((t$1) => t$1.template === results.template)) templateId = templateDef.id;
2226
+ if (templateDef = templates.find((t) => t.template === results.template)) templateId = templateDef.id;
2228
2227
  else {
2229
2228
  templateId = path.scope.generateUidIdentifier("tmpl$");
2230
2229
  templates.push({
@@ -2343,8 +2342,8 @@ var postprocess_default = (path, state) => {
2343
2342
  if (state.skip) return;
2344
2343
  if (path.scope.data.events) path.node.body.push(t.expressionStatement(t.callExpression(registerImportMethod(path, "delegateEvents", getRendererConfig(path, "dom").moduleName), [t.arrayExpression(Array.from(path.scope.data.events).map((e) => t.stringLiteral(e)))])));
2345
2344
  if (path.scope.data.templates?.length) {
2346
- if (path.hub.file.metadata.config.validate) for (const template$1 of path.scope.data.templates) {
2347
- const html = template$1.templateWithClosingTags;
2345
+ if (path.hub.file.metadata.config.validate) for (const template of path.scope.data.templates) {
2346
+ const html = template.templateWithClosingTags;
2348
2347
  if (typeof html === "string") {
2349
2348
  const result = isInvalidMarkup(html);
2350
2349
  if (result) {
@@ -2429,7 +2428,6 @@ const jsxTransform = () => {
2429
2428
  }
2430
2429
  };
2431
2430
  };
2432
- var babel_plugin_jsx_dom_expressions_default = jsxTransform;
2433
2431
 
2434
2432
  //#endregion
2435
2433
  //#region src/plugin-transform-typescript/enum.ts
@@ -2454,39 +2452,39 @@ const buildEnumWrapper = template.expression(`
2454
2452
  return ID;
2455
2453
  })(INIT)
2456
2454
  `);
2457
- function transpileEnum(path, t$1) {
2455
+ function transpileEnum(path, t) {
2458
2456
  const { node, parentPath } = path;
2459
2457
  if (node.declare) {
2460
2458
  path.remove();
2461
2459
  return;
2462
2460
  }
2463
2461
  const name = node.id.name;
2464
- const { fill, data, isPure } = enumFill(path, t$1, node.id);
2462
+ const { fill, data, isPure } = enumFill(path, t, node.id);
2465
2463
  switch (parentPath.type) {
2466
2464
  case "BlockStatement":
2467
2465
  case "ExportNamedDeclaration":
2468
2466
  case "Program": {
2469
- const isGlobal = t$1.isProgram(path.parent);
2467
+ const isGlobal = t.isProgram(path.parent);
2470
2468
  const isSeen = seen(parentPath);
2471
- let init = t$1.objectExpression([]);
2472
- if (isSeen || isGlobal) init = t$1.logicalExpression("||", t$1.cloneNode(fill.ID), init);
2469
+ let init = t.objectExpression([]);
2470
+ if (isSeen || isGlobal) init = t.logicalExpression("||", t.cloneNode(fill.ID), init);
2473
2471
  const enumIIFE = buildEnumWrapper({
2474
2472
  ...fill,
2475
2473
  INIT: init
2476
2474
  });
2477
2475
  if (isPure) annotateAsPure(enumIIFE);
2478
- if (isSeen) (parentPath.isExportDeclaration() ? parentPath : path).replaceWith(t$1.expressionStatement(t$1.assignmentExpression("=", t$1.cloneNode(node.id), enumIIFE)));
2479
- else path.scope.registerDeclaration(path.replaceWith(t$1.variableDeclaration(isGlobal ? "var" : "let", [t$1.variableDeclarator(node.id, enumIIFE)]))[0]);
2476
+ if (isSeen) (parentPath.isExportDeclaration() ? parentPath : path).replaceWith(t.expressionStatement(t.assignmentExpression("=", t.cloneNode(node.id), enumIIFE)));
2477
+ else path.scope.registerDeclaration(path.replaceWith(t.variableDeclaration(isGlobal ? "var" : "let", [t.variableDeclarator(node.id, enumIIFE)]))[0]);
2480
2478
  ENUMS.set(path.scope.getBindingIdentifier(name), data);
2481
2479
  break;
2482
2480
  }
2483
2481
  default: throw new Error(`Unexpected enum parent '${path.parent.type}`);
2484
2482
  }
2485
- function seen(parentPath$1) {
2486
- if (parentPath$1.isExportDeclaration()) return seen(parentPath$1.parentPath);
2487
- if (parentPath$1.getData(name)) return true;
2483
+ function seen(parentPath) {
2484
+ if (parentPath.isExportDeclaration()) return seen(parentPath.parentPath);
2485
+ if (parentPath.getData(name)) return true;
2488
2486
  else {
2489
- parentPath$1.setData(name, true);
2487
+ parentPath.setData(name, true);
2490
2488
  return false;
2491
2489
  }
2492
2490
  }
@@ -2502,21 +2500,21 @@ const buildEnumMember = (isString, options) => (isString ? buildStringAssignment
2502
2500
  * Generates the statement that fills in the variable declared by the enum.
2503
2501
  * `(function (E) { ... assignments ... })(E || (E = {}));`
2504
2502
  */
2505
- function enumFill(path, t$1, id) {
2506
- const { enumValues, data, isPure } = translateEnumValues(path, t$1);
2507
- const enumMembers = path.get("members");
2503
+ function enumFill(path, t, id) {
2504
+ const { enumValues, data, isPure } = translateEnumValues(path, t);
2505
+ const enumMembers = path.get("body").get("members");
2508
2506
  const assignments = [];
2509
2507
  for (let i = 0; i < enumMembers.length; i++) {
2510
2508
  const [memberName, memberValue] = enumValues[i];
2511
- assignments.push(t$1.inheritsComments(buildEnumMember(isSyntacticallyString(memberValue), {
2512
- ENUM: t$1.cloneNode(id),
2509
+ assignments.push(t.inheritsComments(buildEnumMember(isSyntacticallyString(memberValue), {
2510
+ ENUM: t.cloneNode(id),
2513
2511
  NAME: memberName,
2514
2512
  VALUE: memberValue
2515
2513
  }), enumMembers[i].node));
2516
2514
  }
2517
2515
  return {
2518
2516
  fill: {
2519
- ID: t$1.cloneNode(id),
2517
+ ID: t.cloneNode(id),
2520
2518
  ASSIGNMENTS: assignments
2521
2519
  },
2522
2520
  data,
@@ -2537,24 +2535,24 @@ function isSyntacticallyString(expr) {
2537
2535
  return false;
2538
2536
  }
2539
2537
  function ReferencedIdentifier(expr, state) {
2540
- const { seen, path, t: t$1 } = state;
2538
+ const { seen, path, t } = state;
2541
2539
  const name = expr.node.name;
2542
2540
  if (seen.has(name)) {
2543
2541
  for (let curScope = expr.scope; curScope !== path.scope; curScope = curScope.parent) if (curScope.hasOwnBinding(name)) return;
2544
- expr.replaceWith(t$1.memberExpression(t$1.cloneNode(path.node.id), t$1.cloneNode(expr.node)));
2542
+ expr.replaceWith(t.memberExpression(t.cloneNode(path.node.id), t.cloneNode(expr.node)));
2545
2543
  expr.skip();
2546
2544
  }
2547
2545
  }
2548
2546
  const enumSelfReferenceVisitor = { ReferencedIdentifier };
2549
- function translateEnumValues(path, t$1) {
2547
+ function translateEnumValues(path, t) {
2550
2548
  const bindingIdentifier = path.scope.getBindingIdentifier(path.node.id.name);
2551
2549
  const seen = ENUMS.get(bindingIdentifier) ?? /* @__PURE__ */ new Map();
2552
2550
  let constValue = -1;
2553
2551
  let lastName;
2554
2552
  let isPure = true;
2555
- const enumValues = path.get("members").map((memberPath) => {
2553
+ const enumValues = path.get("body").get("members").map((memberPath) => {
2556
2554
  const member = memberPath.node;
2557
- const name = t$1.isIdentifier(member.id) ? member.id.name : member.id.value;
2555
+ const name = t.isIdentifier(member.id) ? member.id.name : member.id.value;
2558
2556
  const initializerPath = memberPath.get("initializer");
2559
2557
  const initializer = member.initializer;
2560
2558
  let value;
@@ -2563,18 +2561,18 @@ function translateEnumValues(path, t$1) {
2563
2561
  if (constValue !== void 0) {
2564
2562
  seen.set(name, constValue);
2565
2563
  assert(typeof constValue === "number" || typeof constValue === "string");
2566
- if (constValue === Infinity || Number.isNaN(constValue)) value = t$1.identifier(String(constValue));
2567
- else if (constValue === -Infinity) value = t$1.unaryExpression("-", t$1.identifier("Infinity"));
2568
- else value = t$1.valueToNode(constValue);
2564
+ if (constValue === Infinity || Number.isNaN(constValue)) value = t.identifier(String(constValue));
2565
+ else if (constValue === -Infinity) value = t.unaryExpression("-", t.identifier("Infinity"));
2566
+ else value = t.valueToNode(constValue);
2569
2567
  } else {
2570
2568
  isPure &&= initializerPath.isPure();
2571
2569
  if (initializerPath.isReferencedIdentifier()) ReferencedIdentifier(initializerPath, {
2572
- t: t$1,
2570
+ t,
2573
2571
  seen,
2574
2572
  path
2575
2573
  });
2576
2574
  else initializerPath.traverse(enumSelfReferenceVisitor, {
2577
- t: t$1,
2575
+ t,
2578
2576
  seen,
2579
2577
  path
2580
2578
  });
@@ -2583,12 +2581,12 @@ function translateEnumValues(path, t$1) {
2583
2581
  }
2584
2582
  } else if (typeof constValue === "number") {
2585
2583
  constValue += 1;
2586
- value = t$1.numericLiteral(constValue);
2584
+ value = t.numericLiteral(constValue);
2587
2585
  seen.set(name, constValue);
2588
2586
  } else if (typeof constValue === "string") throw path.buildCodeFrameError("Enum member must have initializer.");
2589
2587
  else {
2590
- const lastRef = t$1.memberExpression(t$1.cloneNode(path.node.id), t$1.stringLiteral(lastName), true);
2591
- value = t$1.binaryExpression("+", t$1.numericLiteral(1), lastRef);
2588
+ const lastRef = t.memberExpression(t.cloneNode(path.node.id), t.stringLiteral(lastName), true);
2589
+ value = t.binaryExpression("+", t.numericLiteral(1), lastRef);
2592
2590
  seen.set(name, void 0);
2593
2591
  }
2594
2592
  lastName = name;
@@ -2602,19 +2600,19 @@ function translateEnumValues(path, t$1) {
2602
2600
  }
2603
2601
  function computeConstantValue(path, prevMembers, seen = /* @__PURE__ */ new Set()) {
2604
2602
  return evaluate(path);
2605
- function evaluate(path$1) {
2606
- const expr = path$1.node;
2603
+ function evaluate(path) {
2604
+ const expr = path.node;
2607
2605
  switch (expr.type) {
2608
- case "MemberExpression": return evaluateRef(path$1, prevMembers, seen);
2606
+ case "MemberExpression": return evaluateRef(path, prevMembers, seen);
2609
2607
  case "StringLiteral": return expr.value;
2610
- case "UnaryExpression": return evalUnaryExpression(path$1);
2611
- case "BinaryExpression": return evalBinaryExpression(path$1);
2608
+ case "UnaryExpression": return evalUnaryExpression(path);
2609
+ case "BinaryExpression": return evalBinaryExpression(path);
2612
2610
  case "NumericLiteral": return expr.value;
2613
- case "ParenthesizedExpression": return evaluate(path$1.get("expression"));
2614
- case "Identifier": return evaluateRef(path$1, prevMembers, seen);
2611
+ case "ParenthesizedExpression": return evaluate(path.get("expression"));
2612
+ case "Identifier": return evaluateRef(path, prevMembers, seen);
2615
2613
  case "TemplateLiteral": {
2616
2614
  if (expr.quasis.length === 1) return expr.quasis[0].value.cooked;
2617
- const paths = path$1.get("expressions");
2615
+ const paths = path.get("expressions");
2618
2616
  const quasis = expr.quasis;
2619
2617
  let str = "";
2620
2618
  for (let i = 0; i < quasis.length; i++) {
@@ -2630,44 +2628,44 @@ function computeConstantValue(path, prevMembers, seen = /* @__PURE__ */ new Set(
2630
2628
  default: return;
2631
2629
  }
2632
2630
  }
2633
- function evaluateRef(path$1, prevMembers$1, seen$1) {
2634
- if (path$1.isMemberExpression()) {
2635
- const expr = path$1.node;
2631
+ function evaluateRef(path, prevMembers, seen) {
2632
+ if (path.isMemberExpression()) {
2633
+ const expr = path.node;
2636
2634
  const obj = expr.object;
2637
2635
  const prop = expr.property;
2638
2636
  if (!t.isIdentifier(obj) || (expr.computed ? !t.isStringLiteral(prop) : !t.isIdentifier(prop))) return;
2639
- const bindingIdentifier = path$1.scope.getBindingIdentifier(obj.name);
2637
+ const bindingIdentifier = path.scope.getBindingIdentifier(obj.name);
2640
2638
  const data = ENUMS.get(bindingIdentifier);
2641
2639
  if (!data) return;
2642
2640
  return data.get(prop.computed ? prop.value : prop.name);
2643
- } else if (path$1.isIdentifier()) {
2644
- const name = path$1.node.name;
2641
+ } else if (path.isIdentifier()) {
2642
+ const name = path.node.name;
2645
2643
  if (["Infinity", "NaN"].includes(name)) return Number(name);
2646
- let value = prevMembers$1?.get(name);
2644
+ let value = prevMembers?.get(name);
2647
2645
  if (value !== void 0) return value;
2648
- if (prevMembers$1?.has(name)) return;
2649
- if (seen$1.has(path$1.node)) return;
2650
- seen$1.add(path$1.node);
2651
- value = computeConstantValue(path$1.resolve(), prevMembers$1, seen$1);
2646
+ if (prevMembers?.has(name)) return;
2647
+ if (seen.has(path.node)) return;
2648
+ seen.add(path.node);
2649
+ value = computeConstantValue(path.resolve(), prevMembers, seen);
2652
2650
  return value;
2653
2651
  }
2654
2652
  }
2655
- function evalUnaryExpression(path$1) {
2656
- const value = evaluate(path$1.get("argument"));
2653
+ function evalUnaryExpression(path) {
2654
+ const value = evaluate(path.get("argument"));
2657
2655
  if (value === void 0) return;
2658
- switch (path$1.node.operator) {
2656
+ switch (path.node.operator) {
2659
2657
  case "+": return value;
2660
2658
  case "-": return -value;
2661
2659
  case "~": return ~value;
2662
2660
  default: return;
2663
2661
  }
2664
2662
  }
2665
- function evalBinaryExpression(path$1) {
2666
- const left = evaluate(path$1.get("left"));
2663
+ function evalBinaryExpression(path) {
2664
+ const left = evaluate(path.get("left"));
2667
2665
  if (left === void 0) return;
2668
- const right = evaluate(path$1.get("right"));
2666
+ const right = evaluate(path.get("right"));
2669
2667
  if (right === void 0) return;
2670
- switch (path$1.node.operator) {
2668
+ switch (path.node.operator) {
2671
2669
  case "|": return left | right;
2672
2670
  case "&": return left & right;
2673
2671
  case ">>": return left >> right;
@@ -2688,35 +2686,35 @@ function computeConstantValue(path, prevMembers, seen = /* @__PURE__ */ new Set(
2688
2686
  //#endregion
2689
2687
  //#region src/plugin-transform-typescript/const-enum.ts
2690
2688
  const EXPORTED_CONST_ENUMS_IN_NAMESPACE = /* @__PURE__ */ new WeakSet();
2691
- function transpileConstEnum(path, t$1) {
2689
+ function transpileConstEnum(path, t) {
2692
2690
  const { name } = path.node.id;
2693
2691
  const parentIsExport = path.parentPath.isExportNamedDeclaration();
2694
2692
  let isExported = parentIsExport;
2695
- if (!isExported && t$1.isProgram(path.parent)) isExported = path.parent.body.some((stmt) => t$1.isExportNamedDeclaration(stmt) && stmt.exportKind !== "type" && !stmt.source && stmt.specifiers.some((spec) => t$1.isExportSpecifier(spec) && spec.exportKind !== "type" && spec.local.name === name));
2696
- const { enumValues: entries } = translateEnumValues(path, t$1);
2693
+ if (!isExported && t.isProgram(path.parent)) isExported = path.parent.body.some((stmt) => t.isExportNamedDeclaration(stmt) && stmt.exportKind !== "type" && !stmt.source && stmt.specifiers.some((spec) => t.isExportSpecifier(spec) && spec.exportKind !== "type" && spec.local.name === name));
2694
+ const { enumValues: entries } = translateEnumValues(path, t);
2697
2695
  if (isExported || EXPORTED_CONST_ENUMS_IN_NAMESPACE.has(path.node)) {
2698
- const obj = t$1.objectExpression(entries.map(([name$1, value]) => t$1.objectProperty(t$1.isValidIdentifier(name$1) ? t$1.identifier(name$1) : t$1.stringLiteral(name$1), value)));
2699
- if (path.scope.hasOwnBinding(name)) (parentIsExport ? path.parentPath : path).replaceWith(t$1.expressionStatement(t$1.callExpression(t$1.memberExpression(t$1.identifier("Object"), t$1.identifier("assign")), [path.node.id, obj])));
2696
+ const obj = t.objectExpression(entries.map(([name, value]) => t.objectProperty(t.isValidIdentifier(name) ? t.identifier(name) : t.stringLiteral(name), value)));
2697
+ if (path.scope.hasOwnBinding(name)) (parentIsExport ? path.parentPath : path).replaceWith(t.expressionStatement(t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("assign")), [path.node.id, obj])));
2700
2698
  else {
2701
- path.replaceWith(t$1.variableDeclaration("var", [t$1.variableDeclarator(path.node.id, obj)]));
2699
+ path.replaceWith(t.variableDeclaration("const", [t.variableDeclarator(path.node.id, obj)]));
2702
2700
  path.scope.registerDeclaration(path);
2703
2701
  }
2704
2702
  return;
2705
2703
  }
2706
2704
  const entriesMap = new Map(entries);
2707
2705
  path.scope.path.traverse({
2708
- Scope(path$1) {
2709
- if (path$1.scope.hasOwnBinding(name)) path$1.skip();
2706
+ Scope(path) {
2707
+ if (path.scope.hasOwnBinding(name)) path.skip();
2710
2708
  },
2711
- MemberExpression(path$1) {
2712
- if (!t$1.isIdentifier(path$1.node.object, { name })) return;
2709
+ MemberExpression(path) {
2710
+ if (!t.isIdentifier(path.node.object, { name })) return;
2713
2711
  let key;
2714
- if (path$1.node.computed) if (t$1.isStringLiteral(path$1.node.property)) key = path$1.node.property.value;
2712
+ if (path.node.computed) if (t.isStringLiteral(path.node.property)) key = path.node.property.value;
2715
2713
  else return;
2716
- else if (t$1.isIdentifier(path$1.node.property)) key = path$1.node.property.name;
2714
+ else if (t.isIdentifier(path.node.property)) key = path.node.property.name;
2717
2715
  else return;
2718
2716
  if (!entriesMap.has(key)) return;
2719
- path$1.replaceWith(t$1.cloneNode(entriesMap.get(key)));
2717
+ path.replaceWith(t.cloneNode(entriesMap.get(key)));
2720
2718
  }
2721
2719
  });
2722
2720
  path.remove();
@@ -2861,7 +2859,7 @@ function handleNested(path, node, parentExport) {
2861
2859
  continue;
2862
2860
  case "VariableDeclaration":
2863
2861
  isEmpty = false;
2864
- for (const name$1 in t.getBindingIdentifiers(subNode)) names.add(name$1);
2862
+ for (const name in t.getBindingIdentifiers(subNode)) names.add(name);
2865
2863
  continue;
2866
2864
  default:
2867
2865
  isEmpty &&= t.isTypeScript(subNode);
@@ -2922,7 +2920,7 @@ function handleNested(path, node, parentExport) {
2922
2920
 
2923
2921
  //#endregion
2924
2922
  //#region src/plugin-transform-typescript/plugin-syntax-typescript.ts
2925
- var removePlugin = function(plugins, name) {
2923
+ const removePlugin = function(plugins, name) {
2926
2924
  const indices = [];
2927
2925
  plugins.forEach((plugin, i) => {
2928
2926
  if ((Array.isArray(plugin) ? plugin[0] : plugin) === name) indices.unshift(i);
@@ -2934,14 +2932,11 @@ const syntaxTypeScript = declare((api, opts) => {
2934
2932
  var { isTSX } = opts;
2935
2933
  return {
2936
2934
  name: "syntax-typescript",
2937
- manipulateOptions(opts$1, parserOpts) {
2938
- {
2939
- const { plugins } = parserOpts;
2940
- removePlugin(plugins, "flow");
2941
- removePlugin(plugins, "jsx");
2942
- plugins.push("objectRestSpread", "classProperties");
2943
- if (isTSX) plugins.push("jsx");
2944
- }
2935
+ manipulateOptions(opts, parserOpts) {
2936
+ const { plugins } = parserOpts;
2937
+ removePlugin(plugins, "flow");
2938
+ removePlugin(plugins, "jsx");
2939
+ if (isTSX) plugins.push("jsx");
2945
2940
  parserOpts.plugins.push(["typescript", {
2946
2941
  disallowAmbiguousJSXLike,
2947
2942
  dts
@@ -2949,17 +2944,16 @@ const syntaxTypeScript = declare((api, opts) => {
2949
2944
  }
2950
2945
  };
2951
2946
  });
2952
- var plugin_syntax_typescript_default = syntaxTypeScript;
2953
2947
 
2954
2948
  //#endregion
2955
2949
  //#region src/plugin-transform-typescript/index.ts
2956
2950
  function isInType(path) {
2957
2951
  switch (path.parent.type) {
2958
2952
  case "TSTypeReference":
2959
- case "TSExpressionWithTypeArguments":
2960
- case "TSExpressionWithTypeArguments":
2953
+ case "TSClassImplements":
2954
+ case "TSInterfaceHeritage":
2961
2955
  case "TSTypeQuery": return true;
2962
- case "TSQualifiedName": return path.parentPath.findParent((path$1) => path$1.type !== "TSQualifiedName").type !== "TSImportEqualsDeclaration";
2956
+ case "TSQualifiedName": return path.parentPath.findParent((path) => path.type !== "TSQualifiedName").type !== "TSImportEqualsDeclaration";
2963
2957
  case "ExportSpecifier": return path.parent.exportKind === "type" || path.parentPath.parent.exportKind === "type";
2964
2958
  default: return false;
2965
2959
  }
@@ -2980,22 +2974,18 @@ function assertCjsTransformEnabled(path, pass, wrong, suggestion, extra = "") {
2980
2974
  if (pass.file.get("@babel/plugin-transform-modules-*") !== "commonjs") throw path.buildCodeFrameError(`\`${wrong}\` is only supported when compiling modules to CommonJS.\nPlease consider using \`${suggestion}\`${extra}, or add @babel/plugin-transform-modules-commonjs to your Babel config.`);
2981
2975
  }
2982
2976
  const pluginTransformTypescript = declare((api, opts) => {
2983
- const { types: t$1, template: template$1 } = api;
2977
+ const { types: t, template } = api;
2984
2978
  const JSX_PRAGMA_REGEX = /\*?\s*@jsx((?:Frag)?)\s+(\S+)/;
2985
2979
  const { allowNamespaces = true, jsxPragma = "React.createElement", jsxPragmaFrag = "React.Fragment", onlyRemoveTypeImports = false, optimizeConstEnums = false } = opts;
2986
- var { allowDeclareFields = false } = opts;
2987
2980
  const classMemberVisitors = {
2988
2981
  field(path) {
2989
2982
  const { node } = path;
2990
- if (!allowDeclareFields && node.declare) throw path.buildCodeFrameError("The 'declare' modifier is only allowed when the 'allowDeclareFields' option of @babel/plugin-transform-typescript or @babel/preset-typescript is enabled.");
2991
2983
  if (node.declare) {
2992
2984
  if (node.value) throw path.buildCodeFrameError(`Fields with the 'declare' modifier cannot be initialized here, but only in the constructor`);
2993
2985
  if (!node.decorators) path.remove();
2994
2986
  } else if (node.definite) {
2995
2987
  if (node.value) throw path.buildCodeFrameError(`Definitely assigned fields cannot be initialized here, but only in the constructor`);
2996
- if (!allowDeclareFields && !node.decorators && !t$1.isClassPrivateProperty(node)) path.remove();
2997
2988
  } else if (node.abstract) path.remove();
2998
- else if (!allowDeclareFields && !node.value && !node.decorators && !t$1.isClassPrivateProperty(node)) path.remove();
2999
2989
  if (node.accessibility) node.accessibility = null;
3000
2990
  if (node.abstract) node.abstract = null;
3001
2991
  if (node.readonly) node.readonly = null;
@@ -3022,11 +3012,11 @@ const pluginTransformTypescript = declare((api, opts) => {
3022
3012
  if (PARSED_PARAMS.has(parameter)) continue;
3023
3013
  PARSED_PARAMS.add(parameter);
3024
3014
  let id;
3025
- if (t$1.isIdentifier(parameter)) id = parameter;
3026
- else if (t$1.isAssignmentPattern(parameter) && t$1.isIdentifier(parameter.left)) id = parameter.left;
3015
+ if (t.isIdentifier(parameter)) id = parameter;
3016
+ else if (t.isAssignmentPattern(parameter) && t.isIdentifier(parameter.left)) id = parameter.left;
3027
3017
  else throw paramPath.buildCodeFrameError("Parameter properties can not be destructuring patterns.");
3028
- assigns.push(template$1.statement.ast`
3029
- this.${t$1.cloneNode(id)} = ${t$1.cloneNode(id)}
3018
+ assigns.push(template.statement.ast`
3019
+ this.${t.cloneNode(id)} = ${t.cloneNode(id)}
3030
3020
  `);
3031
3021
  paramPath.replaceWith(paramPath.get("parameter"));
3032
3022
  scope.registerBinding("param", paramPath);
@@ -3037,7 +3027,7 @@ const pluginTransformTypescript = declare((api, opts) => {
3037
3027
  };
3038
3028
  return {
3039
3029
  name: "transform-typescript",
3040
- inherits: plugin_syntax_typescript_default,
3030
+ inherits: syntaxTypeScript,
3041
3031
  visitor: {
3042
3032
  Pattern: visitPattern,
3043
3033
  Identifier: visitPattern,
@@ -3098,7 +3088,7 @@ const pluginTransformTypescript = declare((api, opts) => {
3098
3088
  if (!onlyRemoveTypeImports && stmt.isTSImportEqualsDeclaration()) {
3099
3089
  const { id } = stmt.node;
3100
3090
  const binding = stmt.scope.getBinding(id.name);
3101
- if (binding && !stmt.node.isExport && isImportTypeOnly({
3091
+ if (binding && isImportTypeOnly({
3102
3092
  binding,
3103
3093
  programPath: path,
3104
3094
  pragmaImportName,
@@ -3114,7 +3104,7 @@ const pluginTransformTypescript = declare((api, opts) => {
3114
3104
  }
3115
3105
  },
3116
3106
  exit(path) {
3117
- if (path.node.sourceType === "module" && NEEDS_EXPLICIT_ESM.get(path.node)) path.pushContainer("body", t$1.exportNamedDeclaration());
3107
+ if (path.node.sourceType === "module" && NEEDS_EXPLICIT_ESM.get(path.node)) path.pushContainer("body", t.exportNamedDeclaration());
3118
3108
  }
3119
3109
  },
3120
3110
  ExportNamedDeclaration(path, state) {
@@ -3123,21 +3113,22 @@ const pluginTransformTypescript = declare((api, opts) => {
3123
3113
  path.remove();
3124
3114
  return;
3125
3115
  }
3116
+ if (t.isTSImportEqualsDeclaration(path.node.declaration)) return;
3126
3117
  if (path.node.source && path.node.specifiers.length > 0 && path.node.specifiers.every((specifier) => specifier.type === "ExportSpecifier" && specifier.exportKind === "type")) {
3127
3118
  path.remove();
3128
3119
  return;
3129
3120
  }
3130
- if (!path.node.source && path.node.specifiers.length > 0 && path.node.specifiers.every((specifier) => t$1.isExportSpecifier(specifier) && isGlobalType(path, specifier.local.name))) {
3121
+ if (!path.node.source && path.node.specifiers.length > 0 && path.node.specifiers.every((specifier) => t.isExportSpecifier(specifier) && isGlobalType(path, specifier.local.name))) {
3131
3122
  path.remove();
3132
3123
  return;
3133
3124
  }
3134
- if (t$1.isTSModuleDeclaration(path.node.declaration)) {
3125
+ if (t.isTSModuleDeclaration(path.node.declaration)) {
3135
3126
  const namespace = path.node.declaration;
3136
- if (!t$1.isStringLiteral(namespace.id)) {
3127
+ if (!t.isStringLiteral(namespace.id)) {
3137
3128
  const id = getFirstIdentifier(namespace.id);
3138
3129
  if (path.scope.hasOwnBinding(id.name)) path.replaceWith(namespace);
3139
3130
  else {
3140
- const [newExport] = path.replaceWithMultiple([t$1.exportNamedDeclaration(t$1.variableDeclaration("let", [t$1.variableDeclarator(t$1.cloneNode(id))])), namespace]);
3131
+ const [newExport] = path.replaceWithMultiple([t.exportNamedDeclaration(t.variableDeclaration("let", [t.variableDeclarator(t.cloneNode(id))])), namespace]);
3141
3132
  path.scope.registerDeclaration(newExport);
3142
3133
  }
3143
3134
  }
@@ -3152,7 +3143,7 @@ const pluginTransformTypescript = declare((api, opts) => {
3152
3143
  },
3153
3144
  ExportDefaultDeclaration(path, state) {
3154
3145
  if (!NEEDS_EXPLICIT_ESM.has(state.file.ast.program)) NEEDS_EXPLICIT_ESM.set(state.file.ast.program, true);
3155
- if (t$1.isIdentifier(path.node.declaration) && isGlobalType(path, path.node.declaration.name)) {
3146
+ if (t.isIdentifier(path.node.declaration) && isGlobalType(path, path.node.declaration.name)) {
3156
3147
  path.remove();
3157
3148
  return;
3158
3149
  }
@@ -3180,7 +3171,7 @@ const pluginTransformTypescript = declare((api, opts) => {
3180
3171
  Class(path) {
3181
3172
  const { node } = path;
3182
3173
  if (node.typeParameters) node.typeParameters = null;
3183
- if (node.superTypeParameters) node.superTypeParameters = null;
3174
+ if (node.superTypeArguments) node.superTypeArguments = null;
3184
3175
  if (node.implements) node.implements = null;
3185
3176
  if (node.abstract) node.abstract = null;
3186
3177
  path.get("body.body").forEach((child) => {
@@ -3194,7 +3185,7 @@ const pluginTransformTypescript = declare((api, opts) => {
3194
3185
  if (node.typeParameters) node.typeParameters = null;
3195
3186
  if (node.returnType) node.returnType = null;
3196
3187
  const params = node.params;
3197
- if (params.length > 0 && t$1.isIdentifier(params[0], { name: "this" })) params.shift();
3188
+ if (params.length > 0 && t.isIdentifier(params[0], { name: "this" })) params.shift();
3198
3189
  },
3199
3190
  TSModuleDeclaration(path) {
3200
3191
  transpileNamespace(path, allowNamespaces);
@@ -3206,66 +3197,66 @@ const pluginTransformTypescript = declare((api, opts) => {
3206
3197
  path.remove();
3207
3198
  },
3208
3199
  TSEnumDeclaration(path) {
3209
- if (optimizeConstEnums && path.node.const) transpileConstEnum(path, t$1);
3210
- else transpileEnum(path, t$1);
3200
+ if (optimizeConstEnums && path.node.const) transpileConstEnum(path, t);
3201
+ else transpileEnum(path, t);
3211
3202
  },
3212
3203
  TSImportEqualsDeclaration(path, pass) {
3213
3204
  const { id, moduleReference } = path.node;
3214
3205
  let init;
3215
3206
  let varKind;
3216
- if (t$1.isTSExternalModuleReference(moduleReference)) {
3207
+ if (t.isTSExternalModuleReference(moduleReference)) {
3217
3208
  assertCjsTransformEnabled(path, pass, `import ${id.name} = require(...);`, `import ${id.name} from '...';`, " alongside Typescript's --allowSyntheticDefaultImports option");
3218
- init = t$1.callExpression(t$1.identifier("require"), [moduleReference.expression]);
3209
+ init = t.callExpression(t.identifier("require"), [moduleReference.expression]);
3219
3210
  varKind = "const";
3220
3211
  } else {
3221
3212
  init = entityNameToExpr(moduleReference);
3222
3213
  varKind = "var";
3223
3214
  }
3224
- const newNode = t$1.variableDeclaration(varKind, [t$1.variableDeclarator(id, init)]);
3225
- path.replaceWith(path.node.isExport ? t$1.exportNamedDeclaration(newNode) : newNode);
3215
+ const newNode = t.variableDeclaration(varKind, [t.variableDeclarator(id, init)]);
3216
+ path.replaceWith(path.node.isExport ? t.exportNamedDeclaration(newNode) : newNode);
3226
3217
  path.scope.registerDeclaration(path);
3227
3218
  },
3228
3219
  TSExportAssignment(path, pass) {
3229
3220
  assertCjsTransformEnabled(path, pass, `export = <value>;`, `export default <value>;`);
3230
- path.replaceWith(template$1.statement.ast`module.exports = ${path.node.expression}`);
3221
+ path.replaceWith(template.statement.ast`module.exports = ${path.node.expression}`);
3231
3222
  },
3232
3223
  TSTypeAssertion(path) {
3233
3224
  path.replaceWith(path.node.expression);
3234
3225
  },
3235
- [`TSAsExpression${t$1.tsSatisfiesExpression ? "|TSSatisfiesExpression" : ""}`](path) {
3226
+ ["TSAsExpression|TSSatisfiesExpression"](path) {
3236
3227
  let { node } = path;
3237
3228
  do
3238
3229
  node = node.expression;
3239
- while (t$1.isTSAsExpression(node) || t$1.isTSSatisfiesExpression?.(node));
3230
+ while (t.isTSAsExpression(node) || t.isTSSatisfiesExpression?.(node));
3240
3231
  path.replaceWith(node);
3241
3232
  },
3242
- [api.types.tsInstantiationExpression ? "TSNonNullExpression|TSInstantiationExpression" : "TSNonNullExpression"](path) {
3233
+ ["TSNonNullExpression|TSInstantiationExpression"](path) {
3243
3234
  path.replaceWith(path.node.expression);
3244
3235
  },
3245
3236
  CallExpression(path) {
3246
- path.node.typeParameters = null;
3237
+ path.node.typeArguments = null;
3247
3238
  },
3248
3239
  OptionalCallExpression(path) {
3249
- path.node.typeParameters = null;
3240
+ path.node.typeArguments = null;
3250
3241
  },
3251
3242
  NewExpression(path) {
3252
- path.node.typeParameters = null;
3243
+ path.node.typeArguments = null;
3253
3244
  },
3254
3245
  JSXOpeningElement(path) {
3255
- path.node.typeParameters = null;
3246
+ path.node.typeArguments = null;
3256
3247
  },
3257
3248
  TaggedTemplateExpression(path) {
3258
- path.node.typeParameters = null;
3249
+ path.node.typeArguments = null;
3259
3250
  }
3260
3251
  }
3261
3252
  };
3262
3253
  function entityNameToExpr(node) {
3263
- if (t$1.isTSQualifiedName(node)) return t$1.memberExpression(entityNameToExpr(node.left), node.right);
3254
+ if (t.isTSQualifiedName(node)) return t.memberExpression(entityNameToExpr(node.left), node.right);
3264
3255
  return node;
3265
3256
  }
3266
3257
  function visitPattern({ node }) {
3267
3258
  if (node.typeAnnotation) node.typeAnnotation = null;
3268
- if (t$1.isIdentifier(node) && node.optional) node.optional = null;
3259
+ if (t.isIdentifier(node) && node.optional) node.optional = null;
3269
3260
  }
3270
3261
  function isImportTypeOnly({ binding, programPath, pragmaImportName, pragmaFragImportName }) {
3271
3262
  for (const path of binding.referencePaths) if (!isInType(path)) return false;
@@ -3278,7 +3269,6 @@ const pluginTransformTypescript = declare((api, opts) => {
3278
3269
  return !sourceFileHasJsx;
3279
3270
  }
3280
3271
  });
3281
- var plugin_transform_typescript_default = pluginTransformTypescript;
3282
3272
 
3283
3273
  //#endregion
3284
3274
  //#region src/preset-typescript/normalize-options.ts
@@ -3294,51 +3284,44 @@ function normalizeOptions(options = {}) {
3294
3284
  onlyRemoveTypeImports: "onlyRemoveTypeImports",
3295
3285
  optimizeConstEnums: "optimizeConstEnums",
3296
3286
  rewriteImportExtensions: "rewriteImportExtensions",
3297
- allExtensions: "allExtensions",
3298
3287
  isTSX: "isTSX"
3299
3288
  };
3300
3289
  const jsxPragmaFrag = v.validateStringOption(TopLevelOptions.jsxPragmaFrag, options.jsxPragmaFrag, "React.Fragment");
3301
- const allExtensions = v.validateBooleanOption(TopLevelOptions.allExtensions, options.allExtensions, false);
3302
3290
  const isTSX = v.validateBooleanOption(TopLevelOptions.isTSX, options.isTSX, false);
3303
- if (isTSX) v.invariant(allExtensions, "isTSX:true requires allExtensions:true");
3304
- const ignoreExtensions = v.validateBooleanOption(TopLevelOptions.ignoreExtensions, options.ignoreExtensions, false);
3305
- const disallowAmbiguousJSXLike = v.validateBooleanOption(TopLevelOptions.disallowAmbiguousJSXLike, options.disallowAmbiguousJSXLike, false);
3306
- if (disallowAmbiguousJSXLike) v.invariant(allExtensions, "disallowAmbiguousJSXLike:true requires allExtensions:true");
3307
3291
  return {
3308
- ignoreExtensions,
3292
+ ignoreExtensions: v.validateBooleanOption(TopLevelOptions.ignoreExtensions, options.ignoreExtensions, false),
3309
3293
  allowNamespaces,
3310
- disallowAmbiguousJSXLike,
3294
+ disallowAmbiguousJSXLike: v.validateBooleanOption(TopLevelOptions.disallowAmbiguousJSXLike, options.disallowAmbiguousJSXLike, false),
3311
3295
  jsxPragma,
3312
3296
  jsxPragmaFrag,
3313
3297
  onlyRemoveTypeImports,
3314
3298
  optimizeConstEnums: v.validateBooleanOption(TopLevelOptions.optimizeConstEnums, options.optimizeConstEnums, false),
3315
3299
  rewriteImportExtensions: v.validateBooleanOption(TopLevelOptions.rewriteImportExtensions, options.rewriteImportExtensions, false),
3316
- allExtensions,
3317
3300
  isTSX
3318
3301
  };
3319
3302
  }
3320
3303
 
3321
3304
  //#endregion
3322
3305
  //#region src/preset-typescript/plugin-rewrite-ts-imports.ts
3323
- const pluginRewriteTSImports = declare(({ types: t$1, template: template$1 }) => {
3306
+ const pluginRewriteTSImports = declare(({ types: t, template }) => {
3324
3307
  function maybeReplace(source, path, state) {
3325
3308
  if (!source) return;
3326
- if (t$1.isStringLiteral(source)) {
3309
+ if (t.isStringLiteral(source)) {
3327
3310
  if (/^\.\.?\//.test(source.value)) source.value = source.value.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+)?)\.([cm]?)ts$/i, (m, tsx, d, ext, cm) => tsx ? ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js");
3328
3311
  return;
3329
3312
  }
3330
- if (state.availableHelper("tsRewriteRelativeImportExtensions")) path.replaceWith(t$1.callExpression(state.addHelper("tsRewriteRelativeImportExtensions"), [source]));
3331
- else path.replaceWith(template$1.expression.ast`(${source} + "").replace(/([\\/].*\.[mc]?)tsx?$/, "$1js")`);
3313
+ if (state.availableHelper("tsRewriteRelativeImportExtensions")) path.replaceWith(t.callExpression(state.addHelper("tsRewriteRelativeImportExtensions"), [source]));
3314
+ else path.replaceWith(template.expression.ast`(${source} + "").replace(/([\\/].*\.[mc]?)tsx?$/, "$1js")`);
3332
3315
  }
3333
3316
  return {
3334
3317
  name: "preset-typescript/plugin-rewrite-ts-imports",
3335
3318
  visitor: {
3336
3319
  "ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration"(path, state) {
3337
3320
  const node = path.node;
3338
- if ((t$1.isImportDeclaration(node) ? node.importKind : node.exportKind) === "value") maybeReplace(node.source, path.get("source"), state);
3321
+ if ((t.isImportDeclaration(node) ? node.importKind : node.exportKind) === "value") maybeReplace(node.source, path.get("source"), state);
3339
3322
  },
3340
3323
  CallExpression(path, state) {
3341
- if (t$1.isImport(path.node.callee)) maybeReplace(path.node.arguments[0], path.get("arguments.0"), state);
3324
+ if (t.isImport(path.node.callee)) maybeReplace(path.node.arguments[0], path.get("arguments.0"), state);
3342
3325
  },
3343
3326
  ImportExpression(path, state) {
3344
3327
  maybeReplace(path.node.source, path.get("source"), state);
@@ -3346,30 +3329,29 @@ const pluginRewriteTSImports = declare(({ types: t$1, template: template$1 }) =>
3346
3329
  }
3347
3330
  };
3348
3331
  });
3349
- var plugin_rewrite_ts_imports_default = pluginRewriteTSImports;
3350
3332
 
3351
3333
  //#endregion
3352
3334
  //#region src/preset-typescript/index.ts
3353
3335
  const presetTypescript = declarePreset((api, opts) => {
3354
- const { allExtensions, ignoreExtensions, allowNamespaces, disallowAmbiguousJSXLike, isTSX, jsxPragma, jsxPragmaFrag, onlyRemoveTypeImports, optimizeConstEnums, rewriteImportExtensions } = normalizeOptions(opts);
3355
- const pluginOptions = (disallowAmbiguousJSXLike$1) => ({
3336
+ const { ignoreExtensions, allowNamespaces, disallowAmbiguousJSXLike, isTSX, jsxPragma, jsxPragmaFrag, onlyRemoveTypeImports, optimizeConstEnums, rewriteImportExtensions } = normalizeOptions(opts);
3337
+ const pluginOptions = (disallowAmbiguousJSXLike) => ({
3356
3338
  allowDeclareFields: opts.allowDeclareFields,
3357
3339
  allowNamespaces,
3358
- disallowAmbiguousJSXLike: disallowAmbiguousJSXLike$1,
3340
+ disallowAmbiguousJSXLike,
3359
3341
  jsxPragma,
3360
3342
  jsxPragmaFrag,
3361
3343
  onlyRemoveTypeImports,
3362
3344
  optimizeConstEnums
3363
3345
  });
3364
- const getPlugins = (isTSX$1, disallowAmbiguousJSXLike$1) => {
3365
- return [[plugin_transform_typescript_default, {
3366
- isTSX: isTSX$1,
3367
- ...pluginOptions(disallowAmbiguousJSXLike$1)
3346
+ const getPlugins = (isTSX, disallowAmbiguousJSXLike) => {
3347
+ return [[pluginTransformTypescript, {
3348
+ isTSX,
3349
+ ...pluginOptions(disallowAmbiguousJSXLike)
3368
3350
  }]];
3369
3351
  };
3370
3352
  return {
3371
- plugins: rewriteImportExtensions ? [plugin_rewrite_ts_imports_default] : [],
3372
- overrides: allExtensions || ignoreExtensions ? [{ plugins: getPlugins(isTSX, disallowAmbiguousJSXLike) }] : [
3353
+ plugins: rewriteImportExtensions ? [pluginRewriteTSImports] : [],
3354
+ overrides: ignoreExtensions ? [{ plugins: getPlugins(isTSX, disallowAmbiguousJSXLike) }] : [
3373
3355
  {
3374
3356
  test: /\.ts$/,
3375
3357
  plugins: getPlugins(false, false)
@@ -3382,7 +3364,7 @@ const presetTypescript = declarePreset((api, opts) => {
3382
3364
  {
3383
3365
  test: /\.cts$/,
3384
3366
  sourceType: "unambiguous",
3385
- plugins: [[plugin_transform_typescript_default, pluginOptions(true)]]
3367
+ plugins: [[pluginTransformTypescript, pluginOptions(true)]]
3386
3368
  },
3387
3369
  {
3388
3370
  test: /\.tsx$/,
@@ -3391,12 +3373,11 @@ const presetTypescript = declarePreset((api, opts) => {
3391
3373
  ]
3392
3374
  };
3393
3375
  });
3394
- var preset_typescript_default = presetTypescript;
3395
3376
 
3396
3377
  //#endregion
3397
3378
  //#region src/index.ts
3398
3379
  function solidPreset(_context, options = {}) {
3399
- return { plugins: [[babel_plugin_jsx_dom_expressions_default, Object.assign({
3380
+ return { plugins: [[jsxTransform, Object.assign({
3400
3381
  moduleName: "solid-js/web",
3401
3382
  builtIns: [
3402
3383
  "For",
@@ -3427,7 +3408,7 @@ const rolldownPluginSolid = (options) => {
3427
3408
  const { name, ext } = parse(id);
3428
3409
  const filename = name + ext;
3429
3410
  const result = await transformAsync(code, {
3430
- presets: [[solidPreset, options?.solid ?? {}], [preset_typescript_default, options?.typescript ?? {}]],
3411
+ presets: [[solidPreset, options?.solid ?? {}], [presetTypescript, options?.typescript ?? {}]],
3431
3412
  filename,
3432
3413
  sourceMaps: "inline"
3433
3414
  });
@@ -3437,7 +3418,6 @@ const rolldownPluginSolid = (options) => {
3437
3418
  }
3438
3419
  };
3439
3420
  };
3440
- var src_default = rolldownPluginSolid;
3441
3421
 
3442
3422
  //#endregion
3443
- export { src_default as default };
3423
+ export { rolldownPluginSolid as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolldown-plugin/solid",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "A Rolldown plugin for compiling SolidJS JSX/TSX files",
5
5
  "license": "MIT",
6
6
  "author": "gameroman",
@@ -30,31 +30,41 @@
30
30
  "prepublishOnly": "bun run build"
31
31
  },
32
32
  "dependencies": {
33
- "@babel/helper-plugin-utils": "^7.28.6",
34
- "@babel/helper-validator-option": "^7.27.1",
35
- "@babel/core": "^7.28.6",
36
- "@babel/helper-module-imports": "7.28.6",
37
- "@babel/template": "7.28.6",
38
- "@babel/traverse": "7.28.6",
39
- "@babel/types": "7.28.6",
33
+ "@babel/helper-plugin-utils": "^8.0.0-rc.1",
34
+ "@babel/helper-validator-option": "^8.0.0-rc.1",
35
+ "@babel/core": "^8.0.0-rc.1",
36
+ "@babel/helper-module-imports": "^8.0.0-rc.1",
37
+ "@babel/template": "^8.0.0-rc.1",
38
+ "@babel/traverse": "^8.0.0-rc.1",
39
+ "@babel/types": "^8.0.0-rc.1",
40
40
  "html-entities": "2.6.0",
41
41
  "parse5": "^8.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@biomejs/biome": "2.3.12",
45
- "@types/babel__core": "^7.20.5",
46
- "@types/bun": "^1.3.6",
47
- "@types/node": "^25.0.10",
44
+ "@biomejs/biome": "2.4.0",
45
+ "@types/bun": "^1.3.9",
46
+ "@types/node": "^25.2.3",
48
47
  "solid-js": "1.9.11",
49
- "tsdown": "^0.19.0"
48
+ "tsdown": "^0.20.3"
50
49
  },
51
50
  "peerDependencies": {
52
51
  "csstype": "^3.1.0",
53
- "rolldown": ">=1.0.0-beta.59 <1.0.0-beta.999 || ^1.0.0-rc.1 || ^1.0.0",
52
+ "rolldown": "^1.0.0-rc.1 || ^1.0.0",
54
53
  "seroval": "~1.3.0 || ~1.5.0",
55
54
  "solid-js": ">=1.9.0"
56
55
  },
57
56
  "engines": {
58
57
  "node": ">=20.0.0"
58
+ },
59
+ "overrides": {
60
+ "@babel/helper-plugin-utils": "8.0.0-rc.1",
61
+ "@babel/helper-validator-identifier": "8.0.0-rc.1",
62
+ "@babel/helper-validator-option": "8.0.0-rc.1",
63
+ "@babel/code-frame": "8.0.0-rc.1",
64
+ "@babel/core": "8.0.0-rc.1",
65
+ "@babel/helper-module-imports": "8.0.0-rc.1",
66
+ "@babel/template": "8.0.0-rc.1",
67
+ "@babel/traverse": "8.0.0-rc.1",
68
+ "@babel/types": "8.0.0-rc.1"
59
69
  }
60
70
  }