@tsrx/vite-plugin-vue 0.0.65 → 0.0.67

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/index.js +16 -17
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.65",
6
+ "version": "0.0.67",
7
7
  "type": "module",
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -20,7 +20,8 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@tsrx/vue": "0.1.49"
23
+ "@tsrx/core": "0.1.51",
24
+ "@tsrx/vue": "0.1.51"
24
25
  },
25
26
  "peerDependencies": {
26
27
  "vite": "*",
@@ -30,8 +31,7 @@
30
31
  "typescript": "^5.9.3",
31
32
  "vite": "^8.1.5",
32
33
  "vue": "3.6.0-beta.12",
33
- "vue-jsx-vapor": "^3.2.14",
34
- "@tsrx/core": "0.1.49"
34
+ "vue-jsx-vapor": "^3.2.14"
35
35
  },
36
36
  "files": [
37
37
  "src",
package/src/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  /** @import { Plugin } from 'vite' */
2
+ /** @import { DepScanLoadPlugin } from '@tsrx/core/types/vite/dep-scan' */
2
3
 
3
4
  import { readFile } from 'node:fs/promises';
4
5
  import { existsSync } from 'node:fs';
5
6
  import { isAbsolute, resolve as pathResolve } from 'node:path';
6
7
  import { compile } from '@tsrx/vue';
8
+ import { createDepScanLoadPlugin } from '@tsrx/core/vite/dep-scan';
7
9
  import vueJsxVaporModule from 'vue-jsx-vapor/vite';
8
10
  import { createVaporInteropPlugin } from './interop.js';
9
11
 
@@ -123,6 +125,14 @@ function create_tsrx_vue_plugin(options) {
123
125
  },
124
126
  optimizeDeps: {
125
127
  rolldownOptions: {
128
+ // The scan runs its own jsx transform over the tsx the
129
+ // dep-scan plugin hands back, and it defaults to react's
130
+ // automatic runtime — which no Vue project has installed, so
131
+ // the scan would fail on an unresolvable
132
+ // `react/jsx-dev-runtime`. Vue's own jsx handling belongs to
133
+ // `vue-jsx-vapor` downstream; the scan only needs the
134
+ // imports, so leave the jsx alone.
135
+ transform: { jsx: 'preserve' },
126
136
  plugins: [create_tsrx_vue_scan_plugin(isVirtual, toRealPath)],
127
137
  },
128
138
  },
@@ -214,26 +224,15 @@ function create_tsrx_vue_plugin(options) {
214
224
  *
215
225
  * @param {(id: string) => boolean} isVirtual
216
226
  * @param {(id: string) => string} toRealPath
227
+ * @returns {DepScanLoadPlugin}
217
228
  */
218
229
  function create_tsrx_vue_scan_plugin(isVirtual, toRealPath) {
219
- return {
230
+ return createDepScanLoadPlugin({
220
231
  name: '@tsrx/vite-plugin-vue:dep-scan',
221
- /**
222
- * @param {string} id
223
- */
224
- async load(id) {
225
- if (!isVirtual(id)) return null;
226
-
227
- const realPath = toRealPath(id.split('?')[0]);
228
- const source = await readFile(realPath, 'utf-8');
229
- const { code } = compile(source, realPath);
230
-
231
- return {
232
- code,
233
- moduleType: 'tsx',
234
- };
235
- },
236
- };
232
+ isVirtual,
233
+ toRealPath,
234
+ compile,
235
+ });
237
236
  }
238
237
 
239
238
  export default tsrxVue;