@vureact/compiler-core 1.4.0 → 1.5.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 +286 -0
- package/README.md +76 -74
- package/lib/{chunk-NF5BSPYE.esm.js → chunk-IGLKQRRZ.esm.js} +296 -110
- package/lib/{chunk-IVRFEV6H.js → chunk-TSGO73AO.js} +419 -233
- package/lib/cli.esm.js +2 -2
- package/lib/cli.js +10 -10
- package/lib/compiler-core.d.cts +21 -195
- package/lib/compiler-core.d.ts +21 -195
- package/lib/compiler-core.esm.js +2 -2
- package/lib/compiler-core.js +3 -3
- package/package.json +99 -99
- package/README.zh.md +0 -284
|
@@ -1,5 +1,5 @@
|
|
|
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;/**
|
|
2
|
-
* @vureact/compiler-core v1.
|
|
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.5.0
|
|
3
3
|
* (c) 2025-present Ruihong Zhong (Ryan John)
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -35,11 +35,11 @@ var PACKAGE_NAME = {
|
|
|
35
35
|
var RUNTIME_PACKAGES = {
|
|
36
36
|
router: {
|
|
37
37
|
name: PACKAGE_NAME.router,
|
|
38
|
-
version: "^
|
|
38
|
+
version: "^2.0.1"
|
|
39
39
|
},
|
|
40
40
|
runtime: {
|
|
41
41
|
name: PACKAGE_NAME.runtime,
|
|
42
|
-
version: "^1.0.
|
|
42
|
+
version: "^1.0.1"
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
var STYLE_MODULE_NAME = "$style";
|
|
@@ -1827,12 +1827,6 @@ function resolveStyles(descriptor, ctx, result) {
|
|
|
1827
1827
|
{ file: filename }
|
|
1828
1828
|
);
|
|
1829
1829
|
}
|
|
1830
|
-
if (content.includes("@import")) {
|
|
1831
|
-
logger.warn(
|
|
1832
|
-
"Detected @import in scoped style. Imported styles remain global. Consider inlining them to preserve scoping.",
|
|
1833
|
-
{ file: filename }
|
|
1834
|
-
);
|
|
1835
|
-
}
|
|
1836
1830
|
const { code, fileExt } = resolveLessSass(content, {
|
|
1837
1831
|
lang,
|
|
1838
1832
|
filename,
|
|
@@ -1959,7 +1953,7 @@ function insertCSSImport(ctx) {
|
|
|
1959
1953
|
scriptIR.imports.push(importDecl);
|
|
1960
1954
|
}
|
|
1961
1955
|
|
|
1962
|
-
// src/core/transform/sfc/script/syntax-processor/postprocess/
|
|
1956
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-required-imports/index.ts
|
|
1963
1957
|
|
|
1964
1958
|
|
|
1965
1959
|
// src/core/transform/shared.ts
|
|
@@ -1991,51 +1985,147 @@ function replaceVueSuffix(ctx, node) {
|
|
|
1991
1985
|
node.extra = { rawValue: jsxFile, raw: jsxFile };
|
|
1992
1986
|
}
|
|
1993
1987
|
|
|
1994
|
-
// src/core/transform/sfc/script/syntax-processor/postprocess/
|
|
1995
|
-
|
|
1988
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-required-imports/import-strategies.ts
|
|
1989
|
+
var VueRouterStrategy = class {
|
|
1990
|
+
matches(moduleName) {
|
|
1991
|
+
return moduleName === "vue-router" || moduleName.startsWith("vue-router/");
|
|
1992
|
+
}
|
|
1993
|
+
process() {
|
|
1994
|
+
return {
|
|
1995
|
+
shouldReplaceSource: true,
|
|
1996
|
+
newSource: PACKAGE_NAME.router,
|
|
1997
|
+
shouldRemove: false,
|
|
1998
|
+
shouldInjectRuntimeImports: false
|
|
1999
|
+
};
|
|
2000
|
+
}
|
|
2001
|
+
};
|
|
2002
|
+
var VueEcosystemStrategy = class {
|
|
2003
|
+
matches(moduleName) {
|
|
2004
|
+
if (moduleName.startsWith(".") || moduleName.startsWith("/") || moduleName.startsWith("file:")) {
|
|
2005
|
+
return false;
|
|
2006
|
+
}
|
|
2007
|
+
if (moduleName === "vue-router" || moduleName.startsWith("vue-router/")) {
|
|
2008
|
+
return false;
|
|
2009
|
+
}
|
|
2010
|
+
if (moduleName.startsWith("@vue/")) {
|
|
2011
|
+
return true;
|
|
2012
|
+
}
|
|
2013
|
+
for (const pkg of VUE_PACKAGES) {
|
|
2014
|
+
if (moduleName === pkg || moduleName.startsWith(`${pkg}/`)) {
|
|
2015
|
+
return true;
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
return false;
|
|
2019
|
+
}
|
|
2020
|
+
process() {
|
|
2021
|
+
return {
|
|
2022
|
+
shouldReplaceSource: false,
|
|
2023
|
+
shouldRemove: true,
|
|
2024
|
+
shouldInjectRuntimeImports: true
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
};
|
|
2028
|
+
var StyleFileStrategy = (_class3 = class {constructor() { _class3.prototype.__init5.call(this); }
|
|
2029
|
+
__init5() {this.regExp = /\.(less|sass|scss)$/i}
|
|
2030
|
+
matches(moduleName) {
|
|
2031
|
+
return this.regExp.test(moduleName);
|
|
2032
|
+
}
|
|
2033
|
+
process(path9, ctx) {
|
|
2034
|
+
if (!ctx.preprocessStyles) {
|
|
2035
|
+
return {};
|
|
2036
|
+
}
|
|
2037
|
+
const importSource = path9.node.source.value;
|
|
2038
|
+
if (typeof importSource !== "string") {
|
|
2039
|
+
return {};
|
|
2040
|
+
}
|
|
2041
|
+
return {
|
|
2042
|
+
shouldReplaceSource: true,
|
|
2043
|
+
newSource: importSource.replace(this.regExp, ".css"),
|
|
2044
|
+
shouldRemove: false,
|
|
2045
|
+
shouldInjectRuntimeImports: false
|
|
2046
|
+
};
|
|
2047
|
+
}
|
|
2048
|
+
}, _class3);
|
|
2049
|
+
|
|
2050
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-required-imports/import-strategy-manager.ts
|
|
2051
|
+
var ImportStrategyManager = (_class4 = class {
|
|
2052
|
+
__init6() {this.strategies = []}
|
|
2053
|
+
constructor() {;_class4.prototype.__init6.call(this);
|
|
2054
|
+
this.strategies.push(new VueRouterStrategy());
|
|
2055
|
+
this.strategies.push(new VueEcosystemStrategy());
|
|
2056
|
+
this.strategies.push(new StyleFileStrategy());
|
|
2057
|
+
}
|
|
2058
|
+
/** 添加自定义策略 */
|
|
2059
|
+
addStrategy(strategy) {
|
|
2060
|
+
this.strategies.push(strategy);
|
|
2061
|
+
}
|
|
2062
|
+
/** 查找匹配的策略 */
|
|
2063
|
+
findStrategy(moduleName) {
|
|
2064
|
+
for (const strategy of this.strategies) {
|
|
2065
|
+
if (strategy.matches(moduleName)) {
|
|
2066
|
+
return strategy;
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
return null;
|
|
2070
|
+
}
|
|
2071
|
+
}, _class4);
|
|
2072
|
+
|
|
2073
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-required-imports/index.ts
|
|
2074
|
+
function resolveRequiredImports(ctx) {
|
|
1996
2075
|
const processedModules = /* @__PURE__ */ new Set();
|
|
1997
2076
|
let hasProcessedImports = false;
|
|
1998
|
-
|
|
2077
|
+
const strategyManager = new ImportStrategyManager();
|
|
2078
|
+
if (ctx.inputType === "sfc") {
|
|
2079
|
+
recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.memo);
|
|
2080
|
+
}
|
|
1999
2081
|
function resolveRequiredImport(path9) {
|
|
2000
2082
|
const { node } = path9;
|
|
2001
|
-
const
|
|
2002
|
-
const
|
|
2003
|
-
|
|
2004
|
-
|
|
2083
|
+
const originalModuleName = node.source.value.toLowerCase();
|
|
2084
|
+
const strategy = strategyManager.findStrategy(originalModuleName);
|
|
2085
|
+
if (strategy) {
|
|
2086
|
+
const result = strategy.process(path9, ctx, originalModuleName);
|
|
2087
|
+
if (result.shouldReplaceSource && result.newSource) {
|
|
2088
|
+
node.source.value = result.newSource;
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
const normalizedModuleName = node.source.value.toLowerCase();
|
|
2092
|
+
mergeImports(node, ctx, normalizedModuleName);
|
|
2093
|
+
if (processedModules.has(normalizedModuleName) && !path9.removed) {
|
|
2005
2094
|
path9.remove();
|
|
2006
2095
|
return;
|
|
2007
2096
|
}
|
|
2008
|
-
processedModules.add(
|
|
2097
|
+
processedModules.add(normalizedModuleName);
|
|
2009
2098
|
if (!hasProcessedImports) {
|
|
2010
2099
|
const required = createRequiredImports(ctx);
|
|
2011
|
-
if (
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2100
|
+
if (strategy) {
|
|
2101
|
+
const result = strategy.process(path9, ctx, originalModuleName);
|
|
2102
|
+
if (result.shouldRemove) {
|
|
2103
|
+
path9.replaceWithMultiple(required);
|
|
2104
|
+
} else if (normalizedModuleName === PACKAGE_NAME.react) {
|
|
2105
|
+
path9.insertAfter(required);
|
|
2106
|
+
} else {
|
|
2107
|
+
path9.insertBefore(required);
|
|
2108
|
+
}
|
|
2015
2109
|
} else {
|
|
2016
|
-
|
|
2110
|
+
if (normalizedModuleName === PACKAGE_NAME.react) {
|
|
2111
|
+
path9.insertAfter(required);
|
|
2112
|
+
} else {
|
|
2113
|
+
path9.insertBefore(required);
|
|
2114
|
+
}
|
|
2017
2115
|
}
|
|
2018
2116
|
hasProcessedImports = true;
|
|
2019
2117
|
}
|
|
2020
|
-
if (
|
|
2021
|
-
|
|
2022
|
-
|
|
2118
|
+
if (strategy) {
|
|
2119
|
+
const result = strategy.process(path9, ctx, originalModuleName);
|
|
2120
|
+
if (result.shouldRemove && !path9.removed) {
|
|
2121
|
+
path9.remove();
|
|
2122
|
+
return;
|
|
2123
|
+
}
|
|
2023
2124
|
}
|
|
2024
2125
|
replaceVueSuffix(ctx, node.source);
|
|
2025
2126
|
}
|
|
2026
|
-
function resolveStyleFileExt(path9) {
|
|
2027
|
-
if (!ctx.preprocessStyles) return;
|
|
2028
|
-
const { node } = path9;
|
|
2029
|
-
if (!node || !node.source || !node.source.value) return;
|
|
2030
|
-
const importSource = node.source.value;
|
|
2031
|
-
if (typeof importSource !== "string") return;
|
|
2032
|
-
const styleExtRegex = /\.(less|sass|scss)$/i;
|
|
2033
|
-
if (!styleExtRegex.test(importSource)) return;
|
|
2034
|
-
const newSource = importSource.replace(styleExtRegex, ".css");
|
|
2035
|
-
node.source.value = newSource;
|
|
2036
|
-
}
|
|
2037
2127
|
return {
|
|
2038
|
-
//
|
|
2128
|
+
// 兜底:无 ImportDeclaration 的文件也要能注入必需依赖。
|
|
2039
2129
|
Program: {
|
|
2040
2130
|
exit(path9) {
|
|
2041
2131
|
if (hasProcessedImports) return;
|
|
@@ -2046,24 +2136,10 @@ function insertRequiredImports(ctx) {
|
|
|
2046
2136
|
},
|
|
2047
2137
|
ImportDeclaration(path9) {
|
|
2048
2138
|
resolveRequiredImport(path9);
|
|
2049
|
-
resolveStyleFileExt(path9);
|
|
2050
2139
|
}
|
|
2051
2140
|
};
|
|
2052
2141
|
}
|
|
2053
|
-
function
|
|
2054
|
-
if (moduleName.startsWith(".") || moduleName.startsWith("/") || moduleName.startsWith("file:")) {
|
|
2055
|
-
return false;
|
|
2056
|
-
}
|
|
2057
|
-
if (moduleName.startsWith("@vue/")) {
|
|
2058
|
-
return true;
|
|
2059
|
-
}
|
|
2060
|
-
if (moduleName === "vue-router" || moduleName.startsWith("vue-router/")) {
|
|
2061
|
-
return true;
|
|
2062
|
-
}
|
|
2063
|
-
return VUE_PACKAGES.some((name) => moduleName === name || moduleName.startsWith(`${name}/`));
|
|
2064
|
-
}
|
|
2065
|
-
function mergeImports(currentNode, ctx) {
|
|
2066
|
-
const moduleName = currentNode.source.value.toLowerCase();
|
|
2142
|
+
function mergeImports(currentNode, ctx, moduleName) {
|
|
2067
2143
|
const ctxImportItems = ctx.imports.get(moduleName);
|
|
2068
2144
|
if (!_optionalChain([ctxImportItems, 'optionalAccess', _58 => _58.length])) {
|
|
2069
2145
|
return;
|
|
@@ -2078,7 +2154,9 @@ function mergeImports(currentNode, ctx) {
|
|
|
2078
2154
|
}
|
|
2079
2155
|
}
|
|
2080
2156
|
for (const item of ctxImportItems) {
|
|
2081
|
-
if (currentImports.has(item.name))
|
|
2157
|
+
if (currentImports.has(item.name)) {
|
|
2158
|
+
continue;
|
|
2159
|
+
}
|
|
2082
2160
|
const local = t18.identifier(item.name);
|
|
2083
2161
|
const newNode = !item.onDemand ? t18.importDefaultSpecifier(local) : t18.importSpecifier(local, local);
|
|
2084
2162
|
currentNode.specifiers.push(newNode);
|
|
@@ -3171,6 +3249,9 @@ var SLOT_DEFAULT_NAME = "default";
|
|
|
3171
3249
|
var SLOT_CHILDREN_NAME = "children";
|
|
3172
3250
|
var SLOT_FN_PARAM_NAME = "props";
|
|
3173
3251
|
function resolveSlotsTopLevelTypes(ctx) {
|
|
3252
|
+
if (ctx.inputType !== "sfc") {
|
|
3253
|
+
return {};
|
|
3254
|
+
}
|
|
3174
3255
|
return {
|
|
3175
3256
|
"TSInterfaceDeclaration|TSTypeAliasDeclaration"(path9) {
|
|
3176
3257
|
if (!t29.isProgram(path9.parent)) return;
|
|
@@ -3736,6 +3817,9 @@ function resolveAnalysisOnlyAdapter(ctx) {
|
|
|
3736
3817
|
if (!adapter || adapter.type !== "analyzed-deps") {
|
|
3737
3818
|
return;
|
|
3738
3819
|
}
|
|
3820
|
+
if (!isVueApiReference(path9, apiName)) {
|
|
3821
|
+
return;
|
|
3822
|
+
}
|
|
3739
3823
|
if (t32.isCallExpression(node)) {
|
|
3740
3824
|
resolveCallNode(path9, adapter, ctx);
|
|
3741
3825
|
} else {
|
|
@@ -3769,6 +3853,41 @@ function resolveCallNode(path9, adapter, ctx) {
|
|
|
3769
3853
|
replaceCallName(node, adapter.target);
|
|
3770
3854
|
recordImport(ctx, adapter.package, adapter.target);
|
|
3771
3855
|
}
|
|
3856
|
+
function isVueApiReference(path9, apiName) {
|
|
3857
|
+
if (path9.isIdentifier()) {
|
|
3858
|
+
if (path9.parentPath.isCallExpression() && path9.parentPath.node.callee === path9.node) {
|
|
3859
|
+
return false;
|
|
3860
|
+
}
|
|
3861
|
+
if (!path9.isReferencedIdentifier()) {
|
|
3862
|
+
return false;
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
if (path9.isCallExpression()) {
|
|
3866
|
+
const callee = path9.get("callee");
|
|
3867
|
+
if (!callee.isIdentifier()) return false;
|
|
3868
|
+
return isVueImportBinding(callee.scope.getBinding(apiName));
|
|
3869
|
+
}
|
|
3870
|
+
return isVueImportBinding(path9.scope.getBinding(apiName));
|
|
3871
|
+
}
|
|
3872
|
+
function isVueImportBinding(binding) {
|
|
3873
|
+
if (!binding) return false;
|
|
3874
|
+
const bindingPath = binding.path;
|
|
3875
|
+
if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
|
|
3876
|
+
return false;
|
|
3877
|
+
}
|
|
3878
|
+
const parent = _optionalChain([bindingPath, 'access', _97 => _97.parentPath, 'optionalAccess', _98 => _98.node]);
|
|
3879
|
+
if (!parent || !t32.isImportDeclaration(parent)) {
|
|
3880
|
+
return false;
|
|
3881
|
+
}
|
|
3882
|
+
const source = parent.source.value.toLowerCase();
|
|
3883
|
+
if (source.startsWith("@vue/")) {
|
|
3884
|
+
return true;
|
|
3885
|
+
}
|
|
3886
|
+
if (source === "vue-router" || source.startsWith("vue-router/")) {
|
|
3887
|
+
return true;
|
|
3888
|
+
}
|
|
3889
|
+
return VUE_PACKAGES.some((name) => source === name || source.startsWith(`${name}/`));
|
|
3890
|
+
}
|
|
3772
3891
|
|
|
3773
3892
|
// src/core/transform/sfc/script/syntax-processor/process/resolve-arrow-deps.ts
|
|
3774
3893
|
function resolveArrowFnDeps(ctx, ast) {
|
|
@@ -3783,7 +3902,7 @@ function resolveArrowFnDeps(ctx, ast) {
|
|
|
3783
3902
|
const newNode = createUseCallback(node, deps);
|
|
3784
3903
|
const declaratorPath = getVariableDeclaratorPath(path9);
|
|
3785
3904
|
recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useCallback);
|
|
3786
|
-
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess',
|
|
3905
|
+
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _99 => _99.node]), { is_reactive: true, reactive_type: "indirect" });
|
|
3787
3906
|
path9.replaceWith(newNode);
|
|
3788
3907
|
}
|
|
3789
3908
|
};
|
|
@@ -3842,8 +3961,8 @@ function resolveElementRef(ctx) {
|
|
|
3842
3961
|
return;
|
|
3843
3962
|
}
|
|
3844
3963
|
if (isCompRefBindings) {
|
|
3845
|
-
const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call',
|
|
3846
|
-
if (!t33.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess',
|
|
3964
|
+
const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call', _100 => _100(path9), 'optionalAccess', _101 => _101.node]);
|
|
3965
|
+
if (!t33.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess', _102 => _102.id]))) {
|
|
3847
3966
|
return;
|
|
3848
3967
|
}
|
|
3849
3968
|
const varName = varDeclaratorPath.id.name;
|
|
@@ -3866,7 +3985,7 @@ function resolveTypeParameters(ctx, path9) {
|
|
|
3866
3985
|
scriptData
|
|
3867
3986
|
} = ctx;
|
|
3868
3987
|
const { node } = path9;
|
|
3869
|
-
const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call',
|
|
3988
|
+
const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call', _103 => _103(path9), 'optionalAccess', _104 => _104.node]);
|
|
3870
3989
|
if (!scriptData.lang.startsWith("ts") || !varDeclaratorNode) {
|
|
3871
3990
|
return;
|
|
3872
3991
|
}
|
|
@@ -3884,11 +4003,11 @@ function resolveRefValueToCurrent(path9) {
|
|
|
3884
4003
|
return;
|
|
3885
4004
|
}
|
|
3886
4005
|
const rootPath = findRootVariablePath(path9);
|
|
3887
|
-
if (!_optionalChain([rootPath, 'optionalAccess',
|
|
4006
|
+
if (!_optionalChain([rootPath, 'optionalAccess', _105 => _105.node]) || !t33.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
|
|
3888
4007
|
return;
|
|
3889
4008
|
}
|
|
3890
4009
|
const rootId = findRootIdentifier(node);
|
|
3891
|
-
if (!t33.isIdentifier(node.object) || node.object.name !== _optionalChain([rootId, 'optionalAccess',
|
|
4010
|
+
if (!t33.isIdentifier(node.object) || node.object.name !== _optionalChain([rootId, 'optionalAccess', _106 => _106.name])) {
|
|
3892
4011
|
return;
|
|
3893
4012
|
}
|
|
3894
4013
|
node.property.name = "current";
|
|
@@ -3989,7 +4108,7 @@ function resolveProvide(ctx) {
|
|
|
3989
4108
|
return {
|
|
3990
4109
|
CallExpression(path9) {
|
|
3991
4110
|
const { node } = path9;
|
|
3992
|
-
const providerTarget = _optionalChain([ADAPTER_RULES, 'access',
|
|
4111
|
+
const providerTarget = _optionalChain([ADAPTER_RULES, 'access', _107 => _107.runtime, 'access', _108 => _108[VUE_API_MAP.provide], 'optionalAccess', _109 => _109.target]);
|
|
3993
4112
|
const isProvideCall = isCalleeNamed(node, VUE_API_MAP.provide) || providerTarget && isCalleeNamed(node, providerTarget);
|
|
3994
4113
|
if (!isProvideCall) return;
|
|
3995
4114
|
const { provide } = ctx.scriptData;
|
|
@@ -4007,7 +4126,7 @@ function findOrCreateCtxProvider(root) {
|
|
|
4007
4126
|
return root;
|
|
4008
4127
|
}
|
|
4009
4128
|
let cur = root.provide;
|
|
4010
|
-
while (_optionalChain([cur, 'optionalAccess',
|
|
4129
|
+
while (_optionalChain([cur, 'optionalAccess', _110 => _110.isOccupied])) {
|
|
4011
4130
|
cur = _nullishCoalesce(cur.provide, () => ( {}));
|
|
4012
4131
|
}
|
|
4013
4132
|
return cur || (root.provide = {});
|
|
@@ -4049,16 +4168,22 @@ function resolveRenameAdapter(ctx) {
|
|
|
4049
4168
|
} else if (isCallNode && t37.isIdentifier(node.callee)) {
|
|
4050
4169
|
apiName = node.callee.name;
|
|
4051
4170
|
}
|
|
4171
|
+
if (!apiName) {
|
|
4172
|
+
return;
|
|
4173
|
+
}
|
|
4052
4174
|
const runtimeAdapter = ADAPTER_RULES.runtime[apiName];
|
|
4053
4175
|
const routerAdapter = ADAPTER_RULES.router[apiName];
|
|
4054
4176
|
const adapter = runtimeAdapter || routerAdapter;
|
|
4055
4177
|
if (!adapter || adapter.type !== "rename") {
|
|
4056
4178
|
return;
|
|
4057
4179
|
}
|
|
4180
|
+
if (!isVueApiReference2(path9, apiName)) {
|
|
4181
|
+
return;
|
|
4182
|
+
}
|
|
4058
4183
|
if (adapter.isTrackable) {
|
|
4059
4184
|
const reactiveType = getReactiveType(apiName);
|
|
4060
4185
|
const declaratorPath = getVariableDeclaratorPath(path9);
|
|
4061
|
-
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess',
|
|
4186
|
+
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _111 => _111.node]), {
|
|
4062
4187
|
is_reactive: true,
|
|
4063
4188
|
reactive_type: reactiveType
|
|
4064
4189
|
});
|
|
@@ -4075,6 +4200,41 @@ function resolveRenameAdapter(ctx) {
|
|
|
4075
4200
|
}
|
|
4076
4201
|
};
|
|
4077
4202
|
}
|
|
4203
|
+
function isVueApiReference2(path9, apiName) {
|
|
4204
|
+
if (path9.isIdentifier()) {
|
|
4205
|
+
if (path9.parentPath.isCallExpression() && path9.parentPath.node.callee === path9.node) {
|
|
4206
|
+
return false;
|
|
4207
|
+
}
|
|
4208
|
+
if (!path9.isReferencedIdentifier()) {
|
|
4209
|
+
return false;
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
if (path9.isCallExpression()) {
|
|
4213
|
+
const callee = path9.get("callee");
|
|
4214
|
+
if (!callee.isIdentifier()) return false;
|
|
4215
|
+
return isVueImportBinding2(callee.scope.getBinding(apiName));
|
|
4216
|
+
}
|
|
4217
|
+
return isVueImportBinding2(path9.scope.getBinding(apiName));
|
|
4218
|
+
}
|
|
4219
|
+
function isVueImportBinding2(binding) {
|
|
4220
|
+
if (!binding) return false;
|
|
4221
|
+
const bindingPath = binding.path;
|
|
4222
|
+
if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
|
|
4223
|
+
return false;
|
|
4224
|
+
}
|
|
4225
|
+
const parent = _optionalChain([bindingPath, 'access', _112 => _112.parentPath, 'optionalAccess', _113 => _113.node]);
|
|
4226
|
+
if (!parent || !t37.isImportDeclaration(parent)) {
|
|
4227
|
+
return false;
|
|
4228
|
+
}
|
|
4229
|
+
const source = parent.source.value.toLowerCase();
|
|
4230
|
+
if (source.startsWith("@vue/")) {
|
|
4231
|
+
return true;
|
|
4232
|
+
}
|
|
4233
|
+
if (source === "vue-router" || source.startsWith("vue-router/")) {
|
|
4234
|
+
return true;
|
|
4235
|
+
}
|
|
4236
|
+
return VUE_PACKAGES.some((name) => source === name || source.startsWith(`${name}/`));
|
|
4237
|
+
}
|
|
4078
4238
|
|
|
4079
4239
|
// src/core/transform/sfc/script/syntax-processor/index.ts
|
|
4080
4240
|
function processVueSyntax2(ast, ctx) {
|
|
@@ -4106,19 +4266,19 @@ function processVueSyntax2(ast, ctx) {
|
|
|
4106
4266
|
excludeBabel: [resolveTemplateSlotIface, resolveCompIProps]
|
|
4107
4267
|
},
|
|
4108
4268
|
postprocess: {
|
|
4109
|
-
applyBabel: [
|
|
4269
|
+
applyBabel: [resolveRequiredImports, resolveStaticHoisting],
|
|
4110
4270
|
excludeBabel: [insertCSSImport, collectLocalStatements]
|
|
4111
4271
|
}
|
|
4112
4272
|
});
|
|
4113
4273
|
}
|
|
4114
4274
|
function vueSyntaxProcessor2(ast, ctx, options) {
|
|
4115
4275
|
const runExcludeThenApply = (cfg) => {
|
|
4116
|
-
_optionalChain([cfg, 'access',
|
|
4117
|
-
_optionalChain([cfg, 'access',
|
|
4276
|
+
_optionalChain([cfg, 'access', _114 => _114.excludeBabel, 'optionalAccess', _115 => _115.forEach, 'call', _116 => _116((fn) => fn(ctx, ast))]);
|
|
4277
|
+
_optionalChain([cfg, 'access', _117 => _117.applyBabel, 'optionalAccess', _118 => _118.forEach, 'call', _119 => _119((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
|
|
4118
4278
|
};
|
|
4119
4279
|
const runApplyThenExclude = (cfg) => {
|
|
4120
|
-
_optionalChain([cfg, 'access',
|
|
4121
|
-
_optionalChain([cfg, 'access',
|
|
4280
|
+
_optionalChain([cfg, 'access', _120 => _120.applyBabel, 'optionalAccess', _121 => _121.forEach, 'call', _122 => _122((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
|
|
4281
|
+
_optionalChain([cfg, 'access', _123 => _123.excludeBabel, 'optionalAccess', _124 => _124.forEach, 'call', _125 => _125((fn) => fn(ctx, ast))]);
|
|
4122
4282
|
};
|
|
4123
4283
|
runExcludeThenApply(options.preprocess);
|
|
4124
4284
|
runExcludeThenApply(options.process);
|
|
@@ -4247,7 +4407,7 @@ function isIdentifier20(code) {
|
|
|
4247
4407
|
function isStringLiteral12(code) {
|
|
4248
4408
|
try {
|
|
4249
4409
|
const node = _parser.parseExpression.call(void 0, code);
|
|
4250
|
-
return t38.isStringLiteral(node)
|
|
4410
|
+
return t38.isStringLiteral(node);
|
|
4251
4411
|
} catch (e9) {
|
|
4252
4412
|
return false;
|
|
4253
4413
|
}
|
|
@@ -4320,7 +4480,10 @@ function normalizePropName(rawName, name) {
|
|
|
4320
4480
|
case "for":
|
|
4321
4481
|
return "htmlFor";
|
|
4322
4482
|
default:
|
|
4323
|
-
|
|
4483
|
+
if (!isVBind(rawName) && whitelist.test(name)) {
|
|
4484
|
+
return name;
|
|
4485
|
+
}
|
|
4486
|
+
return camelCase(name);
|
|
4324
4487
|
}
|
|
4325
4488
|
}
|
|
4326
4489
|
function isVOn(name) {
|
|
@@ -4336,7 +4499,7 @@ function isVModel(name) {
|
|
|
4336
4499
|
return /^v-model/.test(_nullishCoalesce(name, () => ( "")));
|
|
4337
4500
|
}
|
|
4338
4501
|
function isClassAttr(name) {
|
|
4339
|
-
return /^(class|:class|v-bind:class|className)$/.test(_nullishCoalesce(name, () => ( "")));
|
|
4502
|
+
return /^(class|:class|v-bind:class|className|class-name)$/.test(_nullishCoalesce(name, () => ( "")));
|
|
4340
4503
|
}
|
|
4341
4504
|
function isStyleAttr(name) {
|
|
4342
4505
|
return /^(style|:style|v-bind:style)$/.test(_nullishCoalesce(name, () => ( "")));
|
|
@@ -4354,12 +4517,12 @@ function wrapSingleQuotes(content, condition) {
|
|
|
4354
4517
|
return condition || strCodeTypes.isStringLiteral(content) ? `'${content}'` : content;
|
|
4355
4518
|
}
|
|
4356
4519
|
function checkPropIsDynamicKey(ctx, node) {
|
|
4357
|
-
const isKeyStatic = _optionalChain([node, 'access',
|
|
4520
|
+
const isKeyStatic = _optionalChain([node, 'access', _126 => _126.arg, 'optionalAccess', _127 => _127.isStatic]);
|
|
4358
4521
|
const { source, filename } = ctx;
|
|
4359
4522
|
if (node.rawName === "v-bind" && !node.name) {
|
|
4360
4523
|
logger.warn("Keyless v-bind will overwrite all previously declared props at runtime.", {
|
|
4361
4524
|
source,
|
|
4362
|
-
loc: _optionalChain([node, 'access',
|
|
4525
|
+
loc: _optionalChain([node, 'access', _128 => _128.arg, 'optionalAccess', _129 => _129.loc]),
|
|
4363
4526
|
file: filename
|
|
4364
4527
|
});
|
|
4365
4528
|
return;
|
|
@@ -4367,7 +4530,7 @@ function checkPropIsDynamicKey(ctx, node) {
|
|
|
4367
4530
|
if (isKeyStatic === false) {
|
|
4368
4531
|
logger.warn("Avoid using dynamic slot names, as they generate complex JSX prop expressions.", {
|
|
4369
4532
|
source,
|
|
4370
|
-
loc: _optionalChain([node, 'access',
|
|
4533
|
+
loc: _optionalChain([node, 'access', _130 => _130.arg, 'optionalAccess', _131 => _131.loc]),
|
|
4371
4534
|
file: filename
|
|
4372
4535
|
});
|
|
4373
4536
|
}
|
|
@@ -4412,19 +4575,19 @@ function resolvePropAsBabelExp(ir, ctx) {
|
|
|
4412
4575
|
}
|
|
4413
4576
|
if (isClassAttr(name) && !value.isStringLiteral && !valueContent.startsWith(STYLE_MODULE_NAME)) {
|
|
4414
4577
|
const dirCls = ADAPTER_RULES.runtime.dirCls;
|
|
4415
|
-
const arg = _optionalChain([mergedItems, 'optionalAccess',
|
|
4578
|
+
const arg = _optionalChain([mergedItems, 'optionalAccess', _132 => _132.join, 'call', _133 => _133(",")]) || wrapSingleQuotes(valueContent);
|
|
4416
4579
|
const expression = createRuntimeCall(dirCls.target, [arg]);
|
|
4417
4580
|
applyRuntimeExpression(expression, true, name);
|
|
4418
4581
|
return;
|
|
4419
4582
|
}
|
|
4420
|
-
if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess',
|
|
4583
|
+
if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess', _134 => _134.some, 'call', _135 => _135((item) => !isSimpleStyle(item))]))) {
|
|
4421
4584
|
const dirStyle = ADAPTER_RULES.runtime.dirStyle;
|
|
4422
|
-
const arg = _optionalChain([mergedItems, 'optionalAccess',
|
|
4585
|
+
const arg = _optionalChain([mergedItems, 'optionalAccess', _136 => _136.join, 'call', _137 => _137(",")]) || valueContent;
|
|
4423
4586
|
const expression = createRuntimeCall(dirStyle.target, [arg]);
|
|
4424
4587
|
applyRuntimeExpression(expression, true, name);
|
|
4425
4588
|
return;
|
|
4426
4589
|
}
|
|
4427
|
-
if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access',
|
|
4590
|
+
if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access', _138 => _138.modifiers, 'optionalAccess', _139 => _139.length])) {
|
|
4428
4591
|
const dirOn = ADAPTER_RULES.runtime.dirOn;
|
|
4429
4592
|
const eventName = wrapSingleQuotes(ir.__vOnEvName || name, ir.isStatic);
|
|
4430
4593
|
const expression = createRuntimeCall(dirOn.target, [eventName, valueContent]);
|
|
@@ -4479,7 +4642,7 @@ function resolveElementChildrenRules(children, ctx, parentIR, ir) {
|
|
|
4479
4642
|
continue;
|
|
4480
4643
|
}
|
|
4481
4644
|
const nodeIR = child;
|
|
4482
|
-
if (_optionalChain([parentIR, 'optionalAccess',
|
|
4645
|
+
if (_optionalChain([parentIR, 'optionalAccess', _140 => _140.isBuiltIn])) {
|
|
4483
4646
|
if (parentIR.tag == VUE_API_MAP.Transition) {
|
|
4484
4647
|
resolveTransitionRules(nodeIR, parentIR, ir, ctx);
|
|
4485
4648
|
}
|
|
@@ -4520,7 +4683,7 @@ function walkElementNodes(node, onElement) {
|
|
|
4520
4683
|
}
|
|
4521
4684
|
function resolveDefaultStyleModuleName(node) {
|
|
4522
4685
|
const { exp } = node;
|
|
4523
|
-
if (_optionalChain([exp, 'optionalAccess',
|
|
4686
|
+
if (_optionalChain([exp, 'optionalAccess', _141 => _141.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
4524
4687
|
return;
|
|
4525
4688
|
}
|
|
4526
4689
|
if (exp.content.includes("$style")) {
|
|
@@ -4534,7 +4697,6 @@ function resolveDefaultStyleModuleName(node) {
|
|
|
4534
4697
|
|
|
4535
4698
|
|
|
4536
4699
|
|
|
4537
|
-
|
|
4538
4700
|
function resolveStyleScopeAttribute(node, _ir, ctx) {
|
|
4539
4701
|
if (!ctx.styleData.scopeId) {
|
|
4540
4702
|
return;
|
|
@@ -4554,21 +4716,30 @@ function walkElementNodes2(node, onElement) {
|
|
|
4554
4716
|
}
|
|
4555
4717
|
function injectStyleScopeAttribute(node, ctx) {
|
|
4556
4718
|
const { scopeId } = ctx.styleData;
|
|
4557
|
-
if (!scopeId ||
|
|
4719
|
+
if (!scopeId || _compilercore.isSlotOutlet.call(void 0, node) || _compilercore.isTemplateNode.call(void 0, node)) {
|
|
4558
4720
|
return;
|
|
4559
4721
|
}
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4722
|
+
let hasScopeId = false;
|
|
4723
|
+
let hasClassOrId = false;
|
|
4724
|
+
for (const prop of node.props) {
|
|
4725
|
+
if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
|
|
4726
|
+
if (prop.name === scopeId) {
|
|
4727
|
+
hasScopeId = true;
|
|
4728
|
+
break;
|
|
4729
|
+
}
|
|
4730
|
+
if (getHasClassOrId(prop.name)) {
|
|
4731
|
+
hasClassOrId = true;
|
|
4732
|
+
break;
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4735
|
+
if (prop.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([prop, 'access', _142 => _142.arg, 'optionalAccess', _143 => _143.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
4736
|
+
if (getHasClassOrId(prop.arg.content)) {
|
|
4737
|
+
hasClassOrId = true;
|
|
4738
|
+
break;
|
|
4739
|
+
}
|
|
4563
4740
|
}
|
|
4564
|
-
return prop.arg.content === "is";
|
|
4565
|
-
});
|
|
4566
|
-
const hasScopeId = node.props.some(
|
|
4567
|
-
(prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === scopeId
|
|
4568
|
-
);
|
|
4569
|
-
if (hasDynamicIs || hasScopeId) {
|
|
4570
|
-
return;
|
|
4571
4741
|
}
|
|
4742
|
+
if (hasScopeId || !hasClassOrId) return;
|
|
4572
4743
|
const attr = {
|
|
4573
4744
|
type: _compilercore.NodeTypes.ATTRIBUTE,
|
|
4574
4745
|
name: scopeId,
|
|
@@ -4578,11 +4749,8 @@ function injectStyleScopeAttribute(node, ctx) {
|
|
|
4578
4749
|
};
|
|
4579
4750
|
node.props.push(attr);
|
|
4580
4751
|
}
|
|
4581
|
-
function
|
|
4582
|
-
|
|
4583
|
-
return camelCase(node.tag) !== node.tag;
|
|
4584
|
-
}
|
|
4585
|
-
return node.tagType === _compilercore.ElementTypes.COMPONENT;
|
|
4752
|
+
function getHasClassOrId(ns) {
|
|
4753
|
+
return isClassAttr(ns) || ns === "id";
|
|
4586
4754
|
}
|
|
4587
4755
|
|
|
4588
4756
|
// src/core/transform/sfc/template/shared/prop-merge-utils.ts
|
|
@@ -4624,7 +4792,7 @@ function mergeStyleProps(oldAttr, newAttr) {
|
|
|
4624
4792
|
const oldStyle = oldAttr.value.content;
|
|
4625
4793
|
const newStyle = parseStyleString(newAttr.value.content);
|
|
4626
4794
|
let merged = oldAttr.value.merge;
|
|
4627
|
-
if (!_optionalChain([merged, 'optionalAccess',
|
|
4795
|
+
if (!_optionalChain([merged, 'optionalAccess', _144 => _144.length])) {
|
|
4628
4796
|
merged = oldAttr.value.merge = [oldStyle, newStyle];
|
|
4629
4797
|
} else {
|
|
4630
4798
|
merged.push(newStyle);
|
|
@@ -4654,7 +4822,7 @@ function warnUnsupportedVueDollarVar(ctx, node) {
|
|
|
4654
4822
|
const { source, filename } = ctx;
|
|
4655
4823
|
let value = "";
|
|
4656
4824
|
let loc;
|
|
4657
|
-
if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access',
|
|
4825
|
+
if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access', _145 => _145.exp, 'optionalAccess', _146 => _146.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
4658
4826
|
value = node.exp.content;
|
|
4659
4827
|
loc = node.exp.loc;
|
|
4660
4828
|
} else if (node.type === _compilercore.NodeTypes.INTERPOLATION && node.content.type === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
@@ -4708,11 +4876,11 @@ function resolveRefProp(node, ctx, nodeIR) {
|
|
|
4708
4876
|
} = ctx;
|
|
4709
4877
|
let propIR;
|
|
4710
4878
|
if (node.type === _compilercore.NodeTypes.ATTRIBUTE) {
|
|
4711
|
-
const tag = _optionalChain([node, 'access',
|
|
4879
|
+
const tag = _optionalChain([node, 'access', _147 => _147.value, 'optionalAccess', _148 => _148.content]);
|
|
4712
4880
|
if (!tag) return;
|
|
4713
4881
|
collectComponentRef(tag, ctx);
|
|
4714
4882
|
const domRefBinding = Object.values(refBindings.domRefs).find((r) => r.tag === tag);
|
|
4715
|
-
const refVar = _optionalChain([domRefBinding, 'optionalAccess',
|
|
4883
|
+
const refVar = _optionalChain([domRefBinding, 'optionalAccess', _149 => _149.name]) || _optionalChain([refBindings, 'access', _150 => _150.componentRefs, 'access', _151 => _151[tag], 'optionalAccess', _152 => _152.name]);
|
|
4716
4884
|
propIR = createPropsIR("ref", "ref", refVar || "null");
|
|
4717
4885
|
} else {
|
|
4718
4886
|
const exp = node.exp;
|
|
@@ -4747,8 +4915,8 @@ function collectComponentRef(tag, ctx) {
|
|
|
4747
4915
|
function resolveDynamicAttributeProp(node, ir, ctx, nodeIR) {
|
|
4748
4916
|
const arg = node.arg;
|
|
4749
4917
|
const exp = node.exp;
|
|
4750
|
-
const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
4751
|
-
const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
4918
|
+
const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _153 => _153.content]), () => ( ""));
|
|
4919
|
+
const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _154 => _154.content]), () => ( "true"));
|
|
4752
4920
|
warnUnsupportedVueDollarVar(ctx, node);
|
|
4753
4921
|
if (name === "is") {
|
|
4754
4922
|
resolveDynamicIsProp(node, ir, ctx, nodeIR);
|
|
@@ -4759,7 +4927,7 @@ function resolveDynamicAttributeProp(node, ir, ctx, nodeIR) {
|
|
|
4759
4927
|
return;
|
|
4760
4928
|
}
|
|
4761
4929
|
const dynamicPropIR = createPropsIR(node.rawName, name, content);
|
|
4762
|
-
dynamicPropIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
4930
|
+
dynamicPropIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _155 => _155.isStatic]), () => ( true));
|
|
4763
4931
|
checkPropIsDynamicKey(ctx, node);
|
|
4764
4932
|
resolvePropertyIR(dynamicPropIR, ir, ctx, nodeIR, true);
|
|
4765
4933
|
}
|
|
@@ -4773,7 +4941,12 @@ function resolvePropertyIR(node, ir, ctx, nodeIR, isDynamic = false) {
|
|
|
4773
4941
|
content = node.value.content = parseStyleString(content);
|
|
4774
4942
|
}
|
|
4775
4943
|
if (isDynamic) {
|
|
4776
|
-
|
|
4944
|
+
const isStringLiteral13 = strCodeTypes.isStringLiteral(content);
|
|
4945
|
+
if (isStringLiteral13) {
|
|
4946
|
+
content = normalizeString(content);
|
|
4947
|
+
node.value.content = content;
|
|
4948
|
+
}
|
|
4949
|
+
node.value.isStringLiteral = isStringLiteral13;
|
|
4777
4950
|
}
|
|
4778
4951
|
const existing = findSameProp(nodeIR.props, node);
|
|
4779
4952
|
if (existing) {
|
|
@@ -4783,11 +4956,17 @@ function resolvePropertyIR(node, ir, ctx, nodeIR, isDynamic = false) {
|
|
|
4783
4956
|
}
|
|
4784
4957
|
resolvePropAsBabelExp(_nullishCoalesce(existing, () => ( node)), ctx);
|
|
4785
4958
|
}
|
|
4959
|
+
function normalizeString(s) {
|
|
4960
|
+
if (s.startsWith("'") && s.endsWith("'")) {
|
|
4961
|
+
return s.slice(1, -1);
|
|
4962
|
+
}
|
|
4963
|
+
return s;
|
|
4964
|
+
}
|
|
4786
4965
|
|
|
4787
4966
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-attribute-prop.ts
|
|
4788
4967
|
function resolveAttributeProp(node, ir, ctx, nodeIR) {
|
|
4789
4968
|
const name = node.name;
|
|
4790
|
-
const content = _nullishCoalesce(_optionalChain([node, 'access',
|
|
4969
|
+
const content = _nullishCoalesce(_optionalChain([node, 'access', _156 => _156.value, 'optionalAccess', _157 => _157.content]), () => ( "true"));
|
|
4791
4970
|
if (name === "is") {
|
|
4792
4971
|
resolveStaticIsProp(content, ir, ctx, nodeIR);
|
|
4793
4972
|
return;
|
|
@@ -4811,10 +4990,10 @@ function resolveRouterLinkVSlotProp(node, nodeIR, ctx) {
|
|
|
4811
4990
|
type: 2 /* SLOT */,
|
|
4812
4991
|
name: "customRender",
|
|
4813
4992
|
rawName: _nullishCoalesce(node.rawName, () => ( "v-slot")),
|
|
4814
|
-
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
4993
|
+
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _158 => _158.isStatic]), () => ( true)),
|
|
4815
4994
|
isScoped: true,
|
|
4816
4995
|
callback: {
|
|
4817
|
-
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
4996
|
+
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _159 => _159.content, 'optionalAccess', _160 => _160.trim, 'call', _161 => _161()]), () => ( "")),
|
|
4818
4997
|
exp: []
|
|
4819
4998
|
}
|
|
4820
4999
|
};
|
|
@@ -4830,10 +5009,10 @@ function resolveVFor(node, _ir, _ctx, nodeIR) {
|
|
|
4830
5009
|
};
|
|
4831
5010
|
}
|
|
4832
5011
|
function resolveForResult(forParseResult) {
|
|
4833
|
-
const source = _optionalChain([forParseResult, 'access',
|
|
4834
|
-
const value = _optionalChain([forParseResult, 'access',
|
|
4835
|
-
const index = _optionalChain([forParseResult, 'access',
|
|
4836
|
-
const key = _optionalChain([forParseResult, 'access',
|
|
5012
|
+
const source = _optionalChain([forParseResult, 'access', _162 => _162.source, 'optionalAccess', _163 => _163.content]);
|
|
5013
|
+
const value = _optionalChain([forParseResult, 'access', _164 => _164.value, 'optionalAccess', _165 => _165.content]);
|
|
5014
|
+
const index = _optionalChain([forParseResult, 'access', _166 => _166.index, 'optionalAccess', _167 => _167.content]);
|
|
5015
|
+
const key = _optionalChain([forParseResult, 'access', _168 => _168.key, 'optionalAccess', _169 => _169.content]);
|
|
4837
5016
|
return {
|
|
4838
5017
|
source,
|
|
4839
5018
|
value,
|
|
@@ -4853,7 +5032,7 @@ function resolveVHtml(node, ir, ctx, nodeIR) {
|
|
|
4853
5032
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-if.ts
|
|
4854
5033
|
function resolveVIf(node, _ir, ctx, nodeIR, siblingNodesIR) {
|
|
4855
5034
|
const name = node.name === "else-if" ? "elseIf" : node.name;
|
|
4856
|
-
const value = _nullishCoalesce(_optionalChain([node, 'access',
|
|
5035
|
+
const value = _nullishCoalesce(_optionalChain([node, 'access', _170 => _170.exp, 'optionalAccess', _171 => _171.content]), () => ( "true"));
|
|
4857
5036
|
const prevNode = siblingNodesIR[siblingNodesIR.length - 1];
|
|
4858
5037
|
const isElseBranch = name === "else" || name === "elseIf";
|
|
4859
5038
|
let hasError = false;
|
|
@@ -4892,7 +5071,7 @@ function resolveVIf(node, _ir, ctx, nodeIR, siblingNodesIR) {
|
|
|
4892
5071
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-memo.ts
|
|
4893
5072
|
function resolveVMemo(node, _ir, ctx, nodeIR) {
|
|
4894
5073
|
const exp = node.exp;
|
|
4895
|
-
let value = _optionalChain([exp, 'optionalAccess',
|
|
5074
|
+
let value = _optionalChain([exp, 'optionalAccess', _172 => _172.content]);
|
|
4896
5075
|
if (value !== void 0) {
|
|
4897
5076
|
if (!value.trim() || !value.startsWith("[") && !value.endsWith("]")) {
|
|
4898
5077
|
const { source, filename } = ctx;
|
|
@@ -4932,14 +5111,14 @@ function resolveVModel(node, _ir, ctx, elementNode, nodeIR) {
|
|
|
4932
5111
|
const getterName = exp.content;
|
|
4933
5112
|
const isComponent = elementNode.tagType === _compilercore.ElementTypes.COMPONENT;
|
|
4934
5113
|
const inputType = resolveHtmlInput(elementNode, isComponent);
|
|
4935
|
-
const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5114
|
+
const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _173 => _173.content]), () => ( resolveModelPropName(inputType, isComponent)));
|
|
4936
5115
|
let valuePropIR;
|
|
4937
5116
|
let eventPropIR;
|
|
4938
5117
|
if (isComponent) {
|
|
4939
5118
|
valuePropIR = createPropsIR("v-model", propName, getterName);
|
|
4940
5119
|
const eventReactName = `onUpdate${capitalize(camelCase(propName))}`;
|
|
4941
5120
|
const eventVueName = `update:${propName}`;
|
|
4942
|
-
const isTS = _optionalChain([ctx, 'access',
|
|
5121
|
+
const isTS = _optionalChain([ctx, 'access', _174 => _174.scriptData, 'optionalAccess', _175 => _175.lang, 'optionalAccess', _176 => _176.startsWith, 'call', _177 => _177("ts")]);
|
|
4943
5122
|
const valueArg = isTS ? "value: any" : "value";
|
|
4944
5123
|
const processedValue = applyValueModifiers("value", modifiers);
|
|
4945
5124
|
const handlerBody = `(${valueArg}) => { ${getterName} = ${processedValue} }`;
|
|
@@ -4977,7 +5156,7 @@ function getRadioValue(elementNode) {
|
|
|
4977
5156
|
const valueAttr = elementNode.props.find(
|
|
4978
5157
|
(prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "value"
|
|
4979
5158
|
);
|
|
4980
|
-
if (!_optionalChain([valueAttr, 'optionalAccess',
|
|
5159
|
+
if (!_optionalChain([valueAttr, 'optionalAccess', _178 => _178.value, 'optionalAccess', _179 => _179.content])) return '""';
|
|
4981
5160
|
const content = valueAttr.value.content;
|
|
4982
5161
|
return /^['"]/.test(content) ? content : `"${content}"`;
|
|
4983
5162
|
}
|
|
@@ -4987,7 +5166,7 @@ function resolveHtmlInput(node, isComponent) {
|
|
|
4987
5166
|
const typeProp = node.props.find(
|
|
4988
5167
|
(prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "type"
|
|
4989
5168
|
);
|
|
4990
|
-
return _optionalChain([typeProp, 'optionalAccess',
|
|
5169
|
+
return _optionalChain([typeProp, 'optionalAccess', _180 => _180.value, 'optionalAccess', _181 => _181.content, 'optionalAccess', _182 => _182.toLowerCase, 'call', _183 => _183()]);
|
|
4991
5170
|
}
|
|
4992
5171
|
function applyValueModifiers(valueExp, modifiers) {
|
|
4993
5172
|
let result = valueExp;
|
|
@@ -5007,7 +5186,7 @@ function resolveVOn(node, _ir, ctx, nodeIR) {
|
|
|
5007
5186
|
const exp = node.exp;
|
|
5008
5187
|
const modifiers = node.modifiers.map((item) => item.content);
|
|
5009
5188
|
const captureIndex = modifiers.findIndex((modifier) => modifier === "capture");
|
|
5010
|
-
let eventName =
|
|
5189
|
+
let eventName = normalizeVOnEventName(arg.content);
|
|
5011
5190
|
let handler = resolveSpecialExpressions(exp.content.trim(), ctx);
|
|
5012
5191
|
if (captureIndex > -1) {
|
|
5013
5192
|
eventName = modifiers[captureIndex] ? `${eventName}Capture` : eventName;
|
|
@@ -5018,7 +5197,7 @@ function resolveVOn(node, _ir, ctx, nodeIR) {
|
|
|
5018
5197
|
originalVueEventName = `${arg.content}.${modifiers.join(".")}`;
|
|
5019
5198
|
} else {
|
|
5020
5199
|
const expr = stringToExpr(handler);
|
|
5021
|
-
if (!t40.isFunctionExpression(expr) && !t40.isIdentifier(expr)) {
|
|
5200
|
+
if (!t40.isFunctionExpression(expr) && !t40.isArrowFunctionExpression(expr) && !t40.isIdentifier(expr)) {
|
|
5022
5201
|
handler = `() => {${handler}}`;
|
|
5023
5202
|
}
|
|
5024
5203
|
}
|
|
@@ -5036,6 +5215,11 @@ function resolveVOn(node, _ir, ctx, nodeIR) {
|
|
|
5036
5215
|
}
|
|
5037
5216
|
nodeIR.props.push(eventIR);
|
|
5038
5217
|
}
|
|
5218
|
+
function normalizeVOnEventName(rawEventName) {
|
|
5219
|
+
const segments = rawEventName.split(/[:-]/g).map((segment) => segment.trim()).filter(Boolean);
|
|
5220
|
+
const normalized = segments.map((segment) => capitalize(camelCase(segment))).join("");
|
|
5221
|
+
return `on${normalized}`;
|
|
5222
|
+
}
|
|
5039
5223
|
|
|
5040
5224
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-show.ts
|
|
5041
5225
|
function resolveVShow(node, _ir, ctx, nodeIR) {
|
|
@@ -5186,7 +5370,7 @@ function resolveVSlotProp(node, _ir, ctx) {
|
|
|
5186
5370
|
const name = !arg || arg.content === "default" ? "children" : arg.content;
|
|
5187
5371
|
const content = !isScoped ? [] : void 0;
|
|
5188
5372
|
const callback = isScoped ? {
|
|
5189
|
-
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
5373
|
+
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _184 => _184.content, 'optionalAccess', _185 => _185.trim, 'call', _186 => _186()]), () => ( "")),
|
|
5190
5374
|
exp: []
|
|
5191
5375
|
} : void 0;
|
|
5192
5376
|
checkPropIsDynamicKey(ctx, node);
|
|
@@ -5194,7 +5378,7 @@ function resolveVSlotProp(node, _ir, ctx) {
|
|
|
5194
5378
|
type: 2 /* SLOT */,
|
|
5195
5379
|
name,
|
|
5196
5380
|
rawName: _nullishCoalesce(node.rawName, () => ( "default")),
|
|
5197
|
-
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5381
|
+
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _187 => _187.isStatic]), () => ( true)),
|
|
5198
5382
|
isScoped,
|
|
5199
5383
|
content,
|
|
5200
5384
|
callback
|
|
@@ -5228,7 +5412,7 @@ function resolveElementNode(node, ir, ctx, siblingNodesIR) {
|
|
|
5228
5412
|
if (routerAdapter) {
|
|
5229
5413
|
if (!ctx.route) ctx.route = true;
|
|
5230
5414
|
nodeIR.isRoute = true;
|
|
5231
|
-
recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess',
|
|
5415
|
+
recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess', _188 => _188.package]), routerAdapter.target);
|
|
5232
5416
|
}
|
|
5233
5417
|
resolveProps(node, ir, ctx, nodeIR, siblingNodesIR);
|
|
5234
5418
|
return nodeIR;
|
|
@@ -5364,7 +5548,7 @@ function resolveSlotProps(node, ctx) {
|
|
|
5364
5548
|
for (const prop of node.props) {
|
|
5365
5549
|
if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
|
|
5366
5550
|
const attr = prop.name;
|
|
5367
|
-
const value = _optionalChain([prop, 'access',
|
|
5551
|
+
const value = _optionalChain([prop, 'access', _189 => _189.value, 'optionalAccess', _190 => _190.content, 'access', _191 => _191.trim, 'call', _192 => _192()]);
|
|
5368
5552
|
if (attr === "name" && value) {
|
|
5369
5553
|
result.name = camelCase(value);
|
|
5370
5554
|
} else {
|
|
@@ -5454,19 +5638,19 @@ function resolveTemplate2(root, ctx) {
|
|
|
5454
5638
|
// src/core/transform/sfc/index.ts
|
|
5455
5639
|
function transform(ast, ctx, options) {
|
|
5456
5640
|
const { template, script, style } = ast;
|
|
5457
|
-
const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess',
|
|
5458
|
-
const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess',
|
|
5641
|
+
const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess', _193 => _193.ast]), ctx);
|
|
5642
|
+
const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess', _194 => _194.ast]), ctx);
|
|
5459
5643
|
const result = {
|
|
5460
5644
|
template: templateIR,
|
|
5461
5645
|
script: scriptIR,
|
|
5462
|
-
style: _optionalChain([style, 'optionalAccess',
|
|
5646
|
+
style: _optionalChain([style, 'optionalAccess', _195 => _195.source, 'optionalAccess', _196 => _196.content])
|
|
5463
5647
|
};
|
|
5464
|
-
executePlugins(_optionalChain([options, 'optionalAccess',
|
|
5648
|
+
executePlugins(_optionalChain([options, 'optionalAccess', _197 => _197.plugins]), result, ctx);
|
|
5465
5649
|
return result;
|
|
5466
5650
|
}
|
|
5467
5651
|
|
|
5468
5652
|
// package.json
|
|
5469
|
-
var version = "1.
|
|
5653
|
+
var version = "1.5.0";
|
|
5470
5654
|
var bin = {
|
|
5471
5655
|
vureact: "./bin/vureact.js"
|
|
5472
5656
|
};
|
|
@@ -5653,14 +5837,14 @@ var FileLockManager = class _FileLockManager {
|
|
|
5653
5837
|
var fileLock = FileLockManager.getInstance();
|
|
5654
5838
|
|
|
5655
5839
|
// src/compiler/shared/helper.ts
|
|
5656
|
-
var Helper = (
|
|
5840
|
+
var Helper = (_class5 = class {
|
|
5657
5841
|
|
|
5658
5842
|
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
constructor(opts) {;
|
|
5843
|
+
__init7() {this.workspaceDir = ".vureact"}
|
|
5844
|
+
__init8() {this.outDir = "react-app"}
|
|
5845
|
+
constructor(opts) {;_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);
|
|
5662
5846
|
this.compilerOpts = opts;
|
|
5663
|
-
if (_optionalChain([opts, 'access',
|
|
5847
|
+
if (_optionalChain([opts, 'access', _198 => _198.output, 'optionalAccess', _199 => _199.workspace])) {
|
|
5664
5848
|
this.workspaceDir = opts.output.workspace;
|
|
5665
5849
|
}
|
|
5666
5850
|
const excludePatterns = PathFilter.withDefaults(opts.exclude || []);
|
|
@@ -5697,7 +5881,7 @@ var Helper = (_class3 = class {
|
|
|
5697
5881
|
}
|
|
5698
5882
|
getOutDirName() {
|
|
5699
5883
|
const { output } = this.compilerOpts;
|
|
5700
|
-
return _optionalChain([output, 'optionalAccess',
|
|
5884
|
+
return _optionalChain([output, 'optionalAccess', _200 => _200.outDir]) || this.outDir;
|
|
5701
5885
|
}
|
|
5702
5886
|
getWorkspaceDir() {
|
|
5703
5887
|
return _path2.default.resolve(this.getProjectRoot(), this.workspaceDir);
|
|
@@ -5711,7 +5895,7 @@ var Helper = (_class3 = class {
|
|
|
5711
5895
|
}
|
|
5712
5896
|
getIgnoreAssets() {
|
|
5713
5897
|
const { output } = this.compilerOpts;
|
|
5714
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
5898
|
+
if (_optionalChain([output, 'optionalAccess', _201 => _201.ignoreAssets])) {
|
|
5715
5899
|
return new Set(output.ignoreAssets.map(normalizePath));
|
|
5716
5900
|
}
|
|
5717
5901
|
return /* @__PURE__ */ new Set([
|
|
@@ -5794,12 +5978,12 @@ var Helper = (_class3 = class {
|
|
|
5794
5978
|
*/
|
|
5795
5979
|
async formatCode({ code, fileInfo }) {
|
|
5796
5980
|
const { format } = this.compilerOpts;
|
|
5797
|
-
if (!_optionalChain([format, 'optionalAccess',
|
|
5798
|
-
if (_optionalChain([format, 'optionalAccess',
|
|
5981
|
+
if (!_optionalChain([format, 'optionalAccess', _202 => _202.enabled])) return code;
|
|
5982
|
+
if (_optionalChain([format, 'optionalAccess', _203 => _203.formatter]) === "builtin") {
|
|
5799
5983
|
return simpleFormat(code);
|
|
5800
5984
|
}
|
|
5801
|
-
const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess',
|
|
5802
|
-
return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess',
|
|
5985
|
+
const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess', _204 => _204.jsx]), () => ( _optionalChain([fileInfo, 'optionalAccess', _205 => _205.script])));
|
|
5986
|
+
return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess', _206 => _206.prettierOptions]));
|
|
5803
5987
|
}
|
|
5804
5988
|
/**
|
|
5805
5989
|
* 通用的缓存校验工具函数
|
|
@@ -5833,7 +6017,7 @@ var Helper = (_class3 = class {
|
|
|
5833
6017
|
* @param options.lock - 是否启用文件锁(默认false)
|
|
5834
6018
|
*/
|
|
5835
6019
|
async writeFileWithDir(filePath, content, options) {
|
|
5836
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
6020
|
+
if (_optionalChain([options, 'optionalAccess', _207 => _207.lock])) {
|
|
5837
6021
|
await fileLock.updateFile(filePath, async () => content, options);
|
|
5838
6022
|
} else {
|
|
5839
6023
|
await _fs2.default.promises.mkdir(_path2.default.dirname(filePath), { recursive: true });
|
|
@@ -5958,7 +6142,7 @@ var Helper = (_class3 = class {
|
|
|
5958
6142
|
* 获取需要排除编译的文件
|
|
5959
6143
|
*/
|
|
5960
6144
|
getExcludes() {
|
|
5961
|
-
if (!_optionalChain([this, 'access',
|
|
6145
|
+
if (!_optionalChain([this, 'access', _208 => _208.compilerOpts, 'access', _209 => _209.exclude, 'optionalAccess', _210 => _210.length])) {
|
|
5962
6146
|
return PathFilter.withDefaults();
|
|
5963
6147
|
}
|
|
5964
6148
|
return this.compilerOpts.exclude;
|
|
@@ -6025,7 +6209,7 @@ var Helper = (_class3 = class {
|
|
|
6025
6209
|
}
|
|
6026
6210
|
return normalizePath(relativePath2);
|
|
6027
6211
|
}
|
|
6028
|
-
},
|
|
6212
|
+
}, _class5);
|
|
6029
6213
|
|
|
6030
6214
|
// src/core/parse/style-only.ts
|
|
6031
6215
|
function parseOnlyStyle(source, ctx, options) {
|
|
@@ -6056,7 +6240,7 @@ function parseOnlyStyle(source, ctx, options) {
|
|
|
6056
6240
|
ast: void 0
|
|
6057
6241
|
}
|
|
6058
6242
|
};
|
|
6059
|
-
executePlugins(_optionalChain([options, 'optionalAccess',
|
|
6243
|
+
executePlugins(_optionalChain([options, 'optionalAccess', _211 => _211.plugins]), result, ctx);
|
|
6060
6244
|
return result;
|
|
6061
6245
|
}
|
|
6062
6246
|
|
|
@@ -6067,8 +6251,8 @@ function parseOnlyStyle(source, ctx, options) {
|
|
|
6067
6251
|
function createCompilationCtx() {
|
|
6068
6252
|
return new CompilationContext();
|
|
6069
6253
|
}
|
|
6070
|
-
var CompilationContext = (
|
|
6071
|
-
|
|
6254
|
+
var CompilationContext = (_class6 = class {constructor() { _class6.prototype.__init9.call(this); }
|
|
6255
|
+
__init9() {this.context = {}}
|
|
6072
6256
|
get data() {
|
|
6073
6257
|
return this.context;
|
|
6074
6258
|
}
|
|
@@ -6121,7 +6305,7 @@ var CompilationContext = (_class4 = class {constructor() { _class4.prototype.__i
|
|
|
6121
6305
|
}
|
|
6122
6306
|
};
|
|
6123
6307
|
}
|
|
6124
|
-
},
|
|
6308
|
+
}, _class6);
|
|
6125
6309
|
|
|
6126
6310
|
// src/compiler/context/adapter.ts
|
|
6127
6311
|
var CompilationAdapter = class _CompilationAdapter {
|
|
@@ -6168,12 +6352,12 @@ var CompilationAdapter = class _CompilationAdapter {
|
|
|
6168
6352
|
};
|
|
6169
6353
|
|
|
6170
6354
|
// src/compiler/shared/base-compiler.ts
|
|
6171
|
-
var BaseCompiler = (
|
|
6172
|
-
|
|
6355
|
+
var BaseCompiler = (_class7 = class extends Helper {
|
|
6356
|
+
__init10() {this.version = exports.version = version}
|
|
6173
6357
|
|
|
6174
|
-
|
|
6358
|
+
__init11() {this.createContext = CompilationAdapter.createContext}
|
|
6175
6359
|
constructor(options = {}) {
|
|
6176
|
-
super(options);
|
|
6360
|
+
super(options);_class7.prototype.__init10.call(this);_class7.prototype.__init11.call(this);;
|
|
6177
6361
|
this.options = options;
|
|
6178
6362
|
}
|
|
6179
6363
|
/** 编译 Vue 源代码为 React 代码 */
|
|
@@ -6188,16 +6372,16 @@ var BaseCompiler = (_class5 = class extends Helper {
|
|
|
6188
6372
|
});
|
|
6189
6373
|
const genOptions = this.prepareGenerateOptions(filename);
|
|
6190
6374
|
const resolveSFCAndScriptFile = () => {
|
|
6191
|
-
const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
6192
|
-
const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
6375
|
+
const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _212 => _212.parser]) });
|
|
6376
|
+
const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _213 => _213.transformer]) });
|
|
6193
6377
|
const gen = generate(ir, ctx.data, {
|
|
6194
6378
|
...genOptions,
|
|
6195
|
-
plugins: _optionalChain([plugins, 'optionalAccess',
|
|
6379
|
+
plugins: _optionalChain([plugins, 'optionalAccess', _214 => _214.codegen])
|
|
6196
6380
|
});
|
|
6197
6381
|
return this.resolveMainResult(ir, gen, ctx.data);
|
|
6198
6382
|
};
|
|
6199
6383
|
const resolveStyleFile = () => {
|
|
6200
|
-
const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
6384
|
+
const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _215 => _215.parser]) });
|
|
6201
6385
|
return this.resolveStyleResult(result, ctx.data);
|
|
6202
6386
|
};
|
|
6203
6387
|
try {
|
|
@@ -6244,9 +6428,9 @@ var BaseCompiler = (_class5 = class extends Helper {
|
|
|
6244
6428
|
lang
|
|
6245
6429
|
},
|
|
6246
6430
|
css: {
|
|
6247
|
-
file: _optionalChain([styleData, 'optionalAccess',
|
|
6248
|
-
hash: _optionalChain([styleData, 'optionalAccess',
|
|
6249
|
-
code: _optionalChain([ir, 'optionalAccess',
|
|
6431
|
+
file: _optionalChain([styleData, 'optionalAccess', _216 => _216.filePath]),
|
|
6432
|
+
hash: _optionalChain([styleData, 'optionalAccess', _217 => _217.scopeId]),
|
|
6433
|
+
code: _optionalChain([ir, 'optionalAccess', _218 => _218.style])
|
|
6250
6434
|
}
|
|
6251
6435
|
},
|
|
6252
6436
|
...base
|
|
@@ -6272,7 +6456,7 @@ var BaseCompiler = (_class5 = class extends Helper {
|
|
|
6272
6456
|
code: content
|
|
6273
6457
|
};
|
|
6274
6458
|
}
|
|
6275
|
-
},
|
|
6459
|
+
}, _class7);
|
|
6276
6460
|
|
|
6277
6461
|
// src/utils/calc-elapsed-time.ts
|
|
6278
6462
|
function calcElapsedTime(start) {
|
|
@@ -6295,14 +6479,14 @@ var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);
|
|
|
6295
6479
|
// src/compiler/shared/file-compiler/asset-manager.ts
|
|
6296
6480
|
|
|
6297
6481
|
|
|
6298
|
-
var AssetManager = (
|
|
6299
|
-
constructor(fileCompiler, cleanupManager) {;
|
|
6482
|
+
var AssetManager = (_class8 = class {
|
|
6483
|
+
constructor(fileCompiler, cleanupManager) {;_class8.prototype.__init12.call(this);_class8.prototype.__init13.call(this);
|
|
6300
6484
|
this.fileCompiler = fileCompiler;
|
|
6301
6485
|
this.cleanupManager = cleanupManager;
|
|
6302
6486
|
}
|
|
6303
6487
|
// 需要经过管线编译处理的文件类型
|
|
6304
|
-
|
|
6305
|
-
|
|
6488
|
+
__init12() {this.pipelineFiles = [".js", ".ts", ".less", ".scss", ".sass"]}
|
|
6489
|
+
__init13() {this.skippedCount = 0}
|
|
6306
6490
|
/**
|
|
6307
6491
|
* 运行资源文件处理管线
|
|
6308
6492
|
*/
|
|
@@ -6316,7 +6500,7 @@ var AssetManager = (_class6 = class {
|
|
|
6316
6500
|
const relativeToRoot = normalizePath(this.fileCompiler.relativePath(p));
|
|
6317
6501
|
const filename = _path2.default.basename(p).toLowerCase();
|
|
6318
6502
|
const ext = _path2.default.extname(p).toLowerCase();
|
|
6319
|
-
if (!_optionalChain([options, 'access',
|
|
6503
|
+
if (!_optionalChain([options, 'access', _219 => _219.output, 'optionalAccess', _220 => _220.ignoreAssets])) {
|
|
6320
6504
|
const shouldExclude = Array.from(exclusions).some((pattern) => {
|
|
6321
6505
|
if (pattern.endsWith(".")) {
|
|
6322
6506
|
return filename.startsWith(pattern);
|
|
@@ -6397,14 +6581,14 @@ var AssetManager = (_class6 = class {
|
|
|
6397
6581
|
resetSkippedCount() {
|
|
6398
6582
|
this.skippedCount = 0;
|
|
6399
6583
|
}
|
|
6400
|
-
},
|
|
6584
|
+
}, _class8);
|
|
6401
6585
|
|
|
6402
6586
|
// src/compiler/shared/file-compiler/cache-manager.ts
|
|
6403
|
-
var CacheManager = (
|
|
6404
|
-
constructor(fileCompiler) {;
|
|
6587
|
+
var CacheManager = (_class9 = class {
|
|
6588
|
+
constructor(fileCompiler) {;_class9.prototype.__init14.call(this);
|
|
6405
6589
|
this.fileCompiler = fileCompiler;
|
|
6406
6590
|
}
|
|
6407
|
-
|
|
6591
|
+
__init14() {this.pendingUpdates = /* @__PURE__ */ new Map()}
|
|
6408
6592
|
/**
|
|
6409
6593
|
* 批量更新缓存记录
|
|
6410
6594
|
*/
|
|
@@ -6413,12 +6597,12 @@ var CacheManager = (_class7 = class {
|
|
|
6413
6597
|
const meta = { ...unit };
|
|
6414
6598
|
delete meta.source;
|
|
6415
6599
|
if (key === "sfc" /* SFC */) {
|
|
6416
|
-
_optionalChainDelete([meta, 'access',
|
|
6417
|
-
_optionalChainDelete([meta, 'access',
|
|
6600
|
+
_optionalChainDelete([meta, 'access', _221 => _221.output, 'optionalAccess', _222 => _222.jsx, 'access', _223 => delete _223.code]);
|
|
6601
|
+
_optionalChainDelete([meta, 'access', _224 => _224.output, 'optionalAccess', _225 => _225.css, 'access', _226 => delete _226.code]);
|
|
6418
6602
|
} else if (key === "script" /* SCRIPT */) {
|
|
6419
|
-
_optionalChainDelete([meta, 'access',
|
|
6603
|
+
_optionalChainDelete([meta, 'access', _227 => _227.output, 'optionalAccess', _228 => _228.script, 'access', _229 => delete _229.code]);
|
|
6420
6604
|
} else if (key === "style" /* STYLE */) {
|
|
6421
|
-
_optionalChainDelete([meta, 'access',
|
|
6605
|
+
_optionalChainDelete([meta, 'access', _230 => _230.output, 'optionalAccess', _231 => _231.style, 'access', _232 => delete _232.code]);
|
|
6422
6606
|
}
|
|
6423
6607
|
if (!this.pendingUpdates.has(key)) {
|
|
6424
6608
|
this.pendingUpdates.set(key, []);
|
|
@@ -6452,7 +6636,7 @@ var CacheManager = (_class7 = class {
|
|
|
6452
6636
|
cache.target.push(newData);
|
|
6453
6637
|
}
|
|
6454
6638
|
}
|
|
6455
|
-
},
|
|
6639
|
+
}, _class9);
|
|
6456
6640
|
|
|
6457
6641
|
// src/compiler/shared/file-compiler/cleanup-manager.ts
|
|
6458
6642
|
|
|
@@ -6488,7 +6672,7 @@ var CleanupManager = class {
|
|
|
6488
6672
|
meta = m;
|
|
6489
6673
|
const { jsx, css } = meta.output;
|
|
6490
6674
|
await this.fileCompiler.removeOutputFile(jsx.file);
|
|
6491
|
-
if (_optionalChain([css, 'optionalAccess',
|
|
6675
|
+
if (_optionalChain([css, 'optionalAccess', _233 => _233.file])) {
|
|
6492
6676
|
await this.fileCompiler.removeOutputFile(css.file);
|
|
6493
6677
|
}
|
|
6494
6678
|
break;
|
|
@@ -6549,7 +6733,7 @@ var CompilationUnitProcessor = class {
|
|
|
6549
6733
|
const isScriptFile = key === "script" /* SCRIPT */;
|
|
6550
6734
|
const isStyleFile = key === "style" /* STYLE */;
|
|
6551
6735
|
if (isSFC || isScriptFile) {
|
|
6552
|
-
unit.hasRoute = _optionalChain([result, 'optionalAccess',
|
|
6736
|
+
unit.hasRoute = _optionalChain([result, 'optionalAccess', _234 => _234.hasRoute]);
|
|
6553
6737
|
}
|
|
6554
6738
|
const resolveFileInfo = () => {
|
|
6555
6739
|
if (isSFC) {
|
|
@@ -6569,7 +6753,7 @@ var CompilationUnitProcessor = class {
|
|
|
6569
6753
|
const { script } = result.fileInfo;
|
|
6570
6754
|
unit.output = {
|
|
6571
6755
|
script: {
|
|
6572
|
-
file: _optionalChain([script, 'optionalAccess',
|
|
6756
|
+
file: _optionalChain([script, 'optionalAccess', _235 => _235.file]),
|
|
6573
6757
|
code
|
|
6574
6758
|
}
|
|
6575
6759
|
};
|
|
@@ -6617,13 +6801,13 @@ var CompilationUnitProcessor = class {
|
|
|
6617
6801
|
|
|
6618
6802
|
|
|
6619
6803
|
|
|
6620
|
-
var FileProcessor = (
|
|
6621
|
-
constructor(fileCompiler, compilationUnitProcessor, cacheManager) {;
|
|
6804
|
+
var FileProcessor = (_class10 = class {
|
|
6805
|
+
constructor(fileCompiler, compilationUnitProcessor, cacheManager) {;_class10.prototype.__init15.call(this);
|
|
6622
6806
|
this.fileCompiler = fileCompiler;
|
|
6623
6807
|
this.compilationUnitProcessor = compilationUnitProcessor;
|
|
6624
6808
|
this.cacheManager = cacheManager;
|
|
6625
6809
|
}
|
|
6626
|
-
|
|
6810
|
+
__init15() {this.skippedCount = 0}
|
|
6627
6811
|
/**
|
|
6628
6812
|
* Process a single Vue file (this method is called directly in CLI Watch mode)
|
|
6629
6813
|
*/
|
|
@@ -6646,7 +6830,7 @@ var FileProcessor = (_class8 = class {
|
|
|
6646
6830
|
const absPath = this.fileCompiler.getAbsPath(filePath);
|
|
6647
6831
|
const fileMeta = await this.fileCompiler.getFileMeta(absPath);
|
|
6648
6832
|
const cache = (this.fileCompiler.getIsCache() ? existingCache : void 0) || await this.fileCompiler.loadCache(key);
|
|
6649
|
-
const record = _optionalChain([cache, 'optionalAccess',
|
|
6833
|
+
const record = _optionalChain([cache, 'optionalAccess', _236 => _236.target, 'access', _237 => _237.find, 'call', _238 => _238((c) => c.file === absPath)]);
|
|
6650
6834
|
const { shouldCompile, hash } = await this.fileCompiler.checkCacheStatus(
|
|
6651
6835
|
fileMeta,
|
|
6652
6836
|
record,
|
|
@@ -6668,10 +6852,10 @@ var FileProcessor = (_class8 = class {
|
|
|
6668
6852
|
hash: hash || this.fileCompiler.genHash(source)
|
|
6669
6853
|
};
|
|
6670
6854
|
const processed = await this.compilationUnitProcessor.resolve(initUnit, key);
|
|
6671
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
6855
|
+
if (_optionalChain([processed, 'optionalAccess', _239 => _239.output])) {
|
|
6672
6856
|
await this.compilationUnitProcessor.saveCompiledFiles(processed, key);
|
|
6673
6857
|
if (key === "sfc" /* SFC */ || key === "script" /* SCRIPT */) {
|
|
6674
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
6858
|
+
if (_optionalChain([processed, 'optionalAccess', _240 => _240.hasRoute])) {
|
|
6675
6859
|
await this.addRouterToPackageJson();
|
|
6676
6860
|
await this.updateEntryWithRouterProvider();
|
|
6677
6861
|
}
|
|
@@ -6685,13 +6869,13 @@ var FileProcessor = (_class8 = class {
|
|
|
6685
6869
|
*/
|
|
6686
6870
|
async addRouterToPackageJson() {
|
|
6687
6871
|
const { output } = this.fileCompiler.options;
|
|
6688
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
6872
|
+
if (_optionalChain([output, 'optionalAccess', _241 => _241.bootstrapVite]) === false) {
|
|
6689
6873
|
return;
|
|
6690
6874
|
}
|
|
6691
6875
|
const { router } = RUNTIME_PACKAGES;
|
|
6692
6876
|
const filePath = this.fileCompiler.getOutputPkgPath();
|
|
6693
6877
|
const packageJson = await this.fileCompiler.resolvePackageFile(filePath);
|
|
6694
|
-
if (_optionalChain([packageJson, 'optionalAccess',
|
|
6878
|
+
if (_optionalChain([packageJson, 'optionalAccess', _242 => _242.dependencies, 'optionalAccess', _243 => _243[router.name]])) {
|
|
6695
6879
|
return;
|
|
6696
6880
|
}
|
|
6697
6881
|
if (!packageJson.dependencies) {
|
|
@@ -6710,7 +6894,7 @@ var FileProcessor = (_class8 = class {
|
|
|
6710
6894
|
const { exclude, output, router } = this.fileCompiler.options;
|
|
6711
6895
|
const inputPath = this.fileCompiler.getInputPath();
|
|
6712
6896
|
const outputPath = this.fileCompiler.getOuputPath(true);
|
|
6713
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
6897
|
+
if (_optionalChain([output, 'optionalAccess', _244 => _244.bootstrapVite]) === false || _optionalChain([router, 'optionalAccess', _245 => _245.autoUpdateEntry]) === false || !_optionalChain([router, 'optionalAccess', _246 => _246.configFile])) {
|
|
6714
6898
|
return;
|
|
6715
6899
|
}
|
|
6716
6900
|
const getMainFile = async (filename) => {
|
|
@@ -6731,7 +6915,7 @@ var FileProcessor = (_class8 = class {
|
|
|
6731
6915
|
const prepareRouterEntry = () => {
|
|
6732
6916
|
const importPath = this.fileCompiler.resolveRelativePath(inputPath, router.configFile);
|
|
6733
6917
|
let content = fileData.content;
|
|
6734
|
-
if (_optionalChain([exclude, 'optionalAccess',
|
|
6918
|
+
if (_optionalChain([exclude, 'optionalAccess', _247 => _247.includes, 'call', _248 => _248(router.configFile)]) || _optionalChain([exclude, 'optionalAccess', _249 => _249.includes, 'call', _250 => _250(importPath)])) {
|
|
6735
6919
|
return content;
|
|
6736
6920
|
}
|
|
6737
6921
|
const routerModule = "RouterInstance";
|
|
@@ -6770,17 +6954,17 @@ ${routerImport}`);
|
|
|
6770
6954
|
resetSkippedCount() {
|
|
6771
6955
|
this.skippedCount = 0;
|
|
6772
6956
|
}
|
|
6773
|
-
},
|
|
6957
|
+
}, _class10);
|
|
6774
6958
|
|
|
6775
6959
|
// src/compiler/shared/file-compiler/pipeline-manager.ts
|
|
6776
6960
|
|
|
6777
|
-
var PipelineManager = (
|
|
6778
|
-
constructor(fileCompiler, fileProcessor) {;
|
|
6961
|
+
var PipelineManager = (_class11 = class {
|
|
6962
|
+
constructor(fileCompiler, fileProcessor) {;_class11.prototype.__init16.call(this);
|
|
6779
6963
|
this.fileCompiler = fileCompiler;
|
|
6780
6964
|
this.fileProcessor = fileProcessor;
|
|
6781
6965
|
this.cleanupManager = new CleanupManager(fileCompiler);
|
|
6782
6966
|
}
|
|
6783
|
-
|
|
6967
|
+
__init16() {this.skippedCount = 0}
|
|
6784
6968
|
|
|
6785
6969
|
/**
|
|
6786
6970
|
* 运行 SFC 编译管线
|
|
@@ -6842,20 +7026,20 @@ var PipelineManager = (_class9 = class {
|
|
|
6842
7026
|
resetSkippedCount() {
|
|
6843
7027
|
this.skippedCount = 0;
|
|
6844
7028
|
}
|
|
6845
|
-
},
|
|
7029
|
+
}, _class11);
|
|
6846
7030
|
|
|
6847
7031
|
// src/compiler/shared/file-compiler/vite-bootstrapper.ts
|
|
6848
7032
|
var _child_process = require('child_process');
|
|
6849
7033
|
|
|
6850
7034
|
|
|
6851
7035
|
|
|
6852
|
-
var ViteBootstrapper = (
|
|
6853
|
-
constructor(fileCompiler, options) {;
|
|
7036
|
+
var ViteBootstrapper = (_class12 = class {
|
|
7037
|
+
constructor(fileCompiler, options) {;_class12.prototype.__init17.call(this);_class12.prototype.__init18.call(this);
|
|
6854
7038
|
this.fileCompiler = fileCompiler;
|
|
6855
7039
|
this.options = options;
|
|
6856
7040
|
}
|
|
6857
|
-
|
|
6858
|
-
|
|
7041
|
+
__init17() {this.spinner = _ora2.default.call(void 0, )}
|
|
7042
|
+
__init18() {this.defaultConfig = {
|
|
6859
7043
|
template: "react-ts",
|
|
6860
7044
|
viteVersion: "@latest"
|
|
6861
7045
|
}}
|
|
@@ -6874,31 +7058,31 @@ var ViteBootstrapper = (_class10 = class {
|
|
|
6874
7058
|
* 利用 Vite 官方脚手架创建标准 React 环境
|
|
6875
7059
|
*/
|
|
6876
7060
|
async bootstrapIfNeeded() {
|
|
6877
|
-
const {
|
|
7061
|
+
const { output } = this.options;
|
|
6878
7062
|
const workspaceDir = this.fileCompiler.getWorkspaceDir();
|
|
6879
7063
|
await _fs2.default.promises.mkdir(workspaceDir, { recursive: true });
|
|
6880
|
-
if (bootstrapVite === false) {
|
|
7064
|
+
if (_optionalChain([output, 'optionalAccess', _251 => _251.bootstrapVite]) === false) {
|
|
6881
7065
|
return false;
|
|
6882
7066
|
}
|
|
6883
7067
|
if (this.isSingleFile()) {
|
|
6884
7068
|
console.info("Skipping Vite initialization for single file compilation");
|
|
6885
|
-
return
|
|
7069
|
+
return;
|
|
6886
7070
|
}
|
|
6887
7071
|
const outputPkgPath = this.fileCompiler.getOutputPkgPath();
|
|
6888
7072
|
if (_fs2.default.existsSync(outputPkgPath)) {
|
|
6889
|
-
return
|
|
7073
|
+
return;
|
|
6890
7074
|
}
|
|
6891
|
-
this.spinner.start("Bootstrapping Vite React environment...");
|
|
6892
7075
|
try {
|
|
7076
|
+
this.spinner.start("Bootstrapping Vite React environment...");
|
|
6893
7077
|
await this.resolveViteCreateApp();
|
|
6894
7078
|
} catch (err) {
|
|
6895
|
-
this.spinner.stop();
|
|
6896
7079
|
console.error(
|
|
6897
7080
|
_kleur2.default.red("\u2716"),
|
|
6898
|
-
"Failed to bootstrap Vite environment. Please check npm/network
|
|
7081
|
+
"Failed to bootstrap Vite environment. Please check npm/network.\n",
|
|
6899
7082
|
err
|
|
6900
7083
|
);
|
|
6901
|
-
|
|
7084
|
+
this.spinner.stop();
|
|
7085
|
+
return;
|
|
6902
7086
|
}
|
|
6903
7087
|
const removeVuePackages = (deps) => {
|
|
6904
7088
|
for (const name in deps) {
|
|
@@ -6920,15 +7104,15 @@ var ViteBootstrapper = (_class10 = class {
|
|
|
6920
7104
|
}
|
|
6921
7105
|
return deps;
|
|
6922
7106
|
};
|
|
6923
|
-
const
|
|
6924
|
-
const
|
|
6925
|
-
|
|
6926
|
-
const newDeps = resolveDeps(
|
|
6927
|
-
const newDevDeps = resolveDeps(
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
await this.fileCompiler.writeFileWithDir(outputPkgPath,
|
|
7107
|
+
const sourcePkgPath = this.fileCompiler.getRootPkgPath();
|
|
7108
|
+
const sourcePkg = await this.fileCompiler.resolvePackageFile(sourcePkgPath);
|
|
7109
|
+
let newPkg = await this.fileCompiler.resolvePackageFile(outputPkgPath);
|
|
7110
|
+
const newDeps = resolveDeps(sourcePkg.dependencies, newPkg.dependencies);
|
|
7111
|
+
const newDevDeps = resolveDeps(sourcePkg.devDependencies, newPkg.devDependencies, true);
|
|
7112
|
+
newPkg.dependencies = newDeps;
|
|
7113
|
+
newPkg.devDependencies = newDevDeps;
|
|
7114
|
+
newPkg = _optionalChain([output, 'optionalAccess', _252 => _252.packageJson, 'optionalCall', _253 => _253(newPkg)]) || newPkg;
|
|
7115
|
+
await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
|
|
6932
7116
|
this.spinner.succeed("Standard Vite React environment initialized");
|
|
6933
7117
|
return true;
|
|
6934
7118
|
}
|
|
@@ -6938,12 +7122,12 @@ var ViteBootstrapper = (_class10 = class {
|
|
|
6938
7122
|
async resolveViteCreateApp() {
|
|
6939
7123
|
const { output } = this.options;
|
|
6940
7124
|
const { viteVersion, template: tmpl } = this.defaultConfig;
|
|
6941
|
-
const bootstrapVite = _optionalChain([output, 'optionalAccess',
|
|
7125
|
+
const bootstrapVite = _optionalChain([output, 'optionalAccess', _254 => _254.bootstrapVite]);
|
|
6942
7126
|
const outDirName = this.fileCompiler.getOutDirName();
|
|
6943
7127
|
const configObject = typeof bootstrapVite === "object" ? bootstrapVite : null;
|
|
6944
|
-
const viteVer = _optionalChain([configObject, 'optionalAccess',
|
|
6945
|
-
const reactVer = _optionalChain([configObject, 'optionalAccess',
|
|
6946
|
-
const template = _optionalChain([configObject, 'optionalAccess',
|
|
7128
|
+
const viteVer = _optionalChain([configObject, 'optionalAccess', _255 => _255.vite]) || viteVersion;
|
|
7129
|
+
const reactVer = _optionalChain([configObject, 'optionalAccess', _256 => _256.react]);
|
|
7130
|
+
const template = _optionalChain([configObject, 'optionalAccess', _257 => _257.template]) || tmpl;
|
|
6947
7131
|
const cmd = `npm create vite${viteVer} ${outDirName} -- --template ${template}`;
|
|
6948
7132
|
_child_process.execSync.call(void 0, cmd, {
|
|
6949
7133
|
cwd: this.fileCompiler.getWorkspaceDir(),
|
|
@@ -6960,17 +7144,17 @@ var ViteBootstrapper = (_class10 = class {
|
|
|
6960
7144
|
*/
|
|
6961
7145
|
async resolveReactVersion(ver) {
|
|
6962
7146
|
const outputPkgPath = this.fileCompiler.getOutputPkgPath();
|
|
6963
|
-
const
|
|
6964
|
-
const
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
}
|
|
6973
|
-
},
|
|
7147
|
+
const curPkg = await this.fileCompiler.resolvePackageFile(outputPkgPath);
|
|
7148
|
+
const mainVer = Number(ver.split(".")[0]);
|
|
7149
|
+
const typeVer = !isNaN(mainVer) ? `^${mainVer.toString().replace(/@|\^|~|>=|>|/, "")}.0.0` : "^19.0.0";
|
|
7150
|
+
curPkg.dependencies.react = ver;
|
|
7151
|
+
curPkg.dependencies["react-dom"] = ver;
|
|
7152
|
+
curPkg.devDependencies["@types/react"] = typeVer;
|
|
7153
|
+
curPkg.devDependencies["@types/react-dom"] = typeVer;
|
|
7154
|
+
await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(curPkg, null, 2));
|
|
7155
|
+
return curPkg;
|
|
7156
|
+
}
|
|
7157
|
+
}, _class12);
|
|
6974
7158
|
|
|
6975
7159
|
// src/compiler/shared/file-compiler/setup-manager.ts
|
|
6976
7160
|
var SetupManager = class {
|
|
@@ -7024,11 +7208,11 @@ var SetupManager = class {
|
|
|
7024
7208
|
};
|
|
7025
7209
|
|
|
7026
7210
|
// src/compiler/shared/file-compiler/index.ts
|
|
7027
|
-
var FileCompiler = (
|
|
7211
|
+
var FileCompiler = (_class13 = class extends BaseCompiler {
|
|
7028
7212
|
|
|
7029
|
-
|
|
7213
|
+
__init19() {this.spinner = _ora2.default.call(void 0, )}
|
|
7030
7214
|
constructor(options = {}) {
|
|
7031
|
-
super(options);
|
|
7215
|
+
super(options);_class13.prototype.__init19.call(this);;
|
|
7032
7216
|
new SetupManager(() => this);
|
|
7033
7217
|
}
|
|
7034
7218
|
/** 执行完整的编译流程 */
|
|
@@ -7047,7 +7231,7 @@ var FileCompiler = (_class11 = class extends BaseCompiler {
|
|
|
7047
7231
|
const scriptCount = await this.runPipelineWithSpinner("script" /* SCRIPT */);
|
|
7048
7232
|
const styleCount = await this.runPipelineWithSpinner("style" /* STYLE */);
|
|
7049
7233
|
const assetCount = await this.runPipelineWithSpinner("copied" /* ASSET */);
|
|
7050
|
-
await _optionalChain([this, 'access',
|
|
7234
|
+
await _optionalChain([this, 'access', _258 => _258.options, 'access', _259 => _259.onSuccess, 'optionalCall', _260 => _260()]);
|
|
7051
7235
|
const endTime = calcElapsedTime(startTime);
|
|
7052
7236
|
this.printCoreLogs();
|
|
7053
7237
|
this.showCompileStats(endTime, sfcCount, scriptCount, styleCount, assetCount);
|
|
@@ -7056,7 +7240,9 @@ var FileCompiler = (_class11 = class extends BaseCompiler {
|
|
|
7056
7240
|
await rmWorkspace();
|
|
7057
7241
|
console.error(_kleur2.default.red("\u2716"), `Build failed in ${endTime}`);
|
|
7058
7242
|
console.error(error);
|
|
7243
|
+
process.exit(-1);
|
|
7059
7244
|
} finally {
|
|
7245
|
+
this.spinner.stop();
|
|
7060
7246
|
this.resetSkippedCount();
|
|
7061
7247
|
}
|
|
7062
7248
|
}
|
|
@@ -7155,7 +7341,7 @@ var FileCompiler = (_class11 = class extends BaseCompiler {
|
|
|
7155
7341
|
this.manager.pipelineManager.resetSkippedCount();
|
|
7156
7342
|
this.manager.assetManager.resetSkippedCount();
|
|
7157
7343
|
}
|
|
7158
|
-
},
|
|
7344
|
+
}, _class13);
|
|
7159
7345
|
|
|
7160
7346
|
// src/compiler/shared/define-config.ts
|
|
7161
7347
|
function defineConfig(config) {
|