@vureact/compiler-core 1.8.1 → 1.8.3

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vureact/compiler-core v1.8.1
2
+ * @vureact/compiler-core v1.8.3
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -1314,9 +1314,6 @@ function resolveComponentName(ctx) {
1314
1314
  if (!name) {
1315
1315
  const defaultName = basename(filename).split(".")[0] || `FC${genHashByXXH(filename)}`;
1316
1316
  name = capitalize(camelCase(defaultName));
1317
- logger.warn(`Unnamed component detected. Using file name: <${name}>`, {
1318
- file: filename
1319
- });
1320
1317
  }
1321
1318
  scriptData.declaredOptions.name = name;
1322
1319
  return t13.identifier(name);
@@ -6612,7 +6609,7 @@ function transform(ast, ctx, options) {
6612
6609
  }
6613
6610
 
6614
6611
  // package.json
6615
- var version = "1.8.1";
6612
+ var version = "1.8.3";
6616
6613
  var bin = {
6617
6614
  vureact: "bin/vureact.js"
6618
6615
  };
@@ -7036,13 +7033,6 @@ var Helper = class {
7036
7033
  }
7037
7034
  logger.clear();
7038
7035
  }
7039
- printCompileInfo(file, duration) {
7040
- this.print(
7041
- kleur4.green("Compiled"),
7042
- kleur4.dim(normalizePath(this.relativePath(file))),
7043
- kleur4.gray(`(${duration})`)
7044
- );
7045
- }
7046
7036
  print(...message) {
7047
7037
  if (this.compilerOpts.watch) {
7048
7038
  const time = (/* @__PURE__ */ new Date()).toLocaleTimeString();
@@ -7817,6 +7807,9 @@ var FileProcessor = class {
7817
7807
  }
7818
7808
  }
7819
7809
  await this.cacheManager.updateCacheIncrementally(processed, key);
7810
+ if (this.fileCompiler.getIsCache() && !existingCache) {
7811
+ await this.cacheManager.flushCache(key);
7812
+ }
7820
7813
  }
7821
7814
  return processed;
7822
7815
  }
@@ -8156,7 +8149,7 @@ var ViteBootstrapper = class {
8156
8149
  newPkg.devDependencies = newDevDeps;
8157
8150
  newPkg = output?.packageJson?.(newPkg) || newPkg;
8158
8151
  await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
8159
- this.spinner.succeed("Initialized Vite React environment");
8152
+ this.spinner.succeed("Vite React environment initialized");
8160
8153
  return true;
8161
8154
  }
8162
8155
  /**
@@ -8292,7 +8285,7 @@ var FileCompiler = class extends BaseCompiler {
8292
8285
  const { viteBootstrapper, fileProcessor, cacheManager, pipelineManager, assetManager } = this.manager;
8293
8286
  let startTime = 0;
8294
8287
  try {
8295
- this.updateSpinner("Initializing Vite React env...");
8288
+ this.updateSpinner("Initializing environment...");
8296
8289
  await viteBootstrapper.bootstrapIfNeeded();
8297
8290
  const cacheMap = await cacheManager.loadAllCache();
8298
8291
  startTime = performance.now();
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13;/**
2
- * @vureact/compiler-core v1.8.1
2
+ * @vureact/compiler-core v1.8.3
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -1314,9 +1314,6 @@ function resolveComponentName(ctx) {
1314
1314
  if (!name) {
1315
1315
  const defaultName = _path.basename.call(void 0, filename).split(".")[0] || `FC${genHashByXXH(filename)}`;
1316
1316
  name = capitalize(camelCase(defaultName));
1317
- logger.warn(`Unnamed component detected. Using file name: <${name}>`, {
1318
- file: filename
1319
- });
1320
1317
  }
1321
1318
  scriptData.declaredOptions.name = name;
1322
1319
  return t13.identifier(name);
@@ -6612,7 +6609,7 @@ function transform(ast, ctx, options) {
6612
6609
  }
6613
6610
 
6614
6611
  // package.json
6615
- var version = "1.8.1";
6612
+ var version = "1.8.3";
6616
6613
  var bin = {
6617
6614
  vureact: "bin/vureact.js"
6618
6615
  };
@@ -7036,13 +7033,6 @@ var Helper = (_class5 = class {
7036
7033
  }
7037
7034
  logger.clear();
7038
7035
  }
7039
- printCompileInfo(file, duration) {
7040
- this.print(
7041
- _kleur2.default.green("Compiled"),
7042
- _kleur2.default.dim(normalizePath(this.relativePath(file))),
7043
- _kleur2.default.gray(`(${duration})`)
7044
- );
7045
- }
7046
7036
  print(...message) {
7047
7037
  if (this.compilerOpts.watch) {
7048
7038
  const time = (/* @__PURE__ */ new Date()).toLocaleTimeString();
