@tsrx/preact 0.0.14 → 0.0.16

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Preact compiler built on @tsrx/core",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.0.14",
6
+ "version": "0.0.16",
7
7
  "type": "module",
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "esrap": "^2.1.0",
32
32
  "zimmerframe": "^1.1.2",
33
- "@tsrx/core": "0.0.19"
33
+ "@tsrx/core": "0.0.21"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "preact": ">=10"
package/src/index.js CHANGED
@@ -24,23 +24,25 @@ export function parse(source, filename, options) {
24
24
  *
25
25
  * @param {string} source
26
26
  * @param {string} [filename]
27
- * @param {CompileOptions & { loose?: boolean }} [compile_options]
27
+ * @param {CompileOptions & { collect?: boolean, loose?: boolean }} [compile_options]
28
28
  * @returns {{ code: string, map: any, css: { code: string, hash: string } | null, errors: CompileError[] }}
29
29
  */
30
30
  export function compile(source, filename, compile_options) {
31
31
  const errors = /** @type {CompileError[]} */ ([]);
32
32
  const comments = /** @type {AST.CommentWithLocation[]} */ ([]);
33
- const collect = !!compile_options?.loose;
33
+ const collect = !!(compile_options?.collect || compile_options?.loose);
34
34
  const ast = parseModule(
35
35
  source,
36
36
  filename,
37
- collect ? { loose: true, errors, comments } : undefined,
37
+ collect ? { collect: true, loose: !!compile_options?.loose, errors, comments } : undefined,
38
38
  );
39
39
  const { ast: _ast, ...result } = transform(
40
40
  ast,
41
41
  source,
42
42
  filename,
43
- collect ? { ...compile_options, loose: true, errors, comments } : compile_options,
43
+ collect
44
+ ? { ...compile_options, collect: true, loose: !!compile_options?.loose, errors, comments }
45
+ : compile_options,
44
46
  );
45
47
  return { ...result, errors };
46
48
  }
@@ -56,10 +58,17 @@ export function compile(source, filename, compile_options) {
56
58
  export function compile_to_volar_mappings(source, filename, options) {
57
59
  const errors = /** @type {import('@tsrx/core/types').CompileError[]} */ ([]);
58
60
  const comments = /** @type {AST.CommentWithLocation[]} */ ([]);
59
- const ast = parseModule(source, filename, { ...options, errors, comments });
61
+ const ast = parseModule(source, filename, {
62
+ ...options,
63
+ collect: true,
64
+ loose: !!options?.loose,
65
+ errors,
66
+ comments,
67
+ });
60
68
  const transformed = transform(ast, source, filename, {
61
69
  ...options,
62
- loose: true,
70
+ collect: true,
71
+ loose: !!options?.loose,
63
72
  errors,
64
73
  comments,
65
74
  });
package/types/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export function parse(source: string, filename?: string, options?: ParseOptions)
12
12
  export function compile(
13
13
  source: string,
14
14
  filename?: string,
15
- compile_options?: CompileOptions & { loose?: boolean },
15
+ compile_options?: CompileOptions & { collect?: boolean; loose?: boolean },
16
16
  ): {
17
17
  code: string;
18
18
  map: unknown;