@tsrx/react 0.1.1 → 0.1.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/package.json +2 -2
- package/src/transform.js +6 -13
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "React compiler built on @tsrx/core",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.2",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"esrap": "^2.1.0",
|
|
27
27
|
"zimmerframe": "^1.1.2",
|
|
28
|
-
"@tsrx/core": "0.0.
|
|
28
|
+
"@tsrx/core": "0.0.8"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": ">=18"
|
package/src/transform.js
CHANGED
|
@@ -1091,6 +1091,9 @@ function is_jsx_child(node) {
|
|
|
1091
1091
|
);
|
|
1092
1092
|
}
|
|
1093
1093
|
|
|
1094
|
+
const TEMPLATE_FRAGMENT_ERROR =
|
|
1095
|
+
'JSX fragment syntax is not needed in TSRX templates. TSRX renders in immediate mode, so everything is already a fragment. Use `<>...</>` only within <tsx>...</tsx>.';
|
|
1096
|
+
|
|
1094
1097
|
/**
|
|
1095
1098
|
* @param {any} node
|
|
1096
1099
|
* @param {TransformContext} transform_context
|
|
@@ -1103,23 +1106,13 @@ function to_jsx_element(node, transform_context) {
|
|
|
1103
1106
|
'`{html ...}` is not supported on the React target. Use `dangerouslySetInnerHTML={{ __html: ... }}` as an element attribute instead.',
|
|
1104
1107
|
);
|
|
1105
1108
|
}
|
|
1109
|
+
if (!node.id) {
|
|
1110
|
+
throw create_compile_error(node, TEMPLATE_FRAGMENT_ERROR);
|
|
1111
|
+
}
|
|
1106
1112
|
if (is_dynamic_element_id(node.id)) {
|
|
1107
1113
|
return dynamic_element_to_jsx_child(node, transform_context);
|
|
1108
1114
|
}
|
|
1109
1115
|
|
|
1110
|
-
if (!node.id) {
|
|
1111
|
-
const children = create_element_children(node.children || [], transform_context);
|
|
1112
|
-
return set_loc(
|
|
1113
|
-
/** @type {any} */ ({
|
|
1114
|
-
type: 'JSXFragment',
|
|
1115
|
-
openingFragment: { type: 'JSXOpeningFragment' },
|
|
1116
|
-
closingFragment: { type: 'JSXClosingFragment' },
|
|
1117
|
-
children,
|
|
1118
|
-
}),
|
|
1119
|
-
node,
|
|
1120
|
-
);
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
1116
|
const name = identifier_to_jsx_name(node.id);
|
|
1124
1117
|
const attributes = (node.attributes || []).map(to_jsx_attribute);
|
|
1125
1118
|
const selfClosing = !!node.selfClosing;
|