@vureact/compiler-core 1.5.0 → 1.5.1
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 +16 -16
- package/README.md +15 -13
- package/lib/{chunk-TSGO73AO.js → chunk-476FX3TF.js} +481 -448
- package/lib/{chunk-IGLKQRRZ.esm.js → chunk-WXMC2IBW.esm.js} +364 -331
- package/lib/cli.esm.js +2 -2
- package/lib/cli.js +10 -10
- package/lib/compiler-core.esm.js +2 -2
- package/lib/compiler-core.js +3 -3
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13;/**
|
|
2
|
-
* @vureact/compiler-core v1.5.
|
|
2
|
+
* @vureact/compiler-core v1.5.1
|
|
3
3
|
* (c) 2025-present Ruihong Zhong (Ryan John)
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -24,7 +24,7 @@ function executePlugins(map, result, ctx) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// src/core/codegen/component/jsx/syntax-processor/postprocess/build-ctx-provider.ts
|
|
27
|
-
var _types = require('@babel/types'); var t11 = _interopRequireWildcard(_types); var t = _interopRequireWildcard(_types); var t10 = _interopRequireWildcard(_types); var t2 = _interopRequireWildcard(_types); var t4 = _interopRequireWildcard(_types); var t3 = _interopRequireWildcard(_types); var t6 = _interopRequireWildcard(_types); var t5 = _interopRequireWildcard(_types); var t7 = _interopRequireWildcard(_types); var t9 = _interopRequireWildcard(_types); var t8 = _interopRequireWildcard(_types); var t14 = _interopRequireWildcard(_types); var t12 = _interopRequireWildcard(_types); var t13 = _interopRequireWildcard(_types); var t15 = _interopRequireWildcard(_types); var t16 = _interopRequireWildcard(_types); var t17 = _interopRequireWildcard(_types); var t18 = _interopRequireWildcard(_types); var
|
|
27
|
+
var _types = require('@babel/types'); var t11 = _interopRequireWildcard(_types); var t = _interopRequireWildcard(_types); var t10 = _interopRequireWildcard(_types); var t2 = _interopRequireWildcard(_types); var t4 = _interopRequireWildcard(_types); var t3 = _interopRequireWildcard(_types); var t6 = _interopRequireWildcard(_types); var t5 = _interopRequireWildcard(_types); var t7 = _interopRequireWildcard(_types); var t9 = _interopRequireWildcard(_types); var t8 = _interopRequireWildcard(_types); var t14 = _interopRequireWildcard(_types); var t12 = _interopRequireWildcard(_types); var t13 = _interopRequireWildcard(_types); var t15 = _interopRequireWildcard(_types); var t16 = _interopRequireWildcard(_types); var t17 = _interopRequireWildcard(_types); var t18 = _interopRequireWildcard(_types); var t19 = _interopRequireWildcard(_types); var t20 = _interopRequireWildcard(_types); var t21 = _interopRequireWildcard(_types); var t23 = _interopRequireWildcard(_types); var t22 = _interopRequireWildcard(_types); var t24 = _interopRequireWildcard(_types); var t25 = _interopRequireWildcard(_types); var t30 = _interopRequireWildcard(_types); var t27 = _interopRequireWildcard(_types); var t26 = _interopRequireWildcard(_types); var t28 = _interopRequireWildcard(_types); var t29 = _interopRequireWildcard(_types); var t32 = _interopRequireWildcard(_types); var t31 = _interopRequireWildcard(_types); var t33 = _interopRequireWildcard(_types); var t34 = _interopRequireWildcard(_types); var t35 = _interopRequireWildcard(_types); var t36 = _interopRequireWildcard(_types); var t37 = _interopRequireWildcard(_types); var t39 = _interopRequireWildcard(_types); var t38 = _interopRequireWildcard(_types); var t40 = _interopRequireWildcard(_types);
|
|
28
28
|
|
|
29
29
|
// src/consts/other.ts
|
|
30
30
|
var PACKAGE_NAME = {
|
|
@@ -1385,7 +1385,12 @@ function generateComponent(ir, ctx, options) {
|
|
|
1385
1385
|
quotes: "single"
|
|
1386
1386
|
// 使用单引号
|
|
1387
1387
|
},
|
|
1388
|
-
minified:
|
|
1388
|
+
minified: false,
|
|
1389
|
+
// 不压缩输出内容
|
|
1390
|
+
retainLines: false,
|
|
1391
|
+
// 不保留行号
|
|
1392
|
+
retainFunctionParens: true,
|
|
1393
|
+
// 保留函数括号
|
|
1389
1394
|
...options
|
|
1390
1395
|
});
|
|
1391
1396
|
const result = {
|
|
@@ -1461,6 +1466,7 @@ function resolveScript(descriptor, ctx, pResult) {
|
|
|
1461
1466
|
source: scriptBlock
|
|
1462
1467
|
};
|
|
1463
1468
|
const options = getBabelParseOptions(scriptBlock.lang, "script", ctx.filename);
|
|
1469
|
+
resolveCtxData(scriptBlock, ctx);
|
|
1464
1470
|
if (descriptor.script) {
|
|
1465
1471
|
const { code, ast, name } = extractSetupBodyToTopLevel(scriptBlock.content, options);
|
|
1466
1472
|
if (ast) {
|
|
@@ -1480,12 +1486,21 @@ function resolveScript(descriptor, ctx, pResult) {
|
|
|
1480
1486
|
logger.warn(msg, { file: ctx.filename });
|
|
1481
1487
|
})]);
|
|
1482
1488
|
}
|
|
1483
|
-
const source = scriptBlock.content;
|
|
1484
|
-
ctx.scriptData.source = source;
|
|
1485
|
-
ctx.compName = extractCompName(source);
|
|
1486
|
-
ctx.scriptData.lang = scriptBlock.lang || "js";
|
|
1487
1489
|
pResult.script = result;
|
|
1488
1490
|
}
|
|
1491
|
+
function resolveCtxData(scriptBlock, ctx) {
|
|
1492
|
+
let { content, lang } = scriptBlock;
|
|
1493
|
+
const resolveVRComment = (source) => {
|
|
1494
|
+
const regx = /\/\/\s*@vr-name:\s*(\w+)/;
|
|
1495
|
+
const nameMatch = source.match(regx);
|
|
1496
|
+
content = content.replace(regx, "");
|
|
1497
|
+
return _optionalChain([nameMatch, 'optionalAccess', _45 => _45[1], 'optionalAccess', _46 => _46.trim, 'call', _47 => _47()]) || "";
|
|
1498
|
+
};
|
|
1499
|
+
ctx.compName = resolveVRComment(content);
|
|
1500
|
+
ctx.scriptData.source = content;
|
|
1501
|
+
ctx.scriptData.lang = lang || "js";
|
|
1502
|
+
scriptBlock.content = content;
|
|
1503
|
+
}
|
|
1489
1504
|
function extractSetupBodyToTopLevel(content, options) {
|
|
1490
1505
|
let name = "";
|
|
1491
1506
|
try {
|
|
@@ -1549,10 +1564,6 @@ function extractSetupBodyToTopLevel(content, options) {
|
|
|
1549
1564
|
return { name, code: content };
|
|
1550
1565
|
}
|
|
1551
1566
|
}
|
|
1552
|
-
function extractCompName(source) {
|
|
1553
|
-
const nameMatch = source.match(/@vr-name:\s*(\w+)/);
|
|
1554
|
-
return _optionalChain([nameMatch, 'optionalAccess', _45 => _45[1], 'optionalAccess', _46 => _46.trim, 'call', _47 => _47()]) || "";
|
|
1555
|
-
}
|
|
1556
1567
|
|
|
1557
1568
|
// src/core/parse/sfc/process/resolve-script-meta.ts
|
|
1558
1569
|
var _core = require('@babel/core');
|
|
@@ -1936,268 +1947,11 @@ function parse(source, ctx, options) {
|
|
|
1936
1947
|
// src/core/transform/sfc/script/syntax-processor/index.ts
|
|
1937
1948
|
|
|
1938
1949
|
|
|
1939
|
-
// src/core/transform/sfc/script/syntax-processor/postprocess/insert-css-import.ts
|
|
1940
|
-
|
|
1941
|
-
function insertCSSImport(ctx) {
|
|
1942
|
-
const { inputType } = ctx;
|
|
1943
|
-
if (inputType !== "sfc") return;
|
|
1944
|
-
const { filePath, moduleName } = ctx.styleData;
|
|
1945
|
-
if (!filePath) return;
|
|
1946
|
-
const scriptIR = getScriptIR(ctx);
|
|
1947
|
-
const filename = normalizePath(filePath).split("/").pop();
|
|
1948
|
-
const importPath = `./${filename}`;
|
|
1949
|
-
const importDecl = t17.importDeclaration(
|
|
1950
|
-
!moduleName ? [] : [t17.importDefaultSpecifier(t17.identifier(moduleName))],
|
|
1951
|
-
t17.stringLiteral(importPath)
|
|
1952
|
-
);
|
|
1953
|
-
scriptIR.imports.push(importDecl);
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-required-imports/index.ts
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
// src/core/transform/shared.ts
|
|
1960
|
-
function recordImport(ctx, pkg, name, onDemand = true) {
|
|
1961
|
-
const { imports } = ctx;
|
|
1962
|
-
if (isTypeOnlyImport(name)) {
|
|
1963
|
-
name = `type ${name}`;
|
|
1964
|
-
}
|
|
1965
|
-
if (imports.has(pkg)) {
|
|
1966
|
-
const list = imports.get(pkg);
|
|
1967
|
-
const foundItem = list.find((item) => item.name === name);
|
|
1968
|
-
if (!foundItem) {
|
|
1969
|
-
list.push({ name, onDemand });
|
|
1970
|
-
}
|
|
1971
|
-
return;
|
|
1972
|
-
}
|
|
1973
|
-
imports.set(pkg, [{ name, onDemand }]);
|
|
1974
|
-
}
|
|
1975
|
-
function isTypeOnlyImport(name) {
|
|
1976
|
-
const arr = [REACT_API_MAP.ReactNode];
|
|
1977
|
-
return arr.includes(name);
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
// src/core/transform/sfc/script/shared/replace-vue-suffix.ts
|
|
1981
|
-
function replaceVueSuffix(ctx, node) {
|
|
1982
|
-
if (!node.value.endsWith(".vue")) return;
|
|
1983
|
-
const jsxFile = node.value.replace(/.vue$/, "");
|
|
1984
|
-
node.value = jsxFile;
|
|
1985
|
-
node.extra = { rawValue: jsxFile, raw: jsxFile };
|
|
1986
|
-
}
|
|
1987
|
-
|
|
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) {
|
|
2075
|
-
const processedModules = /* @__PURE__ */ new Set();
|
|
2076
|
-
let hasProcessedImports = false;
|
|
2077
|
-
const strategyManager = new ImportStrategyManager();
|
|
2078
|
-
if (ctx.inputType === "sfc") {
|
|
2079
|
-
recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.memo);
|
|
2080
|
-
}
|
|
2081
|
-
function resolveRequiredImport(path9) {
|
|
2082
|
-
const { node } = path9;
|
|
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) {
|
|
2094
|
-
path9.remove();
|
|
2095
|
-
return;
|
|
2096
|
-
}
|
|
2097
|
-
processedModules.add(normalizedModuleName);
|
|
2098
|
-
if (!hasProcessedImports) {
|
|
2099
|
-
const required = createRequiredImports(ctx);
|
|
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
|
-
}
|
|
2109
|
-
} else {
|
|
2110
|
-
if (normalizedModuleName === PACKAGE_NAME.react) {
|
|
2111
|
-
path9.insertAfter(required);
|
|
2112
|
-
} else {
|
|
2113
|
-
path9.insertBefore(required);
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
hasProcessedImports = true;
|
|
2117
|
-
}
|
|
2118
|
-
if (strategy) {
|
|
2119
|
-
const result = strategy.process(path9, ctx, originalModuleName);
|
|
2120
|
-
if (result.shouldRemove && !path9.removed) {
|
|
2121
|
-
path9.remove();
|
|
2122
|
-
return;
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2125
|
-
replaceVueSuffix(ctx, node.source);
|
|
2126
|
-
}
|
|
2127
|
-
return {
|
|
2128
|
-
// 兜底:无 ImportDeclaration 的文件也要能注入必需依赖。
|
|
2129
|
-
Program: {
|
|
2130
|
-
exit(path9) {
|
|
2131
|
-
if (hasProcessedImports) return;
|
|
2132
|
-
const required = createRequiredImports(ctx);
|
|
2133
|
-
path9.unshiftContainer("body", required);
|
|
2134
|
-
hasProcessedImports = true;
|
|
2135
|
-
}
|
|
2136
|
-
},
|
|
2137
|
-
ImportDeclaration(path9) {
|
|
2138
|
-
resolveRequiredImport(path9);
|
|
2139
|
-
}
|
|
2140
|
-
};
|
|
2141
|
-
}
|
|
2142
|
-
function mergeImports(currentNode, ctx, moduleName) {
|
|
2143
|
-
const ctxImportItems = ctx.imports.get(moduleName);
|
|
2144
|
-
if (!_optionalChain([ctxImportItems, 'optionalAccess', _58 => _58.length])) {
|
|
2145
|
-
return;
|
|
2146
|
-
}
|
|
2147
|
-
const currentImports = /* @__PURE__ */ new Set();
|
|
2148
|
-
for (const spec of currentNode.specifiers) {
|
|
2149
|
-
if (t18.isImportSpecifier(spec) && t18.isIdentifier(spec.imported)) {
|
|
2150
|
-
currentImports.add(spec.imported.name);
|
|
2151
|
-
}
|
|
2152
|
-
if (t18.isImportDefaultSpecifier(spec) && t18.isIdentifier(spec.local)) {
|
|
2153
|
-
currentImports.add(spec.local.name);
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
for (const item of ctxImportItems) {
|
|
2157
|
-
if (currentImports.has(item.name)) {
|
|
2158
|
-
continue;
|
|
2159
|
-
}
|
|
2160
|
-
const local = t18.identifier(item.name);
|
|
2161
|
-
const newNode = !item.onDemand ? t18.importDefaultSpecifier(local) : t18.importSpecifier(local, local);
|
|
2162
|
-
currentNode.specifiers.push(newNode);
|
|
2163
|
-
}
|
|
2164
|
-
ctx.imports.delete(moduleName);
|
|
2165
|
-
}
|
|
2166
|
-
function createRequiredImports(ctx) {
|
|
2167
|
-
const result = [];
|
|
2168
|
-
const importMap = {};
|
|
2169
|
-
ctx.imports.forEach((items, moduleName) => {
|
|
2170
|
-
const specifier = [];
|
|
2171
|
-
for (const item of items) {
|
|
2172
|
-
const local = t18.identifier(item.name);
|
|
2173
|
-
if (!item.onDemand) {
|
|
2174
|
-
specifier.push(t18.importDefaultSpecifier(local));
|
|
2175
|
-
} else {
|
|
2176
|
-
specifier.push(t18.importSpecifier(local, local));
|
|
2177
|
-
}
|
|
2178
|
-
}
|
|
2179
|
-
importMap[moduleName] = specifier;
|
|
2180
|
-
});
|
|
2181
|
-
for (const name in importMap) {
|
|
2182
|
-
const specifiers = importMap[name];
|
|
2183
|
-
const importDecl = t18.importDeclaration(specifiers, t18.stringLiteral(name));
|
|
2184
|
-
if (name === PACKAGE_NAME.react) {
|
|
2185
|
-
result.unshift(importDecl);
|
|
2186
|
-
} else {
|
|
2187
|
-
result.push(importDecl);
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
return result;
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-static-hoisting.ts
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
1950
|
// src/core/transform/sfc/script/shared/babel-utils.ts
|
|
2197
1951
|
|
|
2198
1952
|
function findRootVariablePath(path9) {
|
|
2199
1953
|
const rootId = findRootIdentifier(path9.node);
|
|
2200
|
-
if (!_optionalChain([rootId, 'optionalAccess',
|
|
1954
|
+
if (!_optionalChain([rootId, 'optionalAccess', _58 => _58.name])) return null;
|
|
2201
1955
|
const binding = path9.scope.getBinding(rootId.name);
|
|
2202
1956
|
if (!binding) return null;
|
|
2203
1957
|
const rootPath = getVariableDeclaratorPath(binding.path);
|
|
@@ -2205,10 +1959,10 @@ function findRootVariablePath(path9) {
|
|
|
2205
1959
|
}
|
|
2206
1960
|
function findRootIdentifier(node) {
|
|
2207
1961
|
let current = node.object;
|
|
2208
|
-
while (
|
|
1962
|
+
while (t17.isMemberExpression(current) || t17.isOptionalMemberExpression(current)) {
|
|
2209
1963
|
current = current.object;
|
|
2210
1964
|
}
|
|
2211
|
-
return
|
|
1965
|
+
return t17.isIdentifier(current) ? current : null;
|
|
2212
1966
|
}
|
|
2213
1967
|
function getVariableDeclaratorPath(path9) {
|
|
2214
1968
|
if (path9.isVariableDeclarator()) {
|
|
@@ -2292,14 +2046,14 @@ function isPropertyName(path9) {
|
|
|
2292
2046
|
}
|
|
2293
2047
|
function replaceCallName(callExp, identifierName) {
|
|
2294
2048
|
const { callee } = callExp;
|
|
2295
|
-
if (!
|
|
2049
|
+
if (!t17.isIdentifier(callee)) return;
|
|
2296
2050
|
callee.name = identifierName;
|
|
2297
2051
|
if (callee.loc) {
|
|
2298
2052
|
callee.loc.identifierName = identifierName;
|
|
2299
2053
|
}
|
|
2300
2054
|
}
|
|
2301
2055
|
function replaceIdName(id, newName) {
|
|
2302
|
-
if (!
|
|
2056
|
+
if (!t17.isIdentifier(id)) return;
|
|
2303
2057
|
id.name = newName;
|
|
2304
2058
|
if (id.loc) {
|
|
2305
2059
|
id.loc.identifierName = newName;
|
|
@@ -2309,69 +2063,110 @@ function stringValueToTSType(ctx, input, tsTypeAnnotation7) {
|
|
|
2309
2063
|
const { filename, scriptData } = ctx;
|
|
2310
2064
|
const exp = stringToExpr(input, scriptData.lang, filename);
|
|
2311
2065
|
const ts = expressionToTSType(exp);
|
|
2312
|
-
return tsTypeAnnotation7 ?
|
|
2066
|
+
return tsTypeAnnotation7 ? t17.tsTypeAnnotation(ts) : ts;
|
|
2313
2067
|
}
|
|
2314
2068
|
function expressionToTSType(exp) {
|
|
2315
|
-
if (
|
|
2316
|
-
if (
|
|
2317
|
-
if (
|
|
2318
|
-
if (
|
|
2319
|
-
if (
|
|
2069
|
+
if (t17.isStringLiteral(exp)) return t17.tsStringKeyword();
|
|
2070
|
+
if (t17.isNumericLiteral(exp)) return t17.tsNumberKeyword();
|
|
2071
|
+
if (t17.isBooleanLiteral(exp)) return t17.tsBooleanKeyword();
|
|
2072
|
+
if (t17.isArrayExpression(exp)) return t17.tsArrayType(t17.tsAnyKeyword());
|
|
2073
|
+
if (t17.isObjectExpression(exp)) {
|
|
2320
2074
|
const members = [];
|
|
2321
2075
|
for (const p of exp.properties) {
|
|
2322
|
-
if (!
|
|
2076
|
+
if (!t17.isObjectProperty(p)) continue;
|
|
2323
2077
|
let key;
|
|
2324
|
-
if (
|
|
2325
|
-
else if (
|
|
2078
|
+
if (t17.isIdentifier(p.key)) key = p.key.name;
|
|
2079
|
+
else if (t17.isStringLiteral(p.key)) key = p.key.value;
|
|
2326
2080
|
if (!key) continue;
|
|
2327
|
-
if (
|
|
2081
|
+
if (t17.isExpression(p.value)) {
|
|
2328
2082
|
members.push(
|
|
2329
|
-
|
|
2083
|
+
t17.tsPropertySignature(t17.identifier(key), t17.tsTypeAnnotation(expressionToTSType(p.value)))
|
|
2330
2084
|
);
|
|
2331
2085
|
} else {
|
|
2332
2086
|
members.push(
|
|
2333
|
-
|
|
2087
|
+
t17.tsPropertySignature(t17.identifier(key), t17.tsTypeAnnotation(t17.tsAnyKeyword()))
|
|
2334
2088
|
);
|
|
2335
2089
|
}
|
|
2336
2090
|
}
|
|
2337
|
-
return
|
|
2091
|
+
return t17.tsTypeLiteral(members);
|
|
2338
2092
|
}
|
|
2339
|
-
if (
|
|
2093
|
+
if (t17.isArrowFunctionExpression(exp) || t17.isFunctionExpression(exp)) {
|
|
2340
2094
|
const params = exp.params.map((p, i) => {
|
|
2341
|
-
const id =
|
|
2342
|
-
id.typeAnnotation =
|
|
2095
|
+
const id = t17.isIdentifier(p) ? t17.identifier(p.name) : t17.identifier(`arg${i}`);
|
|
2096
|
+
id.typeAnnotation = t17.tsTypeAnnotation(t17.tsAnyKeyword());
|
|
2343
2097
|
return id;
|
|
2344
2098
|
});
|
|
2345
|
-
let returnType =
|
|
2346
|
-
if (
|
|
2099
|
+
let returnType = t17.tsAnyKeyword();
|
|
2100
|
+
if (t17.isBlockStatement(exp.body)) {
|
|
2347
2101
|
for (const stmt of exp.body.body) {
|
|
2348
|
-
if (
|
|
2349
|
-
if (
|
|
2102
|
+
if (t17.isReturnStatement(stmt) && stmt.argument) {
|
|
2103
|
+
if (t17.isExpression(stmt.argument)) {
|
|
2350
2104
|
returnType = expressionToTSType(stmt.argument);
|
|
2351
2105
|
break;
|
|
2352
2106
|
}
|
|
2353
2107
|
}
|
|
2354
2108
|
}
|
|
2355
|
-
} else if (
|
|
2109
|
+
} else if (t17.isExpression(exp.body)) {
|
|
2356
2110
|
returnType = expressionToTSType(exp.body);
|
|
2357
2111
|
}
|
|
2358
|
-
return
|
|
2112
|
+
return t17.tsFunctionType(null, params, t17.tsTypeAnnotation(returnType));
|
|
2359
2113
|
}
|
|
2360
|
-
return
|
|
2114
|
+
return t17.tsAnyKeyword();
|
|
2361
2115
|
}
|
|
2362
2116
|
function isCalleeNamed(node, name) {
|
|
2363
|
-
if (!
|
|
2117
|
+
if (!t17.isIdentifier(node.callee)) {
|
|
2364
2118
|
return false;
|
|
2365
2119
|
}
|
|
2366
2120
|
return node.callee.name === name;
|
|
2367
2121
|
}
|
|
2368
2122
|
function isSimpleLiteral(node) {
|
|
2369
2123
|
if (!node) return false;
|
|
2370
|
-
if (
|
|
2124
|
+
if (t17.isStringLiteral(node) || t17.isNumericLiteral(node) || t17.isBooleanLiteral(node) || t17.isNullLiteral(node) || t17.isRegExpLiteral(node) || t17.isBigIntLiteral(node) || t17.isDecimalLiteral(node)) {
|
|
2371
2125
|
return true;
|
|
2372
2126
|
}
|
|
2373
2127
|
return false;
|
|
2374
2128
|
}
|
|
2129
|
+
function forkNode(node, deep = true) {
|
|
2130
|
+
const newNode = t17.cloneNode(node, deep);
|
|
2131
|
+
newNode.leadingComments = node.leadingComments;
|
|
2132
|
+
newNode.innerComments = node.innerComments;
|
|
2133
|
+
newNode.trailingComments = null;
|
|
2134
|
+
cleanNodeLoc(node);
|
|
2135
|
+
cleanNodeComments(node);
|
|
2136
|
+
return newNode;
|
|
2137
|
+
}
|
|
2138
|
+
function cleanNodeLoc(node) {
|
|
2139
|
+
node.start = null;
|
|
2140
|
+
node.end = null;
|
|
2141
|
+
node.loc = null;
|
|
2142
|
+
}
|
|
2143
|
+
function cleanNodeComments(node) {
|
|
2144
|
+
node.leadingComments = null;
|
|
2145
|
+
node.innerComments = null;
|
|
2146
|
+
node.trailingComments = null;
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/resolve-global-type-chunk.ts
|
|
2150
|
+
function resolveGlobalTypeChunks(path9, ir) {
|
|
2151
|
+
if (!_optionalChain([path9, 'access', _59 => _59.parentPath, 'optionalAccess', _60 => _60.isProgram, 'call', _61 => _61()])) {
|
|
2152
|
+
return;
|
|
2153
|
+
}
|
|
2154
|
+
const forked = forkNode(path9.node);
|
|
2155
|
+
ir.tsTypes.push(forked);
|
|
2156
|
+
path9.remove();
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/resolve-module-chunk.ts
|
|
2160
|
+
|
|
2161
|
+
function resolveModuleChunks(path9, ir) {
|
|
2162
|
+
const forked = forkNode(path9.node);
|
|
2163
|
+
if (t18.isImportDeclaration(forked)) {
|
|
2164
|
+
ir.imports.push(forked);
|
|
2165
|
+
} else if (t18.isExportDeclaration(forked)) {
|
|
2166
|
+
ir.exports.push(forked);
|
|
2167
|
+
}
|
|
2168
|
+
path9.remove();
|
|
2169
|
+
}
|
|
2375
2170
|
|
|
2376
2171
|
// src/core/transform/sfc/script/shared/metadata-utils.ts
|
|
2377
2172
|
var META_KEY = "__vureact_metadata";
|
|
@@ -2389,43 +2184,289 @@ function setScriptNodeMeta(node, opts) {
|
|
|
2389
2184
|
node[META_KEY] = opts;
|
|
2390
2185
|
}
|
|
2391
2186
|
|
|
2392
|
-
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-static-
|
|
2393
|
-
function
|
|
2187
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/resolve-static-const-chunk.ts
|
|
2188
|
+
function resolveStaticConstChunks(path9, ir) {
|
|
2189
|
+
const { node, parentPath } = path9;
|
|
2190
|
+
const parent = parentPath.node;
|
|
2191
|
+
if (!isVariableDeclTopLevel(path9) || !parentPath.isVariableDeclaration() || parent.kind !== "const" || !isSimpleLiteral(node.init) || getScriptNodeMeta(node)) {
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
const forked = forkNode(parent);
|
|
2195
|
+
ir.statement.global.push(forked);
|
|
2196
|
+
parentPath.remove();
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/index.ts
|
|
2200
|
+
function resolveASTChunks(ctx, ast) {
|
|
2394
2201
|
const scriptIR = getScriptIR(ctx);
|
|
2395
2202
|
if (ctx.inputType !== "sfc") {
|
|
2396
2203
|
return {};
|
|
2397
2204
|
}
|
|
2205
|
+
scriptIR.statement.local = ast;
|
|
2398
2206
|
return {
|
|
2207
|
+
// 提取 import/export
|
|
2399
2208
|
"ImportDeclaration|ExportDeclaration"(path9) {
|
|
2400
|
-
|
|
2401
|
-
scriptIR.imports.push(path9.node);
|
|
2402
|
-
} else if (t20.isExportDeclaration(path9.node)) {
|
|
2403
|
-
scriptIR.exports.push(path9.node);
|
|
2404
|
-
}
|
|
2405
|
-
path9.remove();
|
|
2209
|
+
resolveModuleChunks(path9, scriptIR);
|
|
2406
2210
|
},
|
|
2211
|
+
// 提取全局类型声明
|
|
2407
2212
|
"TSInterfaceDeclaration|TSTypeAliasDeclaration|TSEnumDeclaration|TSModuleDeclaration|TSModuleDeclaration"(path9) {
|
|
2408
|
-
|
|
2409
|
-
scriptIR.tsTypes.push(path9.node);
|
|
2410
|
-
path9.remove();
|
|
2411
|
-
}
|
|
2213
|
+
resolveGlobalTypeChunks(path9, scriptIR);
|
|
2412
2214
|
},
|
|
2215
|
+
// 提升顶层常量声明
|
|
2413
2216
|
VariableDeclarator(path9) {
|
|
2217
|
+
resolveStaticConstChunks(path9, scriptIR);
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-runtime-imports/index.ts
|
|
2223
|
+
|
|
2224
|
+
|
|
2225
|
+
// src/core/transform/shared.ts
|
|
2226
|
+
function recordImport(ctx, pkg, name, onDemand = true) {
|
|
2227
|
+
const { imports } = ctx;
|
|
2228
|
+
if (isTypeOnlyImport(name)) {
|
|
2229
|
+
name = `type ${name}`;
|
|
2230
|
+
}
|
|
2231
|
+
if (imports.has(pkg)) {
|
|
2232
|
+
const list = imports.get(pkg);
|
|
2233
|
+
const foundItem = list.find((item) => item.name === name);
|
|
2234
|
+
if (!foundItem) {
|
|
2235
|
+
list.push({ name, onDemand });
|
|
2236
|
+
}
|
|
2237
|
+
return;
|
|
2238
|
+
}
|
|
2239
|
+
imports.set(pkg, [{ name, onDemand }]);
|
|
2240
|
+
}
|
|
2241
|
+
function isTypeOnlyImport(name) {
|
|
2242
|
+
const arr = [REACT_API_MAP.ReactNode];
|
|
2243
|
+
return arr.includes(name);
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
// src/core/transform/sfc/script/shared/replace-vue-suffix.ts
|
|
2247
|
+
function replaceVueSuffix(node) {
|
|
2248
|
+
if (!node.value.endsWith(".vue")) return;
|
|
2249
|
+
const replaced = node.value.replace(/.vue$/, "");
|
|
2250
|
+
node.value = replaced;
|
|
2251
|
+
node.extra = {
|
|
2252
|
+
rawValue: replaced,
|
|
2253
|
+
// fix: 当 minified: true 的情况下,输出内容丢失引号
|
|
2254
|
+
raw: `'${replaced}'`
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-runtime-imports/import-strategies.ts
|
|
2259
|
+
var VueRouterStrategy = class {
|
|
2260
|
+
matches(moduleName) {
|
|
2261
|
+
return moduleName === "vue-router" || moduleName.startsWith("vue-router/");
|
|
2262
|
+
}
|
|
2263
|
+
process() {
|
|
2264
|
+
return {
|
|
2265
|
+
shouldReplaceSource: true,
|
|
2266
|
+
newSource: PACKAGE_NAME.router,
|
|
2267
|
+
shouldRemove: false,
|
|
2268
|
+
shouldInjectRuntimeImports: false
|
|
2269
|
+
};
|
|
2270
|
+
}
|
|
2271
|
+
};
|
|
2272
|
+
var VueEcosystemStrategy = class {
|
|
2273
|
+
matches(moduleName) {
|
|
2274
|
+
if (moduleName.startsWith(".") || moduleName.startsWith("/") || moduleName.startsWith("file:")) {
|
|
2275
|
+
return false;
|
|
2276
|
+
}
|
|
2277
|
+
if (moduleName === "vue-router" || moduleName.startsWith("vue-router/")) {
|
|
2278
|
+
return false;
|
|
2279
|
+
}
|
|
2280
|
+
if (moduleName.startsWith("@vue/")) {
|
|
2281
|
+
return true;
|
|
2282
|
+
}
|
|
2283
|
+
for (const pkg of VUE_PACKAGES) {
|
|
2284
|
+
if (moduleName === pkg || moduleName.startsWith(`${pkg}/`)) {
|
|
2285
|
+
return true;
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
return false;
|
|
2289
|
+
}
|
|
2290
|
+
process() {
|
|
2291
|
+
return {
|
|
2292
|
+
shouldReplaceSource: false,
|
|
2293
|
+
shouldRemove: true,
|
|
2294
|
+
shouldInjectRuntimeImports: true
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
};
|
|
2298
|
+
var StyleFileStrategy = (_class3 = class {constructor() { _class3.prototype.__init5.call(this); }
|
|
2299
|
+
__init5() {this.regExp = /\.(less|sass|scss)$/i}
|
|
2300
|
+
matches(moduleName) {
|
|
2301
|
+
return this.regExp.test(moduleName);
|
|
2302
|
+
}
|
|
2303
|
+
process(path9, ctx) {
|
|
2304
|
+
if (!ctx.preprocessStyles) {
|
|
2305
|
+
return {};
|
|
2306
|
+
}
|
|
2307
|
+
const importSource = path9.node.source.value;
|
|
2308
|
+
if (typeof importSource !== "string") {
|
|
2309
|
+
return {};
|
|
2310
|
+
}
|
|
2311
|
+
return {
|
|
2312
|
+
shouldReplaceSource: true,
|
|
2313
|
+
newSource: importSource.replace(this.regExp, ".css"),
|
|
2314
|
+
shouldRemove: false,
|
|
2315
|
+
shouldInjectRuntimeImports: false
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2318
|
+
}, _class3);
|
|
2319
|
+
|
|
2320
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-runtime-imports/import-strategy-manager.ts
|
|
2321
|
+
var ImportStrategyManager = (_class4 = class {
|
|
2322
|
+
__init6() {this.strategies = []}
|
|
2323
|
+
constructor() {;_class4.prototype.__init6.call(this);
|
|
2324
|
+
this.strategies.push(new VueRouterStrategy());
|
|
2325
|
+
this.strategies.push(new VueEcosystemStrategy());
|
|
2326
|
+
this.strategies.push(new StyleFileStrategy());
|
|
2327
|
+
}
|
|
2328
|
+
/** 添加自定义策略 */
|
|
2329
|
+
addStrategy(strategy) {
|
|
2330
|
+
this.strategies.push(strategy);
|
|
2331
|
+
}
|
|
2332
|
+
/** 查找匹配的策略 */
|
|
2333
|
+
findStrategy(moduleName) {
|
|
2334
|
+
for (const strategy of this.strategies) {
|
|
2335
|
+
if (strategy.matches(moduleName)) {
|
|
2336
|
+
return strategy;
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
return null;
|
|
2340
|
+
}
|
|
2341
|
+
}, _class4);
|
|
2342
|
+
|
|
2343
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-runtime-imports/index.ts
|
|
2344
|
+
function resolveRuntimeImports(ctx) {
|
|
2345
|
+
if (ctx.inputType === "sfc") {
|
|
2346
|
+
recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.memo);
|
|
2347
|
+
}
|
|
2348
|
+
const strategyManager = new ImportStrategyManager();
|
|
2349
|
+
const processedModules = /* @__PURE__ */ new Set();
|
|
2350
|
+
let hasImports = false;
|
|
2351
|
+
return {
|
|
2352
|
+
ImportDeclaration(path9) {
|
|
2414
2353
|
const { node } = path9;
|
|
2415
|
-
|
|
2354
|
+
const originalModuleName = node.source.value.toLowerCase();
|
|
2355
|
+
const strategy = strategyManager.findStrategy(originalModuleName);
|
|
2356
|
+
let strategyResult = null;
|
|
2357
|
+
if (strategy) {
|
|
2358
|
+
strategyResult = strategy.process(path9, ctx, originalModuleName);
|
|
2359
|
+
if (strategyResult.shouldReplaceSource && strategyResult.newSource) {
|
|
2360
|
+
node.source.value = strategyResult.newSource;
|
|
2361
|
+
}
|
|
2362
|
+
if (strategyResult.shouldRemove && !path9.removed) {
|
|
2363
|
+
path9.remove();
|
|
2364
|
+
return;
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
replaceVueSuffix(node.source);
|
|
2368
|
+
const finalModuleName = node.source.value.toLowerCase();
|
|
2369
|
+
if (processedModules.has(finalModuleName) && !path9.removed) {
|
|
2370
|
+
path9.remove();
|
|
2416
2371
|
return;
|
|
2417
2372
|
}
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2373
|
+
processedModules.add(finalModuleName);
|
|
2374
|
+
mergeImports(node, ctx, finalModuleName);
|
|
2375
|
+
if (!hasImports) {
|
|
2376
|
+
const importNodes = createImportNodes(ctx);
|
|
2377
|
+
if (importNodes.length) {
|
|
2378
|
+
if (_optionalChain([strategyResult, 'optionalAccess', _62 => _62.shouldInjectRuntimeImports])) {
|
|
2379
|
+
path9.insertAfter(importNodes);
|
|
2380
|
+
} else if (finalModuleName === PACKAGE_NAME.react) {
|
|
2381
|
+
path9.insertAfter(importNodes);
|
|
2382
|
+
} else {
|
|
2383
|
+
forkLeadingComments(importNodes[0], node);
|
|
2384
|
+
path9.insertBefore(importNodes);
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
hasImports = true;
|
|
2388
|
+
}
|
|
2389
|
+
},
|
|
2390
|
+
// 兜底:无 ImportDeclaration 的文件也要能注入必需依赖。
|
|
2391
|
+
Program: {
|
|
2392
|
+
exit(path9) {
|
|
2393
|
+
if (hasImports) return;
|
|
2394
|
+
hasImports = true;
|
|
2395
|
+
const { node } = path9;
|
|
2396
|
+
const importNodes = createImportNodes(ctx);
|
|
2397
|
+
if (!importNodes.length) return;
|
|
2398
|
+
forkLeadingComments(importNodes[0], node);
|
|
2399
|
+
path9.unshiftContainer("body", importNodes);
|
|
2400
|
+
}
|
|
2422
2401
|
}
|
|
2423
2402
|
};
|
|
2424
2403
|
}
|
|
2425
|
-
function
|
|
2404
|
+
function mergeImports(currentNode, ctx, moduleName) {
|
|
2405
|
+
const ctxImportItems = ctx.imports.get(moduleName);
|
|
2406
|
+
if (!_optionalChain([ctxImportItems, 'optionalAccess', _63 => _63.length])) {
|
|
2407
|
+
return;
|
|
2408
|
+
}
|
|
2409
|
+
const currentImports = /* @__PURE__ */ new Set();
|
|
2410
|
+
for (const spec of currentNode.specifiers) {
|
|
2411
|
+
if (t19.isImportSpecifier(spec) && t19.isIdentifier(spec.imported)) {
|
|
2412
|
+
currentImports.add(spec.imported.name);
|
|
2413
|
+
}
|
|
2414
|
+
if (t19.isImportDefaultSpecifier(spec) && t19.isIdentifier(spec.local)) {
|
|
2415
|
+
currentImports.add(spec.local.name);
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
for (const item of ctxImportItems) {
|
|
2419
|
+
if (currentImports.has(item.name)) {
|
|
2420
|
+
continue;
|
|
2421
|
+
}
|
|
2422
|
+
const local = t19.identifier(item.name);
|
|
2423
|
+
const newNode = !item.onDemand ? t19.importDefaultSpecifier(local) : t19.importSpecifier(local, local);
|
|
2424
|
+
currentNode.specifiers.push(newNode);
|
|
2425
|
+
}
|
|
2426
|
+
ctx.imports.delete(moduleName);
|
|
2427
|
+
}
|
|
2428
|
+
function createImportNodes(ctx) {
|
|
2429
|
+
const result = [];
|
|
2430
|
+
const importDeclarations = Array.from(ctx.imports).map(([moduleName, items]) => {
|
|
2431
|
+
const specifiers = items.map((item) => {
|
|
2432
|
+
const local = t19.identifier(item.name);
|
|
2433
|
+
return item.onDemand ? t19.importSpecifier(local, local) : t19.importDefaultSpecifier(local);
|
|
2434
|
+
});
|
|
2435
|
+
return t19.importDeclaration(specifiers, t19.stringLiteral(moduleName));
|
|
2436
|
+
});
|
|
2437
|
+
for (const decl of importDeclarations) {
|
|
2438
|
+
const name = decl.source.value;
|
|
2439
|
+
if (name === PACKAGE_NAME.react) {
|
|
2440
|
+
result.unshift(decl);
|
|
2441
|
+
} else {
|
|
2442
|
+
result.push(decl);
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
return result;
|
|
2446
|
+
}
|
|
2447
|
+
function forkLeadingComments(target, source) {
|
|
2448
|
+
const { leadingComments } = source;
|
|
2449
|
+
if (!_optionalChain([leadingComments, 'optionalAccess', _64 => _64.length])) {
|
|
2450
|
+
return;
|
|
2451
|
+
}
|
|
2452
|
+
const newComments = [...leadingComments];
|
|
2453
|
+
source.leadingComments = null;
|
|
2454
|
+
target.leadingComments = newComments;
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-sfc-css-import.ts
|
|
2458
|
+
|
|
2459
|
+
function resolveSfcCssImport(ctx) {
|
|
2426
2460
|
if (ctx.inputType !== "sfc") return;
|
|
2427
2461
|
const scriptIR = getScriptIR(ctx);
|
|
2428
|
-
|
|
2462
|
+
const { filePath, moduleName } = ctx.styleData;
|
|
2463
|
+
if (!filePath) return;
|
|
2464
|
+
const styleFilename = normalizePath(filePath).split("/").pop();
|
|
2465
|
+
const importDecl = t20.importDeclaration(
|
|
2466
|
+
!moduleName ? [] : [t20.importDefaultSpecifier(t20.identifier(moduleName))],
|
|
2467
|
+
t20.stringLiteral(`./${styleFilename}`)
|
|
2468
|
+
);
|
|
2469
|
+
scriptIR.imports.push(importDecl);
|
|
2429
2470
|
}
|
|
2430
2471
|
|
|
2431
2472
|
// src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-async-component.ts
|
|
@@ -2466,7 +2507,7 @@ function checkIsDynamicImport(ctx, node) {
|
|
|
2466
2507
|
{
|
|
2467
2508
|
source: scriptData.source,
|
|
2468
2509
|
file: filename,
|
|
2469
|
-
loc: _optionalChain([target, 'optionalAccess',
|
|
2510
|
+
loc: _optionalChain([target, 'optionalAccess', _65 => _65.loc]) || {}
|
|
2470
2511
|
}
|
|
2471
2512
|
);
|
|
2472
2513
|
}
|
|
@@ -2485,7 +2526,7 @@ function checkIsDynamicImport(ctx, node) {
|
|
|
2485
2526
|
if (t21.isCallExpression(node)) {
|
|
2486
2527
|
warnIsNotImport(node.callee);
|
|
2487
2528
|
if (t21.isStringLiteral(node.arguments[0])) {
|
|
2488
|
-
replaceVueSuffix(
|
|
2529
|
+
replaceVueSuffix(node.arguments[0]);
|
|
2489
2530
|
}
|
|
2490
2531
|
return;
|
|
2491
2532
|
}
|
|
@@ -2518,7 +2559,7 @@ function pushToGlobalScope(path9, ctx) {
|
|
|
2518
2559
|
declarationPath = declarationPath.parentPath;
|
|
2519
2560
|
}
|
|
2520
2561
|
let fullNode;
|
|
2521
|
-
if (_optionalChain([declarationPath, 'optionalAccess',
|
|
2562
|
+
if (_optionalChain([declarationPath, 'optionalAccess', _66 => _66.isVariableDeclaration, 'call', _67 => _67()])) {
|
|
2522
2563
|
fullNode = declarationPath.node;
|
|
2523
2564
|
declarationPath.remove();
|
|
2524
2565
|
} else if (path9.parentPath.isVariableDeclarator()) {
|
|
@@ -2602,7 +2643,7 @@ function resolveDefineOptions(ctx) {
|
|
|
2602
2643
|
logger.warn("defineOptions was found, but no options were provided.", {
|
|
2603
2644
|
source: scriptData.source,
|
|
2604
2645
|
file: filename,
|
|
2605
|
-
loc: _optionalChain([node, 'optionalAccess',
|
|
2646
|
+
loc: _optionalChain([node, 'optionalAccess', _68 => _68.loc])
|
|
2606
2647
|
});
|
|
2607
2648
|
path9.remove();
|
|
2608
2649
|
return;
|
|
@@ -2611,7 +2652,7 @@ function resolveDefineOptions(ctx) {
|
|
|
2611
2652
|
logger.warn("Argument for defineOptions must be an object expression.", {
|
|
2612
2653
|
source: scriptData.source,
|
|
2613
2654
|
file: filename,
|
|
2614
|
-
loc: _optionalChain([options, 'optionalAccess',
|
|
2655
|
+
loc: _optionalChain([options, 'optionalAccess', _69 => _69.loc])
|
|
2615
2656
|
});
|
|
2616
2657
|
} else {
|
|
2617
2658
|
for (const prop of options.properties) {
|
|
@@ -2636,7 +2677,7 @@ function extractName(prop, ctx) {
|
|
|
2636
2677
|
logger.error(`name must be a string type, but got ${prop.value.type}`, {
|
|
2637
2678
|
source: scriptData.source,
|
|
2638
2679
|
file: filename,
|
|
2639
|
-
loc: _optionalChain([prop, 'access',
|
|
2680
|
+
loc: _optionalChain([prop, 'access', _70 => _70.key, 'optionalAccess', _71 => _71.loc])
|
|
2640
2681
|
});
|
|
2641
2682
|
}
|
|
2642
2683
|
}
|
|
@@ -2679,10 +2720,10 @@ function resolveEmitCalls(ctx) {
|
|
|
2679
2720
|
const [callee, ...args] = node.arguments;
|
|
2680
2721
|
const eventName = t25.isStringLiteral(callee) ? formatEmitEventName(callee.value) : void 0;
|
|
2681
2722
|
if (!eventName) {
|
|
2682
|
-
logger.warn(`Expected String type but got ${_optionalChain([callee, 'optionalAccess',
|
|
2723
|
+
logger.warn(`Expected String type but got ${_optionalChain([callee, 'optionalAccess', _72 => _72.type])}, expression will be removed`, {
|
|
2683
2724
|
file: filename,
|
|
2684
2725
|
source: scriptData.source,
|
|
2685
|
-
loc: _optionalChain([callee, 'optionalAccess',
|
|
2726
|
+
loc: _optionalChain([callee, 'optionalAccess', _73 => _73.loc])
|
|
2686
2727
|
});
|
|
2687
2728
|
path9.remove();
|
|
2688
2729
|
return;
|
|
@@ -2805,8 +2846,8 @@ function resolveTopLevelEmitType(tsType) {
|
|
|
2805
2846
|
function resolveDefineEmitsIface(path9, ctx) {
|
|
2806
2847
|
const { node } = path9;
|
|
2807
2848
|
const [runtimeArg] = node.arguments;
|
|
2808
|
-
const tsParams = _optionalChain([node, 'access',
|
|
2809
|
-
if (_optionalChain([tsParams, 'optionalAccess',
|
|
2849
|
+
const tsParams = _optionalChain([node, 'access', _74 => _74.typeParameters, 'optionalAccess', _75 => _75.params]);
|
|
2850
|
+
if (_optionalChain([tsParams, 'optionalAccess', _76 => _76.length])) {
|
|
2810
2851
|
processExplicitType(ctx, tsParams);
|
|
2811
2852
|
return;
|
|
2812
2853
|
}
|
|
@@ -3004,12 +3045,12 @@ function resolveEmitPropFromPropertySignature(member) {
|
|
|
3004
3045
|
if (!rawName) return null;
|
|
3005
3046
|
const handlerName = resolveEmitHandlerName(rawName);
|
|
3006
3047
|
const key = buildKey(handlerName);
|
|
3007
|
-
const typeAnnotation = _optionalChain([member, 'access',
|
|
3048
|
+
const typeAnnotation = _optionalChain([member, 'access', _77 => _77.typeAnnotation, 'optionalAccess', _78 => _78.typeAnnotation]);
|
|
3008
3049
|
let params = [];
|
|
3009
3050
|
let returnType = t27.tsAnyKeyword();
|
|
3010
3051
|
if (typeAnnotation && t27.isTSFunctionType(typeAnnotation)) {
|
|
3011
3052
|
params = cloneCallableParams(typeAnnotation.parameters);
|
|
3012
|
-
returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'access',
|
|
3053
|
+
returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'access', _79 => _79.typeAnnotation, 'optionalAccess', _80 => _80.typeAnnotation]), () => ( returnType));
|
|
3013
3054
|
} else if (typeAnnotation && t27.isTSTupleType(typeAnnotation)) {
|
|
3014
3055
|
params = resolveTupleTypeParams(typeAnnotation);
|
|
3015
3056
|
} else if (typeAnnotation) {
|
|
@@ -3034,7 +3075,7 @@ function resolveEmitPropsFromCallable(parameters, typeAnnotation) {
|
|
|
3034
3075
|
if (t27.isNoop(paramTypeAnnotation)) return [];
|
|
3035
3076
|
const eventNames = resolveEventNames(paramTypeAnnotation.typeAnnotation);
|
|
3036
3077
|
if (!eventNames.length) return [];
|
|
3037
|
-
const returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'optionalAccess',
|
|
3078
|
+
const returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'optionalAccess', _81 => _81.typeAnnotation]), () => ( t27.tsAnyKeyword()));
|
|
3038
3079
|
return eventNames.map((eventName) => {
|
|
3039
3080
|
const handlerName = resolveEmitHandlerName(eventName);
|
|
3040
3081
|
const key = buildKey(handlerName);
|
|
@@ -3068,7 +3109,7 @@ function resolveTupleElementParam(element, index) {
|
|
|
3068
3109
|
const isNamedTuple = typeof t27.isTSNamedTupleMember === "function" && t27.isTSNamedTupleMember(element);
|
|
3069
3110
|
if (isNamedTuple) {
|
|
3070
3111
|
const tupleMember = element;
|
|
3071
|
-
const name = _optionalChain([tupleMember, 'access',
|
|
3112
|
+
const name = _optionalChain([tupleMember, 'access', _82 => _82.label, 'optionalAccess', _83 => _83.name]) || `arg${index}`;
|
|
3072
3113
|
let innerType = tupleMember.elementType;
|
|
3073
3114
|
let optional = tupleMember.optional;
|
|
3074
3115
|
if (t27.isTSOptionalType(innerType)) {
|
|
@@ -3106,8 +3147,8 @@ function resolveTupleElementParam(element, index) {
|
|
|
3106
3147
|
function resolveDefinePropsIface(path9, ctx) {
|
|
3107
3148
|
const { node } = path9;
|
|
3108
3149
|
const [runtimeArg] = node.arguments;
|
|
3109
|
-
const tsParams = _optionalChain([node, 'access',
|
|
3110
|
-
if (_optionalChain([tsParams, 'optionalAccess',
|
|
3150
|
+
const tsParams = _optionalChain([node, 'access', _84 => _84.typeParameters, 'optionalAccess', _85 => _85.params]);
|
|
3151
|
+
if (_optionalChain([tsParams, 'optionalAccess', _86 => _86.length])) {
|
|
3111
3152
|
const { propsTSIface } = ctx.scriptData;
|
|
3112
3153
|
propsTSIface.propsTypes = tsParams;
|
|
3113
3154
|
return;
|
|
@@ -3162,7 +3203,7 @@ function processInferredTypes2(ctx, runtimeArg) {
|
|
|
3162
3203
|
{
|
|
3163
3204
|
source,
|
|
3164
3205
|
file: filename,
|
|
3165
|
-
loc: _optionalChain([runtimeArg, 'optionalAccess',
|
|
3206
|
+
loc: _optionalChain([runtimeArg, 'optionalAccess', _87 => _87.loc])
|
|
3166
3207
|
}
|
|
3167
3208
|
);
|
|
3168
3209
|
}
|
|
@@ -3279,8 +3320,8 @@ function resolveSlotsTopLevelTypes(ctx) {
|
|
|
3279
3320
|
}
|
|
3280
3321
|
function resolveDefineSlotsIface(path9, ctx) {
|
|
3281
3322
|
const { node } = path9;
|
|
3282
|
-
const tsParams = _optionalChain([node, 'access',
|
|
3283
|
-
if (!_optionalChain([tsParams, 'optionalAccess',
|
|
3323
|
+
const tsParams = _optionalChain([node, 'access', _88 => _88.typeParameters, 'optionalAccess', _89 => _89.params]);
|
|
3324
|
+
if (!_optionalChain([tsParams, 'optionalAccess', _90 => _90.length])) return;
|
|
3284
3325
|
const {
|
|
3285
3326
|
propsTSIface: { slotTypes }
|
|
3286
3327
|
} = ctx.scriptData;
|
|
@@ -3394,7 +3435,7 @@ function hasSlotsSignatureInMember(member) {
|
|
|
3394
3435
|
if (t29.isTSMethodSignature(member)) return true;
|
|
3395
3436
|
if (t29.isTSCallSignatureDeclaration(member)) return true;
|
|
3396
3437
|
if (t29.isTSPropertySignature(member)) {
|
|
3397
|
-
const typeAnnotation = _optionalChain([member, 'access',
|
|
3438
|
+
const typeAnnotation = _optionalChain([member, 'access', _91 => _91.typeAnnotation, 'optionalAccess', _92 => _92.typeAnnotation]);
|
|
3398
3439
|
return !!(typeAnnotation && resolveCallableType(typeAnnotation));
|
|
3399
3440
|
}
|
|
3400
3441
|
return false;
|
|
@@ -3409,7 +3450,7 @@ function resolveSlotPropFromMember(member) {
|
|
|
3409
3450
|
if (t29.isTSPropertySignature(member)) {
|
|
3410
3451
|
const rawName = resolvePropName2(member.key);
|
|
3411
3452
|
if (!rawName) return null;
|
|
3412
|
-
const typeAnnotation = _optionalChain([member, 'access',
|
|
3453
|
+
const typeAnnotation = _optionalChain([member, 'access', _93 => _93.typeAnnotation, 'optionalAccess', _94 => _94.typeAnnotation]);
|
|
3413
3454
|
const callable = typeAnnotation ? resolveCallableType(typeAnnotation) : null;
|
|
3414
3455
|
if (!callable) return null;
|
|
3415
3456
|
const params = cloneCallableParams(callable.parameters);
|
|
@@ -3448,7 +3489,7 @@ function createSlotScopeParam(props, ctx) {
|
|
|
3448
3489
|
const propsSigns = [];
|
|
3449
3490
|
const { reactiveBindings } = ctx.templateData;
|
|
3450
3491
|
props.forEach(({ prop, tsType }) => {
|
|
3451
|
-
const foundBindingValue = _optionalChain([reactiveBindings, 'access',
|
|
3492
|
+
const foundBindingValue = _optionalChain([reactiveBindings, 'access', _95 => _95[prop], 'optionalAccess', _96 => _96.value]);
|
|
3452
3493
|
const foundBindingTypes = foundBindingValue ? expressionToTSType(foundBindingValue) : null;
|
|
3453
3494
|
const typeAnnotation = foundBindingTypes ? t29.tsTypeAnnotation(foundBindingTypes) : tsType;
|
|
3454
3495
|
const key = t29.isValidIdentifier(prop) ? t29.identifier(prop) : t29.stringLiteral(prop);
|
|
@@ -3693,11 +3734,11 @@ function analyzeDeps(node, ctx, parentPath) {
|
|
|
3693
3734
|
const bindingPath = binding.path;
|
|
3694
3735
|
const declaratorPath = getVariableDeclaratorPath(bindingPath);
|
|
3695
3736
|
const isReactiveVarBinding = !!declaratorPath && isReactiveBinding(declaratorPath.node);
|
|
3696
|
-
const nodeInit = _optionalChain([declaratorPath, 'optionalAccess',
|
|
3737
|
+
const nodeInit = _optionalChain([declaratorPath, 'optionalAccess', _97 => _97.node, 'access', _98 => _98.init]);
|
|
3697
3738
|
const isReactiveApiCallVarBinding = !!declaratorPath && t31.isCallExpression(nodeInit) && t31.isIdentifier(nodeInit.callee) && reactiveStateApis.has(nodeInit.callee.name);
|
|
3698
3739
|
const isHookCallVarBinding = !!declaratorPath && t31.isCallExpression(nodeInit) && isHookLikeCallee(nodeInit.callee);
|
|
3699
3740
|
const isFunctionBinding = bindingPath.isFunctionDeclaration() || !!declaratorPath && !!nodeInit && (t31.isArrowFunctionExpression(nodeInit) || t31.isFunctionExpression(nodeInit));
|
|
3700
|
-
const isReactiveFunctionBinding = isFunctionBinding && (isReactiveBinding(_optionalChain([declaratorPath, 'optionalAccess',
|
|
3741
|
+
const isReactiveFunctionBinding = isFunctionBinding && (isReactiveBinding(_optionalChain([declaratorPath, 'optionalAccess', _99 => _99.node])) || isReactiveBinding(bindingPath.node));
|
|
3701
3742
|
return isReactiveVarBinding || isReactiveApiCallVarBinding || isHookCallVarBinding || isReactiveFunctionBinding;
|
|
3702
3743
|
}
|
|
3703
3744
|
function isHookLikeCallee(callee) {
|
|
@@ -3804,7 +3845,7 @@ function isNestedMemberObject(path9) {
|
|
|
3804
3845
|
}
|
|
3805
3846
|
function isReactiveBinding(node) {
|
|
3806
3847
|
if (!node) return false;
|
|
3807
|
-
return !!_optionalChain([getScriptNodeMeta, 'call',
|
|
3848
|
+
return !!_optionalChain([getScriptNodeMeta, 'call', _100 => _100(node), 'optionalAccess', _101 => _101.is_reactive]);
|
|
3808
3849
|
}
|
|
3809
3850
|
|
|
3810
3851
|
// src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
|
|
@@ -3875,7 +3916,7 @@ function isVueImportBinding(binding) {
|
|
|
3875
3916
|
if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
|
|
3876
3917
|
return false;
|
|
3877
3918
|
}
|
|
3878
|
-
const parent = _optionalChain([bindingPath, 'access',
|
|
3919
|
+
const parent = _optionalChain([bindingPath, 'access', _102 => _102.parentPath, 'optionalAccess', _103 => _103.node]);
|
|
3879
3920
|
if (!parent || !t32.isImportDeclaration(parent)) {
|
|
3880
3921
|
return false;
|
|
3881
3922
|
}
|
|
@@ -3902,7 +3943,7 @@ function resolveArrowFnDeps(ctx, ast) {
|
|
|
3902
3943
|
const newNode = createUseCallback(node, deps);
|
|
3903
3944
|
const declaratorPath = getVariableDeclaratorPath(path9);
|
|
3904
3945
|
recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useCallback);
|
|
3905
|
-
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess',
|
|
3946
|
+
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _104 => _104.node]), { is_reactive: true, reactive_type: "indirect" });
|
|
3906
3947
|
path9.replaceWith(newNode);
|
|
3907
3948
|
}
|
|
3908
3949
|
};
|
|
@@ -3961,8 +4002,8 @@ function resolveElementRef(ctx) {
|
|
|
3961
4002
|
return;
|
|
3962
4003
|
}
|
|
3963
4004
|
if (isCompRefBindings) {
|
|
3964
|
-
const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call',
|
|
3965
|
-
if (!t33.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess',
|
|
4005
|
+
const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call', _105 => _105(path9), 'optionalAccess', _106 => _106.node]);
|
|
4006
|
+
if (!t33.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess', _107 => _107.id]))) {
|
|
3966
4007
|
return;
|
|
3967
4008
|
}
|
|
3968
4009
|
const varName = varDeclaratorPath.id.name;
|
|
@@ -3985,7 +4026,7 @@ function resolveTypeParameters(ctx, path9) {
|
|
|
3985
4026
|
scriptData
|
|
3986
4027
|
} = ctx;
|
|
3987
4028
|
const { node } = path9;
|
|
3988
|
-
const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call',
|
|
4029
|
+
const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call', _108 => _108(path9), 'optionalAccess', _109 => _109.node]);
|
|
3989
4030
|
if (!scriptData.lang.startsWith("ts") || !varDeclaratorNode) {
|
|
3990
4031
|
return;
|
|
3991
4032
|
}
|
|
@@ -4003,11 +4044,11 @@ function resolveRefValueToCurrent(path9) {
|
|
|
4003
4044
|
return;
|
|
4004
4045
|
}
|
|
4005
4046
|
const rootPath = findRootVariablePath(path9);
|
|
4006
|
-
if (!_optionalChain([rootPath, 'optionalAccess',
|
|
4047
|
+
if (!_optionalChain([rootPath, 'optionalAccess', _110 => _110.node]) || !t33.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
|
|
4007
4048
|
return;
|
|
4008
4049
|
}
|
|
4009
4050
|
const rootId = findRootIdentifier(node);
|
|
4010
|
-
if (!t33.isIdentifier(node.object) || node.object.name !== _optionalChain([rootId, 'optionalAccess',
|
|
4051
|
+
if (!t33.isIdentifier(node.object) || node.object.name !== _optionalChain([rootId, 'optionalAccess', _111 => _111.name])) {
|
|
4011
4052
|
return;
|
|
4012
4053
|
}
|
|
4013
4054
|
node.property.name = "current";
|
|
@@ -4108,7 +4149,7 @@ function resolveProvide(ctx) {
|
|
|
4108
4149
|
return {
|
|
4109
4150
|
CallExpression(path9) {
|
|
4110
4151
|
const { node } = path9;
|
|
4111
|
-
const providerTarget = _optionalChain([ADAPTER_RULES, 'access',
|
|
4152
|
+
const providerTarget = _optionalChain([ADAPTER_RULES, 'access', _112 => _112.runtime, 'access', _113 => _113[VUE_API_MAP.provide], 'optionalAccess', _114 => _114.target]);
|
|
4112
4153
|
const isProvideCall = isCalleeNamed(node, VUE_API_MAP.provide) || providerTarget && isCalleeNamed(node, providerTarget);
|
|
4113
4154
|
if (!isProvideCall) return;
|
|
4114
4155
|
const { provide } = ctx.scriptData;
|
|
@@ -4126,7 +4167,7 @@ function findOrCreateCtxProvider(root) {
|
|
|
4126
4167
|
return root;
|
|
4127
4168
|
}
|
|
4128
4169
|
let cur = root.provide;
|
|
4129
|
-
while (_optionalChain([cur, 'optionalAccess',
|
|
4170
|
+
while (_optionalChain([cur, 'optionalAccess', _115 => _115.isOccupied])) {
|
|
4130
4171
|
cur = _nullishCoalesce(cur.provide, () => ( {}));
|
|
4131
4172
|
}
|
|
4132
4173
|
return cur || (root.provide = {});
|
|
@@ -4183,7 +4224,7 @@ function resolveRenameAdapter(ctx) {
|
|
|
4183
4224
|
if (adapter.isTrackable) {
|
|
4184
4225
|
const reactiveType = getReactiveType(apiName);
|
|
4185
4226
|
const declaratorPath = getVariableDeclaratorPath(path9);
|
|
4186
|
-
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess',
|
|
4227
|
+
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _116 => _116.node]), {
|
|
4187
4228
|
is_reactive: true,
|
|
4188
4229
|
reactive_type: reactiveType
|
|
4189
4230
|
});
|
|
@@ -4222,7 +4263,7 @@ function isVueImportBinding2(binding) {
|
|
|
4222
4263
|
if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
|
|
4223
4264
|
return false;
|
|
4224
4265
|
}
|
|
4225
|
-
const parent = _optionalChain([bindingPath, 'access',
|
|
4266
|
+
const parent = _optionalChain([bindingPath, 'access', _117 => _117.parentPath, 'optionalAccess', _118 => _118.node]);
|
|
4226
4267
|
if (!parent || !t37.isImportDeclaration(parent)) {
|
|
4227
4268
|
return false;
|
|
4228
4269
|
}
|
|
@@ -4266,19 +4307,19 @@ function processVueSyntax2(ast, ctx) {
|
|
|
4266
4307
|
excludeBabel: [resolveTemplateSlotIface, resolveCompIProps]
|
|
4267
4308
|
},
|
|
4268
4309
|
postprocess: {
|
|
4269
|
-
applyBabel: [
|
|
4270
|
-
excludeBabel: [
|
|
4310
|
+
applyBabel: [resolveRuntimeImports, resolveASTChunks],
|
|
4311
|
+
excludeBabel: [resolveSfcCssImport]
|
|
4271
4312
|
}
|
|
4272
4313
|
});
|
|
4273
4314
|
}
|
|
4274
4315
|
function vueSyntaxProcessor2(ast, ctx, options) {
|
|
4275
4316
|
const runExcludeThenApply = (cfg) => {
|
|
4276
|
-
_optionalChain([cfg, 'access',
|
|
4277
|
-
_optionalChain([cfg, 'access',
|
|
4317
|
+
_optionalChain([cfg, 'access', _119 => _119.excludeBabel, 'optionalAccess', _120 => _120.forEach, 'call', _121 => _121((fn) => fn(ctx, ast))]);
|
|
4318
|
+
_optionalChain([cfg, 'access', _122 => _122.applyBabel, 'optionalAccess', _123 => _123.forEach, 'call', _124 => _124((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
|
|
4278
4319
|
};
|
|
4279
4320
|
const runApplyThenExclude = (cfg) => {
|
|
4280
|
-
_optionalChain([cfg, 'access',
|
|
4281
|
-
_optionalChain([cfg, 'access',
|
|
4321
|
+
_optionalChain([cfg, 'access', _125 => _125.applyBabel, 'optionalAccess', _126 => _126.forEach, 'call', _127 => _127((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
|
|
4322
|
+
_optionalChain([cfg, 'access', _128 => _128.excludeBabel, 'optionalAccess', _129 => _129.forEach, 'call', _130 => _130((fn) => fn(ctx, ast))]);
|
|
4282
4323
|
};
|
|
4283
4324
|
runExcludeThenApply(options.preprocess);
|
|
4284
4325
|
runExcludeThenApply(options.process);
|
|
@@ -4517,12 +4558,12 @@ function wrapSingleQuotes(content, condition) {
|
|
|
4517
4558
|
return condition || strCodeTypes.isStringLiteral(content) ? `'${content}'` : content;
|
|
4518
4559
|
}
|
|
4519
4560
|
function checkPropIsDynamicKey(ctx, node) {
|
|
4520
|
-
const isKeyStatic = _optionalChain([node, 'access',
|
|
4561
|
+
const isKeyStatic = _optionalChain([node, 'access', _131 => _131.arg, 'optionalAccess', _132 => _132.isStatic]);
|
|
4521
4562
|
const { source, filename } = ctx;
|
|
4522
4563
|
if (node.rawName === "v-bind" && !node.name) {
|
|
4523
4564
|
logger.warn("Keyless v-bind will overwrite all previously declared props at runtime.", {
|
|
4524
4565
|
source,
|
|
4525
|
-
loc: _optionalChain([node, 'access',
|
|
4566
|
+
loc: _optionalChain([node, 'access', _133 => _133.arg, 'optionalAccess', _134 => _134.loc]),
|
|
4526
4567
|
file: filename
|
|
4527
4568
|
});
|
|
4528
4569
|
return;
|
|
@@ -4530,7 +4571,7 @@ function checkPropIsDynamicKey(ctx, node) {
|
|
|
4530
4571
|
if (isKeyStatic === false) {
|
|
4531
4572
|
logger.warn("Avoid using dynamic slot names, as they generate complex JSX prop expressions.", {
|
|
4532
4573
|
source,
|
|
4533
|
-
loc: _optionalChain([node, 'access',
|
|
4574
|
+
loc: _optionalChain([node, 'access', _135 => _135.arg, 'optionalAccess', _136 => _136.loc]),
|
|
4534
4575
|
file: filename
|
|
4535
4576
|
});
|
|
4536
4577
|
}
|
|
@@ -4575,19 +4616,19 @@ function resolvePropAsBabelExp(ir, ctx) {
|
|
|
4575
4616
|
}
|
|
4576
4617
|
if (isClassAttr(name) && !value.isStringLiteral && !valueContent.startsWith(STYLE_MODULE_NAME)) {
|
|
4577
4618
|
const dirCls = ADAPTER_RULES.runtime.dirCls;
|
|
4578
|
-
const arg = _optionalChain([mergedItems, 'optionalAccess',
|
|
4619
|
+
const arg = _optionalChain([mergedItems, 'optionalAccess', _137 => _137.join, 'call', _138 => _138(",")]) || wrapSingleQuotes(valueContent);
|
|
4579
4620
|
const expression = createRuntimeCall(dirCls.target, [arg]);
|
|
4580
4621
|
applyRuntimeExpression(expression, true, name);
|
|
4581
4622
|
return;
|
|
4582
4623
|
}
|
|
4583
|
-
if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess',
|
|
4624
|
+
if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess', _139 => _139.some, 'call', _140 => _140((item) => !isSimpleStyle(item))]))) {
|
|
4584
4625
|
const dirStyle = ADAPTER_RULES.runtime.dirStyle;
|
|
4585
|
-
const arg = _optionalChain([mergedItems, 'optionalAccess',
|
|
4626
|
+
const arg = _optionalChain([mergedItems, 'optionalAccess', _141 => _141.join, 'call', _142 => _142(",")]) || valueContent;
|
|
4586
4627
|
const expression = createRuntimeCall(dirStyle.target, [arg]);
|
|
4587
4628
|
applyRuntimeExpression(expression, true, name);
|
|
4588
4629
|
return;
|
|
4589
4630
|
}
|
|
4590
|
-
if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access',
|
|
4631
|
+
if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access', _143 => _143.modifiers, 'optionalAccess', _144 => _144.length])) {
|
|
4591
4632
|
const dirOn = ADAPTER_RULES.runtime.dirOn;
|
|
4592
4633
|
const eventName = wrapSingleQuotes(ir.__vOnEvName || name, ir.isStatic);
|
|
4593
4634
|
const expression = createRuntimeCall(dirOn.target, [eventName, valueContent]);
|
|
@@ -4642,7 +4683,7 @@ function resolveElementChildrenRules(children, ctx, parentIR, ir) {
|
|
|
4642
4683
|
continue;
|
|
4643
4684
|
}
|
|
4644
4685
|
const nodeIR = child;
|
|
4645
|
-
if (_optionalChain([parentIR, 'optionalAccess',
|
|
4686
|
+
if (_optionalChain([parentIR, 'optionalAccess', _145 => _145.isBuiltIn])) {
|
|
4646
4687
|
if (parentIR.tag == VUE_API_MAP.Transition) {
|
|
4647
4688
|
resolveTransitionRules(nodeIR, parentIR, ir, ctx);
|
|
4648
4689
|
}
|
|
@@ -4683,7 +4724,7 @@ function walkElementNodes(node, onElement) {
|
|
|
4683
4724
|
}
|
|
4684
4725
|
function resolveDefaultStyleModuleName(node) {
|
|
4685
4726
|
const { exp } = node;
|
|
4686
|
-
if (_optionalChain([exp, 'optionalAccess',
|
|
4727
|
+
if (_optionalChain([exp, 'optionalAccess', _146 => _146.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
4687
4728
|
return;
|
|
4688
4729
|
}
|
|
4689
4730
|
if (exp.content.includes("$style")) {
|
|
@@ -4732,7 +4773,7 @@ function injectStyleScopeAttribute(node, ctx) {
|
|
|
4732
4773
|
break;
|
|
4733
4774
|
}
|
|
4734
4775
|
}
|
|
4735
|
-
if (prop.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([prop, 'access',
|
|
4776
|
+
if (prop.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([prop, 'access', _147 => _147.arg, 'optionalAccess', _148 => _148.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
4736
4777
|
if (getHasClassOrId(prop.arg.content)) {
|
|
4737
4778
|
hasClassOrId = true;
|
|
4738
4779
|
break;
|
|
@@ -4792,7 +4833,7 @@ function mergeStyleProps(oldAttr, newAttr) {
|
|
|
4792
4833
|
const oldStyle = oldAttr.value.content;
|
|
4793
4834
|
const newStyle = parseStyleString(newAttr.value.content);
|
|
4794
4835
|
let merged = oldAttr.value.merge;
|
|
4795
|
-
if (!_optionalChain([merged, 'optionalAccess',
|
|
4836
|
+
if (!_optionalChain([merged, 'optionalAccess', _149 => _149.length])) {
|
|
4796
4837
|
merged = oldAttr.value.merge = [oldStyle, newStyle];
|
|
4797
4838
|
} else {
|
|
4798
4839
|
merged.push(newStyle);
|
|
@@ -4822,7 +4863,7 @@ function warnUnsupportedVueDollarVar(ctx, node) {
|
|
|
4822
4863
|
const { source, filename } = ctx;
|
|
4823
4864
|
let value = "";
|
|
4824
4865
|
let loc;
|
|
4825
|
-
if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access',
|
|
4866
|
+
if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access', _150 => _150.exp, 'optionalAccess', _151 => _151.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
4826
4867
|
value = node.exp.content;
|
|
4827
4868
|
loc = node.exp.loc;
|
|
4828
4869
|
} else if (node.type === _compilercore.NodeTypes.INTERPOLATION && node.content.type === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
@@ -4876,11 +4917,11 @@ function resolveRefProp(node, ctx, nodeIR) {
|
|
|
4876
4917
|
} = ctx;
|
|
4877
4918
|
let propIR;
|
|
4878
4919
|
if (node.type === _compilercore.NodeTypes.ATTRIBUTE) {
|
|
4879
|
-
const tag = _optionalChain([node, 'access',
|
|
4920
|
+
const tag = _optionalChain([node, 'access', _152 => _152.value, 'optionalAccess', _153 => _153.content]);
|
|
4880
4921
|
if (!tag) return;
|
|
4881
4922
|
collectComponentRef(tag, ctx);
|
|
4882
4923
|
const domRefBinding = Object.values(refBindings.domRefs).find((r) => r.tag === tag);
|
|
4883
|
-
const refVar = _optionalChain([domRefBinding, 'optionalAccess',
|
|
4924
|
+
const refVar = _optionalChain([domRefBinding, 'optionalAccess', _154 => _154.name]) || _optionalChain([refBindings, 'access', _155 => _155.componentRefs, 'access', _156 => _156[tag], 'optionalAccess', _157 => _157.name]);
|
|
4884
4925
|
propIR = createPropsIR("ref", "ref", refVar || "null");
|
|
4885
4926
|
} else {
|
|
4886
4927
|
const exp = node.exp;
|
|
@@ -4915,8 +4956,8 @@ function collectComponentRef(tag, ctx) {
|
|
|
4915
4956
|
function resolveDynamicAttributeProp(node, ir, ctx, nodeIR) {
|
|
4916
4957
|
const arg = node.arg;
|
|
4917
4958
|
const exp = node.exp;
|
|
4918
|
-
const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
4919
|
-
const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
4959
|
+
const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _158 => _158.content]), () => ( ""));
|
|
4960
|
+
const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _159 => _159.content]), () => ( "true"));
|
|
4920
4961
|
warnUnsupportedVueDollarVar(ctx, node);
|
|
4921
4962
|
if (name === "is") {
|
|
4922
4963
|
resolveDynamicIsProp(node, ir, ctx, nodeIR);
|
|
@@ -4927,7 +4968,7 @@ function resolveDynamicAttributeProp(node, ir, ctx, nodeIR) {
|
|
|
4927
4968
|
return;
|
|
4928
4969
|
}
|
|
4929
4970
|
const dynamicPropIR = createPropsIR(node.rawName, name, content);
|
|
4930
|
-
dynamicPropIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
4971
|
+
dynamicPropIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _160 => _160.isStatic]), () => ( true));
|
|
4931
4972
|
checkPropIsDynamicKey(ctx, node);
|
|
4932
4973
|
resolvePropertyIR(dynamicPropIR, ir, ctx, nodeIR, true);
|
|
4933
4974
|
}
|
|
@@ -4966,7 +5007,7 @@ function normalizeString(s) {
|
|
|
4966
5007
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-attribute-prop.ts
|
|
4967
5008
|
function resolveAttributeProp(node, ir, ctx, nodeIR) {
|
|
4968
5009
|
const name = node.name;
|
|
4969
|
-
const content = _nullishCoalesce(_optionalChain([node, 'access',
|
|
5010
|
+
const content = _nullishCoalesce(_optionalChain([node, 'access', _161 => _161.value, 'optionalAccess', _162 => _162.content]), () => ( "true"));
|
|
4970
5011
|
if (name === "is") {
|
|
4971
5012
|
resolveStaticIsProp(content, ir, ctx, nodeIR);
|
|
4972
5013
|
return;
|
|
@@ -4990,10 +5031,10 @@ function resolveRouterLinkVSlotProp(node, nodeIR, ctx) {
|
|
|
4990
5031
|
type: 2 /* SLOT */,
|
|
4991
5032
|
name: "customRender",
|
|
4992
5033
|
rawName: _nullishCoalesce(node.rawName, () => ( "v-slot")),
|
|
4993
|
-
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5034
|
+
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _163 => _163.isStatic]), () => ( true)),
|
|
4994
5035
|
isScoped: true,
|
|
4995
5036
|
callback: {
|
|
4996
|
-
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
5037
|
+
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _164 => _164.content, 'optionalAccess', _165 => _165.trim, 'call', _166 => _166()]), () => ( "")),
|
|
4997
5038
|
exp: []
|
|
4998
5039
|
}
|
|
4999
5040
|
};
|
|
@@ -5009,10 +5050,10 @@ function resolveVFor(node, _ir, _ctx, nodeIR) {
|
|
|
5009
5050
|
};
|
|
5010
5051
|
}
|
|
5011
5052
|
function resolveForResult(forParseResult) {
|
|
5012
|
-
const source = _optionalChain([forParseResult, 'access',
|
|
5013
|
-
const value = _optionalChain([forParseResult, 'access',
|
|
5014
|
-
const index = _optionalChain([forParseResult, 'access',
|
|
5015
|
-
const key = _optionalChain([forParseResult, 'access',
|
|
5053
|
+
const source = _optionalChain([forParseResult, 'access', _167 => _167.source, 'optionalAccess', _168 => _168.content]);
|
|
5054
|
+
const value = _optionalChain([forParseResult, 'access', _169 => _169.value, 'optionalAccess', _170 => _170.content]);
|
|
5055
|
+
const index = _optionalChain([forParseResult, 'access', _171 => _171.index, 'optionalAccess', _172 => _172.content]);
|
|
5056
|
+
const key = _optionalChain([forParseResult, 'access', _173 => _173.key, 'optionalAccess', _174 => _174.content]);
|
|
5016
5057
|
return {
|
|
5017
5058
|
source,
|
|
5018
5059
|
value,
|
|
@@ -5032,7 +5073,7 @@ function resolveVHtml(node, ir, ctx, nodeIR) {
|
|
|
5032
5073
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-if.ts
|
|
5033
5074
|
function resolveVIf(node, _ir, ctx, nodeIR, siblingNodesIR) {
|
|
5034
5075
|
const name = node.name === "else-if" ? "elseIf" : node.name;
|
|
5035
|
-
const value = _nullishCoalesce(_optionalChain([node, 'access',
|
|
5076
|
+
const value = _nullishCoalesce(_optionalChain([node, 'access', _175 => _175.exp, 'optionalAccess', _176 => _176.content]), () => ( "true"));
|
|
5036
5077
|
const prevNode = siblingNodesIR[siblingNodesIR.length - 1];
|
|
5037
5078
|
const isElseBranch = name === "else" || name === "elseIf";
|
|
5038
5079
|
let hasError = false;
|
|
@@ -5071,7 +5112,7 @@ function resolveVIf(node, _ir, ctx, nodeIR, siblingNodesIR) {
|
|
|
5071
5112
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-memo.ts
|
|
5072
5113
|
function resolveVMemo(node, _ir, ctx, nodeIR) {
|
|
5073
5114
|
const exp = node.exp;
|
|
5074
|
-
let value = _optionalChain([exp, 'optionalAccess',
|
|
5115
|
+
let value = _optionalChain([exp, 'optionalAccess', _177 => _177.content]);
|
|
5075
5116
|
if (value !== void 0) {
|
|
5076
5117
|
if (!value.trim() || !value.startsWith("[") && !value.endsWith("]")) {
|
|
5077
5118
|
const { source, filename } = ctx;
|
|
@@ -5111,14 +5152,14 @@ function resolveVModel(node, _ir, ctx, elementNode, nodeIR) {
|
|
|
5111
5152
|
const getterName = exp.content;
|
|
5112
5153
|
const isComponent = elementNode.tagType === _compilercore.ElementTypes.COMPONENT;
|
|
5113
5154
|
const inputType = resolveHtmlInput(elementNode, isComponent);
|
|
5114
|
-
const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5155
|
+
const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _178 => _178.content]), () => ( resolveModelPropName(inputType, isComponent)));
|
|
5115
5156
|
let valuePropIR;
|
|
5116
5157
|
let eventPropIR;
|
|
5117
5158
|
if (isComponent) {
|
|
5118
5159
|
valuePropIR = createPropsIR("v-model", propName, getterName);
|
|
5119
5160
|
const eventReactName = `onUpdate${capitalize(camelCase(propName))}`;
|
|
5120
5161
|
const eventVueName = `update:${propName}`;
|
|
5121
|
-
const isTS = _optionalChain([ctx, 'access',
|
|
5162
|
+
const isTS = _optionalChain([ctx, 'access', _179 => _179.scriptData, 'optionalAccess', _180 => _180.lang, 'optionalAccess', _181 => _181.startsWith, 'call', _182 => _182("ts")]);
|
|
5122
5163
|
const valueArg = isTS ? "value: any" : "value";
|
|
5123
5164
|
const processedValue = applyValueModifiers("value", modifiers);
|
|
5124
5165
|
const handlerBody = `(${valueArg}) => { ${getterName} = ${processedValue} }`;
|
|
@@ -5156,7 +5197,7 @@ function getRadioValue(elementNode) {
|
|
|
5156
5197
|
const valueAttr = elementNode.props.find(
|
|
5157
5198
|
(prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "value"
|
|
5158
5199
|
);
|
|
5159
|
-
if (!_optionalChain([valueAttr, 'optionalAccess',
|
|
5200
|
+
if (!_optionalChain([valueAttr, 'optionalAccess', _183 => _183.value, 'optionalAccess', _184 => _184.content])) return '""';
|
|
5160
5201
|
const content = valueAttr.value.content;
|
|
5161
5202
|
return /^['"]/.test(content) ? content : `"${content}"`;
|
|
5162
5203
|
}
|
|
@@ -5166,7 +5207,7 @@ function resolveHtmlInput(node, isComponent) {
|
|
|
5166
5207
|
const typeProp = node.props.find(
|
|
5167
5208
|
(prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "type"
|
|
5168
5209
|
);
|
|
5169
|
-
return _optionalChain([typeProp, 'optionalAccess',
|
|
5210
|
+
return _optionalChain([typeProp, 'optionalAccess', _185 => _185.value, 'optionalAccess', _186 => _186.content, 'optionalAccess', _187 => _187.toLowerCase, 'call', _188 => _188()]);
|
|
5170
5211
|
}
|
|
5171
5212
|
function applyValueModifiers(valueExp, modifiers) {
|
|
5172
5213
|
let result = valueExp;
|
|
@@ -5370,7 +5411,7 @@ function resolveVSlotProp(node, _ir, ctx) {
|
|
|
5370
5411
|
const name = !arg || arg.content === "default" ? "children" : arg.content;
|
|
5371
5412
|
const content = !isScoped ? [] : void 0;
|
|
5372
5413
|
const callback = isScoped ? {
|
|
5373
|
-
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
5414
|
+
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _189 => _189.content, 'optionalAccess', _190 => _190.trim, 'call', _191 => _191()]), () => ( "")),
|
|
5374
5415
|
exp: []
|
|
5375
5416
|
} : void 0;
|
|
5376
5417
|
checkPropIsDynamicKey(ctx, node);
|
|
@@ -5378,7 +5419,7 @@ function resolveVSlotProp(node, _ir, ctx) {
|
|
|
5378
5419
|
type: 2 /* SLOT */,
|
|
5379
5420
|
name,
|
|
5380
5421
|
rawName: _nullishCoalesce(node.rawName, () => ( "default")),
|
|
5381
|
-
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5422
|
+
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _192 => _192.isStatic]), () => ( true)),
|
|
5382
5423
|
isScoped,
|
|
5383
5424
|
content,
|
|
5384
5425
|
callback
|
|
@@ -5412,7 +5453,7 @@ function resolveElementNode(node, ir, ctx, siblingNodesIR) {
|
|
|
5412
5453
|
if (routerAdapter) {
|
|
5413
5454
|
if (!ctx.route) ctx.route = true;
|
|
5414
5455
|
nodeIR.isRoute = true;
|
|
5415
|
-
recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess',
|
|
5456
|
+
recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess', _193 => _193.package]), routerAdapter.target);
|
|
5416
5457
|
}
|
|
5417
5458
|
resolveProps(node, ir, ctx, nodeIR, siblingNodesIR);
|
|
5418
5459
|
return nodeIR;
|
|
@@ -5548,7 +5589,7 @@ function resolveSlotProps(node, ctx) {
|
|
|
5548
5589
|
for (const prop of node.props) {
|
|
5549
5590
|
if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
|
|
5550
5591
|
const attr = prop.name;
|
|
5551
|
-
const value = _optionalChain([prop, 'access',
|
|
5592
|
+
const value = _optionalChain([prop, 'access', _194 => _194.value, 'optionalAccess', _195 => _195.content, 'access', _196 => _196.trim, 'call', _197 => _197()]);
|
|
5552
5593
|
if (attr === "name" && value) {
|
|
5553
5594
|
result.name = camelCase(value);
|
|
5554
5595
|
} else {
|
|
@@ -5638,19 +5679,19 @@ function resolveTemplate2(root, ctx) {
|
|
|
5638
5679
|
// src/core/transform/sfc/index.ts
|
|
5639
5680
|
function transform(ast, ctx, options) {
|
|
5640
5681
|
const { template, script, style } = ast;
|
|
5641
|
-
const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess',
|
|
5642
|
-
const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess',
|
|
5682
|
+
const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess', _198 => _198.ast]), ctx);
|
|
5683
|
+
const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess', _199 => _199.ast]), ctx);
|
|
5643
5684
|
const result = {
|
|
5644
5685
|
template: templateIR,
|
|
5645
5686
|
script: scriptIR,
|
|
5646
|
-
style: _optionalChain([style, 'optionalAccess',
|
|
5687
|
+
style: _optionalChain([style, 'optionalAccess', _200 => _200.source, 'optionalAccess', _201 => _201.content])
|
|
5647
5688
|
};
|
|
5648
|
-
executePlugins(_optionalChain([options, 'optionalAccess',
|
|
5689
|
+
executePlugins(_optionalChain([options, 'optionalAccess', _202 => _202.plugins]), result, ctx);
|
|
5649
5690
|
return result;
|
|
5650
5691
|
}
|
|
5651
5692
|
|
|
5652
5693
|
// package.json
|
|
5653
|
-
var version = "1.5.
|
|
5694
|
+
var version = "1.5.1";
|
|
5654
5695
|
var bin = {
|
|
5655
5696
|
vureact: "./bin/vureact.js"
|
|
5656
5697
|
};
|
|
@@ -5844,7 +5885,7 @@ var Helper = (_class5 = class {
|
|
|
5844
5885
|
__init8() {this.outDir = "react-app"}
|
|
5845
5886
|
constructor(opts) {;_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);
|
|
5846
5887
|
this.compilerOpts = opts;
|
|
5847
|
-
if (_optionalChain([opts, 'access',
|
|
5888
|
+
if (_optionalChain([opts, 'access', _203 => _203.output, 'optionalAccess', _204 => _204.workspace])) {
|
|
5848
5889
|
this.workspaceDir = opts.output.workspace;
|
|
5849
5890
|
}
|
|
5850
5891
|
const excludePatterns = PathFilter.withDefaults(opts.exclude || []);
|
|
@@ -5881,7 +5922,7 @@ var Helper = (_class5 = class {
|
|
|
5881
5922
|
}
|
|
5882
5923
|
getOutDirName() {
|
|
5883
5924
|
const { output } = this.compilerOpts;
|
|
5884
|
-
return _optionalChain([output, 'optionalAccess',
|
|
5925
|
+
return _optionalChain([output, 'optionalAccess', _205 => _205.outDir]) || this.outDir;
|
|
5885
5926
|
}
|
|
5886
5927
|
getWorkspaceDir() {
|
|
5887
5928
|
return _path2.default.resolve(this.getProjectRoot(), this.workspaceDir);
|
|
@@ -5895,7 +5936,7 @@ var Helper = (_class5 = class {
|
|
|
5895
5936
|
}
|
|
5896
5937
|
getIgnoreAssets() {
|
|
5897
5938
|
const { output } = this.compilerOpts;
|
|
5898
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
5939
|
+
if (_optionalChain([output, 'optionalAccess', _206 => _206.ignoreAssets])) {
|
|
5899
5940
|
return new Set(output.ignoreAssets.map(normalizePath));
|
|
5900
5941
|
}
|
|
5901
5942
|
return /* @__PURE__ */ new Set([
|
|
@@ -5978,12 +6019,12 @@ var Helper = (_class5 = class {
|
|
|
5978
6019
|
*/
|
|
5979
6020
|
async formatCode({ code, fileInfo }) {
|
|
5980
6021
|
const { format } = this.compilerOpts;
|
|
5981
|
-
if (!_optionalChain([format, 'optionalAccess',
|
|
5982
|
-
if (_optionalChain([format, 'optionalAccess',
|
|
6022
|
+
if (!_optionalChain([format, 'optionalAccess', _207 => _207.enabled])) return code;
|
|
6023
|
+
if (_optionalChain([format, 'optionalAccess', _208 => _208.formatter]) === "builtin") {
|
|
5983
6024
|
return simpleFormat(code);
|
|
5984
6025
|
}
|
|
5985
|
-
const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess',
|
|
5986
|
-
return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess',
|
|
6026
|
+
const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess', _209 => _209.jsx]), () => ( _optionalChain([fileInfo, 'optionalAccess', _210 => _210.script])));
|
|
6027
|
+
return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess', _211 => _211.prettierOptions]));
|
|
5987
6028
|
}
|
|
5988
6029
|
/**
|
|
5989
6030
|
* 通用的缓存校验工具函数
|
|
@@ -6017,7 +6058,7 @@ var Helper = (_class5 = class {
|
|
|
6017
6058
|
* @param options.lock - 是否启用文件锁(默认false)
|
|
6018
6059
|
*/
|
|
6019
6060
|
async writeFileWithDir(filePath, content, options) {
|
|
6020
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
6061
|
+
if (_optionalChain([options, 'optionalAccess', _212 => _212.lock])) {
|
|
6021
6062
|
await fileLock.updateFile(filePath, async () => content, options);
|
|
6022
6063
|
} else {
|
|
6023
6064
|
await _fs2.default.promises.mkdir(_path2.default.dirname(filePath), { recursive: true });
|
|
@@ -6142,7 +6183,7 @@ var Helper = (_class5 = class {
|
|
|
6142
6183
|
* 获取需要排除编译的文件
|
|
6143
6184
|
*/
|
|
6144
6185
|
getExcludes() {
|
|
6145
|
-
if (!_optionalChain([this, 'access',
|
|
6186
|
+
if (!_optionalChain([this, 'access', _213 => _213.compilerOpts, 'access', _214 => _214.exclude, 'optionalAccess', _215 => _215.length])) {
|
|
6146
6187
|
return PathFilter.withDefaults();
|
|
6147
6188
|
}
|
|
6148
6189
|
return this.compilerOpts.exclude;
|
|
@@ -6240,7 +6281,7 @@ function parseOnlyStyle(source, ctx, options) {
|
|
|
6240
6281
|
ast: void 0
|
|
6241
6282
|
}
|
|
6242
6283
|
};
|
|
6243
|
-
executePlugins(_optionalChain([options, 'optionalAccess',
|
|
6284
|
+
executePlugins(_optionalChain([options, 'optionalAccess', _216 => _216.plugins]), result, ctx);
|
|
6244
6285
|
return result;
|
|
6245
6286
|
}
|
|
6246
6287
|
|
|
@@ -6372,16 +6413,16 @@ var BaseCompiler = (_class7 = class extends Helper {
|
|
|
6372
6413
|
});
|
|
6373
6414
|
const genOptions = this.prepareGenerateOptions(filename);
|
|
6374
6415
|
const resolveSFCAndScriptFile = () => {
|
|
6375
|
-
const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
6376
|
-
const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
6416
|
+
const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _217 => _217.parser]) });
|
|
6417
|
+
const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _218 => _218.transformer]) });
|
|
6377
6418
|
const gen = generate(ir, ctx.data, {
|
|
6378
6419
|
...genOptions,
|
|
6379
|
-
plugins: _optionalChain([plugins, 'optionalAccess',
|
|
6420
|
+
plugins: _optionalChain([plugins, 'optionalAccess', _219 => _219.codegen])
|
|
6380
6421
|
});
|
|
6381
6422
|
return this.resolveMainResult(ir, gen, ctx.data);
|
|
6382
6423
|
};
|
|
6383
6424
|
const resolveStyleFile = () => {
|
|
6384
|
-
const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
6425
|
+
const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _220 => _220.parser]) });
|
|
6385
6426
|
return this.resolveStyleResult(result, ctx.data);
|
|
6386
6427
|
};
|
|
6387
6428
|
try {
|
|
@@ -6398,18 +6439,10 @@ var BaseCompiler = (_class7 = class extends Helper {
|
|
|
6398
6439
|
}
|
|
6399
6440
|
prepareGenerateOptions(filename) {
|
|
6400
6441
|
const userOptions = this.options.generate || {};
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
minimal: true,
|
|
6404
|
-
quotes: "single"
|
|
6405
|
-
},
|
|
6406
|
-
minified: true,
|
|
6407
|
-
...userOptions
|
|
6408
|
-
};
|
|
6409
|
-
if (mergedOptions.sourceMaps && filename) {
|
|
6410
|
-
mergedOptions.sourceFileName = mergedOptions.sourceFileName || filename;
|
|
6442
|
+
if (userOptions.sourceMaps && filename) {
|
|
6443
|
+
userOptions.sourceFileName = userOptions.sourceFileName || filename;
|
|
6411
6444
|
}
|
|
6412
|
-
return
|
|
6445
|
+
return userOptions;
|
|
6413
6446
|
}
|
|
6414
6447
|
resolveMainResult(ir, gen, ctxData) {
|
|
6415
6448
|
const { fileId, filename, scriptData, styleData, inputType } = ctxData;
|
|
@@ -6428,9 +6461,9 @@ var BaseCompiler = (_class7 = class extends Helper {
|
|
|
6428
6461
|
lang
|
|
6429
6462
|
},
|
|
6430
6463
|
css: {
|
|
6431
|
-
file: _optionalChain([styleData, 'optionalAccess',
|
|
6432
|
-
hash: _optionalChain([styleData, 'optionalAccess',
|
|
6433
|
-
code: _optionalChain([ir, 'optionalAccess',
|
|
6464
|
+
file: _optionalChain([styleData, 'optionalAccess', _221 => _221.filePath]),
|
|
6465
|
+
hash: _optionalChain([styleData, 'optionalAccess', _222 => _222.scopeId]),
|
|
6466
|
+
code: _optionalChain([ir, 'optionalAccess', _223 => _223.style])
|
|
6434
6467
|
}
|
|
6435
6468
|
},
|
|
6436
6469
|
...base
|
|
@@ -6500,7 +6533,7 @@ var AssetManager = (_class8 = class {
|
|
|
6500
6533
|
const relativeToRoot = normalizePath(this.fileCompiler.relativePath(p));
|
|
6501
6534
|
const filename = _path2.default.basename(p).toLowerCase();
|
|
6502
6535
|
const ext = _path2.default.extname(p).toLowerCase();
|
|
6503
|
-
if (!_optionalChain([options, 'access',
|
|
6536
|
+
if (!_optionalChain([options, 'access', _224 => _224.output, 'optionalAccess', _225 => _225.ignoreAssets])) {
|
|
6504
6537
|
const shouldExclude = Array.from(exclusions).some((pattern) => {
|
|
6505
6538
|
if (pattern.endsWith(".")) {
|
|
6506
6539
|
return filename.startsWith(pattern);
|
|
@@ -6597,12 +6630,12 @@ var CacheManager = (_class9 = class {
|
|
|
6597
6630
|
const meta = { ...unit };
|
|
6598
6631
|
delete meta.source;
|
|
6599
6632
|
if (key === "sfc" /* SFC */) {
|
|
6600
|
-
_optionalChainDelete([meta, 'access',
|
|
6601
|
-
_optionalChainDelete([meta, 'access',
|
|
6633
|
+
_optionalChainDelete([meta, 'access', _226 => _226.output, 'optionalAccess', _227 => _227.jsx, 'access', _228 => delete _228.code]);
|
|
6634
|
+
_optionalChainDelete([meta, 'access', _229 => _229.output, 'optionalAccess', _230 => _230.css, 'access', _231 => delete _231.code]);
|
|
6602
6635
|
} else if (key === "script" /* SCRIPT */) {
|
|
6603
|
-
_optionalChainDelete([meta, 'access',
|
|
6636
|
+
_optionalChainDelete([meta, 'access', _232 => _232.output, 'optionalAccess', _233 => _233.script, 'access', _234 => delete _234.code]);
|
|
6604
6637
|
} else if (key === "style" /* STYLE */) {
|
|
6605
|
-
_optionalChainDelete([meta, 'access',
|
|
6638
|
+
_optionalChainDelete([meta, 'access', _235 => _235.output, 'optionalAccess', _236 => _236.style, 'access', _237 => delete _237.code]);
|
|
6606
6639
|
}
|
|
6607
6640
|
if (!this.pendingUpdates.has(key)) {
|
|
6608
6641
|
this.pendingUpdates.set(key, []);
|
|
@@ -6672,7 +6705,7 @@ var CleanupManager = class {
|
|
|
6672
6705
|
meta = m;
|
|
6673
6706
|
const { jsx, css } = meta.output;
|
|
6674
6707
|
await this.fileCompiler.removeOutputFile(jsx.file);
|
|
6675
|
-
if (_optionalChain([css, 'optionalAccess',
|
|
6708
|
+
if (_optionalChain([css, 'optionalAccess', _238 => _238.file])) {
|
|
6676
6709
|
await this.fileCompiler.removeOutputFile(css.file);
|
|
6677
6710
|
}
|
|
6678
6711
|
break;
|
|
@@ -6733,7 +6766,7 @@ var CompilationUnitProcessor = class {
|
|
|
6733
6766
|
const isScriptFile = key === "script" /* SCRIPT */;
|
|
6734
6767
|
const isStyleFile = key === "style" /* STYLE */;
|
|
6735
6768
|
if (isSFC || isScriptFile) {
|
|
6736
|
-
unit.hasRoute = _optionalChain([result, 'optionalAccess',
|
|
6769
|
+
unit.hasRoute = _optionalChain([result, 'optionalAccess', _239 => _239.hasRoute]);
|
|
6737
6770
|
}
|
|
6738
6771
|
const resolveFileInfo = () => {
|
|
6739
6772
|
if (isSFC) {
|
|
@@ -6753,7 +6786,7 @@ var CompilationUnitProcessor = class {
|
|
|
6753
6786
|
const { script } = result.fileInfo;
|
|
6754
6787
|
unit.output = {
|
|
6755
6788
|
script: {
|
|
6756
|
-
file: _optionalChain([script, 'optionalAccess',
|
|
6789
|
+
file: _optionalChain([script, 'optionalAccess', _240 => _240.file]),
|
|
6757
6790
|
code
|
|
6758
6791
|
}
|
|
6759
6792
|
};
|
|
@@ -6830,7 +6863,7 @@ var FileProcessor = (_class10 = class {
|
|
|
6830
6863
|
const absPath = this.fileCompiler.getAbsPath(filePath);
|
|
6831
6864
|
const fileMeta = await this.fileCompiler.getFileMeta(absPath);
|
|
6832
6865
|
const cache = (this.fileCompiler.getIsCache() ? existingCache : void 0) || await this.fileCompiler.loadCache(key);
|
|
6833
|
-
const record = _optionalChain([cache, 'optionalAccess',
|
|
6866
|
+
const record = _optionalChain([cache, 'optionalAccess', _241 => _241.target, 'access', _242 => _242.find, 'call', _243 => _243((c) => c.file === absPath)]);
|
|
6834
6867
|
const { shouldCompile, hash } = await this.fileCompiler.checkCacheStatus(
|
|
6835
6868
|
fileMeta,
|
|
6836
6869
|
record,
|
|
@@ -6852,10 +6885,10 @@ var FileProcessor = (_class10 = class {
|
|
|
6852
6885
|
hash: hash || this.fileCompiler.genHash(source)
|
|
6853
6886
|
};
|
|
6854
6887
|
const processed = await this.compilationUnitProcessor.resolve(initUnit, key);
|
|
6855
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
6888
|
+
if (_optionalChain([processed, 'optionalAccess', _244 => _244.output])) {
|
|
6856
6889
|
await this.compilationUnitProcessor.saveCompiledFiles(processed, key);
|
|
6857
6890
|
if (key === "sfc" /* SFC */ || key === "script" /* SCRIPT */) {
|
|
6858
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
6891
|
+
if (_optionalChain([processed, 'optionalAccess', _245 => _245.hasRoute])) {
|
|
6859
6892
|
await this.addRouterToPackageJson();
|
|
6860
6893
|
await this.updateEntryWithRouterProvider();
|
|
6861
6894
|
}
|
|
@@ -6869,13 +6902,13 @@ var FileProcessor = (_class10 = class {
|
|
|
6869
6902
|
*/
|
|
6870
6903
|
async addRouterToPackageJson() {
|
|
6871
6904
|
const { output } = this.fileCompiler.options;
|
|
6872
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
6905
|
+
if (_optionalChain([output, 'optionalAccess', _246 => _246.bootstrapVite]) === false) {
|
|
6873
6906
|
return;
|
|
6874
6907
|
}
|
|
6875
6908
|
const { router } = RUNTIME_PACKAGES;
|
|
6876
6909
|
const filePath = this.fileCompiler.getOutputPkgPath();
|
|
6877
6910
|
const packageJson = await this.fileCompiler.resolvePackageFile(filePath);
|
|
6878
|
-
if (_optionalChain([packageJson, 'optionalAccess',
|
|
6911
|
+
if (_optionalChain([packageJson, 'optionalAccess', _247 => _247.dependencies, 'optionalAccess', _248 => _248[router.name]])) {
|
|
6879
6912
|
return;
|
|
6880
6913
|
}
|
|
6881
6914
|
if (!packageJson.dependencies) {
|
|
@@ -6894,7 +6927,7 @@ var FileProcessor = (_class10 = class {
|
|
|
6894
6927
|
const { exclude, output, router } = this.fileCompiler.options;
|
|
6895
6928
|
const inputPath = this.fileCompiler.getInputPath();
|
|
6896
6929
|
const outputPath = this.fileCompiler.getOuputPath(true);
|
|
6897
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
6930
|
+
if (_optionalChain([output, 'optionalAccess', _249 => _249.bootstrapVite]) === false || _optionalChain([router, 'optionalAccess', _250 => _250.autoUpdateEntry]) === false || !_optionalChain([router, 'optionalAccess', _251 => _251.configFile])) {
|
|
6898
6931
|
return;
|
|
6899
6932
|
}
|
|
6900
6933
|
const getMainFile = async (filename) => {
|
|
@@ -6915,7 +6948,7 @@ var FileProcessor = (_class10 = class {
|
|
|
6915
6948
|
const prepareRouterEntry = () => {
|
|
6916
6949
|
const importPath = this.fileCompiler.resolveRelativePath(inputPath, router.configFile);
|
|
6917
6950
|
let content = fileData.content;
|
|
6918
|
-
if (_optionalChain([exclude, 'optionalAccess',
|
|
6951
|
+
if (_optionalChain([exclude, 'optionalAccess', _252 => _252.includes, 'call', _253 => _253(router.configFile)]) || _optionalChain([exclude, 'optionalAccess', _254 => _254.includes, 'call', _255 => _255(importPath)])) {
|
|
6919
6952
|
return content;
|
|
6920
6953
|
}
|
|
6921
6954
|
const routerModule = "RouterInstance";
|
|
@@ -7061,7 +7094,7 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7061
7094
|
const { output } = this.options;
|
|
7062
7095
|
const workspaceDir = this.fileCompiler.getWorkspaceDir();
|
|
7063
7096
|
await _fs2.default.promises.mkdir(workspaceDir, { recursive: true });
|
|
7064
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
7097
|
+
if (_optionalChain([output, 'optionalAccess', _256 => _256.bootstrapVite]) === false) {
|
|
7065
7098
|
return false;
|
|
7066
7099
|
}
|
|
7067
7100
|
if (this.isSingleFile()) {
|
|
@@ -7111,7 +7144,7 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7111
7144
|
const newDevDeps = resolveDeps(sourcePkg.devDependencies, newPkg.devDependencies, true);
|
|
7112
7145
|
newPkg.dependencies = newDeps;
|
|
7113
7146
|
newPkg.devDependencies = newDevDeps;
|
|
7114
|
-
newPkg = _optionalChain([output, 'optionalAccess',
|
|
7147
|
+
newPkg = _optionalChain([output, 'optionalAccess', _257 => _257.packageJson, 'optionalCall', _258 => _258(newPkg)]) || newPkg;
|
|
7115
7148
|
await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
|
|
7116
7149
|
this.spinner.succeed("Standard Vite React environment initialized");
|
|
7117
7150
|
return true;
|
|
@@ -7122,12 +7155,12 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7122
7155
|
async resolveViteCreateApp() {
|
|
7123
7156
|
const { output } = this.options;
|
|
7124
7157
|
const { viteVersion, template: tmpl } = this.defaultConfig;
|
|
7125
|
-
const bootstrapVite = _optionalChain([output, 'optionalAccess',
|
|
7158
|
+
const bootstrapVite = _optionalChain([output, 'optionalAccess', _259 => _259.bootstrapVite]);
|
|
7126
7159
|
const outDirName = this.fileCompiler.getOutDirName();
|
|
7127
7160
|
const configObject = typeof bootstrapVite === "object" ? bootstrapVite : null;
|
|
7128
|
-
const viteVer = _optionalChain([configObject, 'optionalAccess',
|
|
7129
|
-
const reactVer = _optionalChain([configObject, 'optionalAccess',
|
|
7130
|
-
const template = _optionalChain([configObject, 'optionalAccess',
|
|
7161
|
+
const viteVer = _optionalChain([configObject, 'optionalAccess', _260 => _260.vite]) || viteVersion;
|
|
7162
|
+
const reactVer = _optionalChain([configObject, 'optionalAccess', _261 => _261.react]);
|
|
7163
|
+
const template = _optionalChain([configObject, 'optionalAccess', _262 => _262.template]) || tmpl;
|
|
7131
7164
|
const cmd = `npm create vite${viteVer} ${outDirName} -- --template ${template}`;
|
|
7132
7165
|
_child_process.execSync.call(void 0, cmd, {
|
|
7133
7166
|
cwd: this.fileCompiler.getWorkspaceDir(),
|
|
@@ -7231,7 +7264,7 @@ var FileCompiler = (_class13 = class extends BaseCompiler {
|
|
|
7231
7264
|
const scriptCount = await this.runPipelineWithSpinner("script" /* SCRIPT */);
|
|
7232
7265
|
const styleCount = await this.runPipelineWithSpinner("style" /* STYLE */);
|
|
7233
7266
|
const assetCount = await this.runPipelineWithSpinner("copied" /* ASSET */);
|
|
7234
|
-
await _optionalChain([this, 'access',
|
|
7267
|
+
await _optionalChain([this, 'access', _263 => _263.options, 'access', _264 => _264.onSuccess, 'optionalCall', _265 => _265()]);
|
|
7235
7268
|
const endTime = calcElapsedTime(startTime);
|
|
7236
7269
|
this.printCoreLogs();
|
|
7237
7270
|
this.showCompileStats(endTime, sfcCount, scriptCount, styleCount, assetCount);
|