@tsrx/preact 0.1.70 → 0.1.71
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 +21 -4
- package/types/index.d.ts +1 -1
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.1.
|
|
6
|
+
"version": "0.1.71",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"esrap": "^2.3.2",
|
|
39
39
|
"zimmerframe": "^1.1.2",
|
|
40
|
-
"@tsrx/core": "0.1.
|
|
40
|
+
"@tsrx/core": "0.1.71",
|
|
41
41
|
"@tsrx/preact-runtime": "0.1.7"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
package/src/index.js
CHANGED
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
/** @import { NonEmptyString } from '@tsrx/core/types/helpers' */
|
|
4
4
|
/** @import { CompileOptions } from '../types/index' */
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
analyzeTsrx,
|
|
8
|
+
createVolarMappingsResult,
|
|
9
|
+
dedupeMappings,
|
|
10
|
+
hasPlatformNamespace,
|
|
11
|
+
parseModule,
|
|
12
|
+
specializePlatform,
|
|
13
|
+
withPlatformTypes,
|
|
14
|
+
} from '@tsrx/core';
|
|
7
15
|
import { DEFAULT_SUSPENSE_SOURCE, transform } from './transform.js';
|
|
8
16
|
|
|
9
17
|
export { DEFAULT_SUSPENSE_SOURCE };
|
|
@@ -35,11 +43,17 @@ export function compile(source, filename, compile_options) {
|
|
|
35
43
|
const errors = /** @type {CompileError[]} */ ([]);
|
|
36
44
|
const comments = /** @type {AST.CommentWithLocation[]} */ ([]);
|
|
37
45
|
const collect = !!(compile_options?.collect || compile_options?.loose);
|
|
38
|
-
|
|
46
|
+
let ast = parseModule(
|
|
39
47
|
source,
|
|
40
48
|
filename,
|
|
41
49
|
collect ? { collect: true, loose: !!compile_options?.loose, errors, comments } : undefined,
|
|
42
50
|
);
|
|
51
|
+
ast = specializePlatform(
|
|
52
|
+
ast,
|
|
53
|
+
compile_options?.platform,
|
|
54
|
+
filename,
|
|
55
|
+
collect ? { errors, comments } : undefined,
|
|
56
|
+
);
|
|
43
57
|
analyzeTsrx(
|
|
44
58
|
ast,
|
|
45
59
|
filename,
|
|
@@ -75,7 +89,7 @@ export function compile(source, filename, compile_options) {
|
|
|
75
89
|
export function compile_to_volar_mappings(source, filename, options) {
|
|
76
90
|
const errors = /** @type {CompileError[]} */ ([]);
|
|
77
91
|
const comments = /** @type {AST.CommentWithLocation[]} */ ([]);
|
|
78
|
-
|
|
92
|
+
let ast = parseModule(source, filename, {
|
|
79
93
|
...options,
|
|
80
94
|
collect: true,
|
|
81
95
|
loose: !!options?.loose,
|
|
@@ -84,6 +98,8 @@ export function compile_to_volar_mappings(source, filename, options) {
|
|
|
84
98
|
errors,
|
|
85
99
|
comments,
|
|
86
100
|
});
|
|
101
|
+
const uses_platform_flags = hasPlatformNamespace(ast);
|
|
102
|
+
ast = specializePlatform(ast, options?.platform, filename, { errors, comments });
|
|
87
103
|
analyzeTsrx(ast, filename, {
|
|
88
104
|
collect: true,
|
|
89
105
|
loose: !!options?.loose,
|
|
@@ -108,8 +124,9 @@ export function compile_to_volar_mappings(source, filename, options) {
|
|
|
108
124
|
errors,
|
|
109
125
|
});
|
|
110
126
|
|
|
111
|
-
|
|
127
|
+
const deduped = {
|
|
112
128
|
...result,
|
|
113
129
|
mappings: dedupeMappings(result.mappings),
|
|
114
130
|
};
|
|
131
|
+
return uses_platform_flags ? withPlatformTypes(deduped, options?.platform) : deduped;
|
|
115
132
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Program } from 'estree';
|
|
2
2
|
import type { BaseCompileOptions, CompileFn, ParseOptions, VolarCompileFn } from '@tsrx/core/types';
|
|
3
3
|
|
|
4
|
-
export type { RuntimeImportMode } from '@tsrx/core/types';
|
|
4
|
+
export type { Platform, RuntimeImportMode, TsrxPlatformFlags } from '@tsrx/core/types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Per-call compile options for tsrx-preact. Exposed publicly so the Vite
|