@vureact/compiler-core 1.8.1 → 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/lib/cli.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * @vureact/compiler-core v1.8.1
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-QXYYGKFW.esm.js";
16
+ } from "./chunk-S6IFUYGO.esm.js";
17
17
 
18
18
  // src/cli/index.ts
19
19
  import { cac } from "cac";
@@ -81,7 +81,6 @@ function setupWatcher(compiler, config) {
81
81
  ignored: cmpHelper.getExcludes(),
82
82
  persistent: true,
83
83
  ignoreInitial: true
84
- // 初始扫描已由 compiler.execute 完成
85
84
  });
86
85
  watcher.on("all", async (event, filePath) => {
87
86
  switch (event) {
@@ -105,36 +104,38 @@ function setupWatcher(compiler, config) {
105
104
  };
106
105
  const onRecompile = async (event, filePath) => {
107
106
  const ext = path2.extname(filePath);
107
+ const relativePath = normalizePath(cmpHelper.relativePath(filePath));
108
108
  if (ext in processors) {
109
109
  spinner.start("Recompiling...");
110
110
  const startTime = performance.now();
111
111
  const fn = processors[ext];
112
112
  const unit = await fn(filePath);
113
113
  cmpHelper.printCoreLogs();
114
- cmpHelper.printCompileInfo(filePath, calcElapsedTime(startTime));
115
114
  if (unit) {
115
+ cmpHelper.print(
116
+ kleur2.green("compiled"),
117
+ kleur2.dim(relativePath),
118
+ kleur2.gray(`(${calcElapsedTime(startTime)})`)
119
+ );
116
120
  await config.onChange?.(event, unit);
121
+ } else {
122
+ cmpHelper.print(kleur2.gray("cached"), kleur2.dim(relativePath));
117
123
  }
118
124
  } else {
119
125
  spinner.start("Updating assets...");
120
126
  await compiler.processAsset(filePath);
121
- cmpHelper.print(
122
- kleur2.blue("Copied Asset"),
123
- kleur2.dim(normalizePath(cmpHelper.relativePath(filePath)))
124
- );
127
+ cmpHelper.print(kleur2.blue("Copied Asset"), kleur2.dim(relativePath));
125
128
  }
126
129
  spinner.stop();
127
130
  };
128
131
  const onRemoveFile = async (type, filePath) => {
129
132
  const ext = path2.extname(filePath);
133
+ const relativePath = normalizePath(cmpHelper.relativePath(filePath));
130
134
  const scriptExtRegex = /\.(js|ts)$/i;
131
135
  const styleExtRegex = /\.(css|less|sass|scss)$/i;
132
- const removeFile = async (type2) => {
133
- await compiler.removeOutputPath(filePath, type2);
134
- cmpHelper.print(
135
- kleur2.yellow("Removed"),
136
- kleur2.dim(normalizePath(cmpHelper.relativePath(filePath)))
137
- );
136
+ const removeFile = async (cacheKey) => {
137
+ await compiler.removeOutputPath(filePath, cacheKey);
138
+ cmpHelper.print(kleur2.yellow("Removed"), kleur2.dim(relativePath));
138
139
  };
139
140
  if (type === "unlink") {
140
141
  if (ext === ".vue") {
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.1
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 _chunkSGP2JC7Fjs = require('./chunk-SGP2JC7F.js');
16
+ var _chunkEH3325ZPjs = require('./chunk-EH3325ZP.js');
17
17
 
18
18
  // src/cli/index.ts
19
19
  var _cac = require('cac');
@@ -76,12 +76,11 @@ 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, _chunkSGP2JC7Fjs.Helper)(config);
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,
83
83
  ignoreInitial: true
84
- // 初始扫描已由 compiler.execute 完成
85
84
  });
86
85
  watcher.on("all", async (event, filePath) => {
87
86
  switch (event) {
@@ -105,36 +104,38 @@ function setupWatcher(compiler, config) {
105
104
  };
106
105
  const onRecompile = async (event, filePath) => {
107
106
  const ext = _path2.default.extname(filePath);
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();
111
111
  const fn = processors[ext];
112
112
  const unit = await fn(filePath);
113
113
  cmpHelper.printCoreLogs();
114
- cmpHelper.printCompileInfo(filePath, _chunkSGP2JC7Fjs.calcElapsedTime.call(void 0, startTime));
115
114
  if (unit) {
115
+ cmpHelper.print(
116
+ _kleur2.default.green("compiled"),
117
+ _kleur2.default.dim(relativePath),
118
+ _kleur2.default.gray(`(${_chunkEH3325ZPjs.calcElapsedTime.call(void 0, startTime)})`)
119
+ );
116
120
  await _optionalChain([config, 'access', _5 => _5.onChange, 'optionalCall', _6 => _6(event, unit)]);
121
+ } else {
122
+ cmpHelper.print(_kleur2.default.gray("cached"), _kleur2.default.dim(relativePath));
117
123
  }
118
124
  } else {
119
125
  spinner.start("Updating assets...");
120
126
  await compiler.processAsset(filePath);
121
- cmpHelper.print(
122
- _kleur2.default.blue("Copied Asset"),
123
- _kleur2.default.dim(_chunkSGP2JC7Fjs.normalizePath.call(void 0, cmpHelper.relativePath(filePath)))
124
- );
127
+ cmpHelper.print(_kleur2.default.blue("Copied Asset"), _kleur2.default.dim(relativePath));
125
128
  }
126
129
  spinner.stop();
127
130
  };
128
131
  const onRemoveFile = async (type, filePath) => {
129
132
  const ext = _path2.default.extname(filePath);
133
+ const relativePath = _chunkEH3325ZPjs.normalizePath.call(void 0, cmpHelper.relativePath(filePath));
130
134
  const scriptExtRegex = /\.(js|ts)$/i;
131
135
  const styleExtRegex = /\.(css|less|sass|scss)$/i;
132
- const removeFile = async (type2) => {
133
- await compiler.removeOutputPath(filePath, type2);
134
- cmpHelper.print(
135
- _kleur2.default.yellow("Removed"),
136
- _kleur2.default.dim(_chunkSGP2JC7Fjs.normalizePath.call(void 0, cmpHelper.relativePath(filePath)))
137
- );
136
+ const removeFile = async (cacheKey) => {
137
+ await compiler.removeOutputPath(filePath, cacheKey);
138
+ cmpHelper.print(_kleur2.default.yellow("Removed"), _kleur2.default.dim(relativePath));
138
139
  };
139
140
  if (type === "unlink") {
140
141
  if (ext === ".vue") {
@@ -166,7 +167,7 @@ async function resolveAction(root, options) {
166
167
  const projectRoot = root ? _path2.default.resolve(process.cwd(), root) : process.cwd();
167
168
  const userConfig = await loadUserConfig(projectRoot);
168
169
  const finalConfig = mergeConfig(projectRoot, options, userConfig);
169
- const compiler = new (0, _chunkSGP2JC7Fjs.VuReact)(finalConfig);
170
+ const compiler = new (0, _chunkEH3325ZPjs.VuReact)(finalConfig);
170
171
  await compiler.execute();
171
172
  if (finalConfig.watch) {
172
173
  setupWatcher(compiler, finalConfig);
@@ -189,7 +190,7 @@ function resolveOptions(command) {
189
190
 
190
191
 
191
192
  var _updatenotifier = require('update-notifier'); var _updatenotifier2 = _interopRequireDefault(_updatenotifier);
192
- var __dirname = _chunkSGP2JC7Fjs.getDirname.call(void 0, import.meta.url);
193
+ var __dirname = _chunkEH3325ZPjs.getDirname.call(void 0, import.meta.url);
193
194
  function checkForUpdates() {
194
195
  try {
195
196
  const possiblePaths = [
@@ -230,7 +231,7 @@ function checkForUpdates() {
230
231
  }
231
232
 
232
233
  // src/cli/index.ts
233
- var [programName] = Object.keys(_chunkSGP2JC7Fjs.bin);
234
+ var [programName] = Object.keys(_chunkEH3325ZPjs.bin);
234
235
  var cli = _cac.cac.call(void 0, programName);
235
236
  checkForUpdates();
236
237
  var buildCommand = cli.command("build [root]", "Compile Vue3 to React (one-time)");
@@ -241,4 +242,4 @@ var watchCommand = cli.command("watch [root]", "Compile Vue3 to React and watch
241
242
  resolveOptions(watchCommand).action((root, options) => {
242
243
  resolveAction(root, { ...options, watch: true });
243
244
  });
244
- cli.help().version(_chunkSGP2JC7Fjs.version).parse();
245
+ cli.help().version(_chunkEH3325ZPjs.version).parse();
@@ -645,7 +645,6 @@ declare class Helper {
645
645
  * 打印 core 模块执行过程中收集的日志
646
646
  */
647
647
  printCoreLogs(): void;
648
- printCompileInfo(file: string, duration: string): void;
649
648
  print(...message: any[]): void;
650
649
  /**
651
650
  * 读取 package.json 文件内容,并处理成对象返回
@@ -645,7 +645,6 @@ declare class Helper {
645
645
  * 打印 core 模块执行过程中收集的日志
646
646
  */
647
647
  printCoreLogs(): void;
648
- printCompileInfo(file: string, duration: string): void;
649
648
  print(...message: any[]): void;
650
649
  /**
651
650
  * 读取 package.json 文件内容,并处理成对象返回
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vureact/compiler-core v1.8.1
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-QXYYGKFW.esm.js";
21
+ } from "./chunk-S6IFUYGO.esm.js";
22
22
  export {
23
23
  BaseCompiler,
24
24
  CacheKey,
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});/**
2
- * @vureact/compiler-core v1.8.1
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 _chunkSGP2JC7Fjs = require('./chunk-SGP2JC7F.js');
21
+ var _chunkEH3325ZPjs = require('./chunk-EH3325ZP.js');
22
22
 
23
23
 
24
24
 
@@ -33,4 +33,4 @@ var _chunkSGP2JC7Fjs = require('./chunk-SGP2JC7F.js');
33
33
 
34
34
 
35
35
 
36
- exports.BaseCompiler = _chunkSGP2JC7Fjs.BaseCompiler; exports.CacheKey = _chunkSGP2JC7Fjs.CacheKey; exports.FileCompiler = _chunkSGP2JC7Fjs.FileCompiler; exports.Helper = _chunkSGP2JC7Fjs.Helper; exports.VuReact = _chunkSGP2JC7Fjs.VuReact; exports.defineConfig = _chunkSGP2JC7Fjs.defineConfig; exports.generate = _chunkSGP2JC7Fjs.generate; exports.generateComponent = _chunkSGP2JC7Fjs.generateComponent; exports.generateOnlyScript = _chunkSGP2JC7Fjs.generateOnlyScript; exports.parse = _chunkSGP2JC7Fjs.parse; exports.parseOnlyScript = _chunkSGP2JC7Fjs.parseOnlyScript; exports.parseSFC = _chunkSGP2JC7Fjs.parseSFC; exports.transform = _chunkSGP2JC7Fjs.transform;
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.1",
4
- "description": "🌀 Write in Vue 3, compile to React 18+ output.",
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",
@@ -63,7 +63,8 @@
63
63
  },
64
64
  "scripts": {
65
65
  "build": "tsup",
66
- "test": "tsx watch"
66
+ "test": "tsx watch",
67
+ "prepublishOnly": "npm run build"
67
68
  },
68
69
  "peerDependencies": {
69
70
  "prettier": "^3.0.0"
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
- [![Downloads](https://img.shields.io/npm/dt/@vureact/compiler-core?label=Downloads&style=flat-square)](https://www.npmjs.com/package/@vureact/compiler-core)
11
- [![Node](https://img.shields.io/badge/node-%3E%3D19.0.0-green?label=Node)](https://nodejs.org/)
12
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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)