@tsrx/solid 0.0.2 → 0.0.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/transform.js +16 -1
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Solid compiler built on @tsrx/core",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.0.2",
6
+ "version": "0.0.4",
7
7
  "type": "module",
8
8
  "publishConfig": {
9
9
  "access": "public"
package/src/transform.js CHANGED
@@ -1103,7 +1103,22 @@ function to_jsx_element(node, transform_context) {
1103
1103
  */
1104
1104
  function create_element_children(children, transform_context) {
1105
1105
  if (children.length === 0) return [];
1106
- // Solid doesn't need React's hook-safe IIFE wrapping; every child is inline.
1106
+
1107
+ // If any child is a plain statement (VariableDeclaration, ExpressionStatement,
1108
+ // DebuggerStatement, etc.) interleaved with JSX, we can't emit it as a JSX
1109
+ // child directly — Solid's JSX runtime would treat the node as an opaque
1110
+ // value and the source code would print as literal text. Wrap the whole
1111
+ // children list in an IIFE so the statements execute during render and
1112
+ // their locals scope to the block, matching the authored intent of
1113
+ // mid-template locals.
1114
+ const has_non_jsx_child = children.some(
1115
+ (/** @type {any} */ child) => child && !is_jsx_child(child),
1116
+ );
1117
+ if (has_non_jsx_child) {
1118
+ const body_jsx = body_to_jsx_child(children, transform_context);
1119
+ return [jsx_child_wrap(iife_if_arrow(body_jsx))];
1120
+ }
1121
+
1107
1122
  return children.map((/** @type {any} */ child) => to_jsx_child(child, transform_context));
1108
1123
  }
1109
1124