@zeus-js/compiler 0.1.0-beta.0 → 0.1.0-beta.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.
@@ -1,10 +1,9 @@
1
1
  /**
2
- * compiler v0.1.0-beta.0
2
+ * compiler v0.1.0-beta.2
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
6
6
  import { declare } from "@babel/helper-plugin-utils";
7
- import syntaxJsx from "@babel/plugin-syntax-jsx";
8
7
  import { extend } from "@zeus-js/shared";
9
8
  import * as t from "@babel/types";
10
9
  //#region packages/core/compiler/src/codegen/support/imports.ts
@@ -639,8 +638,8 @@ function emitFor(node, context) {
639
638
  function emitMountFor(node, context) {
640
639
  var _node$by;
641
640
  const params = [node.item];
642
- const path = node.domPath;
643
641
  if (node.index) params.push(node.index);
642
+ const path = node.domPath;
644
643
  if (!path || path.kind !== "Marker") throw new Error("For DOM path is not assigned");
645
644
  return t.callExpression(context.importRuntime("mountFor"), [
646
645
  t.identifier(path.parent.name),
@@ -652,9 +651,10 @@ function emitMountFor(node, context) {
652
651
  }
653
652
  function emitHost(node, context) {
654
653
  const props = buildHostProps(node, context);
655
- const hostCall = t.callExpression(context.importRuntime("Host"), [t.objectExpression(props)]);
656
- if (!node.child) return hostCall;
654
+ const hostIdent = context.importRuntime("Host");
655
+ if (!node.child) return t.callExpression(hostIdent, [t.objectExpression(props)]);
657
656
  const childExpr = emitNodeExpression(node.child, context);
657
+ const hostCall = t.callExpression(hostIdent, [t.objectExpression(props)]);
658
658
  return t.callExpression(t.arrowFunctionExpression([], t.blockStatement([t.expressionStatement(hostCall), t.returnStatement(childExpr)])), []);
659
659
  }
660
660
  function buildHostProps(node, context) {
@@ -1743,11 +1743,18 @@ function createVisitor(config) {
1743
1743
  }
1744
1744
  //#endregion
1745
1745
  //#region packages/core/compiler/src/index.ts
1746
+ function hasParserPlugin(plugins, name) {
1747
+ return plugins.some((plugin) => (Array.isArray(plugin) ? plugin[0] : plugin) === name);
1748
+ }
1746
1749
  var src_default = declare((api, options) => {
1747
1750
  api.assertVersion(7);
1748
1751
  return {
1749
1752
  name: "babel-plugin-zeus-compiler",
1750
- inherits: syntaxJsx,
1753
+ manipulateOptions(_opts, parserOpts) {
1754
+ var _parserOpts$plugins;
1755
+ (_parserOpts$plugins = parserOpts.plugins) !== null && _parserOpts$plugins !== void 0 || (parserOpts.plugins = []);
1756
+ if (!hasParserPlugin(parserOpts.plugins, "jsx")) parserOpts.plugins.push("jsx");
1757
+ },
1751
1758
  visitor: createVisitor(resolveConfig(options))
1752
1759
  };
1753
1760
  });