@tsrx/vite-plugin-vue 0.0.85 → 0.0.87

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": "Vite plugin for @tsrx/vue (.tsrx modules)",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.0.85",
6
+ "version": "0.0.87",
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.69",
24
- "@tsrx/vue": "0.1.69"
23
+ "@tsrx/core": "0.1.71",
24
+ "@tsrx/vue": "0.1.71"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "vite": "*",
package/src/index.js CHANGED
@@ -6,6 +6,8 @@ import { readFile } from 'node:fs/promises';
6
6
  import { existsSync } from 'node:fs';
7
7
  import { isAbsolute, resolve as pathResolve } from 'node:path';
8
8
  import { compile } from '@tsrx/vue';
9
+ import { mergePlatformDefinitions, validatePlatform } from '@tsrx/core';
10
+ import { resolveBuildPlatform } from '@tsrx/core/config';
9
11
  import { createDepScanLoadPlugin } from '@tsrx/core/vite/dep-scan';
10
12
  import vueJsxVaporModule from 'vue-jsx-vapor/vite';
11
13
  import { createVaporInteropPlugin } from './interop.js';
@@ -77,6 +79,8 @@ function resolve_vapor_options(options) {
77
79
  * @returns {Plugin}
78
80
  */
79
81
  function create_tsrx_vue_plugin(options) {
82
+ const explicit_platform = validatePlatform(options.platform);
83
+ let platform = explicit_platform;
80
84
  /** @type {Map<string, string>} */
81
85
  const cssCache = new Map();
82
86
 
@@ -84,7 +88,20 @@ function create_tsrx_vue_plugin(options) {
84
88
  let rootDir = process.cwd();
85
89
 
86
90
  const includePattern = options.include ?? DEFAULT_TSRX_PATTERN;
87
- const compile_options = { runtimeImports: options.runtimeImports };
91
+ const compile_options = { runtimeImports: options.runtimeImports, platform };
92
+
93
+ /** @param {import('vite').UserConfig} config */
94
+ function resolve_platform(config) {
95
+ platform = resolveBuildPlatform({
96
+ root: config.root ?? process.cwd(),
97
+ tsconfig:
98
+ options.tsconfig ??
99
+ /** @type {{ tsconfig?: string }} */ (/** @type {unknown} */ (config)).tsconfig,
100
+ platform: explicit_platform,
101
+ integration: '@tsrx/vite-plugin-vue',
102
+ });
103
+ compile_options.platform = platform;
104
+ }
88
105
 
89
106
  /**
90
107
  * @param {string} path
@@ -120,8 +137,16 @@ function create_tsrx_vue_plugin(options) {
120
137
  name: '@tsrx/vite-plugin-vue',
121
138
  enforce: 'pre',
122
139
 
123
- config() {
140
+ config(config = /** @type {import('vite').UserConfig} */ ({})) {
141
+ resolve_platform(config);
124
142
  return {
143
+ ...(platform === undefined
144
+ ? {}
145
+ : {
146
+ define: mergePlatformDefinitions(config.define, platform, {
147
+ integration: 'Vite',
148
+ }),
149
+ }),
125
150
  resolve: {
126
151
  dedupe: ['vue', 'vue-jsx-vapor'],
127
152
  },
@@ -141,6 +166,15 @@ function create_tsrx_vue_plugin(options) {
141
166
  };
142
167
  },
143
168
 
169
+ configEnvironment(name, config = /** @type {import('vite').EnvironmentOptions} */ ({})) {
170
+ if (platform === undefined) return;
171
+ return {
172
+ define: mergePlatformDefinitions(config.define, platform, {
173
+ integration: `Vite environment ${JSON.stringify(name)}`,
174
+ }),
175
+ };
176
+ },
177
+
144
178
  configResolved(config) {
145
179
  rootDir = config.root;
146
180
  },
@@ -225,7 +259,7 @@ function create_tsrx_vue_plugin(options) {
225
259
  *
226
260
  * @param {(id: string) => boolean} isVirtual
227
261
  * @param {(id: string) => string} toRealPath
228
- * @param {{ runtimeImports?: RuntimeImportMode }} compile_options
262
+ * @param {{ runtimeImports?: RuntimeImportMode, platform?: import('@tsrx/vue').Platform }} compile_options
229
263
  * @returns {DepScanLoadPlugin}
230
264
  */
231
265
  function create_tsrx_vue_scan_plugin(isVirtual, toRealPath, compile_options) {
package/types/index.d.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  import type { Plugin } from 'vite';
2
- import type { RuntimeImportMode } from '@tsrx/vue';
2
+ import type { Platform, RuntimeImportMode } from '@tsrx/vue';
3
3
 
4
4
  export interface TsrxVueOptions {
5
5
  /** Direct mode requires `@tsrx/vue-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$/`.