@tsrx/vite-plugin-solid 0.0.100 → 0.0.101
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 +3 -3
- package/src/index.js +36 -2
- package/types/index.d.ts +5 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Vite plugin for @tsrx/solid (.tsrx modules) targeting Solid 2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.101",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tsrx/core": "0.1.
|
|
24
|
-
"@tsrx/solid": "0.1.
|
|
23
|
+
"@tsrx/core": "0.1.71",
|
|
24
|
+
"@tsrx/solid": "0.1.71"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"vite": "*"
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,8 @@ import { readFile } from 'node:fs/promises';
|
|
|
4
4
|
import { existsSync } from 'node:fs';
|
|
5
5
|
import { resolve as path_resolve, isAbsolute } from 'node:path';
|
|
6
6
|
import { compile } from '@tsrx/solid';
|
|
7
|
+
import { mergePlatformDefinitions, validatePlatform } from '@tsrx/core';
|
|
8
|
+
import { resolveBuildPlatform } from '@tsrx/core/config';
|
|
7
9
|
import { createDepScanLoadPlugin } from '@tsrx/core/vite/dep-scan';
|
|
8
10
|
|
|
9
11
|
const DEFAULT_TSRX_PATTERN = /\.tsrx$/;
|
|
@@ -21,6 +23,8 @@ const CSS_QUERY = '?tsrx-solid-css&lang.css';
|
|
|
21
23
|
* @returns {Plugin}
|
|
22
24
|
*/
|
|
23
25
|
export function tsrxSolid(options = {}) {
|
|
26
|
+
const explicit_platform = validatePlatform(options.platform);
|
|
27
|
+
let platform = explicit_platform;
|
|
24
28
|
/** @type {Map<string, string>} */
|
|
25
29
|
const css_cache = new Map();
|
|
26
30
|
|
|
@@ -28,7 +32,20 @@ export function tsrxSolid(options = {}) {
|
|
|
28
32
|
let root_dir = process.cwd();
|
|
29
33
|
|
|
30
34
|
const include_pattern = options.include ?? DEFAULT_TSRX_PATTERN;
|
|
31
|
-
const compile_options = { runtimeImports: options.runtimeImports };
|
|
35
|
+
const compile_options = { runtimeImports: options.runtimeImports, platform };
|
|
36
|
+
|
|
37
|
+
/** @param {import('vite').UserConfig} config */
|
|
38
|
+
function resolve_platform(config) {
|
|
39
|
+
platform = resolveBuildPlatform({
|
|
40
|
+
root: config.root ?? process.cwd(),
|
|
41
|
+
tsconfig:
|
|
42
|
+
options.tsconfig ??
|
|
43
|
+
/** @type {{ tsconfig?: string }} */ (/** @type {unknown} */ (config)).tsconfig,
|
|
44
|
+
platform: explicit_platform,
|
|
45
|
+
integration: '@tsrx/vite-plugin-solid',
|
|
46
|
+
});
|
|
47
|
+
compile_options.platform = platform;
|
|
48
|
+
}
|
|
32
49
|
|
|
33
50
|
/**
|
|
34
51
|
* Decide whether a real (on-disk) path should be treated as a tsrx
|
|
@@ -76,8 +93,16 @@ export function tsrxSolid(options = {}) {
|
|
|
76
93
|
name: '@tsrx/vite-plugin-solid',
|
|
77
94
|
enforce: 'pre',
|
|
78
95
|
|
|
79
|
-
config() {
|
|
96
|
+
config(config = /** @type {import('vite').UserConfig} */ ({})) {
|
|
97
|
+
resolve_platform(config);
|
|
80
98
|
return {
|
|
99
|
+
...(platform === undefined
|
|
100
|
+
? {}
|
|
101
|
+
: {
|
|
102
|
+
define: mergePlatformDefinitions(config.define, platform, {
|
|
103
|
+
integration: 'Vite',
|
|
104
|
+
}),
|
|
105
|
+
}),
|
|
81
106
|
optimizeDeps: {
|
|
82
107
|
rolldownOptions: {
|
|
83
108
|
// The scan runs its own jsx transform over the tsx the
|
|
@@ -101,6 +126,15 @@ export function tsrxSolid(options = {}) {
|
|
|
101
126
|
};
|
|
102
127
|
},
|
|
103
128
|
|
|
129
|
+
configEnvironment(name, config = /** @type {import('vite').EnvironmentOptions} */ ({})) {
|
|
130
|
+
if (platform === undefined) return;
|
|
131
|
+
return {
|
|
132
|
+
define: mergePlatformDefinitions(config.define, platform, {
|
|
133
|
+
integration: `Vite environment ${JSON.stringify(name)}`,
|
|
134
|
+
}),
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
|
|
104
138
|
configResolved(config) {
|
|
105
139
|
root_dir = config.root;
|
|
106
140
|
},
|
package/types/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
import type { RuntimeImportMode } from '@tsrx/solid';
|
|
2
|
+
import type { Platform, RuntimeImportMode } from '@tsrx/solid';
|
|
3
3
|
|
|
4
4
|
export interface TsrxSolidOptions {
|
|
5
5
|
/** Direct mode requires `@tsrx/solid-runtime` as a direct production dependency. */
|
|
6
6
|
runtimeImports?: RuntimeImportMode;
|
|
7
|
+
/** Optional override; inferred from tsconfig by default and must agree when both exist. */
|
|
8
|
+
platform?: Platform;
|
|
9
|
+
/** Optional tsconfig path override, resolved from Vite's project root. */
|
|
10
|
+
tsconfig?: string;
|
|
7
11
|
/**
|
|
8
12
|
* Regular expression matched against file paths to decide which modules
|
|
9
13
|
* the plugin should compile as tsrx sources. Defaults to `/\.tsrx$/`,
|