@@ -7817,6 +7807,9 @@ var FileProcessor = (_class10 = class {
7817
7807
  }
7818
7808
  }
7819
7809
  await this.cacheManager.updateCacheIncrementally(processed, key);
7810
+ if (this.fileCompiler.getIsCache() && !existingCache) {
7811
+ await this.cacheManager.flushCache(key);
7812
+ }
7820
7813
  }
7821
7814
  return processed;
7822
7815
  }
@@ -8156,7 +8149,7 @@ var ViteBootstrapper = (_class12 = class {
8156
8149
  newPkg.devDependencies = newDevDeps;
8157
8150
  newPkg = _optionalChain([output, 'optionalAccess', _304 => _304.packageJson, 'optionalCall', _305 => _305(newPkg)]) || newPkg;
8158
8151
  await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
8159
- this.spinner.succeed("Initialized Vite React environment");
8152
+ this.spinner.succeed("Vite React environment initialized");
8160
8153
  return true;
8161
8154
  }
8162
8155
  /**
@@ -8292,7 +8285,7 @@ var FileCompiler = (_class13 = class extends BaseCompiler {
8292
8285
  const { viteBootstrapper, fileProcessor, cacheManager, pipelineManager, assetManager } = this.manager;
8293
8286
  let startTime = 0;
8294
8287
  try {
8295
- this.updateSpinner("Initializing Vite React env...");
8288
+ this.updateSpinner("Initializing environment...");
8296
8289
  await viteBootstrapper.bootstrapIfNeeded();
8297
8290
  const cacheMap = await cacheManager.loadAllCache();
8298
8291
  startTime = performance.now();
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.3
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-QPW3RUZH.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.3
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 _chunkR34TQK4Xjs = require('./chunk-R34TQK4X.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, _chunkR34TQK4Xjs.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 = _chunkR34TQK4Xjs.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(`(${_chunkR34TQK4Xjs.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 = _chunkR34TQK4Xjs.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, _chunkR34TQK4Xjs.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 = _chunkR34TQK4Xjs.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(_chunkR34TQK4Xjs.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(_chunkR34TQK4Xjs.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.3
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-QPW3RUZH.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.3
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 _chunkR34TQK4Xjs = require('./chunk-R34TQK4X.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 = _chunkR34TQK4Xjs.BaseCompiler; exports.CacheKey = _chunkR34TQK4Xjs.CacheKey; exports.FileCompiler = _chunkR34TQK4Xjs.FileCompiler; exports.Helper = _chunkR34TQK4Xjs.Helper; exports.VuReact = _chunkR34TQK4Xjs.VuReact; exports.defineConfig = _chunkR34TQK4Xjs.defineConfig; exports.generate = _chunkR34TQK4Xjs.generate; exports.generateComponent = _chunkR34TQK4Xjs.generateComponent; exports.generateOnlyScript = _chunkR34TQK4Xjs.generateOnlyScript; exports.parse = _chunkR34TQK4Xjs.parse; exports.parseOnlyScript = _chunkR34TQK4Xjs.parseOnlyScript; exports.parseSFC = _chunkR34TQK4Xjs.parseSFC; exports.transform = _chunkR34TQK4Xjs.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.3",
4
+ "description": "🌀 Write in Vue 3, compile to React 18+.",
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"
@@ -98,4 +99,4 @@
98
99
  "engines": {
99
100
  "node": ">=19.0.0"
100
101
  }
101
- }
102
+ }