@tsrx/solid 0.0.13 → 0.0.15
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 +11 -7
- package/src/transform.js +1 -0
- package/types/index.d.ts +3 -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.
|
|
6
|
+
"version": "0.0.15",
|
|
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.15"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"solid-js": ">=1.8 || >=2.0.0-beta"
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @import * as AST from 'estree' */
|
|
2
|
-
/** @import { ParseOptions } from '@tsrx/core/types' */
|
|
2
|
+
/** @import { CompileError, ParseOptions } from '@tsrx/core/types' */
|
|
3
3
|
|
|
4
4
|
import { createVolarMappingsResult, dedupeMappings, parseModule } from '@tsrx/core';
|
|
5
5
|
import { transform } from './transform.js';
|
|
@@ -21,12 +21,15 @@ export function parse(source, filename, options) {
|
|
|
21
21
|
*
|
|
22
22
|
* @param {string} source
|
|
23
23
|
* @param {string} [filename]
|
|
24
|
-
* @
|
|
24
|
+
* @param {{ loose?: boolean }} [options]
|
|
25
|
+
* @returns {{ code: string, map: any, css: { code: string, hash: string } | null, errors: CompileError[] }}
|
|
25
26
|
*/
|
|
26
|
-
export function compile(source, filename) {
|
|
27
|
-
const
|
|
27
|
+
export function compile(source, filename, options) {
|
|
28
|
+
const errors = /** @type {CompileError[]} */ ([]);
|
|
29
|
+
const collect = !!options?.loose;
|
|
30
|
+
const ast = parseModule(source, filename, collect ? { loose: true, errors } : undefined);
|
|
28
31
|
const { ast: _ast, ...result } = transform(ast, source, filename);
|
|
29
|
-
return result;
|
|
32
|
+
return { ...result, errors };
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
/**
|
|
@@ -38,7 +41,8 @@ export function compile(source, filename) {
|
|
|
38
41
|
* @returns {import('@tsrx/core/types').VolarMappingsResult}
|
|
39
42
|
*/
|
|
40
43
|
export function compile_to_volar_mappings(source, filename, options) {
|
|
41
|
-
const
|
|
44
|
+
const errors = /** @type {import('@tsrx/core/types').CompileError[]} */ ([]);
|
|
45
|
+
const ast = parseModule(source, filename, { ...options, errors });
|
|
42
46
|
const transformed = transform(ast, source, filename);
|
|
43
47
|
const result = createVolarMappingsResult({
|
|
44
48
|
ast: transformed.ast,
|
|
@@ -46,7 +50,7 @@ export function compile_to_volar_mappings(source, filename, options) {
|
|
|
46
50
|
source,
|
|
47
51
|
generated_code: transformed.code,
|
|
48
52
|
source_map: transformed.map,
|
|
49
|
-
errors
|
|
53
|
+
errors,
|
|
50
54
|
});
|
|
51
55
|
|
|
52
56
|
return {
|
package/src/transform.js
CHANGED
|
@@ -282,6 +282,7 @@ function component_to_function_declaration(component, transform_context) {
|
|
|
282
282
|
const fn = /** @type {any} */ ({
|
|
283
283
|
type: 'FunctionDeclaration',
|
|
284
284
|
id: component.id,
|
|
285
|
+
typeParameters: component.typeParameters,
|
|
285
286
|
params: final_params,
|
|
286
287
|
body: final_body,
|
|
287
288
|
async: false,
|
package/types/index.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import type { Program } from 'estree';
|
|
2
|
-
import type { ParseOptions, VolarMappingsResult } from '@tsrx/core/types';
|
|
2
|
+
import type { CompileError, ParseOptions, VolarMappingsResult } from '@tsrx/core/types';
|
|
3
3
|
|
|
4
4
|
export function parse(source: string, filename?: string, options?: ParseOptions): Program;
|
|
5
5
|
|
|
6
6
|
export function compile(
|
|
7
7
|
source: string,
|
|
8
8
|
filename?: string,
|
|
9
|
+
options?: { loose?: boolean },
|
|
9
10
|
): {
|
|
10
11
|
code: string;
|
|
11
12
|
map: unknown;
|
|
12
13
|
css: { code: string; hash: string } | null;
|
|
14
|
+
errors: CompileError[];
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
export function compile_to_volar_mappings(
|