@vureact/compiler-core 1.7.0 → 1.8.0
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.en.md +3 -1
- package/README.md +3 -1
- package/lib/{chunk-Q7HZAZHD.esm.js → chunk-6MTN25KZ.esm.js} +646 -548
- package/lib/{chunk-Q36XF5TP.js → chunk-V7G7OQWK.js} +667 -569
- package/lib/cli.esm.js +3 -2
- package/lib/cli.js +11 -10
- package/lib/compiler-core.d.cts +72 -57
- package/lib/compiler-core.d.ts +72 -57
- package/lib/compiler-core.esm.js +2 -2
- package/lib/compiler-core.js +3 -3
- package/package.json +5 -4
package/lib/cli.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @vureact/compiler-core v1.
|
|
3
|
+
* @vureact/compiler-core v1.8.0
|
|
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-6MTN25KZ.esm.js";
|
|
17
17
|
|
|
18
18
|
// src/cli/index.ts
|
|
19
19
|
import { cac } from "cac";
|
|
@@ -220,6 +220,7 @@ function checkForUpdates() {
|
|
|
220
220
|
// 每天检查一次 (24小时)
|
|
221
221
|
shouldNotifyInNpmScript: true
|
|
222
222
|
});
|
|
223
|
+
notifier.check();
|
|
223
224
|
notifier.notify();
|
|
224
225
|
} catch (error) {
|
|
225
226
|
if (process.env.NODE_ENV === "development") {
|
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.
|
|
3
|
+
* @vureact/compiler-core v1.8.0
|
|
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 _chunkV7G7OQWKjs = require('./chunk-V7G7OQWK.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, _chunkV7G7OQWKjs.Helper)(config);
|
|
80
80
|
const watcher = _chokidar2.default.watch(cmpHelper.getInputPath(), {
|
|
81
81
|
ignored: cmpHelper.getExcludes(),
|
|
82
82
|
persistent: true,
|
|
@@ -111,7 +111,7 @@ function setupWatcher(compiler, config) {
|
|
|
111
111
|
const fn = processors[ext];
|
|
112
112
|
const unit = await fn(filePath);
|
|
113
113
|
cmpHelper.printCoreLogs();
|
|
114
|
-
cmpHelper.printCompileInfo(filePath,
|
|
114
|
+
cmpHelper.printCompileInfo(filePath, _chunkV7G7OQWKjs.calcElapsedTime.call(void 0, startTime));
|
|
115
115
|
if (unit) {
|
|
116
116
|
await _optionalChain([config, 'access', _5 => _5.onChange, 'optionalCall', _6 => _6(event, unit)]);
|
|
117
117
|
}
|
|
@@ -120,7 +120,7 @@ function setupWatcher(compiler, config) {
|
|
|
120
120
|
await compiler.processAsset(filePath);
|
|
121
121
|
cmpHelper.print(
|
|
122
122
|
_kleur2.default.blue("Copied Asset"),
|
|
123
|
-
_kleur2.default.dim(
|
|
123
|
+
_kleur2.default.dim(_chunkV7G7OQWKjs.normalizePath.call(void 0, cmpHelper.relativePath(filePath)))
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
spinner.stop();
|
|
@@ -133,7 +133,7 @@ function setupWatcher(compiler, config) {
|
|
|
133
133
|
await compiler.removeOutputPath(filePath, type2);
|
|
134
134
|
cmpHelper.print(
|
|
135
135
|
_kleur2.default.yellow("Removed"),
|
|
136
|
-
_kleur2.default.dim(
|
|
136
|
+
_kleur2.default.dim(_chunkV7G7OQWKjs.normalizePath.call(void 0, cmpHelper.relativePath(filePath)))
|
|
137
137
|
);
|
|
138
138
|
};
|
|
139
139
|
if (type === "unlink") {
|
|
@@ -166,7 +166,7 @@ async function resolveAction(root, options) {
|
|
|
166
166
|
const projectRoot = root ? _path2.default.resolve(process.cwd(), root) : process.cwd();
|
|
167
167
|
const userConfig = await loadUserConfig(projectRoot);
|
|
168
168
|
const finalConfig = mergeConfig(projectRoot, options, userConfig);
|
|
169
|
-
const compiler = new (0,
|
|
169
|
+
const compiler = new (0, _chunkV7G7OQWKjs.VuReact)(finalConfig);
|
|
170
170
|
await compiler.execute();
|
|
171
171
|
if (finalConfig.watch) {
|
|
172
172
|
setupWatcher(compiler, finalConfig);
|
|
@@ -189,7 +189,7 @@ function resolveOptions(command) {
|
|
|
189
189
|
|
|
190
190
|
|
|
191
191
|
var _updatenotifier = require('update-notifier'); var _updatenotifier2 = _interopRequireDefault(_updatenotifier);
|
|
192
|
-
var __dirname =
|
|
192
|
+
var __dirname = _chunkV7G7OQWKjs.getDirname.call(void 0, import.meta.url);
|
|
193
193
|
function checkForUpdates() {
|
|
194
194
|
try {
|
|
195
195
|
const possiblePaths = [
|
|
@@ -220,6 +220,7 @@ function checkForUpdates() {
|
|
|
220
220
|
// 每天检查一次 (24小时)
|
|
221
221
|
shouldNotifyInNpmScript: true
|
|
222
222
|
});
|
|
223
|
+
notifier.check();
|
|
223
224
|
notifier.notify();
|
|
224
225
|
} catch (error) {
|
|
225
226
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -229,7 +230,7 @@ function checkForUpdates() {
|
|
|
229
230
|
}
|
|
230
231
|
|
|
231
232
|
// src/cli/index.ts
|
|
232
|
-
var [programName] = Object.keys(
|
|
233
|
+
var [programName] = Object.keys(_chunkV7G7OQWKjs.bin);
|
|
233
234
|
var cli = _cac.cac.call(void 0, programName);
|
|
234
235
|
checkForUpdates();
|
|
235
236
|
var buildCommand = cli.command("build [root]", "Compile Vue3 to React (one-time)");
|
|
@@ -240,4 +241,4 @@ var watchCommand = cli.command("watch [root]", "Compile Vue3 to React and watch
|
|
|
240
241
|
resolveOptions(watchCommand).action((root, options) => {
|
|
241
242
|
resolveAction(root, { ...options, watch: true });
|
|
242
243
|
});
|
|
243
|
-
cli.help().version(
|
|
244
|
+
cli.help().version(_chunkV7G7OQWKjs.version).parse();
|
package/lib/compiler-core.d.cts
CHANGED
|
@@ -75,6 +75,7 @@ interface OutputItem {
|
|
|
75
75
|
code: string;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
type CacheMap = Record<CacheKey, LoadedCache>;
|
|
78
79
|
type LoadedCache<T = CacheMeta> = {
|
|
79
80
|
key: CacheKey;
|
|
80
81
|
target: T[];
|
|
@@ -561,10 +562,6 @@ declare class Helper {
|
|
|
561
562
|
* 获取输入文件的路径
|
|
562
563
|
*/
|
|
563
564
|
getInputPath(): string;
|
|
564
|
-
/**
|
|
565
|
-
* 检查 input 路径是否是单个文件
|
|
566
|
-
*/
|
|
567
|
-
isSingleFile(): boolean;
|
|
568
565
|
/**
|
|
569
566
|
* 获取输出文件的路径。如:'[root]/.vureact/dist/'
|
|
570
567
|
* @param addInput 会输出如:'[root]/.vureact/dist/[input]/'
|
|
@@ -586,6 +583,10 @@ declare class Helper {
|
|
|
586
583
|
* 返回 output 的 package.json 路径
|
|
587
584
|
*/
|
|
588
585
|
getOutputPkgPath(): string;
|
|
586
|
+
/**
|
|
587
|
+
* 获取缓存文件路径
|
|
588
|
+
*/
|
|
589
|
+
getCachePath(): string;
|
|
589
590
|
/**
|
|
590
591
|
* 返回文件相对工作区的路径
|
|
591
592
|
*/
|
|
@@ -631,26 +632,7 @@ declare class Helper {
|
|
|
631
632
|
lock?: boolean;
|
|
632
633
|
}): Promise<void>;
|
|
633
634
|
rmFile(filePath: string): Promise<void>;
|
|
634
|
-
/**
|
|
635
|
-
* 加载指定文件的缓存内容
|
|
636
|
-
* @param key 缓存键
|
|
637
|
-
*/
|
|
638
|
-
loadCache(key: CacheKey.SFC): Promise<LoadedCache<Vue2ReactCacheMeta>>;
|
|
639
|
-
loadCache(key: CacheKey.SCRIPT | CacheKey.STYLE | CacheKey.ASSET): Promise<LoadedCache<FileCacheMeta>>;
|
|
640
|
-
loadCache(key: CacheKey.SFC | CacheKey.SCRIPT | CacheKey.STYLE | CacheKey.ASSET): Promise<LoadedCache<Vue2ReactCacheMeta | FileCacheMeta>>;
|
|
641
|
-
createCacheData(key: CacheKey): LoadedCache;
|
|
642
|
-
/**
|
|
643
|
-
* 获取缓存文件路径
|
|
644
|
-
*/
|
|
645
|
-
getCachePath(): string;
|
|
646
|
-
saveCache(data?: LoadedCache): Promise<void>;
|
|
647
635
|
genHash(content: string): string;
|
|
648
|
-
/**
|
|
649
|
-
* 扫描指定目录下的所有文件
|
|
650
|
-
* @param dir 目标目录
|
|
651
|
-
* @param filter 筛选指定的文件后缀名
|
|
652
|
-
*/
|
|
653
|
-
scanFiles(dir: string, filter: (file: string) => boolean): string[];
|
|
654
636
|
getAbsPath(filePath: string): string;
|
|
655
637
|
getFileMeta(filePath: string): Promise<FileMeta>;
|
|
656
638
|
removeOutputFile(filePath: string, resolveOutputPath?: boolean): Promise<void>;
|
|
@@ -694,29 +676,69 @@ declare class BaseCompiler extends Helper {
|
|
|
694
676
|
private resolveStyleResult;
|
|
695
677
|
}
|
|
696
678
|
|
|
697
|
-
declare class
|
|
679
|
+
declare class CacheManager {
|
|
698
680
|
private fileCompiler;
|
|
681
|
+
private pendingUpdates;
|
|
682
|
+
/** 缓存文件仅读取一次,之后复用此副本 */
|
|
683
|
+
private cachedData;
|
|
699
684
|
constructor(fileCompiler: FileCompiler);
|
|
700
685
|
/**
|
|
701
|
-
*
|
|
686
|
+
* 批量更新缓存记录
|
|
687
|
+
*/
|
|
688
|
+
updateCacheIncrementally(unit: CompilationUnit, key: CacheKey): Promise<void>;
|
|
689
|
+
/**
|
|
690
|
+
* 一次性刷新所有缓存(只写一次文件)
|
|
691
|
+
*/
|
|
692
|
+
flushAllCache(): Promise<void>;
|
|
693
|
+
/**
|
|
694
|
+
* 一次性加载所有缓存(只读一次文件)
|
|
695
|
+
*/
|
|
696
|
+
loadAllCache(): Promise<CacheMap>;
|
|
697
|
+
/**
|
|
698
|
+
* 加载指定类型的缓存(watch 等场景使用)
|
|
699
|
+
*/
|
|
700
|
+
loadCache(key: CacheKey): Promise<LoadedCache>;
|
|
701
|
+
/**
|
|
702
|
+
* 刷新指定 key 的缓存(统一由 flushAllCache 写入,此方法仅用于外部兼容调用)
|
|
703
|
+
*/
|
|
704
|
+
flushCache(key: CacheKey): Promise<void>;
|
|
705
|
+
private getEmptyList;
|
|
706
|
+
/**
|
|
707
|
+
* 保存缓存数据到文件(watch 等场景使用)
|
|
708
|
+
*/
|
|
709
|
+
saveCache(data: LoadedCache): Promise<void>;
|
|
710
|
+
private buildLoadedCache;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
declare class CleanupManager {
|
|
714
|
+
private fileCompiler;
|
|
715
|
+
private cacheManager;
|
|
716
|
+
constructor(fileCompiler: FileCompiler, cacheManager: CacheManager);
|
|
717
|
+
/**
|
|
718
|
+
* 删除指定路径对应的构建产物和缓存
|
|
702
719
|
*/
|
|
703
720
|
removeOutputPath(targetPath: string, type: CacheKey): Promise<void>;
|
|
704
721
|
/**
|
|
705
|
-
*
|
|
722
|
+
* 删除匹配的输出文件,并从内存缓存中移除对应条目(不写磁盘)
|
|
723
|
+
*/
|
|
724
|
+
removeMatchedFromCache(key: CacheKey, cache: LoadedCache, filter: (m: CacheMeta) => boolean): Promise<void>;
|
|
725
|
+
/**
|
|
726
|
+
* 删除单个缓存元数据对应的输出文件(不操作缓存)
|
|
706
727
|
*/
|
|
707
|
-
|
|
728
|
+
removeCacheMeta(key: CacheKey, meta: CacheMeta): Promise<void>;
|
|
708
729
|
}
|
|
709
730
|
|
|
710
731
|
declare class AssetManager {
|
|
711
732
|
private fileCompiler;
|
|
712
733
|
private cleanupManager;
|
|
734
|
+
private cacheManager;
|
|
713
735
|
pipelineFiles: string[];
|
|
714
736
|
private skippedCount;
|
|
715
|
-
constructor(fileCompiler: FileCompiler, cleanupManager: CleanupManager);
|
|
737
|
+
constructor(fileCompiler: FileCompiler, cleanupManager: CleanupManager, cacheManager: CacheManager);
|
|
716
738
|
/**
|
|
717
739
|
* 运行资源文件处理管线
|
|
718
740
|
*/
|
|
719
|
-
|
|
741
|
+
runAsset(files: string[], cacheMap: CacheMap): Promise<number>;
|
|
720
742
|
/**
|
|
721
743
|
* Process single asset file, compare with cache and decide whether to copy.
|
|
722
744
|
*/
|
|
@@ -735,24 +757,6 @@ declare class AssetManager {
|
|
|
735
757
|
resetSkippedCount(): void;
|
|
736
758
|
}
|
|
737
759
|
|
|
738
|
-
declare class CacheManager {
|
|
739
|
-
private fileCompiler;
|
|
740
|
-
private pendingUpdates;
|
|
741
|
-
constructor(fileCompiler: FileCompiler);
|
|
742
|
-
/**
|
|
743
|
-
* 批量更新缓存记录
|
|
744
|
-
*/
|
|
745
|
-
updateCacheIncrementally(unit: CompilationUnit, key: CacheKey): Promise<void>;
|
|
746
|
-
/**
|
|
747
|
-
* 批量保存缓存
|
|
748
|
-
*/
|
|
749
|
-
flushCache(key: CacheKey): Promise<void>;
|
|
750
|
-
/**
|
|
751
|
-
* 更新缓存
|
|
752
|
-
*/
|
|
753
|
-
private updateCache;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
760
|
declare class CompilationUnitProcessor {
|
|
757
761
|
private fileCompiler;
|
|
758
762
|
constructor(fileCompiler: FileCompiler);
|
|
@@ -767,6 +771,12 @@ declare class CompilationUnitProcessor {
|
|
|
767
771
|
saveCompiledFiles(unit: CompilationUnit, key: CacheKey): Promise<void>;
|
|
768
772
|
}
|
|
769
773
|
|
|
774
|
+
interface FileScanResult {
|
|
775
|
+
assets: string[];
|
|
776
|
+
script: string[];
|
|
777
|
+
style: string[];
|
|
778
|
+
vue: string[];
|
|
779
|
+
}
|
|
770
780
|
declare class FileProcessor {
|
|
771
781
|
private fileCompiler;
|
|
772
782
|
private compilationUnitProcessor;
|
|
@@ -817,30 +827,36 @@ declare class FileProcessor {
|
|
|
817
827
|
* 重置跳过的文件数量
|
|
818
828
|
*/
|
|
819
829
|
resetSkippedCount(): void;
|
|
830
|
+
/**
|
|
831
|
+
* 扫描项目中的编译文件和资产文件
|
|
832
|
+
* @param recursive 是否递归扫描子目录
|
|
833
|
+
* @param ignoreAssets 需要忽略的资产文件列表
|
|
834
|
+
*/
|
|
835
|
+
scanFiles(): FileScanResult;
|
|
820
836
|
}
|
|
821
837
|
|
|
822
838
|
declare class PipelineManager {
|
|
823
839
|
private fileCompiler;
|
|
824
840
|
private fileProcessor;
|
|
825
|
-
private skippedCount;
|
|
826
841
|
private cleanupManager;
|
|
827
|
-
|
|
842
|
+
private skippedCount;
|
|
843
|
+
constructor(fileCompiler: FileCompiler, fileProcessor: FileProcessor, cleanupManager: CleanupManager);
|
|
828
844
|
/**
|
|
829
845
|
* 运行 SFC 编译管线
|
|
830
846
|
*/
|
|
831
|
-
|
|
847
|
+
runSFC(files: string[], cacheMap: CacheMap): Promise<number>;
|
|
832
848
|
/**
|
|
833
849
|
* 运行 Script 编译管线
|
|
834
850
|
*/
|
|
835
|
-
|
|
851
|
+
runScript(files: string[], cacheMap: CacheMap): Promise<number>;
|
|
836
852
|
/**
|
|
837
853
|
* 运行 Style 编译管线
|
|
838
854
|
*/
|
|
839
|
-
|
|
855
|
+
runStyle(files: string[], cacheMap: CacheMap): Promise<number>;
|
|
840
856
|
/**
|
|
841
857
|
* 核心编译管线
|
|
842
858
|
*/
|
|
843
|
-
private
|
|
859
|
+
private runCore;
|
|
844
860
|
/**
|
|
845
861
|
* 获取跳过的文件数量
|
|
846
862
|
*/
|
|
@@ -898,6 +914,8 @@ declare class FileCompiler extends BaseCompiler {
|
|
|
898
914
|
manager: CompilerManager;
|
|
899
915
|
private spinner;
|
|
900
916
|
constructor(options?: CompilerOptions);
|
|
917
|
+
private printTitle;
|
|
918
|
+
private updateSpinner;
|
|
901
919
|
/** 执行完整的编译流程 */
|
|
902
920
|
execute(): Promise<void>;
|
|
903
921
|
/** 处理单个 Vue 单文件组件(SFC) */
|
|
@@ -910,11 +928,8 @@ declare class FileCompiler extends BaseCompiler {
|
|
|
910
928
|
processFile(key: CacheKey, filePath: string, existingCache?: LoadedCache): Promise<CompilationUnit | undefined>;
|
|
911
929
|
/** 处理单个资源文件 */
|
|
912
930
|
processAsset(filePath: string, existingCache?: LoadedCache<FileCacheMeta>): Promise<FileCacheMeta | undefined>;
|
|
913
|
-
/** 批量保存缓存 */
|
|
914
|
-
flushCache(key: CacheKey): Promise<void>;
|
|
915
931
|
/** 删除指定路径对应的输出文件和缓存 */
|
|
916
932
|
removeOutputPath(targetPath: string, type: CacheKey): Promise<void>;
|
|
917
|
-
private runPipelineWithSpinner;
|
|
918
933
|
private showCompileStats;
|
|
919
934
|
private resetSkippedCount;
|
|
920
935
|
}
|
|
@@ -1176,4 +1191,4 @@ declare function generateOnlyScript(ir: ReactIRDescriptor, ctx: ICompilationCont
|
|
|
1176
1191
|
*/
|
|
1177
1192
|
declare function generate(ir: ReactIRDescriptor, ctx: ICompilationContext, options?: GeneratorOptions): GeneratorResult;
|
|
1178
1193
|
|
|
1179
|
-
export { type AssetUnit, type BaseCompilationResult, BaseCompiler, type BaseUnit, type CacheCheckResult, CacheKey, type CacheList, type CacheMeta, type CompilationResult, type CompilationUnit, type CompilerOptions, type CompilerPlugins, type FileCacheMeta, FileCompiler, type FileMeta, type FormatConfig, type GeneratorOptions, type GeneratorResult, Helper, type LoadedCache, type LoggingConfig, type OutputConfig, type ParseResult, type ParserOptions, type PluginRegister, type ReactIRDescriptor, type RouterConfig, type SFCCompilationResult, type SFCUnit, type ScriptCacheMeta, type ScriptCompilationResult, type ScriptUnit, type StyleCacheMeta, type StyleCompilationResult, type StyleUnit, type TransformerOptions, type UserConfigFnObject, VuReact, type Vue2ReactCacheMeta, defineConfig, generate, generateComponent, generateOnlyScript, parse, parseOnlyScript, parseSFC, transform };
|
|
1194
|
+
export { type AssetUnit, type BaseCompilationResult, BaseCompiler, type BaseUnit, type CacheCheckResult, CacheKey, type CacheList, type CacheMap, type CacheMeta, type CompilationResult, type CompilationUnit, type CompilerOptions, type CompilerPlugins, type FileCacheMeta, FileCompiler, type FileMeta, type FormatConfig, type GeneratorOptions, type GeneratorResult, Helper, type LoadedCache, type LoggingConfig, type OutputConfig, type ParseResult, type ParserOptions, type PluginRegister, type ReactIRDescriptor, type RouterConfig, type SFCCompilationResult, type SFCUnit, type ScriptCacheMeta, type ScriptCompilationResult, type ScriptUnit, type StyleCacheMeta, type StyleCompilationResult, type StyleUnit, type TransformerOptions, type UserConfigFnObject, VuReact, type Vue2ReactCacheMeta, defineConfig, generate, generateComponent, generateOnlyScript, parse, parseOnlyScript, parseSFC, transform };
|
package/lib/compiler-core.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ interface OutputItem {
|
|
|
75
75
|
code: string;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
type CacheMap = Record<CacheKey, LoadedCache>;
|
|
78
79
|
type LoadedCache<T = CacheMeta> = {
|
|
79
80
|
key: CacheKey;
|
|
80
81
|
target: T[];
|
|
@@ -561,10 +562,6 @@ declare class Helper {
|
|
|
561
562
|
* 获取输入文件的路径
|
|
562
563
|
*/
|
|
563
564
|
getInputPath(): string;
|
|
564
|
-
/**
|
|
565
|
-
* 检查 input 路径是否是单个文件
|
|
566
|
-
*/
|
|
567
|
-
isSingleFile(): boolean;
|
|
568
565
|
/**
|
|
569
566
|
* 获取输出文件的路径。如:'[root]/.vureact/dist/'
|
|
570
567
|
* @param addInput 会输出如:'[root]/.vureact/dist/[input]/'
|
|
@@ -586,6 +583,10 @@ declare class Helper {
|
|
|
586
583
|
* 返回 output 的 package.json 路径
|
|
587
584
|
*/
|
|
588
585
|
getOutputPkgPath(): string;
|
|
586
|
+
/**
|
|
587
|
+
* 获取缓存文件路径
|
|
588
|
+
*/
|
|
589
|
+
getCachePath(): string;
|
|
589
590
|
/**
|
|
590
591
|
* 返回文件相对工作区的路径
|
|
591
592
|
*/
|
|
@@ -631,26 +632,7 @@ declare class Helper {
|
|
|
631
632
|
lock?: boolean;
|
|
632
633
|
}): Promise<void>;
|
|
633
634
|
rmFile(filePath: string): Promise<void>;
|
|
634
|
-
/**
|
|
635
|
-
* 加载指定文件的缓存内容
|
|
636
|
-
* @param key 缓存键
|
|
637
|
-
*/
|
|
638
|
-
loadCache(key: CacheKey.SFC): Promise<LoadedCache<Vue2ReactCacheMeta>>;
|
|
639
|
-
loadCache(key: CacheKey.SCRIPT | CacheKey.STYLE | CacheKey.ASSET): Promise<LoadedCache<FileCacheMeta>>;
|
|
640
|
-
loadCache(key: CacheKey.SFC | CacheKey.SCRIPT | CacheKey.STYLE | CacheKey.ASSET): Promise<LoadedCache<Vue2ReactCacheMeta | FileCacheMeta>>;
|
|
641
|
-
createCacheData(key: CacheKey): LoadedCache;
|
|
642
|
-
/**
|
|
643
|
-
* 获取缓存文件路径
|
|
644
|
-
*/
|
|
645
|
-
getCachePath(): string;
|
|
646
|
-
saveCache(data?: LoadedCache): Promise<void>;
|
|
647
635
|
genHash(content: string): string;
|
|
648
|
-
/**
|
|
649
|
-
* 扫描指定目录下的所有文件
|
|
650
|
-
* @param dir 目标目录
|
|
651
|
-
* @param filter 筛选指定的文件后缀名
|
|
652
|
-
*/
|
|
653
|
-
scanFiles(dir: string, filter: (file: string) => boolean): string[];
|
|
654
636
|
getAbsPath(filePath: string): string;
|
|
655
637
|
getFileMeta(filePath: string): Promise<FileMeta>;
|
|
656
638
|
removeOutputFile(filePath: string, resolveOutputPath?: boolean): Promise<void>;
|
|
@@ -694,29 +676,69 @@ declare class BaseCompiler extends Helper {
|
|
|
694
676
|
private resolveStyleResult;
|
|
695
677
|
}
|
|
696
678
|
|
|
697
|
-
declare class
|
|
679
|
+
declare class CacheManager {
|
|
698
680
|
private fileCompiler;
|
|
681
|
+
private pendingUpdates;
|
|
682
|
+
/** 缓存文件仅读取一次,之后复用此副本 */
|
|
683
|
+
private cachedData;
|
|
699
684
|
constructor(fileCompiler: FileCompiler);
|
|
700
685
|
/**
|
|
701
|
-
*
|
|
686
|
+
* 批量更新缓存记录
|
|
687
|
+
*/
|
|
688
|
+
updateCacheIncrementally(unit: CompilationUnit, key: CacheKey): Promise<void>;
|
|
689
|
+
/**
|
|
690
|
+
* 一次性刷新所有缓存(只写一次文件)
|
|
691
|
+
*/
|
|
692
|
+
flushAllCache(): Promise<void>;
|
|
693
|
+
/**
|
|
694
|
+
* 一次性加载所有缓存(只读一次文件)
|
|
695
|
+
*/
|
|
696
|
+
loadAllCache(): Promise<CacheMap>;
|
|
697
|
+
/**
|
|
698
|
+
* 加载指定类型的缓存(watch 等场景使用)
|
|
699
|
+
*/
|
|
700
|
+
loadCache(key: CacheKey): Promise<LoadedCache>;
|
|
701
|
+
/**
|
|
702
|
+
* 刷新指定 key 的缓存(统一由 flushAllCache 写入,此方法仅用于外部兼容调用)
|
|
703
|
+
*/
|
|
704
|
+
flushCache(key: CacheKey): Promise<void>;
|
|
705
|
+
private getEmptyList;
|
|
706
|
+
/**
|
|
707
|
+
* 保存缓存数据到文件(watch 等场景使用)
|
|
708
|
+
*/
|
|
709
|
+
saveCache(data: LoadedCache): Promise<void>;
|
|
710
|
+
private buildLoadedCache;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
declare class CleanupManager {
|
|
714
|
+
private fileCompiler;
|
|
715
|
+
private cacheManager;
|
|
716
|
+
constructor(fileCompiler: FileCompiler, cacheManager: CacheManager);
|
|
717
|
+
/**
|
|
718
|
+
* 删除指定路径对应的构建产物和缓存
|
|
702
719
|
*/
|
|
703
720
|
removeOutputPath(targetPath: string, type: CacheKey): Promise<void>;
|
|
704
721
|
/**
|
|
705
|
-
*
|
|
722
|
+
* 删除匹配的输出文件,并从内存缓存中移除对应条目(不写磁盘)
|
|
723
|
+
*/
|
|
724
|
+
removeMatchedFromCache(key: CacheKey, cache: LoadedCache, filter: (m: CacheMeta) => boolean): Promise<void>;
|
|
725
|
+
/**
|
|
726
|
+
* 删除单个缓存元数据对应的输出文件(不操作缓存)
|
|
706
727
|
*/
|
|
707
|
-
|
|
728
|
+
removeCacheMeta(key: CacheKey, meta: CacheMeta): Promise<void>;
|
|
708
729
|
}
|
|
709
730
|
|
|
710
731
|
declare class AssetManager {
|
|
711
732
|
private fileCompiler;
|
|
712
733
|
private cleanupManager;
|
|
734
|
+
private cacheManager;
|
|
713
735
|
pipelineFiles: string[];
|
|
714
736
|
private skippedCount;
|
|
715
|
-
constructor(fileCompiler: FileCompiler, cleanupManager: CleanupManager);
|
|
737
|
+
constructor(fileCompiler: FileCompiler, cleanupManager: CleanupManager, cacheManager: CacheManager);
|
|
716
738
|
/**
|
|
717
739
|
* 运行资源文件处理管线
|
|
718
740
|
*/
|
|
719
|
-
|
|
741
|
+
runAsset(files: string[], cacheMap: CacheMap): Promise<number>;
|
|
720
742
|
/**
|
|
721
743
|
* Process single asset file, compare with cache and decide whether to copy.
|
|
722
744
|
*/
|
|
@@ -735,24 +757,6 @@ declare class AssetManager {
|
|
|
735
757
|
resetSkippedCount(): void;
|
|
736
758
|
}
|
|
737
759
|
|
|
738
|
-
declare class CacheManager {
|
|
739
|
-
private fileCompiler;
|
|
740
|
-
private pendingUpdates;
|
|
741
|
-
constructor(fileCompiler: FileCompiler);
|
|
742
|
-
/**
|
|
743
|
-
* 批量更新缓存记录
|
|
744
|
-
*/
|
|
745
|
-
updateCacheIncrementally(unit: CompilationUnit, key: CacheKey): Promise<void>;
|
|
746
|
-
/**
|
|
747
|
-
* 批量保存缓存
|
|
748
|
-
*/
|
|
749
|
-
flushCache(key: CacheKey): Promise<void>;
|
|
750
|
-
/**
|
|
751
|
-
* 更新缓存
|
|
752
|
-
*/
|
|
753
|
-
private updateCache;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
760
|
declare class CompilationUnitProcessor {
|
|
757
761
|
private fileCompiler;
|
|
758
762
|
constructor(fileCompiler: FileCompiler);
|
|
@@ -767,6 +771,12 @@ declare class CompilationUnitProcessor {
|
|
|
767
771
|
saveCompiledFiles(unit: CompilationUnit, key: CacheKey): Promise<void>;
|
|
768
772
|
}
|
|
769
773
|
|
|
774
|
+
interface FileScanResult {
|
|
775
|
+
assets: string[];
|
|
776
|
+
script: string[];
|
|
777
|
+
style: string[];
|
|
778
|
+
vue: string[];
|
|
779
|
+
}
|
|
770
780
|
declare class FileProcessor {
|
|
771
781
|
private fileCompiler;
|
|
772
782
|
private compilationUnitProcessor;
|
|
@@ -817,30 +827,36 @@ declare class FileProcessor {
|
|
|
817
827
|
* 重置跳过的文件数量
|
|
818
828
|
*/
|
|
819
829
|
resetSkippedCount(): void;
|
|
830
|
+
/**
|
|
831
|
+
* 扫描项目中的编译文件和资产文件
|
|
832
|
+
* @param recursive 是否递归扫描子目录
|
|
833
|
+
* @param ignoreAssets 需要忽略的资产文件列表
|
|
834
|
+
*/
|
|
835
|
+
scanFiles(): FileScanResult;
|
|
820
836
|
}
|
|
821
837
|
|
|
822
838
|
declare class PipelineManager {
|
|
823
839
|
private fileCompiler;
|
|
824
840
|
private fileProcessor;
|
|
825
|
-
private skippedCount;
|
|
826
841
|
private cleanupManager;
|
|
827
|
-
|
|
842
|
+
private skippedCount;
|
|
843
|
+
constructor(fileCompiler: FileCompiler, fileProcessor: FileProcessor, cleanupManager: CleanupManager);
|
|
828
844
|
/**
|
|
829
845
|
* 运行 SFC 编译管线
|
|
830
846
|
*/
|
|
831
|
-
|
|
847
|
+
runSFC(files: string[], cacheMap: CacheMap): Promise<number>;
|
|
832
848
|
/**
|
|
833
849
|
* 运行 Script 编译管线
|
|
834
850
|
*/
|
|
835
|
-
|
|
851
|
+
runScript(files: string[], cacheMap: CacheMap): Promise<number>;
|
|
836
852
|
/**
|
|
837
853
|
* 运行 Style 编译管线
|
|
838
854
|
*/
|
|
839
|
-
|
|
855
|
+
runStyle(files: string[], cacheMap: CacheMap): Promise<number>;
|
|
840
856
|
/**
|
|
841
857
|
* 核心编译管线
|
|
842
858
|
*/
|
|
843
|
-
private
|
|
859
|
+
private runCore;
|
|
844
860
|
/**
|
|
845
861
|
* 获取跳过的文件数量
|
|
846
862
|
*/
|
|
@@ -898,6 +914,8 @@ declare class FileCompiler extends BaseCompiler {
|
|
|
898
914
|
manager: CompilerManager;
|
|
899
915
|
private spinner;
|
|
900
916
|
constructor(options?: CompilerOptions);
|
|
917
|
+
private printTitle;
|
|
918
|
+
private updateSpinner;
|
|
901
919
|
/** 执行完整的编译流程 */
|
|
902
920
|
execute(): Promise<void>;
|
|
903
921
|
/** 处理单个 Vue 单文件组件(SFC) */
|
|
@@ -910,11 +928,8 @@ declare class FileCompiler extends BaseCompiler {
|
|
|
910
928
|
processFile(key: CacheKey, filePath: string, existingCache?: LoadedCache): Promise<CompilationUnit | undefined>;
|
|
911
929
|
/** 处理单个资源文件 */
|
|
912
930
|
processAsset(filePath: string, existingCache?: LoadedCache<FileCacheMeta>): Promise<FileCacheMeta | undefined>;
|
|
913
|
-
/** 批量保存缓存 */
|
|
914
|
-
flushCache(key: CacheKey): Promise<void>;
|
|
915
931
|
/** 删除指定路径对应的输出文件和缓存 */
|
|
916
932
|
removeOutputPath(targetPath: string, type: CacheKey): Promise<void>;
|
|
917
|
-
private runPipelineWithSpinner;
|
|
918
933
|
private showCompileStats;
|
|
919
934
|
private resetSkippedCount;
|
|
920
935
|
}
|
|
@@ -1176,4 +1191,4 @@ declare function generateOnlyScript(ir: ReactIRDescriptor, ctx: ICompilationCont
|
|
|
1176
1191
|
*/
|
|
1177
1192
|
declare function generate(ir: ReactIRDescriptor, ctx: ICompilationContext, options?: GeneratorOptions): GeneratorResult;
|
|
1178
1193
|
|
|
1179
|
-
export { type AssetUnit, type BaseCompilationResult, BaseCompiler, type BaseUnit, type CacheCheckResult, CacheKey, type CacheList, type CacheMeta, type CompilationResult, type CompilationUnit, type CompilerOptions, type CompilerPlugins, type FileCacheMeta, FileCompiler, type FileMeta, type FormatConfig, type GeneratorOptions, type GeneratorResult, Helper, type LoadedCache, type LoggingConfig, type OutputConfig, type ParseResult, type ParserOptions, type PluginRegister, type ReactIRDescriptor, type RouterConfig, type SFCCompilationResult, type SFCUnit, type ScriptCacheMeta, type ScriptCompilationResult, type ScriptUnit, type StyleCacheMeta, type StyleCompilationResult, type StyleUnit, type TransformerOptions, type UserConfigFnObject, VuReact, type Vue2ReactCacheMeta, defineConfig, generate, generateComponent, generateOnlyScript, parse, parseOnlyScript, parseSFC, transform };
|
|
1194
|
+
export { type AssetUnit, type BaseCompilationResult, BaseCompiler, type BaseUnit, type CacheCheckResult, CacheKey, type CacheList, type CacheMap, type CacheMeta, type CompilationResult, type CompilationUnit, type CompilerOptions, type CompilerPlugins, type FileCacheMeta, FileCompiler, type FileMeta, type FormatConfig, type GeneratorOptions, type GeneratorResult, Helper, type LoadedCache, type LoggingConfig, type OutputConfig, type ParseResult, type ParserOptions, type PluginRegister, type ReactIRDescriptor, type RouterConfig, type SFCCompilationResult, type SFCUnit, type ScriptCacheMeta, type ScriptCompilationResult, type ScriptUnit, type StyleCacheMeta, type StyleCompilationResult, type StyleUnit, type TransformerOptions, type UserConfigFnObject, VuReact, type Vue2ReactCacheMeta, defineConfig, generate, generateComponent, generateOnlyScript, parse, parseOnlyScript, parseSFC, transform };
|
package/lib/compiler-core.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vureact/compiler-core v1.
|
|
2
|
+
* @vureact/compiler-core v1.8.0
|
|
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-6MTN25KZ.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.
|
|
2
|
+
* @vureact/compiler-core v1.8.0
|
|
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 _chunkV7G7OQWKjs = require('./chunk-V7G7OQWK.js');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -33,4 +33,4 @@ var _chunkQ36XF5TPjs = require('./chunk-Q36XF5TP.js');
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
exports.BaseCompiler =
|
|
36
|
+
exports.BaseCompiler = _chunkV7G7OQWKjs.BaseCompiler; exports.CacheKey = _chunkV7G7OQWKjs.CacheKey; exports.FileCompiler = _chunkV7G7OQWKjs.FileCompiler; exports.Helper = _chunkV7G7OQWKjs.Helper; exports.VuReact = _chunkV7G7OQWKjs.VuReact; exports.defineConfig = _chunkV7G7OQWKjs.defineConfig; exports.generate = _chunkV7G7OQWKjs.generate; exports.generateComponent = _chunkV7G7OQWKjs.generateComponent; exports.generateOnlyScript = _chunkV7G7OQWKjs.generateOnlyScript; exports.parse = _chunkV7G7OQWKjs.parse; exports.parseOnlyScript = _chunkV7G7OQWKjs.parseOnlyScript; exports.parseSFC = _chunkV7G7OQWKjs.parseSFC; exports.transform = _chunkV7G7OQWKjs.transform;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vureact/compiler-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "⚡ Write in Vue 3, compile to React 18+ code.",
|
|
5
5
|
"author": "Ruihong Zhong (Ryan John)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"jsx",
|
|
36
36
|
"sfc",
|
|
37
37
|
"veaury",
|
|
38
|
+
"vuera",
|
|
38
39
|
"mitosis",
|
|
39
40
|
"vue3-to-react",
|
|
40
41
|
"vue-react",
|
|
@@ -51,14 +52,14 @@
|
|
|
51
52
|
"homepage": "https://vureact.top",
|
|
52
53
|
"repository": {
|
|
53
54
|
"type": "git",
|
|
54
|
-
"url": "https://github.com/vureact-js/core.git",
|
|
55
|
+
"url": "git+https://github.com/vureact-js/core.git",
|
|
55
56
|
"directory": "packages/compiler-core"
|
|
56
57
|
},
|
|
57
58
|
"bugs": {
|
|
58
59
|
"url": "https://github.com/vureact-js/core/issues"
|
|
59
60
|
},
|
|
60
61
|
"bin": {
|
|
61
|
-
"vureact": "
|
|
62
|
+
"vureact": "bin/vureact.js"
|
|
62
63
|
},
|
|
63
64
|
"scripts": {
|
|
64
65
|
"build": "tsup",
|
|
@@ -97,4 +98,4 @@
|
|
|
97
98
|
"engines": {
|
|
98
99
|
"node": ">=19.0.0"
|
|
99
100
|
}
|
|
100
|
-
}
|
|
101
|
+
}
|