@tsrx/solid 0.0.26 → 0.0.27
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/index.js +2 -1
- package/src/transform.js +12 -1
- package/types/index.d.ts +3 -16
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.
|
|
6
|
+
"version": "0.0.27",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"esrap": "^2.1.0",
|
|
24
24
|
"zimmerframe": "^1.1.2",
|
|
25
|
-
"@tsrx/core": "0.0.
|
|
25
|
+
"@tsrx/core": "0.0.27"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"solid-js": ">=1.8 || >=2.0.0-beta"
|
package/src/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export function parse(source, filename, options) {
|
|
|
22
22
|
* @param {string} source
|
|
23
23
|
* @param {string} [filename]
|
|
24
24
|
* @param {{ collect?: boolean, loose?: boolean }} [options]
|
|
25
|
-
* @returns {{ code: string, map: any, css:
|
|
25
|
+
* @returns {{ code: string, map: any, css: string, cssHash: string | null, errors: CompileError[] }}
|
|
26
26
|
*/
|
|
27
27
|
export function compile(source, filename, options) {
|
|
28
28
|
const errors = /** @type {CompileError[]} */ ([]);
|
|
@@ -63,6 +63,7 @@ export function compile_to_volar_mappings(source, filename, options) {
|
|
|
63
63
|
const transformed = transform(ast, source, filename, {
|
|
64
64
|
collect: true,
|
|
65
65
|
loose: !!options?.loose,
|
|
66
|
+
typeOnly: true,
|
|
66
67
|
errors,
|
|
67
68
|
comments,
|
|
68
69
|
});
|
package/src/transform.js
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
flatten_switch_consequent,
|
|
27
27
|
get_for_of_iteration_params,
|
|
28
28
|
identifier_to_jsx_name,
|
|
29
|
+
is_bare_render_expression,
|
|
29
30
|
is_dynamic_element_id,
|
|
30
31
|
is_jsx_child,
|
|
31
32
|
set_loc,
|
|
@@ -176,7 +177,11 @@ function component_to_function_declaration(component, transform_context) {
|
|
|
176
177
|
const params = component.params || [];
|
|
177
178
|
const body = /** @type {any[]} */ (component.body || []);
|
|
178
179
|
|
|
179
|
-
|
|
180
|
+
// In type-only mode the lazy rewrite is skipped so destructuring patterns
|
|
181
|
+
// survive into the virtual TSX and TypeScript can flow real types.
|
|
182
|
+
const lazy_bindings = transform_context.typeOnly
|
|
183
|
+
? new Map()
|
|
184
|
+
: collect_lazy_bindings_from_component(params, body, transform_context);
|
|
180
185
|
|
|
181
186
|
// Detect top-level early-return patterns such as `if (cond) { return; }`
|
|
182
187
|
// and `if (cond) { <p />; return; }`.
|
|
@@ -290,6 +295,8 @@ function component_to_function_declaration(component, transform_context) {
|
|
|
290
295
|
} else {
|
|
291
296
|
render_nodes.push(jsx);
|
|
292
297
|
}
|
|
298
|
+
} else if (is_bare_render_expression(child)) {
|
|
299
|
+
render_nodes.push(to_jsx_expression_container(child, child));
|
|
293
300
|
} else {
|
|
294
301
|
statements.push(child);
|
|
295
302
|
}
|
|
@@ -482,6 +489,8 @@ function body_to_jsx_child(body_nodes, transform_context) {
|
|
|
482
489
|
} else {
|
|
483
490
|
children.push(jsx);
|
|
484
491
|
}
|
|
492
|
+
} else if (is_bare_render_expression(child)) {
|
|
493
|
+
children.push(to_jsx_expression_container(child, child));
|
|
485
494
|
} else {
|
|
486
495
|
statements.push(child);
|
|
487
496
|
}
|
|
@@ -661,6 +670,8 @@ function loop_body_to_callback_statements(body_nodes, transform_context) {
|
|
|
661
670
|
|
|
662
671
|
if (is_jsx_child(child)) {
|
|
663
672
|
children.push(to_jsx_child(child, transform_context));
|
|
673
|
+
} else if (is_bare_render_expression(child)) {
|
|
674
|
+
children.push(to_jsx_expression_container(child, child));
|
|
664
675
|
} else {
|
|
665
676
|
statements.push(child);
|
|
666
677
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import type { Program } from 'estree';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CompileFn, ParseOptions, VolarCompileFn } from '@tsrx/core/types';
|
|
3
3
|
|
|
4
4
|
export function parse(source: string, filename?: string, options?: ParseOptions): Program;
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
source: string,
|
|
8
|
-
filename?: string,
|
|
9
|
-
options?: { collect?: boolean; loose?: boolean },
|
|
10
|
-
): {
|
|
11
|
-
code: string;
|
|
12
|
-
map: unknown;
|
|
13
|
-
css: { code: string; hash: string } | null;
|
|
14
|
-
errors: CompileError[];
|
|
15
|
-
};
|
|
6
|
+
export const compile: CompileFn;
|
|
16
7
|
|
|
17
|
-
export
|
|
18
|
-
source: string,
|
|
19
|
-
filename?: string,
|
|
20
|
-
options?: ParseOptions,
|
|
21
|
-
): VolarMappingsResult;
|
|
8
|
+
export const compile_to_volar_mappings: VolarCompileFn;
|