@vureact/compiler-core 1.8.3 → 1.8.5

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/README.md CHANGED
@@ -1,54 +1,58 @@
1
1
  # @vureact/compiler-core
2
2
 
3
- **写 Vue,生成可维护的 React。**
3
+ `@vureact/compiler-core` is a complete solution for Vue-to-React migration and hybrid development. **CLI and core compiler package** of VuReact.
4
4
 
5
- `@vureact/compiler-core` VuReact **CLI 与核心编译包**。
6
- 它用于将 Vue 3 的 SFC、脚本和样式文件编译为 **纯 React 18+ 代码**,适合渐进式迁移,以及“保持 Vue 心智模型、输出 React 工程”的场景。
7
-
8
- 它是 **编译时方案**,不是运行时桥接。
5
+ It is used to fully convert Vue 3 SFCs, Scripts, and Styles into pure React (non-runtime bridge) code and output engineered artifacts, covering all core features of `<script setup>`, and supporting progressive migration and hybrid development.
9
6
 
7
+ [![Stars](https://img.shields.io/github/stars/vureact-js/core?style=flat-square&color=magenta)](https://github.com/vureact-js/core/stargazers)
10
8
  [![Downloads](https://img.shields.io/npm/dt/@vureact/compiler-core?label=Downloads&style=flat-square)](https://www.npmjs.com/package/@vureact/compiler-core)
11
9
  [![Node](https://img.shields.io/badge/node-%3E%3D19.0.0-green?label=Node)](https://nodejs.org/)
12
10
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/vureact-js/core/blob/master/LICENSE)
13
11
 
14
- 简体中文 | [English](./README.en.md)
12
+ English | [简体中文](./README.zh-CN.md)
13
+
14
+ ## Who this package is for
15
15
 
16
- ## 这个包适合谁
16
+ - Projects need to migrate incrementally from Vue 3 to React, but do not want to rewrite from scratch, preferring to find existing solutions first.
17
+ - Some developers use Vue as their primary technology stack, are accustomed to its mental model, and consider React's overhead to be heavier than Vue's.
18
+ - Backend developers do not want to learn both frameworks; Vue is quick to pick up and intuitive, and they are reluctant to engage with React.
19
+ - The converted React code must completely detach from the Vue runtime to avoid performance and bundle size issues caused by a dual-framework runtime.
17
20
 
18
- - 正在把 Vue 3 项目渐进迁移到 React
19
- - 想继续按 Vue 约定写代码,但产出 React 工程
20
- - 需要基于配置文件执行 `build/watch` 编译流程
21
+ ## Usage
21
22
 
22
- ## 使用方式
23
+ > 💡 **Official guide from scratch:** [VuReact Quick Start](https://vureact.top/en/guide/quick-start.html)
24
+ >
25
+ > 💡 **Hybrid migration walkthrough:** [Customer Support Hub (Vue + React)](https://vureact.top/en/guide/customer-support-hub)
23
26
 
24
- ### 1. 安装
27
+ ### 1. Install
25
28
 
26
29
  ```bash
27
30
  npm install -D @vureact/compiler-core
28
31
  ```
29
32
 
30
- 也可以使用:
33
+ You can also use:
31
34
 
32
35
  ```bash
33
36
  pnpm add -D @vureact/compiler-core
34
37
  yarn add -D @vureact/compiler-core
35
38
  ```
36
39
 
37
- ### 2. 创建配置文件
40
+ ### 2. Create a config file
38
41
 
39
- 在项目根目录新建 `vureact.config.ts`:
42
+ Create `vureact.config.ts` in your project root:
40
43
 
41
44
  ```ts
42
45
  import { defineConfig } from '@vureact/compiler-core';
43
46
 
44
47
  export default defineConfig({
45
- exclude: ['src/main.ts'], // 排除 Vue 入口文件
48
+ input: '', // input path: a single file or a directory
49
+ exclude: ['src/main.ts'], // exclude the Vue entry file
46
50
  });
47
51
  ```
48
52
 
49
- 如果你只想用默认工作区和输出目录,这样就够了。
53
+ If you are fine with the default workspace and output directory, this is enough.
50
54
 
51
- 如果需要显式指定输出配置,可以写成:
55
+ If you want to make the output settings explicit, you can write:
52
56
 
53
57
  ```ts
54
58
  import { defineConfig } from '@vureact/compiler-core';
@@ -64,7 +68,7 @@ export default defineConfig({
64
68
  });
65
69
  ```
66
70
 
67
- 如果项目使用 Vue Router,通常还会补上:
71
+ If your project uses Vue Router, you will usually also add:
68
72
 
69
73
  ```ts
70
74
  router: {
@@ -72,9 +76,9 @@ router: {
72
76
  }
73
77
  ```
74
78
 
75
- ### 3. 先从单文件试点
79
+ ### 3. Start with a single-file pilot
76
80
 
77
- 如果你想先验证一个组件能否稳定转换,可以先只编译单个 SFC
81
+ If you want to validate the transformation first, start with one SFC:
78
82
 
79
83
  ```ts
80
84
  export default defineConfig({
@@ -83,15 +87,15 @@ export default defineConfig({
83
87
  });
84
88
  ```
85
89
 
86
- 这适合:
90
+ This is useful when you want to:
87
91
 
88
- - 先验证编译约定
89
- - 先看生成结果
90
- - 先小范围试点,而不是直接全仓推进
92
+ - validate the compilation conventions first
93
+ - inspect the generated output first
94
+ - run a small pilot before scaling to the whole codebase
91
95
 
92
- ### 4. 再扩展到整个项目
96
+ ### 4. Expand to the whole project
93
97
 
94
- 当单文件试点通过后,再把 `input` 指向目录:
98
+ Once the single-file pilot works, point `input` to a directory:
95
99
 
96
100
  ```ts
97
101
  export default defineConfig({
@@ -100,22 +104,22 @@ export default defineConfig({
100
104
  });
101
105
  ```
102
106
 
103
- 这会递归处理目录下的 Vue / Script / Style 文件。
107
+ This will recursively process Vue, script, and style files under that directory.
104
108
 
105
- > 注意:VuReact 优先支持基于 `<script setup>` 的现代 Vue 3 写法。
106
- > 如果你的项目使用 Vue Router,请同时查看 [路由适配指南](https://vureact.top/guide/router-adaptation.html)
109
+ > Note: VuReact primarily targets modern Vue 3 codebases built around `<script setup>`.
110
+ > If your project uses Vue Router, also see the [router adaptation guide](https://vureact.top/en/guide/router-adaptation.html).
107
111
 
108
- ### 5. 执行编译
112
+ ### 5. Run the compiler
109
113
 
110
114
  ```bash
111
- # 一次性编译
115
+ # one-time build
112
116
  npx vureact build
113
117
 
114
- # 监听模式
118
+ # watch mode
115
119
  npx vureact watch
116
120
  ```
117
121
 
118
- 如果你更喜欢脚本命令,也可以写进 `package.json`:
122
+ If you prefer scripts, add them to `package.json`:
119
123
 
120
124
  ```json
121
125
  {
@@ -126,15 +130,15 @@ npx vureact watch
126
130
  }
127
131
  ```
128
132
 
129
- ### 6. 查看输出结果
133
+ ### 6. Check the output
130
134
 
131
- 默认情况下,VuReact 会生成:
135
+ By default, VuReact generates:
132
136
 
133
- - `.vureact/cache`:编译缓存
134
- - `.vureact/react-app`:React 工程产物
135
- - 与源目录结构对应的 `.tsx` / `.css` 文件
137
+ - `.vureact/cache` for compilation cache
138
+ - `.vureact/react-app` for the React app output
139
+ - `.tsx` / `.css` files that mirror your source structure
136
140
 
137
- 目录大致如下:
141
+ The project layout typically looks like:
138
142
 
139
143
  ```txt
140
144
  vue-project/
@@ -149,7 +153,7 @@ vue-project/
149
153
  └── vureact.config.ts
150
154
  ```
151
155
 
152
- 进入产物目录后可直接运行:
156
+ You can then run the generated app directly:
153
157
 
154
158
  ```bash
155
159
  cd .vureact/react-app
@@ -157,35 +161,35 @@ npm install
157
161
  npm run dev
158
162
  ```
159
163
 
160
- 如果你想更系统地了解 build/watch 的差异,可以继续阅读:
164
+ If you want a deeper explanation of the two modes, continue with:
161
165
 
162
- - [监听模式](https://vureact.top/guide/watch-mode.html)
163
- - [增量编译](https://vureact.top/guide/incremental-compilation.html)
166
+ - [Watch Mode](https://vureact.top/en/guide/watch-mode.html)
167
+ - [Incremental Compilation](https://vureact.top/en/guide/incremental-compilation.html)
164
168
 
165
- ## 这个包不负责什么
169
+ ## What this package is not
166
170
 
167
- - 它不是 Vue in React / React in Vue 的运行时桥接层
168
- - 它不是对任意 Vue 代码都“零约定”生效的通用 codemod
169
- - 它更适合遵循 VuReact 编译约定的工程化项目
171
+ - It is not a Vue-in-React / React-in-Vue runtime bridge
172
+ - It is not a zero-convention codemod for arbitrary Vue code
173
+ - It works best in projects that follow VuReact compilation conventions
170
174
 
171
- ## 相关包
175
+ ## Related packages
172
176
 
173
- - [@vureact/runtime-core](https://runtime.vureact.top/)React Vue 运行时适配 API
174
- - [@vureact/router](https://router.vureact.top/)Vue Router React Router 的适配方案
177
+ - [@vureact/runtime-core](https://runtime.vureact.top/en/) - React-side Vue runtime adaptation APIs
178
+ - [@vureact/router](https://router.vureact.top/en/) - Vue Router to React Router adaptation
175
179
 
176
- ## 文档入口
180
+ ## Documentation
177
181
 
178
- - [快速开始](https://vureact.top/guide/quick-start.html)
179
- - [关键配置](https://vureact.top/guide/key-configuration.html)
180
- - [监听模式](https://vureact.top/guide/watch-mode.html)
181
- - [增量编译](https://vureact.top/guide/incremental-compilation.html)
182
- - [渐进式迁移指南](https://vureact.top/guide/progressive-migration.html)
183
- - [配置 API](https://vureact.top/api/config.html)
184
- - [FAQ](https://vureact.top/guide/faq.html)
182
+ - [Quick Start](https://vureact.top/en/guide/quick-start.html)
183
+ - [Key Configuration](https://vureact.top/en/guide/key-configuration.html)
184
+ - [Watch Mode](https://vureact.top/en/guide/watch-mode.html)
185
+ - [Incremental Compilation](https://vureact.top/en/guide/incremental-compilation.html)
186
+ - [Progressive Migration Guide](https://vureact.top/en/guide/progressive-migration.html)
187
+ - [Config API](https://vureact.top/en/api/config.html)
188
+ - [FAQ](https://vureact.top/en/guide/faq.html)
185
189
 
186
- ## 仓库与许可证
190
+ ## Repository and license
187
191
 
188
192
  - GitHub: <https://github.com/vureact-js/core>
189
- - 文档: <https://vureact.top>
193
+ - Docs: <https://vureact.top/en>
190
194
 
191
195
  MIT License © 2025 Ruihong Zhong (Ryan John)
@@ -0,0 +1,193 @@
1
+ # @vureact/compiler-core
2
+
3
+ `@vureact/compiler-core` 是一套面向 Vue 迁移 React 和混合开发的完整解决方案。VuReact 的 **CLI 与核心编译包**。
4
+ 它用于将 Vue 3 SFCs・Scripts・Styles 完整转为纯 React(非运行时桥接)代码并输出工程化产物,覆盖 `<script setup>` 核心全特性,支持渐进式迁移和混合开发。
5
+
6
+ [![Stars](https://img.shields.io/github/stars/vureact-js/core?style=flat-square&color=magenta)](https://github.com/vureact-js/core/stargazers)
7
+ [![Downloads](https://img.shields.io/npm/dt/@vureact/compiler-core?label=Downloads&style=flat-square)](https://www.npmjs.com/package/@vureact/compiler-core)
8
+ [![Node](https://img.shields.io/badge/node-%3E%3D19.0.0-green?label=Node)](https://nodejs.org/)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/vureact-js/core/blob/master/LICENSE)
10
+
11
+ 简体中文 | [English](./README.md)
12
+
13
+ ## 这个包适合谁
14
+
15
+ - 项目需从 Vue 3 渐进式迁移到 React,但不想从头重写,优先寻找现有解决方案
16
+ - 部分开发者以 Vue 为主技术栈,习惯其心智模型,认为 React 的额外负担比 Vue 更重
17
+ - 后端开发者不想学习双框架,Vue 上手快、符合直觉,不愿接触 React
18
+ - 转换后的 React 需完全脱离 Vue 运行时,避免双框架运行时所带来的性能和体积问题
19
+
20
+ ## 使用方式
21
+
22
+ > 💡 **从零开始的官方指南:**[VuReact 快速入门](https://vureact.top/guide/quick-start.html)
23
+ >
24
+ > 💡 **混合项目迁移实践:**[客户支持协同后台(Vue + React)](https://vureact.top/guide/customer-support-hub)
25
+
26
+ ### 1. 安装
27
+
28
+ ```bash
29
+ npm install -D @vureact/compiler-core
30
+ ```
31
+
32
+ 也可以使用:
33
+
34
+ ```bash
35
+ pnpm add -D @vureact/compiler-core
36
+ yarn add -D @vureact/compiler-core
37
+ ```
38
+
39
+ ### 2. 创建配置文件
40
+
41
+ 在项目根目录新建 `vureact.config.ts`:
42
+
43
+ ```ts
44
+ import { defineConfig } from '@vureact/compiler-core';
45
+
46
+ export default defineConfig({
47
+ exclude: ['src/main.ts'], // 排除 Vue 入口文件
48
+ });
49
+ ```
50
+
51
+ 如果你只想用默认工作区和输出目录,这样就够了。
52
+
53
+ 如果需要显式指定输出配置,可以写成:
54
+
55
+ ```ts
56
+ import { defineConfig } from '@vureact/compiler-core';
57
+
58
+ export default defineConfig({
59
+ input: './src',
60
+ exclude: ['src/main.ts'],
61
+ output: {
62
+ workspace: '.vureact',
63
+ outDir: 'react-app',
64
+ bootstrapVite: true,
65
+ },
66
+ });
67
+ ```
68
+
69
+ 如果项目使用 Vue Router,通常还会补上:
70
+
71
+ ```ts
72
+ router: {
73
+ configFile: 'src/router/index.ts',
74
+ }
75
+ ```
76
+
77
+ ### 3. 先从单文件试点
78
+
79
+ 如果你想先验证一个组件能否稳定转换,可以先只编译单个 SFC:
80
+
81
+ ```ts
82
+ export default defineConfig({
83
+ input: './src/your-component.vue',
84
+ exclude: ['src/main.ts'],
85
+ });
86
+ ```
87
+
88
+ 这适合:
89
+
90
+ - 先验证编译约定
91
+ - 先看生成结果
92
+ - 先小范围试点,而不是直接全仓推进
93
+
94
+ ### 4. 再扩展到整个项目
95
+
96
+ 当单文件试点通过后,再把 `input` 指向目录:
97
+
98
+ ```ts
99
+ export default defineConfig({
100
+ input: './src',
101
+ exclude: ['src/main.ts'],
102
+ });
103
+ ```
104
+
105
+ 这会递归处理目录下的 Vue / Script / Style 文件。
106
+
107
+ > 注意:VuReact 优先支持基于 `<script setup>` 的现代 Vue 3 写法。
108
+ > 如果你的项目使用 Vue Router,请同时查看 [路由适配指南](https://vureact.top/guide/router-adaptation.html)。
109
+
110
+ ### 5. 执行编译
111
+
112
+ ```bash
113
+ # 一次性编译
114
+ npx vureact build
115
+
116
+ # 监听模式
117
+ npx vureact watch
118
+ ```
119
+
120
+ 如果你更喜欢脚本命令,也可以写进 `package.json`:
121
+
122
+ ```json
123
+ {
124
+ "scripts": {
125
+ "vr:build": "vureact build",
126
+ "vr:watch": "vureact watch"
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### 6. 查看输出结果
132
+
133
+ 默认情况下,VuReact 会生成:
134
+
135
+ - `.vureact/cache`:编译缓存
136
+ - `.vureact/react-app`:React 工程产物
137
+ - 与源目录结构对应的 `.tsx` / `.css` 文件
138
+
139
+ 目录大致如下:
140
+
141
+ ```txt
142
+ vue-project/
143
+ ├── .vureact/
144
+ │ ├── cache/
145
+ │ ├── react-app/
146
+ │ │ ├── src/
147
+ │ │ ├── package.json
148
+ │ │ ├── vite.config.ts
149
+ ├── src/
150
+ ├── package.json
151
+ └── vureact.config.ts
152
+ ```
153
+
154
+ 进入产物目录后可直接运行:
155
+
156
+ ```bash
157
+ cd .vureact/react-app
158
+ npm install
159
+ npm run dev
160
+ ```
161
+
162
+ 如果你想更系统地了解 build/watch 的差异,可以继续阅读:
163
+
164
+ - [监听模式](https://vureact.top/guide/watch-mode.html)
165
+ - [增量编译](https://vureact.top/guide/incremental-compilation.html)
166
+
167
+ ## 这个包不负责什么
168
+
169
+ - 它不是 Vue in React / React in Vue 的运行时桥接层
170
+ - 它不是对任意 Vue 代码都“零约定”生效的通用 codemod
171
+ - 它更适合遵循 VuReact 编译约定的工程化项目
172
+
173
+ ## 相关包
174
+
175
+ - [@vureact/runtime-core](https://runtime.vureact.top/):React 版 Vue 运行时适配 API
176
+ - [@vureact/router](https://router.vureact.top/):Vue Router 到 React Router 的适配方案
177
+
178
+ ## 文档入口
179
+
180
+ - [快速开始](https://vureact.top/guide/quick-start.html)
181
+ - [关键配置](https://vureact.top/guide/key-configuration.html)
182
+ - [监听模式](https://vureact.top/guide/watch-mode.html)
183
+ - [增量编译](https://vureact.top/guide/incremental-compilation.html)
184
+ - [渐进式迁移指南](https://vureact.top/guide/progressive-migration.html)
185
+ - [配置 API](https://vureact.top/api/config.html)
186
+ - [FAQ](https://vureact.top/guide/faq.html)
187
+
188
+ ## 仓库与许可证
189
+
190
+ - GitHub: <https://github.com/vureact-js/core>
191
+ - 文档: <https://vureact.top>
192
+
193
+ MIT License © 2025 Ruihong Zhong (Ryan John)