@vureact/compiler-core 1.8.3 → 1.8.4
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 +64 -61
- package/README.zh-CN.md +193 -0
- package/lib/{chunk-R34TQK4X.js → chunk-EH3325ZP.js} +460 -397
- package/lib/{chunk-QPW3RUZH.esm.js → chunk-S6IFUYGO.esm.js} +411 -348
- package/lib/cli.esm.js +2 -2
- package/lib/cli.js +10 -10
- package/lib/compiler-core.esm.js +2 -2
- package/lib/compiler-core.js +3 -3
- package/package.json +3 -3
- package/README.en.md +0 -192
package/lib/cli.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @vureact/compiler-core v1.8.
|
|
3
|
+
* @vureact/compiler-core v1.8.4
|
|
4
4
|
* (c) 2025-present Ruihong Zhong (Ryan John)
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
getDirname,
|
|
14
14
|
normalizePath,
|
|
15
15
|
version
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-S6IFUYGO.esm.js";
|
|
17
17
|
|
|
18
18
|
// src/cli/index.ts
|
|
19
19
|
import { cac } from "cac";
|
package/lib/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
3
|
-
* @vureact/compiler-core v1.8.
|
|
3
|
+
* @vureact/compiler-core v1.8.4
|
|
4
4
|
* (c) 2025-present Ruihong Zhong (Ryan John)
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkEH3325ZPjs = require('./chunk-EH3325ZP.js');
|
|
17
17
|
|
|
18
18
|
// src/cli/index.ts
|
|
19
19
|
var _cac = require('cac');
|
|
@@ -76,7 +76,7 @@ var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);
|
|
|
76
76
|
|
|
77
77
|
function setupWatcher(compiler, config) {
|
|
78
78
|
const spinner = _ora2.default.call(void 0, );
|
|
79
|
-
const cmpHelper = new (0,
|
|
79
|
+
const cmpHelper = new (0, _chunkEH3325ZPjs.Helper)(config);
|
|
80
80
|
const watcher = _chokidar2.default.watch(cmpHelper.getInputPath(), {
|
|
81
81
|
ignored: cmpHelper.getExcludes(),
|
|
82
82
|
persistent: true,
|
|
@@ -104,7 +104,7 @@ function setupWatcher(compiler, config) {
|
|
|
104
104
|
};
|
|
105
105
|
const onRecompile = async (event, filePath) => {
|
|
106
106
|
const ext = _path2.default.extname(filePath);
|
|
107
|
-
const relativePath =
|
|
107
|
+
const relativePath = _chunkEH3325ZPjs.normalizePath.call(void 0, cmpHelper.relativePath(filePath));
|
|
108
108
|
if (ext in processors) {
|
|
109
109
|
spinner.start("Recompiling...");
|
|
110
110
|
const startTime = performance.now();
|
|
@@ -115,7 +115,7 @@ function setupWatcher(compiler, config) {
|
|
|
115
115
|
cmpHelper.print(
|
|
116
116
|
_kleur2.default.green("compiled"),
|
|
117
117
|
_kleur2.default.dim(relativePath),
|
|
118
|
-
_kleur2.default.gray(`(${
|
|
118
|
+
_kleur2.default.gray(`(${_chunkEH3325ZPjs.calcElapsedTime.call(void 0, startTime)})`)
|
|
119
119
|
);
|
|
120
120
|
await _optionalChain([config, 'access', _5 => _5.onChange, 'optionalCall', _6 => _6(event, unit)]);
|
|
121
121
|
} else {
|
|
@@ -130,7 +130,7 @@ function setupWatcher(compiler, config) {
|
|
|
130
130
|
};
|
|
131
131
|
const onRemoveFile = async (type, filePath) => {
|
|
132
132
|
const ext = _path2.default.extname(filePath);
|
|
133
|
-
const relativePath =
|
|
133
|
+
const relativePath = _chunkEH3325ZPjs.normalizePath.call(void 0, cmpHelper.relativePath(filePath));
|
|
134
134
|
const scriptExtRegex = /\.(js|ts)$/i;
|
|
135
135
|
const styleExtRegex = /\.(css|less|sass|scss)$/i;
|
|
136
136
|
const removeFile = async (cacheKey) => {
|
|
@@ -167,7 +167,7 @@ async function resolveAction(root, options) {
|
|
|
167
167
|
const projectRoot = root ? _path2.default.resolve(process.cwd(), root) : process.cwd();
|
|
168
168
|
const userConfig = await loadUserConfig(projectRoot);
|
|
169
169
|
const finalConfig = mergeConfig(projectRoot, options, userConfig);
|
|
170
|
-
const compiler = new (0,
|
|
170
|
+
const compiler = new (0, _chunkEH3325ZPjs.VuReact)(finalConfig);
|
|
171
171
|
await compiler.execute();
|
|
172
172
|
if (finalConfig.watch) {
|
|
173
173
|
setupWatcher(compiler, finalConfig);
|
|
@@ -190,7 +190,7 @@ function resolveOptions(command) {
|
|
|
190
190
|
|
|
191
191
|
|
|
192
192
|
var _updatenotifier = require('update-notifier'); var _updatenotifier2 = _interopRequireDefault(_updatenotifier);
|
|
193
|
-
var __dirname =
|
|
193
|
+
var __dirname = _chunkEH3325ZPjs.getDirname.call(void 0, import.meta.url);
|
|
194
194
|
function checkForUpdates() {
|
|
195
195
|
try {
|
|
196
196
|
const possiblePaths = [
|
|
@@ -231,7 +231,7 @@ function checkForUpdates() {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
// src/cli/index.ts
|
|
234
|
-
var [programName] = Object.keys(
|
|
234
|
+
var [programName] = Object.keys(_chunkEH3325ZPjs.bin);
|
|
235
235
|
var cli = _cac.cac.call(void 0, programName);
|
|
236
236
|
checkForUpdates();
|
|
237
237
|
var buildCommand = cli.command("build [root]", "Compile Vue3 to React (one-time)");
|
|
@@ -242,4 +242,4 @@ var watchCommand = cli.command("watch [root]", "Compile Vue3 to React and watch
|
|
|
242
242
|
resolveOptions(watchCommand).action((root, options) => {
|
|
243
243
|
resolveAction(root, { ...options, watch: true });
|
|
244
244
|
});
|
|
245
|
-
cli.help().version(
|
|
245
|
+
cli.help().version(_chunkEH3325ZPjs.version).parse();
|
package/lib/compiler-core.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vureact/compiler-core v1.8.
|
|
2
|
+
* @vureact/compiler-core v1.8.4
|
|
3
3
|
* (c) 2025-present Ruihong Zhong (Ryan John)
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
parseOnlyScript,
|
|
19
19
|
parseSFC,
|
|
20
20
|
transform
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-S6IFUYGO.esm.js";
|
|
22
22
|
export {
|
|
23
23
|
BaseCompiler,
|
|
24
24
|
CacheKey,
|
package/lib/compiler-core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});/**
|
|
2
|
-
* @vureact/compiler-core v1.8.
|
|
2
|
+
* @vureact/compiler-core v1.8.4
|
|
3
3
|
* (c) 2025-present Ruihong Zhong (Ryan John)
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkEH3325ZPjs = require('./chunk-EH3325ZP.js');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -33,4 +33,4 @@ var _chunkR34TQK4Xjs = require('./chunk-R34TQK4X.js');
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
exports.BaseCompiler =
|
|
36
|
+
exports.BaseCompiler = _chunkEH3325ZPjs.BaseCompiler; exports.CacheKey = _chunkEH3325ZPjs.CacheKey; exports.FileCompiler = _chunkEH3325ZPjs.FileCompiler; exports.Helper = _chunkEH3325ZPjs.Helper; exports.VuReact = _chunkEH3325ZPjs.VuReact; exports.defineConfig = _chunkEH3325ZPjs.defineConfig; exports.generate = _chunkEH3325ZPjs.generate; exports.generateComponent = _chunkEH3325ZPjs.generateComponent; exports.generateOnlyScript = _chunkEH3325ZPjs.generateOnlyScript; exports.parse = _chunkEH3325ZPjs.parse; exports.parseOnlyScript = _chunkEH3325ZPjs.parseOnlyScript; exports.parseSFC = _chunkEH3325ZPjs.parseSFC; exports.transform = _chunkEH3325ZPjs.transform;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vureact/compiler-core",
|
|
3
|
-
"version": "1.8.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.8.4",
|
|
4
|
+
"description": "Migrate Vue to React, or write React in Vue syntax.",
|
|
5
5
|
"author": "Ruihong Zhong (Ryan John)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -99,4 +99,4 @@
|
|
|
99
99
|
"engines": {
|
|
100
100
|
"node": ">=19.0.0"
|
|
101
101
|
}
|
|
102
|
-
}
|
|
102
|
+
}
|
package/README.en.md
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
# @vureact/compiler-core
|
|
2
|
-
|
|
3
|
-
**Write in Vue, generate maintainable React.**
|
|
4
|
-
|
|
5
|
-
`@vureact/compiler-core` is the **CLI and core compiler package** of VuReact.
|
|
6
|
-
It compiles Vue 3 SFC, script, and style files into **pure React 18+ code**, making it suitable for progressive migration and for teams that want to keep Vue authoring conventions while targeting a React app.
|
|
7
|
-
|
|
8
|
-
It is a **compile-time solution**, not a runtime bridge.
|
|
9
|
-
|
|
10
|
-
[](https://www.npmjs.com/package/@vureact/compiler-core)
|
|
11
|
-
[](https://nodejs.org/)
|
|
12
|
-
[](https://github.com/vureact-js/core/blob/master/LICENSE)
|
|
13
|
-
|
|
14
|
-
English | [简体中文](./README.md)
|
|
15
|
-
|
|
16
|
-
## Who this package is for
|
|
17
|
-
|
|
18
|
-
- Teams progressively migrating a Vue 3 codebase to React
|
|
19
|
-
- Developers who want Vue-style authoring with React output
|
|
20
|
-
- Projects that need a config-driven `build/watch` compilation workflow
|
|
21
|
-
|
|
22
|
-
## Usage
|
|
23
|
-
|
|
24
|
-
### 1. Install
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install -D @vureact/compiler-core
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
You can also use:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
pnpm add -D @vureact/compiler-core
|
|
34
|
-
yarn add -D @vureact/compiler-core
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### 2. Create a config file
|
|
38
|
-
|
|
39
|
-
Create `vureact.config.ts` in your project root:
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
import { defineConfig } from '@vureact/compiler-core';
|
|
43
|
-
|
|
44
|
-
export default defineConfig({
|
|
45
|
-
input: '', // input path: a single file or a directory
|
|
46
|
-
exclude: ['src/main.ts'], // exclude the Vue entry file
|
|
47
|
-
});
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
If you are fine with the default workspace and output directory, this is enough.
|
|
51
|
-
|
|
52
|
-
If you want to make the output settings explicit, you can write:
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
import { defineConfig } from '@vureact/compiler-core';
|
|
56
|
-
|
|
57
|
-
export default defineConfig({
|
|
58
|
-
input: './src',
|
|
59
|
-
exclude: ['src/main.ts'],
|
|
60
|
-
output: {
|
|
61
|
-
workspace: '.vureact',
|
|
62
|
-
outDir: 'react-app',
|
|
63
|
-
bootstrapVite: true,
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
If your project uses Vue Router, you will usually also add:
|
|
69
|
-
|
|
70
|
-
```ts
|
|
71
|
-
router: {
|
|
72
|
-
configFile: 'src/router/index.ts',
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### 3. Start with a single-file pilot
|
|
77
|
-
|
|
78
|
-
If you want to validate the transformation first, start with one SFC:
|
|
79
|
-
|
|
80
|
-
```ts
|
|
81
|
-
export default defineConfig({
|
|
82
|
-
input: './src/your-component.vue',
|
|
83
|
-
exclude: ['src/main.ts'],
|
|
84
|
-
});
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
This is useful when you want to:
|
|
88
|
-
|
|
89
|
-
- validate the compilation conventions first
|
|
90
|
-
- inspect the generated output first
|
|
91
|
-
- run a small pilot before scaling to the whole codebase
|
|
92
|
-
|
|
93
|
-
### 4. Expand to the whole project
|
|
94
|
-
|
|
95
|
-
Once the single-file pilot works, point `input` to a directory:
|
|
96
|
-
|
|
97
|
-
```ts
|
|
98
|
-
export default defineConfig({
|
|
99
|
-
input: './src',
|
|
100
|
-
exclude: ['src/main.ts'],
|
|
101
|
-
});
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
This will recursively process Vue, script, and style files under that directory.
|
|
105
|
-
|
|
106
|
-
> Note: VuReact primarily targets modern Vue 3 codebases built around `<script setup>`.
|
|
107
|
-
> If your project uses Vue Router, also see the [router adaptation guide](https://vureact.top/en/guide/router-adaptation.html).
|
|
108
|
-
|
|
109
|
-
### 5. Run the compiler
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# one-time build
|
|
113
|
-
npx vureact build
|
|
114
|
-
|
|
115
|
-
# watch mode
|
|
116
|
-
npx vureact watch
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
If you prefer scripts, add them to `package.json`:
|
|
120
|
-
|
|
121
|
-
```json
|
|
122
|
-
{
|
|
123
|
-
"scripts": {
|
|
124
|
-
"vr:build": "vureact build",
|
|
125
|
-
"vr:watch": "vureact watch"
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### 6. Check the output
|
|
131
|
-
|
|
132
|
-
By default, VuReact generates:
|
|
133
|
-
|
|
134
|
-
- `.vureact/cache` for compilation cache
|
|
135
|
-
- `.vureact/react-app` for the React app output
|
|
136
|
-
- `.tsx` / `.css` files that mirror your source structure
|
|
137
|
-
|
|
138
|
-
The project layout typically looks like:
|
|
139
|
-
|
|
140
|
-
```txt
|
|
141
|
-
vue-project/
|
|
142
|
-
├── .vureact/
|
|
143
|
-
│ ├── cache/
|
|
144
|
-
│ ├── react-app/
|
|
145
|
-
│ │ ├── src/
|
|
146
|
-
│ │ ├── package.json
|
|
147
|
-
│ │ ├── vite.config.ts
|
|
148
|
-
├── src/
|
|
149
|
-
├── package.json
|
|
150
|
-
└── vureact.config.ts
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
You can then run the generated app directly:
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
cd .vureact/react-app
|
|
157
|
-
npm install
|
|
158
|
-
npm run dev
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
If you want a deeper explanation of the two modes, continue with:
|
|
162
|
-
|
|
163
|
-
- [Watch Mode](https://vureact.top/en/guide/watch-mode.html)
|
|
164
|
-
- [Incremental Compilation](https://vureact.top/en/guide/incremental-compilation.html)
|
|
165
|
-
|
|
166
|
-
## What this package is not
|
|
167
|
-
|
|
168
|
-
- It is not a Vue-in-React / React-in-Vue runtime bridge
|
|
169
|
-
- It is not a zero-convention codemod for arbitrary Vue code
|
|
170
|
-
- It works best in projects that follow VuReact compilation conventions
|
|
171
|
-
|
|
172
|
-
## Related packages
|
|
173
|
-
|
|
174
|
-
- [@vureact/runtime-core](https://runtime.vureact.top/en/) - React-side Vue runtime adaptation APIs
|
|
175
|
-
- [@vureact/router](https://router.vureact.top/en/) - Vue Router to React Router adaptation
|
|
176
|
-
|
|
177
|
-
## Documentation
|
|
178
|
-
|
|
179
|
-
- [Quick Start](https://vureact.top/en/guide/quick-start.html)
|
|
180
|
-
- [Key Configuration](https://vureact.top/en/guide/key-configuration.html)
|
|
181
|
-
- [Watch Mode](https://vureact.top/en/guide/watch-mode.html)
|
|
182
|
-
- [Incremental Compilation](https://vureact.top/en/guide/incremental-compilation.html)
|
|
183
|
-
- [Progressive Migration Guide](https://vureact.top/en/guide/progressive-migration.html)
|
|
184
|
-
- [Config API](https://vureact.top/en/api/config.html)
|
|
185
|
-
- [FAQ](https://vureact.top/en/guide/faq.html)
|
|
186
|
-
|
|
187
|
-
## Repository and license
|
|
188
|
-
|
|
189
|
-
- GitHub: <https://github.com/vureact-js/core>
|
|
190
|
-
- Docs: <https://vureact.top/en>
|
|
191
|
-
|
|
192
|
-
MIT License © 2025 Ruihong Zhong (Ryan John)
|