@tsrx/bun-plugin-vue 0.0.14 → 0.0.15

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": "Bun plugin for @tsrx/vue (.tsrx modules)",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.0.14",
6
+ "version": "0.0.15",
7
7
  "type": "module",
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -20,18 +20,18 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@tsrx/vue": "0.1.10"
23
+ "@tsrx/vue": "0.1.11"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "bun": "^1.0.0",
27
27
  "vue": ">=3.5",
28
- "vue-jsx-vapor": ">=3.2.12"
28
+ "vue-jsx-vapor": ">=3.2.14"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/bun": "^1.3.9",
32
32
  "typescript": "^5.9.3",
33
- "vue": "3.6.0-beta.10",
34
- "vue-jsx-vapor": "^3.2.12"
33
+ "vue": "3.6.0-beta.12",
34
+ "vue-jsx-vapor": "^3.2.14"
35
35
  },
36
36
  "files": [
37
37
  "src",
package/src/index.js CHANGED
@@ -3,13 +3,16 @@
3
3
  import { readFile } from 'node:fs/promises';
4
4
  import { createRequire } from 'node:module';
5
5
  import { compile } from '@tsrx/vue';
6
+ import { addVaporInteropToCreateVaporApp } from '@tsrx/vue/interop';
6
7
 
7
8
  const require = createRequire(import.meta.url);
8
9
  const { transformVueJsxVapor } = require('vue-jsx-vapor/api');
9
10
 
10
11
  const DEFAULT_INCLUDE = /\.tsrx$/;
12
+ const SOURCE_EXTENSION_PATTERN = /\.[cm]?[jt]sx?$/;
11
13
  const CSS_QUERY = '?tsrx-css&lang.css';
12
14
  const CSS_QUERY_PATTERN = /\?tsrx-css&lang\.css$/;
15
+ const NODE_MODULES_PATTERN = /[/\\]node_modules[/\\]/;
13
16
  const DEFAULT_VAPOR_OPTIONS = {
14
17
  macros: true,
15
18
  compiler: {
@@ -23,7 +26,6 @@ const DEFAULT_VAPOR_OPTIONS = {
23
26
  * exclude?: RegExp | RegExp[],
24
27
  * emitCss?: boolean,
25
28
  * vapor?: {
26
- * interop?: boolean,
27
29
  * macros?: boolean | object,
28
30
  * compiler?: { runtimeModuleName?: string },
29
31
  * },
@@ -71,6 +73,17 @@ function to_css_id(file_path) {
71
73
  return file_path + CSS_QUERY;
72
74
  }
73
75
 
76
+ /**
77
+ * @param {string} file_path
78
+ * @returns {'js' | 'jsx' | 'ts' | 'tsx'}
79
+ */
80
+ function get_source_loader(file_path) {
81
+ if (/\.[cm]?tsx$/.test(file_path)) return 'tsx';
82
+ if (/\.[cm]?ts$/.test(file_path)) return 'ts';
83
+ if (/\.[cm]?jsx$/.test(file_path)) return 'jsx';
84
+ return 'js';
85
+ }
86
+
74
87
  /**
75
88
  * @param {Target | undefined} target
76
89
  * @returns {Transpiler | null}
@@ -89,12 +102,16 @@ function create_transpiler(target) {
89
102
  * @param {TsrxVueBunPluginOptions['vapor']} options
90
103
  */
91
104
  function resolve_vapor_options(options) {
105
+ const { interop: _interop, ...rest } =
106
+ /** @type {{ interop?: boolean, macros?: boolean | object, compiler?: { runtimeModuleName?: string } }} */ (
107
+ options ?? {}
108
+ );
92
109
  return {
93
110
  ...DEFAULT_VAPOR_OPTIONS,
94
- ...options,
111
+ ...rest,
95
112
  compiler: {
96
113
  ...DEFAULT_VAPOR_OPTIONS.compiler,
97
- ...options?.compiler,
114
+ ...rest.compiler,
98
115
  },
99
116
  };
100
117
  }
@@ -172,6 +189,19 @@ export function tsrxVue(options = {}) {
172
189
  };
173
190
  },
174
191
  );
192
+
193
+ build.onLoad({ filter: SOURCE_EXTENSION_PATTERN, namespace: 'file' }, async (args) => {
194
+ if (NODE_MODULES_PATTERN.test(args.path)) return undefined;
195
+
196
+ const source = await readFile(args.path, 'utf-8');
197
+ const transformed = addVaporInteropToCreateVaporApp(source);
198
+ if (transformed === source) return undefined;
199
+
200
+ return {
201
+ contents: transformed,
202
+ loader: get_source_loader(args.path),
203
+ };
204
+ });
175
205
  },
176
206
  };
177
207
  }
package/types/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type { BunPlugin } from 'bun';
2
2
 
3
3
  export interface TsrxVueBunPluginVaporOptions {
4
- interop?: boolean;
5
4
  macros?: boolean | object;
6
5
  compiler?: {
7
6
  runtimeModuleName?: string;