@vitarx/plugin-vite 0.0.1-beta.1 → 0.0.1-beta.2

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.
@@ -17,7 +17,6 @@ export declare const VITARX_APIS: {
17
17
  * 这些 API 用于创建视图,在 HMR 时需要识别
18
18
  */
19
19
  export declare const UI_API_NAMES: readonly ["createView", "branch", "dynamic", "access", "withDirectives"];
20
- export type UIApiName = (typeof UI_API_NAMES)[number];
21
20
  /**
22
21
  * Ref 相关 API 名称
23
22
  * 用于识别 ref 变量
package/dist/index.js CHANGED
@@ -1,7 +1,15 @@
1
1
  import path from 'node:path';
2
- import { transformWithOxc } from 'vite';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { defineConfig, version } from 'vite';
3
4
  import { transform } from './transform.js';
4
- const __dirname = path.dirname(new URL(import.meta.url).pathname);
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+ let viteTransform;
7
+ if (version.startsWith('8')) {
8
+ viteTransform = (await import('vite')).transformWithOxc;
9
+ }
10
+ else {
11
+ viteTransform = (await import('vite')).transformWithEsbuild;
12
+ }
5
13
  /**
6
14
  * vite-plugin-vitarx
7
15
  *
@@ -25,10 +33,14 @@ export default function vitarx(_options) {
25
33
  isDEV = env.command === 'serve' && !env.isPreview;
26
34
  const configSSR = !!config.build?.ssr;
27
35
  isSSR = env.isSsrBuild === true || configSSR;
28
- return {
36
+ return defineConfig({
29
37
  oxc: {
30
38
  jsx: 'preserve',
31
- exclude: /\.[jt]sx$/,
39
+ exclude: /\.[jt]sx$/
40
+ },
41
+ esbuild: {
42
+ jsx: 'preserve',
43
+ exclude: /\.[jt]sx$/
32
44
  },
33
45
  define: {
34
46
  __VITARX_DEV__: JSON.stringify(isDEV),
@@ -39,7 +51,7 @@ export default function vitarx(_options) {
39
51
  '@vitarx/vite-plugin/hmr-client': path.join(__dirname, 'hmr-client/index.js')
40
52
  }
41
53
  }
42
- };
54
+ });
43
55
  },
44
56
  configResolved(config) {
45
57
  viteConfig = config;
@@ -53,12 +65,9 @@ export default function vitarx(_options) {
53
65
  },
54
66
  async transform(code, id) {
55
67
  const result = await transform(code, id, compileOptions);
56
- if (result) {
57
- return await transformWithOxc(result.code, id, {
58
- jsx: 'preserve'
59
- }, this.getCombinedSourcemap(), viteConfig);
60
- }
61
- return null;
68
+ if (!result)
69
+ return null;
70
+ return await viteTransform(result.code, id, undefined, this.getCombinedSourcemap(), viteConfig);
62
71
  }
63
72
  };
64
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitarx/plugin-vite",
3
- "version": "0.0.1-beta.1",
3
+ "version": "0.0.1-beta.2",
4
4
  "description": "The official plugin for Vitarx support in Vite.",
5
5
  "author": "ZhuChongLin <8210856@qq.com>",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "peerDependencies": {
32
32
  "vitarx": "^4.0.0-0",
33
- "vite": "^8.0.0-0"
33
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0"
34
34
  },
35
35
  "dependencies": {
36
36
  "@babel/generator": "^7.29.1",
@@ -50,6 +50,7 @@
50
50
  "@types/node": "^25.3.2",
51
51
  "husky": "^9.1.7",
52
52
  "node": "^25.7.0",
53
+ "prettier": "^3.8.1",
53
54
  "rimraf": "^6.1.3",
54
55
  "vitarx": "^4.0.0-beta.0",
55
56
  "vite": "^8.0.0-beta.16",