@vureact/compiler-core 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -1
- package/README.md +3 -1
- package/lib/{chunk-Q7HZAZHD.esm.js → chunk-6MTN25KZ.esm.js} +646 -548
- package/lib/{chunk-Q36XF5TP.js → chunk-V7G7OQWK.js} +667 -569
- package/lib/cli.esm.js +3 -2
- package/lib/cli.js +11 -10
- package/lib/compiler-core.d.cts +72 -57
- package/lib/compiler-core.d.ts +72 -57
- package/lib/compiler-core.esm.js +2 -2
- package/lib/compiler-core.js +3 -3
- package/package.json +5 -4
|
@@ -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.
|
|
2
|
+
* @vureact/compiler-core v1.8.0
|
|
3
3
|
* (c) 2025-present Ruihong Zhong (Ryan John)
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -451,8 +451,8 @@ function getBabelParseOptions(lang = "js", context = "script", filename) {
|
|
|
451
451
|
function stringToExpr(input, lang, filename = "") {
|
|
452
452
|
return _parser.parseExpression.call(void 0, input, getBabelParseOptions(lang, "expression", filename));
|
|
453
453
|
}
|
|
454
|
-
function atComponentOrHookRoot(
|
|
455
|
-
const { parentPath, scope } =
|
|
454
|
+
function atComponentOrHookRoot(path8, rootScope, inScriptFile = false) {
|
|
455
|
+
const { parentPath, scope } = path8;
|
|
456
456
|
const parentBlock = scope.block;
|
|
457
457
|
if (!parentPath) return !inScriptFile;
|
|
458
458
|
if (parentBlock === rootScope) {
|
|
@@ -1521,10 +1521,10 @@ var _core = require('@babel/core');
|
|
|
1521
1521
|
|
|
1522
1522
|
// src/core/transform/sfc/script/shared/babel-utils.ts
|
|
1523
1523
|
|
|
1524
|
-
function findRootVariablePath(
|
|
1525
|
-
const rootId = findRootIdentifier(
|
|
1524
|
+
function findRootVariablePath(path8) {
|
|
1525
|
+
const rootId = findRootIdentifier(path8.node);
|
|
1526
1526
|
if (!_optionalChain([rootId, 'optionalAccess', _46 => _46.name])) return null;
|
|
1527
|
-
const binding =
|
|
1527
|
+
const binding = path8.scope.getBinding(rootId.name);
|
|
1528
1528
|
if (!binding) return null;
|
|
1529
1529
|
const rootPath = getVariableDeclaratorPath(binding.path);
|
|
1530
1530
|
return rootPath;
|
|
@@ -1536,14 +1536,14 @@ function findRootIdentifier(node) {
|
|
|
1536
1536
|
}
|
|
1537
1537
|
return t15.isIdentifier(current) ? current : null;
|
|
1538
1538
|
}
|
|
1539
|
-
function getVariableDeclaratorPath(
|
|
1540
|
-
if (
|
|
1541
|
-
return
|
|
1539
|
+
function getVariableDeclaratorPath(path8) {
|
|
1540
|
+
if (path8.isVariableDeclarator()) {
|
|
1541
|
+
return path8;
|
|
1542
1542
|
}
|
|
1543
|
-
return
|
|
1543
|
+
return path8.findParent((p) => p.isVariableDeclarator());
|
|
1544
1544
|
}
|
|
1545
|
-
function isVariableDeclTopLevel(
|
|
1546
|
-
const variableDeclaratorPath =
|
|
1545
|
+
function isVariableDeclTopLevel(path8) {
|
|
1546
|
+
const variableDeclaratorPath = path8;
|
|
1547
1547
|
const variableDeclarationPath = variableDeclaratorPath.parentPath;
|
|
1548
1548
|
if (!variableDeclarationPath) {
|
|
1549
1549
|
return false;
|
|
@@ -1557,61 +1557,61 @@ function isVariableDeclTopLevel(path9) {
|
|
|
1557
1557
|
}
|
|
1558
1558
|
return false;
|
|
1559
1559
|
}
|
|
1560
|
-
function isRealVariableAccess(
|
|
1561
|
-
return isIdentifierAccess(
|
|
1560
|
+
function isRealVariableAccess(path8) {
|
|
1561
|
+
return isIdentifierAccess(path8) && !isPropertyName(path8);
|
|
1562
1562
|
}
|
|
1563
|
-
function isIdentifierAccess(
|
|
1564
|
-
if (isIdentifierDeclaration(
|
|
1563
|
+
function isIdentifierAccess(path8) {
|
|
1564
|
+
if (isIdentifierDeclaration(path8)) {
|
|
1565
1565
|
return false;
|
|
1566
1566
|
}
|
|
1567
|
-
const binding =
|
|
1567
|
+
const binding = path8.scope.getBinding(path8.node.name);
|
|
1568
1568
|
if (!binding) {
|
|
1569
1569
|
return true;
|
|
1570
1570
|
}
|
|
1571
|
-
return binding.identifier !==
|
|
1571
|
+
return binding.identifier !== path8.node;
|
|
1572
1572
|
}
|
|
1573
|
-
function isIdentifierDeclaration(
|
|
1574
|
-
const parent =
|
|
1573
|
+
function isIdentifierDeclaration(path8) {
|
|
1574
|
+
const parent = path8.parentPath;
|
|
1575
1575
|
if (!parent) return false;
|
|
1576
|
-
if (parent.isVariableDeclarator() && parent.node.id ===
|
|
1576
|
+
if (parent.isVariableDeclarator() && parent.node.id === path8.node) {
|
|
1577
1577
|
return true;
|
|
1578
1578
|
}
|
|
1579
|
-
if (parent.isFunctionDeclaration() && parent.node.id ===
|
|
1579
|
+
if (parent.isFunctionDeclaration() && parent.node.id === path8.node) {
|
|
1580
1580
|
return true;
|
|
1581
1581
|
}
|
|
1582
|
-
if (parent.isFunctionExpression() && parent.node.id ===
|
|
1582
|
+
if (parent.isFunctionExpression() && parent.node.id === path8.node) {
|
|
1583
1583
|
return true;
|
|
1584
1584
|
}
|
|
1585
|
-
if (parent.isClassDeclaration() && parent.node.id ===
|
|
1585
|
+
if (parent.isClassDeclaration() && parent.node.id === path8.node) {
|
|
1586
1586
|
return true;
|
|
1587
1587
|
}
|
|
1588
|
-
if (parent.isImportSpecifier() && parent.node.local ===
|
|
1588
|
+
if (parent.isImportSpecifier() && parent.node.local === path8.node) {
|
|
1589
1589
|
return true;
|
|
1590
1590
|
}
|
|
1591
|
-
if (parent.isImportDefaultSpecifier() && parent.node.local ===
|
|
1591
|
+
if (parent.isImportDefaultSpecifier() && parent.node.local === path8.node) {
|
|
1592
1592
|
return true;
|
|
1593
1593
|
}
|
|
1594
|
-
if (parent.isImportNamespaceSpecifier() && parent.node.local ===
|
|
1594
|
+
if (parent.isImportNamespaceSpecifier() && parent.node.local === path8.node) {
|
|
1595
1595
|
return true;
|
|
1596
1596
|
}
|
|
1597
|
-
if (parent.isFunction() && parent.node.params.includes(
|
|
1597
|
+
if (parent.isFunction() && parent.node.params.includes(path8.node)) {
|
|
1598
1598
|
return true;
|
|
1599
1599
|
}
|
|
1600
|
-
if (parent.isCatchClause() && parent.node.param ===
|
|
1600
|
+
if (parent.isCatchClause() && parent.node.param === path8.node) {
|
|
1601
1601
|
return true;
|
|
1602
1602
|
}
|
|
1603
1603
|
return false;
|
|
1604
1604
|
}
|
|
1605
|
-
function isPropertyName(
|
|
1606
|
-
const parent =
|
|
1605
|
+
function isPropertyName(path8) {
|
|
1606
|
+
const parent = path8.parentPath;
|
|
1607
1607
|
if (!parent) return false;
|
|
1608
|
-
if (parent.isObjectProperty() && parent.node.key ===
|
|
1608
|
+
if (parent.isObjectProperty() && parent.node.key === path8.node) {
|
|
1609
1609
|
return true;
|
|
1610
1610
|
}
|
|
1611
|
-
if (parent.isClassProperty() && parent.node.key ===
|
|
1611
|
+
if (parent.isClassProperty() && parent.node.key === path8.node) {
|
|
1612
1612
|
return true;
|
|
1613
1613
|
}
|
|
1614
|
-
if (parent.isMemberExpression() && parent.node.property ===
|
|
1614
|
+
if (parent.isMemberExpression() && parent.node.property === path8.node) {
|
|
1615
1615
|
return true;
|
|
1616
1616
|
}
|
|
1617
1617
|
return false;
|
|
@@ -1707,7 +1707,7 @@ function forkNode(node, deep = true) {
|
|
|
1707
1707
|
cleanNodeComments(node);
|
|
1708
1708
|
return newNode;
|
|
1709
1709
|
}
|
|
1710
|
-
function replaceNode(
|
|
1710
|
+
function replaceNode(path8, target, source) {
|
|
1711
1711
|
const { start, end, loc, leadingComments, innerComments, trailingComments } = source;
|
|
1712
1712
|
target.start = start;
|
|
1713
1713
|
target.end = end;
|
|
@@ -1717,7 +1717,7 @@ function replaceNode(path9, target, source) {
|
|
|
1717
1717
|
target.trailingComments = trailingComments;
|
|
1718
1718
|
cleanNodeLoc(source);
|
|
1719
1719
|
cleanNodeComments(source);
|
|
1720
|
-
|
|
1720
|
+
path8.replaceWith(target);
|
|
1721
1721
|
}
|
|
1722
1722
|
function cleanNodeLoc(node) {
|
|
1723
1723
|
node.start = null;
|
|
@@ -1731,8 +1731,8 @@ function cleanNodeComments(node) {
|
|
|
1731
1731
|
}
|
|
1732
1732
|
|
|
1733
1733
|
// src/core/parse/sfc/postprocess/resolve-script-metadata/resolve-declared-options.ts
|
|
1734
|
-
function resolveDeclaredOptions(
|
|
1735
|
-
const { node } =
|
|
1734
|
+
function resolveDeclaredOptions(path8, ctx) {
|
|
1735
|
+
const { node } = path8;
|
|
1736
1736
|
const { filename, scriptData } = ctx;
|
|
1737
1737
|
if (!isCalleeNamed(node, MACRO_API_NAMES.options)) {
|
|
1738
1738
|
return;
|
|
@@ -1854,11 +1854,11 @@ function resolveStaticName(key) {
|
|
|
1854
1854
|
}
|
|
1855
1855
|
return null;
|
|
1856
1856
|
}
|
|
1857
|
-
function resolveLocalTypeFromReference(
|
|
1857
|
+
function resolveLocalTypeFromReference(path8, typeRef, ctx, macroName, visitedTypeRefs, warnedImportedTypeRefs) {
|
|
1858
1858
|
const refName = resolveTypeReferenceName(typeRef.typeName);
|
|
1859
1859
|
if (!refName) return null;
|
|
1860
1860
|
if (visitedTypeRefs.has(refName)) return null;
|
|
1861
|
-
const binding =
|
|
1861
|
+
const binding = path8.scope.getBinding(refName);
|
|
1862
1862
|
if (binding) {
|
|
1863
1863
|
if (binding.path.isImportSpecifier() || binding.path.isImportDefaultSpecifier() || binding.path.isImportNamespaceSpecifier()) {
|
|
1864
1864
|
const key = `${macroName}:${refName}`;
|
|
@@ -1869,7 +1869,7 @@ function resolveLocalTypeFromReference(path9, typeRef, ctx, macroName, visitedTy
|
|
|
1869
1869
|
{
|
|
1870
1870
|
file: ctx.filename,
|
|
1871
1871
|
source: ctx.source,
|
|
1872
|
-
loc: typeRef.loc ||
|
|
1872
|
+
loc: typeRef.loc || path8.node.loc
|
|
1873
1873
|
}
|
|
1874
1874
|
);
|
|
1875
1875
|
}
|
|
@@ -1883,7 +1883,7 @@ function resolveLocalTypeFromReference(path9, typeRef, ctx, macroName, visitedTy
|
|
|
1883
1883
|
return binding.path.node.typeAnnotation;
|
|
1884
1884
|
}
|
|
1885
1885
|
}
|
|
1886
|
-
const programPath =
|
|
1886
|
+
const programPath = path8.findParent((p) => p.isProgram());
|
|
1887
1887
|
if (!_optionalChain([programPath, 'optionalAccess', _51 => _51.isProgram, 'call', _52 => _52()])) {
|
|
1888
1888
|
return null;
|
|
1889
1889
|
}
|
|
@@ -1902,7 +1902,7 @@ function resolveLocalTypeFromReference(path9, typeRef, ctx, macroName, visitedTy
|
|
|
1902
1902
|
{
|
|
1903
1903
|
file: ctx.filename,
|
|
1904
1904
|
source: ctx.source,
|
|
1905
|
-
loc: typeRef.loc ||
|
|
1905
|
+
loc: typeRef.loc || path8.node.loc
|
|
1906
1906
|
}
|
|
1907
1907
|
);
|
|
1908
1908
|
}
|
|
@@ -1959,8 +1959,8 @@ function resolveImportedTypeSourceInProgram(body, typeName) {
|
|
|
1959
1959
|
}
|
|
1960
1960
|
|
|
1961
1961
|
// src/core/parse/sfc/postprocess/resolve-script-metadata/resolve-declared-props-emits/resolve-declared-emits.ts
|
|
1962
|
-
function resolveDeclaredEmits(
|
|
1963
|
-
const { node } =
|
|
1962
|
+
function resolveDeclaredEmits(path8, ctx) {
|
|
1963
|
+
const { node } = path8;
|
|
1964
1964
|
const { templateData, scriptData } = ctx;
|
|
1965
1965
|
if (!isCalleeNamed(node, MACRO_API_NAMES.emits)) {
|
|
1966
1966
|
return;
|
|
@@ -1971,28 +1971,28 @@ function resolveDeclaredEmits(path9, ctx) {
|
|
|
1971
1971
|
mergeNames(templateData.declaredEmits, resolveObjectOrArrayLiteralNames(initValue));
|
|
1972
1972
|
return;
|
|
1973
1973
|
}
|
|
1974
|
-
const namesFromType = resolveDeclaredEmitsFromTypeParams(tsTypeDef,
|
|
1974
|
+
const namesFromType = resolveDeclaredEmitsFromTypeParams(tsTypeDef, path8, ctx);
|
|
1975
1975
|
if (namesFromType.size) {
|
|
1976
1976
|
mergeNames(templateData.declaredEmits, namesFromType);
|
|
1977
1977
|
return;
|
|
1978
1978
|
}
|
|
1979
1979
|
mergeNames(templateData.declaredEmits, resolveObjectOrArrayLiteralNames(initValue));
|
|
1980
1980
|
}
|
|
1981
|
-
function resolveDeclaredEmitsFromTypeParams(typeParams,
|
|
1981
|
+
function resolveDeclaredEmitsFromTypeParams(typeParams, path8, ctx) {
|
|
1982
1982
|
const names = /* @__PURE__ */ new Set();
|
|
1983
1983
|
const visitedTypeRefs = /* @__PURE__ */ new Set();
|
|
1984
1984
|
const warnedImportedTypeRefs = /* @__PURE__ */ new Set();
|
|
1985
1985
|
for (const tsType of resolveTsTypes(typeParams)) {
|
|
1986
|
-
collectEmitsFromTsType(tsType, names,
|
|
1986
|
+
collectEmitsFromTsType(tsType, names, path8, ctx, visitedTypeRefs, warnedImportedTypeRefs);
|
|
1987
1987
|
}
|
|
1988
1988
|
return names;
|
|
1989
1989
|
}
|
|
1990
|
-
function collectEmitsFromTsType(tsType, names,
|
|
1990
|
+
function collectEmitsFromTsType(tsType, names, path8, ctx, visitedTypeRefs, warnedImportedTypeRefs) {
|
|
1991
1991
|
if (t18.isTSParenthesizedType(tsType)) {
|
|
1992
1992
|
collectEmitsFromTsType(
|
|
1993
1993
|
tsType.typeAnnotation,
|
|
1994
1994
|
names,
|
|
1995
|
-
|
|
1995
|
+
path8,
|
|
1996
1996
|
ctx,
|
|
1997
1997
|
visitedTypeRefs,
|
|
1998
1998
|
warnedImportedTypeRefs
|
|
@@ -2001,17 +2001,17 @@ function collectEmitsFromTsType(tsType, names, path9, ctx, visitedTypeRefs, warn
|
|
|
2001
2001
|
}
|
|
2002
2002
|
if (t18.isTSIntersectionType(tsType) || t18.isTSUnionType(tsType)) {
|
|
2003
2003
|
for (const type of tsType.types) {
|
|
2004
|
-
collectEmitsFromTsType(type, names,
|
|
2004
|
+
collectEmitsFromTsType(type, names, path8, ctx, visitedTypeRefs, warnedImportedTypeRefs);
|
|
2005
2005
|
}
|
|
2006
2006
|
return;
|
|
2007
2007
|
}
|
|
2008
2008
|
if (t18.isTSTypeReference(tsType)) {
|
|
2009
2009
|
const innerTypes = _optionalChain([tsType, 'access', _53 => _53.typeParameters, 'optionalAccess', _54 => _54.params]) || [];
|
|
2010
2010
|
for (const type of innerTypes) {
|
|
2011
|
-
collectEmitsFromTsType(type, names,
|
|
2011
|
+
collectEmitsFromTsType(type, names, path8, ctx, visitedTypeRefs, warnedImportedTypeRefs);
|
|
2012
2012
|
}
|
|
2013
2013
|
const localType = resolveLocalTypeFromReference(
|
|
2014
|
-
|
|
2014
|
+
path8,
|
|
2015
2015
|
tsType,
|
|
2016
2016
|
ctx,
|
|
2017
2017
|
MACRO_API_NAMES.emits,
|
|
@@ -2019,7 +2019,7 @@ function collectEmitsFromTsType(tsType, names, path9, ctx, visitedTypeRefs, warn
|
|
|
2019
2019
|
warnedImportedTypeRefs
|
|
2020
2020
|
);
|
|
2021
2021
|
if (localType) {
|
|
2022
|
-
collectEmitsFromTsType(localType, names,
|
|
2022
|
+
collectEmitsFromTsType(localType, names, path8, ctx, visitedTypeRefs, warnedImportedTypeRefs);
|
|
2023
2023
|
}
|
|
2024
2024
|
return;
|
|
2025
2025
|
}
|
|
@@ -2095,8 +2095,8 @@ function resolveStringLiteralTypeNames(type) {
|
|
|
2095
2095
|
|
|
2096
2096
|
// src/core/parse/sfc/postprocess/resolve-script-metadata/resolve-declared-props-emits/resolve-declared-props.ts
|
|
2097
2097
|
|
|
2098
|
-
function resolveDeclaredProps(
|
|
2099
|
-
const { node } =
|
|
2098
|
+
function resolveDeclaredProps(path8, ctx) {
|
|
2099
|
+
const { node } = path8;
|
|
2100
2100
|
const { templateData, scriptData } = ctx;
|
|
2101
2101
|
if (!isCalleeNamed(node, MACRO_API_NAMES.props)) {
|
|
2102
2102
|
return;
|
|
@@ -2107,28 +2107,28 @@ function resolveDeclaredProps(path9, ctx) {
|
|
|
2107
2107
|
mergeNames(templateData.declaredProps, resolveObjectOrArrayLiteralNames(initValue));
|
|
2108
2108
|
return;
|
|
2109
2109
|
}
|
|
2110
|
-
const namesFromType = resolveDeclaredPropsFromTypeParams(tsTypeDef,
|
|
2110
|
+
const namesFromType = resolveDeclaredPropsFromTypeParams(tsTypeDef, path8, ctx);
|
|
2111
2111
|
if (namesFromType.size) {
|
|
2112
2112
|
mergeNames(templateData.declaredProps, namesFromType);
|
|
2113
2113
|
return;
|
|
2114
2114
|
}
|
|
2115
2115
|
mergeNames(templateData.declaredProps, resolveObjectOrArrayLiteralNames(initValue));
|
|
2116
2116
|
}
|
|
2117
|
-
function resolveDeclaredPropsFromTypeParams(typeParams,
|
|
2117
|
+
function resolveDeclaredPropsFromTypeParams(typeParams, path8, ctx) {
|
|
2118
2118
|
const names = /* @__PURE__ */ new Set();
|
|
2119
2119
|
const visitedTypeRefs = /* @__PURE__ */ new Set();
|
|
2120
2120
|
const warnedImportedTypeRefs = /* @__PURE__ */ new Set();
|
|
2121
2121
|
for (const tsType of resolveTsTypes(typeParams)) {
|
|
2122
|
-
collectPropsFromTsType(tsType, names,
|
|
2122
|
+
collectPropsFromTsType(tsType, names, path8, ctx, visitedTypeRefs, warnedImportedTypeRefs);
|
|
2123
2123
|
}
|
|
2124
2124
|
return names;
|
|
2125
2125
|
}
|
|
2126
|
-
function collectPropsFromTsType(tsType, names,
|
|
2126
|
+
function collectPropsFromTsType(tsType, names, path8, ctx, visitedTypeRefs, warnedImportedTypeRefs) {
|
|
2127
2127
|
if (t19.isTSParenthesizedType(tsType)) {
|
|
2128
2128
|
collectPropsFromTsType(
|
|
2129
2129
|
tsType.typeAnnotation,
|
|
2130
2130
|
names,
|
|
2131
|
-
|
|
2131
|
+
path8,
|
|
2132
2132
|
ctx,
|
|
2133
2133
|
visitedTypeRefs,
|
|
2134
2134
|
warnedImportedTypeRefs
|
|
@@ -2137,17 +2137,17 @@ function collectPropsFromTsType(tsType, names, path9, ctx, visitedTypeRefs, warn
|
|
|
2137
2137
|
}
|
|
2138
2138
|
if (t19.isTSIntersectionType(tsType) || t19.isTSUnionType(tsType)) {
|
|
2139
2139
|
for (const type of tsType.types) {
|
|
2140
|
-
collectPropsFromTsType(type, names,
|
|
2140
|
+
collectPropsFromTsType(type, names, path8, ctx, visitedTypeRefs, warnedImportedTypeRefs);
|
|
2141
2141
|
}
|
|
2142
2142
|
return;
|
|
2143
2143
|
}
|
|
2144
2144
|
if (t19.isTSTypeReference(tsType)) {
|
|
2145
2145
|
const innerTypes = _optionalChain([tsType, 'access', _55 => _55.typeParameters, 'optionalAccess', _56 => _56.params]) || [];
|
|
2146
2146
|
for (const type of innerTypes) {
|
|
2147
|
-
collectPropsFromTsType(type, names,
|
|
2147
|
+
collectPropsFromTsType(type, names, path8, ctx, visitedTypeRefs, warnedImportedTypeRefs);
|
|
2148
2148
|
}
|
|
2149
2149
|
const localType = resolveLocalTypeFromReference(
|
|
2150
|
-
|
|
2150
|
+
path8,
|
|
2151
2151
|
tsType,
|
|
2152
2152
|
ctx,
|
|
2153
2153
|
MACRO_API_NAMES.props,
|
|
@@ -2155,7 +2155,7 @@ function collectPropsFromTsType(tsType, names, path9, ctx, visitedTypeRefs, warn
|
|
|
2155
2155
|
warnedImportedTypeRefs
|
|
2156
2156
|
);
|
|
2157
2157
|
if (localType) {
|
|
2158
|
-
collectPropsFromTsType(localType, names,
|
|
2158
|
+
collectPropsFromTsType(localType, names, path8, ctx, visitedTypeRefs, warnedImportedTypeRefs);
|
|
2159
2159
|
}
|
|
2160
2160
|
return;
|
|
2161
2161
|
}
|
|
@@ -2174,15 +2174,15 @@ function collectPropsFromTsType(tsType, names, path9, ctx, visitedTypeRefs, warn
|
|
|
2174
2174
|
}
|
|
2175
2175
|
|
|
2176
2176
|
// src/core/parse/sfc/postprocess/resolve-script-metadata/resolve-declared-props-emits/index.ts
|
|
2177
|
-
function resolveDeclaredPropsAndEmits(
|
|
2178
|
-
resolveDeclaredProps(
|
|
2179
|
-
resolveDeclaredEmits(
|
|
2177
|
+
function resolveDeclaredPropsAndEmits(path8, ctx) {
|
|
2178
|
+
resolveDeclaredProps(path8, ctx);
|
|
2179
|
+
resolveDeclaredEmits(path8, ctx);
|
|
2180
2180
|
}
|
|
2181
2181
|
|
|
2182
2182
|
// src/core/parse/sfc/postprocess/resolve-script-metadata/resolve-use-attrs-exists.ts
|
|
2183
2183
|
|
|
2184
|
-
function resolveUseAttrsExists(
|
|
2185
|
-
const { node } =
|
|
2184
|
+
function resolveUseAttrsExists(path8, ctx) {
|
|
2185
|
+
const { node } = path8;
|
|
2186
2186
|
const { templateData, scriptData } = ctx;
|
|
2187
2187
|
if (!isCalleeNamed(node, VUE_API_MAP.useAttrs)) {
|
|
2188
2188
|
return;
|
|
@@ -2191,7 +2191,7 @@ function resolveUseAttrsExists(path9, ctx) {
|
|
|
2191
2191
|
return;
|
|
2192
2192
|
}
|
|
2193
2193
|
scriptData.hasUseAttrsCall = true;
|
|
2194
|
-
const parent = _optionalChain([
|
|
2194
|
+
const parent = _optionalChain([path8, 'access', _58 => _58.parentPath, 'optionalAccess', _59 => _59.node]);
|
|
2195
2195
|
if (parent && t20.isVariableDeclarator(parent) && t20.isIdentifier(parent.id)) {
|
|
2196
2196
|
templateData.declaredAttrs = parent.id.name;
|
|
2197
2197
|
}
|
|
@@ -2356,16 +2356,16 @@ function resolveScriptMeta(result, ctx) {
|
|
|
2356
2356
|
return;
|
|
2357
2357
|
}
|
|
2358
2358
|
_core.traverse.call(void 0, scriptAst, {
|
|
2359
|
-
VariableDeclarator(
|
|
2360
|
-
if (!atComponentOrHookRoot(
|
|
2359
|
+
VariableDeclarator(path8) {
|
|
2360
|
+
if (!atComponentOrHookRoot(path8, scriptAst.program)) {
|
|
2361
2361
|
return;
|
|
2362
2362
|
}
|
|
2363
|
-
resolveVarBindings(
|
|
2363
|
+
resolveVarBindings(path8.node, ctx);
|
|
2364
2364
|
},
|
|
2365
|
-
CallExpression(
|
|
2366
|
-
resolveDeclaredOptions(
|
|
2367
|
-
resolveDeclaredPropsAndEmits(
|
|
2368
|
-
resolveUseAttrsExists(
|
|
2365
|
+
CallExpression(path8) {
|
|
2366
|
+
resolveDeclaredOptions(path8, ctx);
|
|
2367
|
+
resolveDeclaredPropsAndEmits(path8, ctx);
|
|
2368
|
+
resolveUseAttrsExists(path8, ctx);
|
|
2369
2369
|
}
|
|
2370
2370
|
});
|
|
2371
2371
|
}
|
|
@@ -2877,25 +2877,25 @@ function parse(source, ctx, options) {
|
|
|
2877
2877
|
|
|
2878
2878
|
|
|
2879
2879
|
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/resolve-global-type-chunk.ts
|
|
2880
|
-
function resolveGlobalTypeChunks(
|
|
2881
|
-
if (!_optionalChain([
|
|
2880
|
+
function resolveGlobalTypeChunks(path8, ir) {
|
|
2881
|
+
if (!_optionalChain([path8, 'access', _100 => _100.parentPath, 'optionalAccess', _101 => _101.isProgram, 'call', _102 => _102()])) {
|
|
2882
2882
|
return;
|
|
2883
2883
|
}
|
|
2884
|
-
const forked = forkNode(
|
|
2884
|
+
const forked = forkNode(path8.node);
|
|
2885
2885
|
ir.tsTypes.push(forked);
|
|
2886
|
-
|
|
2886
|
+
path8.remove();
|
|
2887
2887
|
}
|
|
2888
2888
|
|
|
2889
2889
|
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/resolve-module-chunk.ts
|
|
2890
2890
|
|
|
2891
|
-
function resolveModuleChunks(
|
|
2892
|
-
const forked = forkNode(
|
|
2891
|
+
function resolveModuleChunks(path8, ir) {
|
|
2892
|
+
const forked = forkNode(path8.node);
|
|
2893
2893
|
if (t22.isImportDeclaration(forked)) {
|
|
2894
2894
|
ir.imports.push(forked);
|
|
2895
2895
|
} else if (t22.isExportDeclaration(forked)) {
|
|
2896
2896
|
ir.exports.push(forked);
|
|
2897
2897
|
}
|
|
2898
|
-
|
|
2898
|
+
path8.remove();
|
|
2899
2899
|
}
|
|
2900
2900
|
|
|
2901
2901
|
// src/core/transform/sfc/script/shared/metadata-utils.ts
|
|
@@ -2915,10 +2915,10 @@ function setScriptNodeMeta(node, opts) {
|
|
|
2915
2915
|
}
|
|
2916
2916
|
|
|
2917
2917
|
// src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/resolve-static-const-chunk.ts
|
|
2918
|
-
function resolveStaticConstChunks(
|
|
2919
|
-
const { node, parentPath } =
|
|
2918
|
+
function resolveStaticConstChunks(path8, ir) {
|
|
2919
|
+
const { node, parentPath } = path8;
|
|
2920
2920
|
const parent = parentPath.node;
|
|
2921
|
-
if (!isVariableDeclTopLevel(
|
|
2921
|
+
if (!isVariableDeclTopLevel(path8) || !parentPath.isVariableDeclaration() || parent.kind !== "const" || !isSimpleLiteral(node.init) || getScriptNodeMeta(node)) {
|
|
2922
2922
|
return;
|
|
2923
2923
|
}
|
|
2924
2924
|
const forked = forkNode(parent);
|
|
@@ -2935,16 +2935,16 @@ function resolveASTChunks(ctx, ast) {
|
|
|
2935
2935
|
scriptIR.statement.local = ast;
|
|
2936
2936
|
return {
|
|
2937
2937
|
// 提取 import/export
|
|
2938
|
-
"ImportDeclaration|ExportDeclaration"(
|
|
2939
|
-
resolveModuleChunks(
|
|
2938
|
+
"ImportDeclaration|ExportDeclaration"(path8) {
|
|
2939
|
+
resolveModuleChunks(path8, scriptIR);
|
|
2940
2940
|
},
|
|
2941
2941
|
// 提取全局类型声明
|
|
2942
|
-
"TSInterfaceDeclaration|TSTypeAliasDeclaration|TSEnumDeclaration|TSModuleDeclaration|TSModuleDeclaration"(
|
|
2943
|
-
resolveGlobalTypeChunks(
|
|
2942
|
+
"TSInterfaceDeclaration|TSTypeAliasDeclaration|TSEnumDeclaration|TSModuleDeclaration|TSModuleDeclaration"(path8) {
|
|
2943
|
+
resolveGlobalTypeChunks(path8, scriptIR);
|
|
2944
2944
|
},
|
|
2945
2945
|
// 提升顶层常量声明
|
|
2946
|
-
VariableDeclarator(
|
|
2947
|
-
resolveStaticConstChunks(
|
|
2946
|
+
VariableDeclarator(path8) {
|
|
2947
|
+
resolveStaticConstChunks(path8, scriptIR);
|
|
2948
2948
|
}
|
|
2949
2949
|
};
|
|
2950
2950
|
}
|
|
@@ -3030,11 +3030,11 @@ var StyleFileStrategy = (_class3 = class {constructor() { _class3.prototype.__in
|
|
|
3030
3030
|
matches(moduleName) {
|
|
3031
3031
|
return this.regExp.test(moduleName);
|
|
3032
3032
|
}
|
|
3033
|
-
process(
|
|
3033
|
+
process(path8, ctx) {
|
|
3034
3034
|
if (!ctx.preprocessStyles) {
|
|
3035
3035
|
return {};
|
|
3036
3036
|
}
|
|
3037
|
-
const importSource =
|
|
3037
|
+
const importSource = path8.node.source.value;
|
|
3038
3038
|
if (typeof importSource !== "string") {
|
|
3039
3039
|
return {};
|
|
3040
3040
|
}
|
|
@@ -3079,25 +3079,25 @@ function resolveRuntimeImports(ctx) {
|
|
|
3079
3079
|
const processedModules = /* @__PURE__ */ new Set();
|
|
3080
3080
|
let hasImports = false;
|
|
3081
3081
|
return {
|
|
3082
|
-
ImportDeclaration(
|
|
3083
|
-
const { node } =
|
|
3082
|
+
ImportDeclaration(path8) {
|
|
3083
|
+
const { node } = path8;
|
|
3084
3084
|
const originalModuleName = node.source.value.toLowerCase();
|
|
3085
3085
|
const strategy = strategyManager.findStrategy(originalModuleName);
|
|
3086
3086
|
let strategyResult = null;
|
|
3087
3087
|
if (strategy) {
|
|
3088
|
-
strategyResult = strategy.process(
|
|
3088
|
+
strategyResult = strategy.process(path8, ctx, originalModuleName);
|
|
3089
3089
|
if (strategyResult.shouldReplaceSource && strategyResult.newSource) {
|
|
3090
3090
|
node.source.value = strategyResult.newSource;
|
|
3091
3091
|
}
|
|
3092
|
-
if (strategyResult.shouldRemove && !
|
|
3093
|
-
|
|
3092
|
+
if (strategyResult.shouldRemove && !path8.removed) {
|
|
3093
|
+
path8.remove();
|
|
3094
3094
|
return;
|
|
3095
3095
|
}
|
|
3096
3096
|
}
|
|
3097
3097
|
replaceVueSuffix(node.source);
|
|
3098
3098
|
const finalModuleName = node.source.value.toLowerCase();
|
|
3099
|
-
if (processedModules.has(finalModuleName) && !
|
|
3100
|
-
|
|
3099
|
+
if (processedModules.has(finalModuleName) && !path8.removed) {
|
|
3100
|
+
path8.remove();
|
|
3101
3101
|
return;
|
|
3102
3102
|
}
|
|
3103
3103
|
processedModules.add(finalModuleName);
|
|
@@ -3106,12 +3106,12 @@ function resolveRuntimeImports(ctx) {
|
|
|
3106
3106
|
const importNodes = createImportNodes(ctx);
|
|
3107
3107
|
if (importNodes.length) {
|
|
3108
3108
|
if (_optionalChain([strategyResult, 'optionalAccess', _103 => _103.shouldInjectRuntimeImports])) {
|
|
3109
|
-
|
|
3109
|
+
path8.insertAfter(importNodes);
|
|
3110
3110
|
} else if (finalModuleName === PACKAGE_NAME.react) {
|
|
3111
|
-
|
|
3111
|
+
path8.insertAfter(importNodes);
|
|
3112
3112
|
} else {
|
|
3113
3113
|
forkFilePreambleLeadingComments(importNodes[0], node);
|
|
3114
|
-
|
|
3114
|
+
path8.insertBefore(importNodes);
|
|
3115
3115
|
}
|
|
3116
3116
|
}
|
|
3117
3117
|
hasImports = true;
|
|
@@ -3119,14 +3119,14 @@ function resolveRuntimeImports(ctx) {
|
|
|
3119
3119
|
},
|
|
3120
3120
|
// 兜底:无 ImportDeclaration 的文件也要能注入必需依赖。
|
|
3121
3121
|
Program: {
|
|
3122
|
-
exit(
|
|
3122
|
+
exit(path8) {
|
|
3123
3123
|
if (hasImports) return;
|
|
3124
3124
|
hasImports = true;
|
|
3125
|
-
const { node } =
|
|
3125
|
+
const { node } = path8;
|
|
3126
3126
|
const importNodes = createImportNodes(ctx);
|
|
3127
3127
|
if (!importNodes.length) return;
|
|
3128
3128
|
forkProgramTopLeadingComments(importNodes[0], node);
|
|
3129
|
-
|
|
3129
|
+
path8.unshiftContainer("body", importNodes);
|
|
3130
3130
|
}
|
|
3131
3131
|
}
|
|
3132
3132
|
};
|
|
@@ -3227,8 +3227,8 @@ function resolveSfcCssImport(ctx) {
|
|
|
3227
3227
|
|
|
3228
3228
|
function resolveDefineAsyncComponent(ctx) {
|
|
3229
3229
|
return {
|
|
3230
|
-
CallExpression(
|
|
3231
|
-
const { node } =
|
|
3230
|
+
CallExpression(path8) {
|
|
3231
|
+
const { node } = path8;
|
|
3232
3232
|
if (!isCalleeNamed(node, VUE_API_MAP.defineAsyncComponent)) {
|
|
3233
3233
|
return;
|
|
3234
3234
|
}
|
|
@@ -3276,15 +3276,15 @@ function createUseImperativeHandle(refId, init) {
|
|
|
3276
3276
|
function resolveDefineExpose(ctx) {
|
|
3277
3277
|
if (ctx.inputType !== "sfc") return {};
|
|
3278
3278
|
return {
|
|
3279
|
-
CallExpression(
|
|
3280
|
-
const { node } =
|
|
3279
|
+
CallExpression(path8) {
|
|
3280
|
+
const { node } = path8;
|
|
3281
3281
|
const { filename, scriptData } = ctx;
|
|
3282
3282
|
if (!isCalleeNamed(node, MACRO_API_NAMES.expose)) {
|
|
3283
3283
|
return;
|
|
3284
3284
|
}
|
|
3285
3285
|
const [expose] = node.arguments;
|
|
3286
3286
|
if (!expose) {
|
|
3287
|
-
|
|
3287
|
+
path8.remove();
|
|
3288
3288
|
return;
|
|
3289
3289
|
}
|
|
3290
3290
|
const adapter = ADAPTER_RULES.react[MACRO_API_NAMES.expose];
|
|
@@ -3301,7 +3301,7 @@ function resolveDefineExpose(ctx) {
|
|
|
3301
3301
|
const { forwardRef } = scriptData;
|
|
3302
3302
|
const newNode = createUseImperativeHandle(t27.identifier(forwardRef.refField), init);
|
|
3303
3303
|
forwardRef.enabled = true;
|
|
3304
|
-
replaceNode(
|
|
3304
|
+
replaceNode(path8, newNode, node);
|
|
3305
3305
|
}
|
|
3306
3306
|
};
|
|
3307
3307
|
}
|
|
@@ -3309,12 +3309,12 @@ function resolveDefineExpose(ctx) {
|
|
|
3309
3309
|
// src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-options.ts
|
|
3310
3310
|
function resolveDefineOptions(ctx) {
|
|
3311
3311
|
return {
|
|
3312
|
-
CallExpression(
|
|
3313
|
-
const { node } =
|
|
3312
|
+
CallExpression(path8) {
|
|
3313
|
+
const { node } = path8;
|
|
3314
3314
|
if (!isCalleeNamed(node, MACRO_API_NAMES.options)) {
|
|
3315
3315
|
return;
|
|
3316
3316
|
}
|
|
3317
|
-
|
|
3317
|
+
path8.remove();
|
|
3318
3318
|
}
|
|
3319
3319
|
};
|
|
3320
3320
|
}
|
|
@@ -3331,8 +3331,8 @@ function resolveEmitCalls(ctx) {
|
|
|
3331
3331
|
return `on${capitalize(camelCase(normalized))}`;
|
|
3332
3332
|
};
|
|
3333
3333
|
return {
|
|
3334
|
-
CallExpression(
|
|
3335
|
-
const { node } =
|
|
3334
|
+
CallExpression(path8) {
|
|
3335
|
+
const { node } = path8;
|
|
3336
3336
|
const { filename, templateData, scriptData } = ctx;
|
|
3337
3337
|
if (!t28.isIdentifier(node.callee)) return;
|
|
3338
3338
|
const { name } = node.callee;
|
|
@@ -3343,7 +3343,7 @@ function resolveEmitCalls(ctx) {
|
|
|
3343
3343
|
result = meta.source === MACRO_API_NAMES.emits;
|
|
3344
3344
|
}
|
|
3345
3345
|
if (!result) {
|
|
3346
|
-
const binding =
|
|
3346
|
+
const binding = path8.scope.getBinding(name);
|
|
3347
3347
|
if (binding) {
|
|
3348
3348
|
const parent = binding.path.node;
|
|
3349
3349
|
if (t28.isVariableDeclarator(parent) && t28.isCallExpression(parent.init) && t28.isIdentifier(parent.init.callee)) {
|
|
@@ -3370,7 +3370,7 @@ function resolveEmitCalls(ctx) {
|
|
|
3370
3370
|
}
|
|
3371
3371
|
);
|
|
3372
3372
|
}
|
|
3373
|
-
replaceNode(
|
|
3373
|
+
replaceNode(path8, propCall, node);
|
|
3374
3374
|
}
|
|
3375
3375
|
};
|
|
3376
3376
|
}
|
|
@@ -3415,9 +3415,9 @@ function cloneCallableParams(params) {
|
|
|
3415
3415
|
// src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-emits.ts
|
|
3416
3416
|
function resolveEmitsTopLevelTypes(ctx) {
|
|
3417
3417
|
return {
|
|
3418
|
-
"TSInterfaceDeclaration|TSTypeAliasDeclaration"(
|
|
3419
|
-
if (!t30.isProgram(
|
|
3420
|
-
const { node } =
|
|
3418
|
+
"TSInterfaceDeclaration|TSTypeAliasDeclaration"(path8) {
|
|
3419
|
+
if (!t30.isProgram(path8.parent)) return;
|
|
3420
|
+
const { node } = path8;
|
|
3421
3421
|
if (t30.isTSInterfaceDeclaration(node)) {
|
|
3422
3422
|
const typeLiteral = t30.tsTypeLiteral(node.body.body);
|
|
3423
3423
|
if (!hasEmitsSignatureInType(typeLiteral)) return;
|
|
@@ -3482,8 +3482,8 @@ function resolveTopLevelEmitType(tsType) {
|
|
|
3482
3482
|
}
|
|
3483
3483
|
return tsType;
|
|
3484
3484
|
}
|
|
3485
|
-
function resolveDefineEmitsIface(
|
|
3486
|
-
const { node } =
|
|
3485
|
+
function resolveDefineEmitsIface(path8, ctx) {
|
|
3486
|
+
const { node } = path8;
|
|
3487
3487
|
const [runtimeArg] = node.arguments;
|
|
3488
3488
|
const tsParams = _optionalChain([node, 'access', _107 => _107.typeParameters, 'optionalAccess', _108 => _108.params]);
|
|
3489
3489
|
if (_optionalChain([tsParams, 'optionalAccess', _109 => _109.length])) {
|
|
@@ -3783,8 +3783,8 @@ function resolveTupleElementParam(element, index) {
|
|
|
3783
3783
|
|
|
3784
3784
|
// src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-props.ts
|
|
3785
3785
|
|
|
3786
|
-
function resolveDefinePropsIface(
|
|
3787
|
-
const { node } =
|
|
3786
|
+
function resolveDefinePropsIface(path8, ctx) {
|
|
3787
|
+
const { node } = path8;
|
|
3788
3788
|
const [runtimeArg] = node.arguments;
|
|
3789
3789
|
const tsParams = _optionalChain([node, 'access', _117 => _117.typeParameters, 'optionalAccess', _118 => _118.params]);
|
|
3790
3790
|
if (_optionalChain([tsParams, 'optionalAccess', _119 => _119.length])) {
|
|
@@ -3972,9 +3972,9 @@ function recordReactNode(ctx) {
|
|
|
3972
3972
|
}
|
|
3973
3973
|
recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.ReactNode);
|
|
3974
3974
|
}
|
|
3975
|
-
function collectLocalTypeDeclarations(
|
|
3975
|
+
function collectLocalTypeDeclarations(path8) {
|
|
3976
3976
|
const declarations = /* @__PURE__ */ new Map();
|
|
3977
|
-
const programPath =
|
|
3977
|
+
const programPath = path8.findParent(
|
|
3978
3978
|
(parentPath) => parentPath.isProgram()
|
|
3979
3979
|
);
|
|
3980
3980
|
if (!programPath) {
|
|
@@ -4244,14 +4244,14 @@ function resolveSlotPropFromMember(member) {
|
|
|
4244
4244
|
}
|
|
4245
4245
|
|
|
4246
4246
|
// src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/define-slots.ts
|
|
4247
|
-
function resolveDefineSlotsIface(
|
|
4248
|
-
const { node } =
|
|
4247
|
+
function resolveDefineSlotsIface(path8, ctx) {
|
|
4248
|
+
const { node } = path8;
|
|
4249
4249
|
const tsParams = _optionalChain([node, 'access', _140 => _140.typeParameters, 'optionalAccess', _141 => _141.params]);
|
|
4250
4250
|
if (!_optionalChain([tsParams, 'optionalAccess', _142 => _142.length])) return;
|
|
4251
4251
|
const {
|
|
4252
4252
|
propsTSIface: { slotTypes }
|
|
4253
4253
|
} = ctx.scriptData;
|
|
4254
|
-
const localTypeDeclarations = collectLocalTypeDeclarations(
|
|
4254
|
+
const localTypeDeclarations = collectLocalTypeDeclarations(path8);
|
|
4255
4255
|
let shouldRecordReactNode = false;
|
|
4256
4256
|
for (const tsType of tsParams) {
|
|
4257
4257
|
const { type: resolved, shouldRecordReactNode: needsReactNode } = resolveSlotType(tsType, {
|
|
@@ -4295,8 +4295,8 @@ function resolveTemplateSlotIface(ctx) {
|
|
|
4295
4295
|
function resolvePropsIface(ctx) {
|
|
4296
4296
|
const isTS = ctx.scriptData.lang.startsWith("ts");
|
|
4297
4297
|
return {
|
|
4298
|
-
CallExpression(
|
|
4299
|
-
const { node, parentPath } =
|
|
4298
|
+
CallExpression(path8) {
|
|
4299
|
+
const { node, parentPath } = path8;
|
|
4300
4300
|
const name = node.callee.name;
|
|
4301
4301
|
if (!isCalleeNamed(node, MACRO_API_NAMES.props) && !isCalleeNamed(node, MACRO_API_NAMES.emits) && !isCalleeNamed(node, MACRO_API_NAMES.slots)) {
|
|
4302
4302
|
return;
|
|
@@ -4305,7 +4305,7 @@ function resolvePropsIface(ctx) {
|
|
|
4305
4305
|
if (parentPath.isVariableDeclaration() || parentPath.isVariableDeclarator()) {
|
|
4306
4306
|
parentPath.remove();
|
|
4307
4307
|
} else {
|
|
4308
|
-
|
|
4308
|
+
path8.remove();
|
|
4309
4309
|
}
|
|
4310
4310
|
};
|
|
4311
4311
|
if (ctx.inputType !== "sfc") {
|
|
@@ -4319,11 +4319,11 @@ function resolvePropsIface(ctx) {
|
|
|
4319
4319
|
propsTSIface.hasPropsInJsEnv = true;
|
|
4320
4320
|
} else {
|
|
4321
4321
|
if (name === MACRO_API_NAMES.props) {
|
|
4322
|
-
resolveDefinePropsIface(
|
|
4322
|
+
resolveDefinePropsIface(path8, ctx);
|
|
4323
4323
|
} else if (name === MACRO_API_NAMES.emits) {
|
|
4324
|
-
resolveDefineEmitsIface(
|
|
4324
|
+
resolveDefineEmitsIface(path8, ctx);
|
|
4325
4325
|
} else if (name === MACRO_API_NAMES.slots) {
|
|
4326
|
-
resolveDefineSlotsIface(
|
|
4326
|
+
resolveDefineSlotsIface(path8, ctx);
|
|
4327
4327
|
}
|
|
4328
4328
|
}
|
|
4329
4329
|
removePath();
|
|
@@ -4352,10 +4352,10 @@ function resolveCompIProps(ctx, ast) {
|
|
|
4352
4352
|
|
|
4353
4353
|
function resolveUseAttrs(ctx) {
|
|
4354
4354
|
return {
|
|
4355
|
-
VariableDeclarator(
|
|
4356
|
-
const { init, id } =
|
|
4355
|
+
VariableDeclarator(path8) {
|
|
4356
|
+
const { init, id } = path8.node;
|
|
4357
4357
|
if (!init) return;
|
|
4358
|
-
const initPath =
|
|
4358
|
+
const initPath = path8.get("init");
|
|
4359
4359
|
const propsIdentifier = t37.identifier(ctx.propField);
|
|
4360
4360
|
if (t37.isTSAsExpression(init) && isUseAttrsCall(init.expression)) {
|
|
4361
4361
|
const typeAssertion = createPropsTypeAssertion(propsIdentifier, init.typeAnnotation);
|
|
@@ -4486,19 +4486,19 @@ function getDependencyKey(exp) {
|
|
|
4486
4486
|
|
|
4487
4487
|
// src/core/transform/sfc/script/shared/dependency-analyzer/dep-normalizer.ts
|
|
4488
4488
|
|
|
4489
|
-
function normalizeDependencyExpr(
|
|
4490
|
-
if (t40.isIdentifier(
|
|
4491
|
-
return t40.identifier(
|
|
4489
|
+
function normalizeDependencyExpr(path8, rootName, ctx) {
|
|
4490
|
+
if (t40.isIdentifier(path8.node)) {
|
|
4491
|
+
return t40.identifier(path8.node.name);
|
|
4492
4492
|
}
|
|
4493
|
-
if (t40.isMemberExpression(
|
|
4493
|
+
if (t40.isMemberExpression(path8.node) || t40.isOptionalMemberExpression(path8.node)) {
|
|
4494
4494
|
if (rootName === ctx.propField) {
|
|
4495
|
-
const safePropsExp = ensureOptionalForMemberChain(
|
|
4495
|
+
const safePropsExp = ensureOptionalForMemberChain(path8.node);
|
|
4496
4496
|
if (isReactValidDependencyExpr(safePropsExp)) {
|
|
4497
4497
|
return t40.cloneNode(safePropsExp, true);
|
|
4498
4498
|
}
|
|
4499
4499
|
return t40.identifier(rootName);
|
|
4500
4500
|
}
|
|
4501
|
-
const normalizedExp = normalizeMemberForCallSite(
|
|
4501
|
+
const normalizedExp = normalizeMemberForCallSite(path8, path8.node);
|
|
4502
4502
|
const safeExp = t40.isMemberExpression(normalizedExp) || t40.isOptionalMemberExpression(normalizedExp) ? ensureOptionalForMemberChain(normalizedExp) : normalizedExp;
|
|
4503
4503
|
if (isReactValidDependencyExpr(safeExp)) {
|
|
4504
4504
|
return t40.cloneNode(safeExp, true);
|
|
@@ -4522,8 +4522,8 @@ function normalizeSourcedDependency(exp) {
|
|
|
4522
4522
|
}
|
|
4523
4523
|
return null;
|
|
4524
4524
|
}
|
|
4525
|
-
function normalizeMemberForCallSite(
|
|
4526
|
-
const parent =
|
|
4525
|
+
function normalizeMemberForCallSite(path8, node) {
|
|
4526
|
+
const parent = path8.parentPath;
|
|
4527
4527
|
const isDirectCallee = !!parent && (parent.isCallExpression() && parent.node.callee === node || parent.isOptionalCallExpression() && parent.node.callee === node);
|
|
4528
4528
|
if (!isDirectCallee) {
|
|
4529
4529
|
return node;
|
|
@@ -4550,11 +4550,11 @@ function hasTrailingMemberAccess(node) {
|
|
|
4550
4550
|
|
|
4551
4551
|
// src/core/transform/sfc/script/shared/dependency-analyzer/shared-utils.ts
|
|
4552
4552
|
var TRACE_MAX_DEPTH = 20;
|
|
4553
|
-
function isNestedMemberObject(
|
|
4554
|
-
const parent =
|
|
4553
|
+
function isNestedMemberObject(path8) {
|
|
4554
|
+
const parent = path8.parentPath;
|
|
4555
4555
|
if (!parent) return false;
|
|
4556
4556
|
if (parent.isMemberExpression() || parent.isOptionalMemberExpression()) {
|
|
4557
|
-
return parent.node.object ===
|
|
4557
|
+
return parent.node.object === path8.node;
|
|
4558
4558
|
}
|
|
4559
4559
|
return false;
|
|
4560
4560
|
}
|
|
@@ -4657,11 +4657,11 @@ function analyzeDeps(node, ctx, parentPath) {
|
|
|
4657
4657
|
analyzeTarget,
|
|
4658
4658
|
{
|
|
4659
4659
|
"MemberExpression|OptionalMemberExpression"(memberPath) {
|
|
4660
|
-
const
|
|
4661
|
-
if (isNestedMemberObject(
|
|
4662
|
-
const rootId = findRootIdentifier(
|
|
4660
|
+
const path8 = memberPath;
|
|
4661
|
+
if (isNestedMemberObject(path8)) return;
|
|
4662
|
+
const rootId = findRootIdentifier(path8.node);
|
|
4663
4663
|
if (!rootId) return;
|
|
4664
|
-
tryAddDependency(
|
|
4664
|
+
tryAddDependency(path8, rootId.name, path8.scope);
|
|
4665
4665
|
processedIdentifiers.add(rootId);
|
|
4666
4666
|
},
|
|
4667
4667
|
Identifier(idPath) {
|
|
@@ -4707,18 +4707,18 @@ function analyzeDeps(node, ctx, parentPath) {
|
|
|
4707
4707
|
// src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
|
|
4708
4708
|
function resolveAnalysisOnlyAdapter(ctx) {
|
|
4709
4709
|
return {
|
|
4710
|
-
"CallExpression|Identifier"(
|
|
4711
|
-
const node =
|
|
4710
|
+
"CallExpression|Identifier"(path8) {
|
|
4711
|
+
const node = path8.node;
|
|
4712
4712
|
const apiName = getApiName(node);
|
|
4713
4713
|
const adapter = ADAPTER_RULES.runtime[apiName];
|
|
4714
4714
|
if (!adapter || adapter.type !== "analyzed-deps") {
|
|
4715
4715
|
return;
|
|
4716
4716
|
}
|
|
4717
|
-
if (!isVueApiReference(
|
|
4717
|
+
if (!isVueApiReference(path8, apiName)) {
|
|
4718
4718
|
return;
|
|
4719
4719
|
}
|
|
4720
4720
|
if (t43.isCallExpression(node)) {
|
|
4721
|
-
resolveCallNode(
|
|
4721
|
+
resolveCallNode(path8, adapter, ctx);
|
|
4722
4722
|
} else {
|
|
4723
4723
|
replaceIdName(node, adapter.target);
|
|
4724
4724
|
}
|
|
@@ -4736,35 +4736,35 @@ function getApiName(node) {
|
|
|
4736
4736
|
}
|
|
4737
4737
|
return apiName;
|
|
4738
4738
|
}
|
|
4739
|
-
function resolveCallNode(
|
|
4740
|
-
const { node } =
|
|
4739
|
+
function resolveCallNode(path8, adapter, ctx) {
|
|
4740
|
+
const { node } = path8;
|
|
4741
4741
|
const { arguments: args } = node;
|
|
4742
4742
|
if (!args.length) return;
|
|
4743
4743
|
const fn = args[0];
|
|
4744
4744
|
if (!t43.isArrowFunctionExpression(fn) && !t43.isFunctionExpression(fn)) {
|
|
4745
4745
|
return;
|
|
4746
4746
|
}
|
|
4747
|
-
const fnPath =
|
|
4747
|
+
const fnPath = path8.get("arguments")[0];
|
|
4748
4748
|
const deps = analyzeDeps(fn, ctx, fnPath);
|
|
4749
4749
|
args.push(deps);
|
|
4750
4750
|
replaceCallName(node, adapter.target);
|
|
4751
4751
|
recordImport(ctx, adapter.package, adapter.target);
|
|
4752
4752
|
}
|
|
4753
|
-
function isVueApiReference(
|
|
4754
|
-
if (
|
|
4755
|
-
if (
|
|
4753
|
+
function isVueApiReference(path8, apiName) {
|
|
4754
|
+
if (path8.isIdentifier()) {
|
|
4755
|
+
if (path8.parentPath.isCallExpression() && path8.parentPath.node.callee === path8.node) {
|
|
4756
4756
|
return false;
|
|
4757
4757
|
}
|
|
4758
|
-
if (!
|
|
4758
|
+
if (!path8.isReferencedIdentifier()) {
|
|
4759
4759
|
return false;
|
|
4760
4760
|
}
|
|
4761
4761
|
}
|
|
4762
|
-
if (
|
|
4763
|
-
const callee =
|
|
4762
|
+
if (path8.isCallExpression()) {
|
|
4763
|
+
const callee = path8.get("callee");
|
|
4764
4764
|
if (!callee.isIdentifier()) return false;
|
|
4765
4765
|
return isVueImportBinding(callee.scope.getBinding(apiName));
|
|
4766
4766
|
}
|
|
4767
|
-
return isVueImportBinding(
|
|
4767
|
+
return isVueImportBinding(path8.scope.getBinding(apiName));
|
|
4768
4768
|
}
|
|
4769
4769
|
function isVueImportBinding(binding) {
|
|
4770
4770
|
if (!binding) return false;
|
|
@@ -4789,24 +4789,24 @@ function isVueImportBinding(binding) {
|
|
|
4789
4789
|
// src/core/transform/sfc/script/syntax-processor/process/resolve-arrow-deps.ts
|
|
4790
4790
|
function resolveArrowFnDeps(ctx, ast) {
|
|
4791
4791
|
return {
|
|
4792
|
-
ArrowFunctionExpression(
|
|
4793
|
-
const { node, parentPath } =
|
|
4794
|
-
if (isSkip(
|
|
4792
|
+
ArrowFunctionExpression(path8) {
|
|
4793
|
+
const { node, parentPath } = path8;
|
|
4794
|
+
if (isSkip(path8) || !atComponentOrHookRoot(parentPath, ast.program)) {
|
|
4795
4795
|
return;
|
|
4796
4796
|
}
|
|
4797
|
-
const deps = analyzeDeps(node, ctx,
|
|
4797
|
+
const deps = analyzeDeps(node, ctx, path8);
|
|
4798
4798
|
if (!deps.elements.length) return;
|
|
4799
4799
|
const newNode = createUseCallback(node, deps);
|
|
4800
|
-
const declaratorPath = getVariableDeclaratorPath(
|
|
4800
|
+
const declaratorPath = getVariableDeclaratorPath(path8);
|
|
4801
4801
|
recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useCallback);
|
|
4802
4802
|
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _150 => _150.node]), { is_reactive: true, reactive_type: "indirect" });
|
|
4803
|
-
replaceNode(
|
|
4803
|
+
replaceNode(path8, newNode, node);
|
|
4804
4804
|
}
|
|
4805
4805
|
};
|
|
4806
4806
|
}
|
|
4807
|
-
function isSkip(
|
|
4808
|
-
const { parentPath } =
|
|
4809
|
-
const isVariableDecl = () => getVariableDeclaratorPath(
|
|
4807
|
+
function isSkip(path8) {
|
|
4808
|
+
const { parentPath } = path8;
|
|
4809
|
+
const isVariableDecl = () => getVariableDeclaratorPath(path8) !== null;
|
|
4810
4810
|
const isReturnFunc = () => !isVariableDecl() && parentPath.isReturnStatement();
|
|
4811
4811
|
const isCallback = () => {
|
|
4812
4812
|
if (!parentPath) {
|
|
@@ -4815,12 +4815,12 @@ function isSkip(path9) {
|
|
|
4815
4815
|
if (parentPath.isCallExpression()) {
|
|
4816
4816
|
const callExpressionPath = parentPath;
|
|
4817
4817
|
const args = callExpressionPath.node.arguments;
|
|
4818
|
-
return args.some((arg) => arg ===
|
|
4818
|
+
return args.some((arg) => arg === path8.node);
|
|
4819
4819
|
}
|
|
4820
4820
|
if (parentPath.isArrayExpression()) {
|
|
4821
4821
|
const arrayExpressionPath = parentPath;
|
|
4822
4822
|
const elements = arrayExpressionPath.node.elements;
|
|
4823
|
-
return elements.some((element) => element ===
|
|
4823
|
+
return elements.some((element) => element === path8.node);
|
|
4824
4824
|
}
|
|
4825
4825
|
return false;
|
|
4826
4826
|
};
|
|
@@ -4844,13 +4844,13 @@ function isSkip(path9) {
|
|
|
4844
4844
|
|
|
4845
4845
|
function resolveElementRef(ctx) {
|
|
4846
4846
|
return {
|
|
4847
|
-
CallExpression(
|
|
4847
|
+
CallExpression(path8) {
|
|
4848
4848
|
const {
|
|
4849
4849
|
inputType,
|
|
4850
4850
|
templateData: { refBindings }
|
|
4851
4851
|
} = ctx;
|
|
4852
4852
|
if (inputType !== "sfc") return;
|
|
4853
|
-
const { node } =
|
|
4853
|
+
const { node } = path8;
|
|
4854
4854
|
const isUseTemplateRef = isCalleeNamed(node, VUE_API_MAP.useTemplateRef);
|
|
4855
4855
|
const isCompRefBindings = Object.keys(refBindings.componentRefs).length > 0 && isCalleeNamed(node, VUE_API_MAP.ref);
|
|
4856
4856
|
const shouldProcess = isUseTemplateRef || isCompRefBindings;
|
|
@@ -4858,7 +4858,7 @@ function resolveElementRef(ctx) {
|
|
|
4858
4858
|
return;
|
|
4859
4859
|
}
|
|
4860
4860
|
if (isCompRefBindings) {
|
|
4861
|
-
const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call', _151 => _151(
|
|
4861
|
+
const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call', _151 => _151(path8), 'optionalAccess', _152 => _152.node]);
|
|
4862
4862
|
if (!t44.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess', _153 => _153.id]))) {
|
|
4863
4863
|
return;
|
|
4864
4864
|
}
|
|
@@ -4867,22 +4867,22 @@ function resolveElementRef(ctx) {
|
|
|
4867
4867
|
if (!compRef) return;
|
|
4868
4868
|
}
|
|
4869
4869
|
node.arguments[0] = t44.identifier("null");
|
|
4870
|
-
resolveTypeParameters(ctx,
|
|
4870
|
+
resolveTypeParameters(ctx, path8);
|
|
4871
4871
|
replaceCallName(node, REACT_API_MAP.useRef);
|
|
4872
4872
|
recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useRef);
|
|
4873
4873
|
},
|
|
4874
|
-
MemberExpression(
|
|
4875
|
-
resolveRefValueToCurrent(
|
|
4874
|
+
MemberExpression(path8) {
|
|
4875
|
+
resolveRefValueToCurrent(path8);
|
|
4876
4876
|
}
|
|
4877
4877
|
};
|
|
4878
4878
|
}
|
|
4879
|
-
function resolveTypeParameters(ctx,
|
|
4879
|
+
function resolveTypeParameters(ctx, path8) {
|
|
4880
4880
|
const {
|
|
4881
4881
|
templateData: { refBindings },
|
|
4882
4882
|
scriptData
|
|
4883
4883
|
} = ctx;
|
|
4884
|
-
const { node } =
|
|
4885
|
-
const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call', _154 => _154(
|
|
4884
|
+
const { node } = path8;
|
|
4885
|
+
const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call', _154 => _154(path8), 'optionalAccess', _155 => _155.node]);
|
|
4886
4886
|
if (!scriptData.lang.startsWith("ts") || !varDeclaratorNode) {
|
|
4887
4887
|
return;
|
|
4888
4888
|
}
|
|
@@ -4894,12 +4894,12 @@ function resolveTypeParameters(ctx, path9) {
|
|
|
4894
4894
|
node.typeParameters = t44.tsTypeParameterInstantiation([t44.tsTypeReference(t44.identifier(type))]);
|
|
4895
4895
|
}
|
|
4896
4896
|
}
|
|
4897
|
-
function resolveRefValueToCurrent(
|
|
4898
|
-
const { node } =
|
|
4897
|
+
function resolveRefValueToCurrent(path8) {
|
|
4898
|
+
const { node } = path8;
|
|
4899
4899
|
if (node.computed || !t44.isIdentifier(node.property) || node.property.name !== "value") {
|
|
4900
4900
|
return;
|
|
4901
4901
|
}
|
|
4902
|
-
const rootPath = findRootVariablePath(
|
|
4902
|
+
const rootPath = findRootVariablePath(path8);
|
|
4903
4903
|
if (!_optionalChain([rootPath, 'optionalAccess', _156 => _156.node]) || !t44.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
|
|
4904
4904
|
return;
|
|
4905
4905
|
}
|
|
@@ -4915,15 +4915,15 @@ function resolveRefValueToCurrent(path9) {
|
|
|
4915
4915
|
function resolveExprMemo(ctx, ast) {
|
|
4916
4916
|
const isScriptFile = ctx.inputType !== "sfc";
|
|
4917
4917
|
return {
|
|
4918
|
-
VariableDeclarator(
|
|
4919
|
-
const { node } =
|
|
4918
|
+
VariableDeclarator(path8) {
|
|
4919
|
+
const { node } = path8;
|
|
4920
4920
|
const { init } = node;
|
|
4921
4921
|
const shouldMemo = () => {
|
|
4922
4922
|
if (!init) return false;
|
|
4923
|
-
if (!atComponentOrHookRoot(
|
|
4923
|
+
if (!atComponentOrHookRoot(path8, ast.program, isScriptFile)) {
|
|
4924
4924
|
return false;
|
|
4925
4925
|
}
|
|
4926
|
-
if (!t45.isVariableDeclaration(
|
|
4926
|
+
if (!t45.isVariableDeclaration(path8.parent) || path8.parent.kind !== "const") {
|
|
4927
4927
|
return false;
|
|
4928
4928
|
}
|
|
4929
4929
|
if (t45.isFunction(init)) return false;
|
|
@@ -4933,7 +4933,7 @@ function resolveExprMemo(ctx, ast) {
|
|
|
4933
4933
|
return true;
|
|
4934
4934
|
};
|
|
4935
4935
|
if (!shouldMemo()) return;
|
|
4936
|
-
const initPath =
|
|
4936
|
+
const initPath = path8.get("init");
|
|
4937
4937
|
if (!initPath.isExpression()) return;
|
|
4938
4938
|
const deps = analyzeDeps(initPath.node, ctx, initPath);
|
|
4939
4939
|
if (!deps.elements.length) return;
|
|
@@ -4950,8 +4950,8 @@ function resolveExprMemo(ctx, ast) {
|
|
|
4950
4950
|
function resolveLintRules(ctx, ast) {
|
|
4951
4951
|
const inScriptFile = ctx.inputType !== "sfc";
|
|
4952
4952
|
return {
|
|
4953
|
-
CallExpression(
|
|
4954
|
-
const { node, parentPath } =
|
|
4953
|
+
CallExpression(path8) {
|
|
4954
|
+
const { node, parentPath } = path8;
|
|
4955
4955
|
if (!t46.isIdentifier(node.callee)) return;
|
|
4956
4956
|
const { name: callName } = node.callee;
|
|
4957
4957
|
const addLog = (t52) => {
|
|
@@ -4970,7 +4970,7 @@ function resolveLintRules(ctx, ast) {
|
|
|
4970
4970
|
);
|
|
4971
4971
|
return;
|
|
4972
4972
|
}
|
|
4973
|
-
if (!atComponentOrHookRoot(
|
|
4973
|
+
if (!atComponentOrHookRoot(path8, ast.program)) {
|
|
4974
4974
|
addLog(
|
|
4975
4975
|
`The ${macro} must be defined at the top level of the component, not inside blocks or functions.`
|
|
4976
4976
|
);
|
|
@@ -4986,7 +4986,7 @@ function resolveLintRules(ctx, ast) {
|
|
|
4986
4986
|
};
|
|
4987
4987
|
const lintHooks = () => {
|
|
4988
4988
|
if (!callName.startsWith("use")) return;
|
|
4989
|
-
if (!atComponentOrHookRoot(
|
|
4989
|
+
if (!atComponentOrHookRoot(path8, ast.program, inScriptFile)) {
|
|
4990
4990
|
addLog(
|
|
4991
4991
|
`The ${callName} hook must be called at the top level, not inside loops, conditions, or nested functions.`
|
|
4992
4992
|
);
|
|
@@ -5004,8 +5004,8 @@ function resolveLintRules(ctx, ast) {
|
|
|
5004
5004
|
function resolveProvide(ctx) {
|
|
5005
5005
|
if (ctx.inputType === "style") return {};
|
|
5006
5006
|
return {
|
|
5007
|
-
CallExpression(
|
|
5008
|
-
const { node } =
|
|
5007
|
+
CallExpression(path8) {
|
|
5008
|
+
const { node } = path8;
|
|
5009
5009
|
const providerTarget = _optionalChain([ADAPTER_RULES, 'access', _158 => _158.runtime, 'access', _159 => _159[VUE_API_MAP.provide], 'optionalAccess', _160 => _160.target]);
|
|
5010
5010
|
const isProvideCall = isCalleeNamed(node, VUE_API_MAP.provide) || providerTarget && isCalleeNamed(node, providerTarget);
|
|
5011
5011
|
if (!isProvideCall) return;
|
|
@@ -5015,7 +5015,7 @@ function resolveProvide(ctx) {
|
|
|
5015
5015
|
const adapter = ADAPTER_RULES.runtime[VUE_API_MAP.provide];
|
|
5016
5016
|
assignProviderValue(target, key, value);
|
|
5017
5017
|
recordImport(ctx, adapter.package, adapter.target);
|
|
5018
|
-
|
|
5018
|
+
path8.parentPath.remove();
|
|
5019
5019
|
}
|
|
5020
5020
|
};
|
|
5021
5021
|
}
|
|
@@ -5057,8 +5057,8 @@ function assignProviderValue(target, key, value) {
|
|
|
5057
5057
|
|
|
5058
5058
|
function resolveRenameAdapter(ctx) {
|
|
5059
5059
|
return {
|
|
5060
|
-
"CallExpression|Identifier"(
|
|
5061
|
-
const node =
|
|
5060
|
+
"CallExpression|Identifier"(path8) {
|
|
5061
|
+
const node = path8.node;
|
|
5062
5062
|
const isCallNode = t48.isCallExpression(node);
|
|
5063
5063
|
let apiName = "";
|
|
5064
5064
|
if (t48.isIdentifier(node)) {
|
|
@@ -5075,12 +5075,12 @@ function resolveRenameAdapter(ctx) {
|
|
|
5075
5075
|
if (!adapter || adapter.type !== "rename") {
|
|
5076
5076
|
return;
|
|
5077
5077
|
}
|
|
5078
|
-
if (!isVueApiReference2(
|
|
5078
|
+
if (!isVueApiReference2(path8, apiName)) {
|
|
5079
5079
|
return;
|
|
5080
5080
|
}
|
|
5081
5081
|
if (adapter.isTrackable) {
|
|
5082
5082
|
const reactiveType = getReactiveType(apiName);
|
|
5083
|
-
const declaratorPath = getVariableDeclaratorPath(
|
|
5083
|
+
const declaratorPath = getVariableDeclaratorPath(path8);
|
|
5084
5084
|
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _162 => _162.node]), {
|
|
5085
5085
|
is_reactive: true,
|
|
5086
5086
|
reactive_type: reactiveType
|
|
@@ -5098,25 +5098,25 @@ function resolveRenameAdapter(ctx) {
|
|
|
5098
5098
|
}
|
|
5099
5099
|
};
|
|
5100
5100
|
}
|
|
5101
|
-
function isVueApiReference2(
|
|
5101
|
+
function isVueApiReference2(path8, apiName) {
|
|
5102
5102
|
const whitelist = [VUE_API_MAP.defineAsyncComponent];
|
|
5103
5103
|
if (whitelist.includes(apiName)) {
|
|
5104
5104
|
return true;
|
|
5105
5105
|
}
|
|
5106
|
-
if (
|
|
5107
|
-
if (
|
|
5106
|
+
if (path8.isIdentifier()) {
|
|
5107
|
+
if (path8.parentPath.isCallExpression() && path8.parentPath.node.callee === path8.node) {
|
|
5108
5108
|
return false;
|
|
5109
5109
|
}
|
|
5110
|
-
if (!
|
|
5110
|
+
if (!path8.isReferencedIdentifier()) {
|
|
5111
5111
|
return false;
|
|
5112
5112
|
}
|
|
5113
5113
|
}
|
|
5114
|
-
if (
|
|
5115
|
-
const callee =
|
|
5114
|
+
if (path8.isCallExpression()) {
|
|
5115
|
+
const callee = path8.get("callee");
|
|
5116
5116
|
if (!callee.isIdentifier()) return false;
|
|
5117
5117
|
return isVueImportBinding2(callee.scope.getBinding(apiName));
|
|
5118
5118
|
}
|
|
5119
|
-
return isVueImportBinding2(
|
|
5119
|
+
return isVueImportBinding2(path8.scope.getBinding(apiName));
|
|
5120
5120
|
}
|
|
5121
5121
|
function isVueImportBinding2(binding) {
|
|
5122
5122
|
if (!binding) return false;
|
|
@@ -6612,20 +6612,11 @@ function transform(ast, ctx, options) {
|
|
|
6612
6612
|
}
|
|
6613
6613
|
|
|
6614
6614
|
// package.json
|
|
6615
|
-
var version = "1.
|
|
6615
|
+
var version = "1.8.0";
|
|
6616
6616
|
var bin = {
|
|
6617
6617
|
vureact: "./bin/vureact.js"
|
|
6618
6618
|
};
|
|
6619
6619
|
|
|
6620
|
-
// src/compiler/shared/types/cache-types.ts
|
|
6621
|
-
var CacheKey = /* @__PURE__ */ ((CacheKey2) => {
|
|
6622
|
-
CacheKey2["SFC"] = "sfc";
|
|
6623
|
-
CacheKey2["SCRIPT"] = "script";
|
|
6624
|
-
CacheKey2["STYLE"] = "style";
|
|
6625
|
-
CacheKey2["ASSET"] = "copied";
|
|
6626
|
-
return CacheKey2;
|
|
6627
|
-
})(CacheKey || {});
|
|
6628
|
-
|
|
6629
6620
|
// src/plugins/prettier.ts
|
|
6630
6621
|
async function formatWithPrettier(code, lang, opts) {
|
|
6631
6622
|
try {
|
|
@@ -6826,13 +6817,6 @@ var Helper = (_class5 = class {
|
|
|
6826
6817
|
const { input = "src" } = this.compilerOpts;
|
|
6827
6818
|
return _path2.default.resolve(this.getProjectRoot(), input);
|
|
6828
6819
|
}
|
|
6829
|
-
/**
|
|
6830
|
-
* 检查 input 路径是否是单个文件
|
|
6831
|
-
*/
|
|
6832
|
-
isSingleFile() {
|
|
6833
|
-
const inputPath = this.getInputPath();
|
|
6834
|
-
return _fs2.default.existsSync(inputPath) && _fs2.default.statSync(inputPath).isFile();
|
|
6835
|
-
}
|
|
6836
6820
|
/**
|
|
6837
6821
|
* 获取输出文件的路径。如:'[root]/.vureact/dist/'
|
|
6838
6822
|
* @param addInput 会输出如:'[root]/.vureact/dist/[input]/'
|
|
@@ -6891,6 +6875,13 @@ var Helper = (_class5 = class {
|
|
|
6891
6875
|
getOutputPkgPath() {
|
|
6892
6876
|
return _path2.default.join(this.getOuputPath(), "package.json");
|
|
6893
6877
|
}
|
|
6878
|
+
/**
|
|
6879
|
+
* 获取缓存文件路径
|
|
6880
|
+
*/
|
|
6881
|
+
getCachePath() {
|
|
6882
|
+
const filename = "_metadata";
|
|
6883
|
+
return _path2.default.resolve(this.getProjectRoot(), this.workspaceDir, "cache", `${filename}.json`);
|
|
6884
|
+
}
|
|
6894
6885
|
/**
|
|
6895
6886
|
* 返回文件相对工作区的路径
|
|
6896
6887
|
*/
|
|
@@ -6988,95 +6979,15 @@ var Helper = (_class5 = class {
|
|
|
6988
6979
|
}
|
|
6989
6980
|
async rmFile(filePath) {
|
|
6990
6981
|
try {
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
}
|
|
6994
|
-
}
|
|
6995
|
-
async loadCache(key) {
|
|
6996
|
-
const cacheFile = this.getCachePath();
|
|
6997
|
-
const defaultData = this.createCacheData(key);
|
|
6998
|
-
if (!_fs2.default.existsSync(cacheFile)) {
|
|
6999
|
-
return defaultData;
|
|
7000
|
-
}
|
|
7001
|
-
try {
|
|
7002
|
-
const content = await _fs2.default.promises.readFile(cacheFile, "utf-8");
|
|
7003
|
-
const data = JSON.parse(content);
|
|
7004
|
-
return {
|
|
7005
|
-
key,
|
|
7006
|
-
target: data[key] || [],
|
|
7007
|
-
source: data
|
|
7008
|
-
};
|
|
7009
|
-
} catch (e17) {
|
|
7010
|
-
return defaultData;
|
|
7011
|
-
}
|
|
7012
|
-
}
|
|
7013
|
-
createCacheData(key) {
|
|
7014
|
-
return {
|
|
7015
|
-
key,
|
|
7016
|
-
target: [],
|
|
7017
|
-
source: {
|
|
7018
|
-
["sfc" /* SFC */]: [],
|
|
7019
|
-
["script" /* SCRIPT */]: [],
|
|
7020
|
-
["style" /* STYLE */]: [],
|
|
7021
|
-
["copied" /* ASSET */]: []
|
|
6982
|
+
if (_fs2.default.existsSync(filePath)) {
|
|
6983
|
+
await _fs2.default.promises.rm(filePath, { recursive: true, force: true });
|
|
7022
6984
|
}
|
|
7023
|
-
}
|
|
7024
|
-
}
|
|
7025
|
-
/**
|
|
7026
|
-
* 获取缓存文件路径
|
|
7027
|
-
*/
|
|
7028
|
-
getCachePath() {
|
|
7029
|
-
const filename = "_metadata";
|
|
7030
|
-
return _path2.default.resolve(this.getProjectRoot(), this.workspaceDir, "cache", `${filename}.json`);
|
|
7031
|
-
}
|
|
7032
|
-
async saveCache(data) {
|
|
7033
|
-
if (!this.getIsCache() || !data) {
|
|
7034
|
-
return;
|
|
6985
|
+
} catch (e16) {
|
|
7035
6986
|
}
|
|
7036
|
-
const getDefaultValue = () => ({
|
|
7037
|
-
["sfc" /* SFC */]: [],
|
|
7038
|
-
["script" /* SCRIPT */]: [],
|
|
7039
|
-
["style" /* STYLE */]: [],
|
|
7040
|
-
["copied" /* ASSET */]: []
|
|
7041
|
-
});
|
|
7042
|
-
const cachePath = this.getCachePath();
|
|
7043
|
-
await fileLock.updateFile(cachePath, (currentData) => {
|
|
7044
|
-
const { key, target } = data;
|
|
7045
|
-
const mergedData = currentData || getDefaultValue();
|
|
7046
|
-
mergedData[key] = target;
|
|
7047
|
-
return mergedData;
|
|
7048
|
-
});
|
|
7049
6987
|
}
|
|
7050
6988
|
genHash(content) {
|
|
7051
6989
|
return genHashByXXH(content);
|
|
7052
6990
|
}
|
|
7053
|
-
/**
|
|
7054
|
-
* 扫描指定目录下的所有文件
|
|
7055
|
-
* @param dir 目标目录
|
|
7056
|
-
* @param filter 筛选指定的文件后缀名
|
|
7057
|
-
*/
|
|
7058
|
-
scanFiles(dir, filter) {
|
|
7059
|
-
const results = [];
|
|
7060
|
-
if (!_fs2.default.existsSync(dir)) {
|
|
7061
|
-
return results;
|
|
7062
|
-
}
|
|
7063
|
-
const stats = _fs2.default.statSync(dir);
|
|
7064
|
-
if (stats.isFile()) {
|
|
7065
|
-
return filter(dir) ? [dir] : [];
|
|
7066
|
-
}
|
|
7067
|
-
const list = _fs2.default.readdirSync(dir);
|
|
7068
|
-
for (const file of list) {
|
|
7069
|
-
const fullPath = _path2.default.resolve(dir, file);
|
|
7070
|
-
if (this.shouldSkipPath(fullPath)) continue;
|
|
7071
|
-
const stat = _fs2.default.statSync(fullPath);
|
|
7072
|
-
if (stat.isDirectory() && this.compilerOpts.recursive !== false) {
|
|
7073
|
-
results.push(...this.scanFiles(fullPath, filter));
|
|
7074
|
-
} else if (filter(fullPath)) {
|
|
7075
|
-
results.push(fullPath);
|
|
7076
|
-
}
|
|
7077
|
-
}
|
|
7078
|
-
return results;
|
|
7079
|
-
}
|
|
7080
6991
|
getAbsPath(filePath) {
|
|
7081
6992
|
return _path2.default.isAbsolute(filePath) ? filePath : _path2.default.resolve(this.getProjectRoot(), filePath);
|
|
7082
6993
|
}
|
|
@@ -7088,9 +6999,9 @@ var Helper = (_class5 = class {
|
|
|
7088
6999
|
};
|
|
7089
7000
|
}
|
|
7090
7001
|
async removeOutputFile(filePath, resolveOutputPath) {
|
|
7091
|
-
const
|
|
7092
|
-
if (!_fs2.default.existsSync(
|
|
7093
|
-
await _fs2.default.promises.unlink(
|
|
7002
|
+
const path8 = resolveOutputPath ? this.resolveOutputPath(filePath) : filePath;
|
|
7003
|
+
if (!_fs2.default.existsSync(path8)) return;
|
|
7004
|
+
await _fs2.default.promises.unlink(path8);
|
|
7094
7005
|
}
|
|
7095
7006
|
updateCache(targetFile, newData, cache) {
|
|
7096
7007
|
const index = cache.target.findIndex((c) => c.file === targetFile);
|
|
@@ -7143,18 +7054,18 @@ var Helper = (_class5 = class {
|
|
|
7143
7054
|
/**
|
|
7144
7055
|
* 读取 package.json 文件内容,并处理成对象返回
|
|
7145
7056
|
*/
|
|
7146
|
-
async resolvePackageFile(
|
|
7147
|
-
if (!_fs2.default.existsSync(
|
|
7057
|
+
async resolvePackageFile(path8) {
|
|
7058
|
+
if (!_fs2.default.existsSync(path8)) {
|
|
7148
7059
|
return {};
|
|
7149
7060
|
}
|
|
7150
7061
|
try {
|
|
7151
|
-
const content = await _fs2.default.promises.readFile(
|
|
7062
|
+
const content = await _fs2.default.promises.readFile(path8, "utf-8");
|
|
7152
7063
|
if (!content.trim()) {
|
|
7153
7064
|
return {};
|
|
7154
7065
|
}
|
|
7155
7066
|
return JSON.parse(content);
|
|
7156
7067
|
} catch (error) {
|
|
7157
|
-
console.error(_kleur2.default.red("\u274C"), `Failed to parse JSON file ${
|
|
7068
|
+
console.error(_kleur2.default.red("\u274C"), `Failed to parse JSON file ${path8}:
|
|
7158
7069
|
`, error);
|
|
7159
7070
|
return {};
|
|
7160
7071
|
}
|
|
@@ -7414,6 +7325,15 @@ var BaseCompiler = (_class7 = class extends Helper {
|
|
|
7414
7325
|
}
|
|
7415
7326
|
}, _class7);
|
|
7416
7327
|
|
|
7328
|
+
// src/compiler/shared/types/cache-types.ts
|
|
7329
|
+
var CacheKey = /* @__PURE__ */ ((CacheKey2) => {
|
|
7330
|
+
CacheKey2["SFC"] = "sfc";
|
|
7331
|
+
CacheKey2["SCRIPT"] = "script";
|
|
7332
|
+
CacheKey2["STYLE"] = "style";
|
|
7333
|
+
CacheKey2["ASSET"] = "copied";
|
|
7334
|
+
return CacheKey2;
|
|
7335
|
+
})(CacheKey || {});
|
|
7336
|
+
|
|
7417
7337
|
// src/utils/calc-elapsed-time.ts
|
|
7418
7338
|
function calcElapsedTime(start) {
|
|
7419
7339
|
const end = performance.now();
|
|
@@ -7436,9 +7356,10 @@ var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);
|
|
|
7436
7356
|
|
|
7437
7357
|
|
|
7438
7358
|
var AssetManager = (_class8 = class {
|
|
7439
|
-
constructor(fileCompiler, cleanupManager) {;_class8.prototype.__init12.call(this);_class8.prototype.__init13.call(this);
|
|
7359
|
+
constructor(fileCompiler, cleanupManager, cacheManager) {;_class8.prototype.__init12.call(this);_class8.prototype.__init13.call(this);
|
|
7440
7360
|
this.fileCompiler = fileCompiler;
|
|
7441
7361
|
this.cleanupManager = cleanupManager;
|
|
7362
|
+
this.cacheManager = cacheManager;
|
|
7442
7363
|
}
|
|
7443
7364
|
// 需要经过管线编译处理的文件类型
|
|
7444
7365
|
__init12() {this.pipelineFiles = [".js", ".ts", ".less", ".scss", ".sass"]}
|
|
@@ -7446,70 +7367,40 @@ var AssetManager = (_class8 = class {
|
|
|
7446
7367
|
/**
|
|
7447
7368
|
* 运行资源文件处理管线
|
|
7448
7369
|
*/
|
|
7449
|
-
async
|
|
7450
|
-
const
|
|
7451
|
-
const
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
const relativeToRoot = normalizePath(this.fileCompiler.relativePath(p));
|
|
7457
|
-
const filename = _path2.default.basename(p).toLowerCase();
|
|
7458
|
-
const ext = _path2.default.extname(p).toLowerCase();
|
|
7459
|
-
if (!_optionalChain([options, 'access', _269 => _269.output, 'optionalAccess', _270 => _270.ignoreAssets])) {
|
|
7460
|
-
const shouldExclude = Array.from(exclusions).some((pattern) => {
|
|
7461
|
-
if (pattern.endsWith(".")) {
|
|
7462
|
-
return filename.startsWith(pattern);
|
|
7463
|
-
}
|
|
7464
|
-
if (pattern.startsWith(".")) {
|
|
7465
|
-
return ext === pattern;
|
|
7466
|
-
}
|
|
7467
|
-
return relativeToRoot === pattern || filename === pattern;
|
|
7468
|
-
});
|
|
7469
|
-
if (shouldExclude) return false;
|
|
7470
|
-
} else if (exclusions.has(relativeToRoot) || exclusions.has(filename)) {
|
|
7471
|
-
return false;
|
|
7472
|
-
}
|
|
7473
|
-
if (ext === ".vue") return false;
|
|
7474
|
-
const isInsideSrc = p.startsWith(inputPath + _path2.default.sep);
|
|
7475
|
-
if (isInsideSrc && this.pipelineFiles.includes(ext)) {
|
|
7476
|
-
return false;
|
|
7477
|
-
}
|
|
7478
|
-
return true;
|
|
7479
|
-
});
|
|
7480
|
-
const absFiles = new Set(assetFiles.map((f) => this.fileCompiler.getAbsPath(f)));
|
|
7481
|
-
await this.cleanupManager.cleanupOldOutput("copied" /* ASSET */, (u) => !absFiles.has(u.file));
|
|
7482
|
-
if (!assetFiles.length) return 0;
|
|
7483
|
-
const cache = await this.fileCompiler.loadCache("copied" /* ASSET */);
|
|
7484
|
-
const copied = await Promise.all(
|
|
7485
|
-
assetFiles.map((file) => {
|
|
7486
|
-
return this.processAsset(file, cache);
|
|
7487
|
-
})
|
|
7370
|
+
async runAsset(files, cacheMap) {
|
|
7371
|
+
const absPaths = new Set(files.map((f) => this.fileCompiler.getAbsPath(f)));
|
|
7372
|
+
const cache = cacheMap["copied" /* ASSET */];
|
|
7373
|
+
await this.cleanupManager.removeMatchedFromCache(
|
|
7374
|
+
"copied" /* ASSET */,
|
|
7375
|
+
cache,
|
|
7376
|
+
(u) => !absPaths.has(u.file)
|
|
7488
7377
|
);
|
|
7489
|
-
|
|
7378
|
+
if (!files.length) return 0;
|
|
7379
|
+
const copied = await Promise.all(files.map((file) => this.processAsset(file, cache)));
|
|
7490
7380
|
return copied.filter(Boolean).length;
|
|
7491
7381
|
}
|
|
7492
7382
|
/**
|
|
7493
7383
|
* Process single asset file, compare with cache and decide whether to copy.
|
|
7494
7384
|
*/
|
|
7495
7385
|
async processAsset(filePath, existingCache) {
|
|
7496
|
-
const
|
|
7386
|
+
const { fileCompiler, cacheManager } = this;
|
|
7387
|
+
const absPath = fileCompiler.getAbsPath(filePath);
|
|
7497
7388
|
const fileMeta = {
|
|
7498
7389
|
file: absPath,
|
|
7499
|
-
...await
|
|
7390
|
+
...await fileCompiler.getFileMeta(absPath)
|
|
7500
7391
|
};
|
|
7501
|
-
const cache = (
|
|
7392
|
+
const cache = (fileCompiler.getIsCache() ? existingCache : void 0) || await cacheManager.loadCache("copied" /* ASSET */);
|
|
7502
7393
|
const record = cache.target.find((f) => f.file === absPath);
|
|
7503
|
-
if (record &&
|
|
7394
|
+
if (record && fileCompiler.compareFileMeta(record, fileMeta)) {
|
|
7504
7395
|
this.skippedCount++;
|
|
7505
7396
|
return;
|
|
7506
7397
|
}
|
|
7507
|
-
const outputPath =
|
|
7398
|
+
const outputPath = fileCompiler.resolveOutputPath(absPath);
|
|
7508
7399
|
await _fs2.default.promises.mkdir(_path2.default.dirname(outputPath), { recursive: true });
|
|
7509
7400
|
await _fs2.default.promises.copyFile(absPath, outputPath);
|
|
7510
7401
|
this.updateCache(absPath, fileMeta, cache);
|
|
7511
|
-
if (
|
|
7512
|
-
await
|
|
7402
|
+
if (fileCompiler.getIsCache() && !existingCache) {
|
|
7403
|
+
await cacheManager.saveCache(cache);
|
|
7513
7404
|
}
|
|
7514
7405
|
return fileMeta;
|
|
7515
7406
|
}
|
|
@@ -7540,11 +7431,14 @@ var AssetManager = (_class8 = class {
|
|
|
7540
7431
|
}, _class8);
|
|
7541
7432
|
|
|
7542
7433
|
// src/compiler/shared/file-compiler/cache-manager.ts
|
|
7434
|
+
|
|
7543
7435
|
var CacheManager = (_class9 = class {
|
|
7544
|
-
constructor(fileCompiler) {;_class9.prototype.__init14.call(this);
|
|
7436
|
+
constructor(fileCompiler) {;_class9.prototype.__init14.call(this);_class9.prototype.__init15.call(this);
|
|
7545
7437
|
this.fileCompiler = fileCompiler;
|
|
7546
7438
|
}
|
|
7547
7439
|
__init14() {this.pendingUpdates = /* @__PURE__ */ new Map()}
|
|
7440
|
+
/** 缓存文件仅读取一次,之后复用此副本 */
|
|
7441
|
+
__init15() {this.cachedData = null}
|
|
7548
7442
|
/**
|
|
7549
7443
|
* 批量更新缓存记录
|
|
7550
7444
|
*/
|
|
@@ -7553,12 +7447,12 @@ var CacheManager = (_class9 = class {
|
|
|
7553
7447
|
const meta = { ...unit };
|
|
7554
7448
|
delete meta.source;
|
|
7555
7449
|
if (key === "sfc" /* SFC */) {
|
|
7556
|
-
_optionalChainDelete([meta, 'access',
|
|
7557
|
-
_optionalChainDelete([meta, 'access',
|
|
7450
|
+
_optionalChainDelete([meta, 'access', _269 => _269.output, 'optionalAccess', _270 => _270.jsx, 'access', _271 => delete _271.code]);
|
|
7451
|
+
_optionalChainDelete([meta, 'access', _272 => _272.output, 'optionalAccess', _273 => _273.css, 'access', _274 => delete _274.code]);
|
|
7558
7452
|
} else if (key === "script" /* SCRIPT */) {
|
|
7559
|
-
_optionalChainDelete([meta, 'access',
|
|
7453
|
+
_optionalChainDelete([meta, 'access', _275 => _275.output, 'optionalAccess', _276 => _276.script, 'access', _277 => delete _277.code]);
|
|
7560
7454
|
} else if (key === "style" /* STYLE */) {
|
|
7561
|
-
_optionalChainDelete([meta, 'access',
|
|
7455
|
+
_optionalChainDelete([meta, 'access', _278 => _278.output, 'optionalAccess', _279 => _279.style, 'access', _280 => delete _280.code]);
|
|
7562
7456
|
}
|
|
7563
7457
|
if (!this.pendingUpdates.has(key)) {
|
|
7564
7458
|
this.pendingUpdates.set(key, []);
|
|
@@ -7566,94 +7460,203 @@ var CacheManager = (_class9 = class {
|
|
|
7566
7460
|
this.pendingUpdates.get(key).push({ unit, meta });
|
|
7567
7461
|
}
|
|
7568
7462
|
/**
|
|
7569
|
-
*
|
|
7463
|
+
* 一次性刷新所有缓存(只写一次文件)
|
|
7570
7464
|
*/
|
|
7571
|
-
async
|
|
7572
|
-
if (!this.fileCompiler.getIsCache()
|
|
7465
|
+
async flushAllCache() {
|
|
7466
|
+
if (!this.fileCompiler.getIsCache()) {
|
|
7573
7467
|
return;
|
|
7574
7468
|
}
|
|
7469
|
+
const keys = Object.values(CacheKey);
|
|
7470
|
+
if (!this.cachedData) {
|
|
7471
|
+
await this.loadAllCache();
|
|
7472
|
+
}
|
|
7473
|
+
for (const key of keys) {
|
|
7474
|
+
const updates = this.pendingUpdates.get(key);
|
|
7475
|
+
if (!_optionalChain([updates, 'optionalAccess', _281 => _281.length])) continue;
|
|
7476
|
+
const activeFiles = new Set(updates.map((u) => u.unit.file));
|
|
7477
|
+
const entries = (this.cachedData[key] || []).filter((c) => activeFiles.has(c.file));
|
|
7478
|
+
updates.forEach(({ unit, meta }) => {
|
|
7479
|
+
const idx = entries.findIndex((c) => c.file === unit.file);
|
|
7480
|
+
if (idx > -1) {
|
|
7481
|
+
entries[idx] = meta;
|
|
7482
|
+
} else {
|
|
7483
|
+
entries.push(meta);
|
|
7484
|
+
}
|
|
7485
|
+
});
|
|
7486
|
+
this.cachedData[key] = entries;
|
|
7487
|
+
this.pendingUpdates.set(key, []);
|
|
7488
|
+
}
|
|
7489
|
+
await fileLock.updateFile(this.fileCompiler.getCachePath(), () => this.cachedData);
|
|
7490
|
+
}
|
|
7491
|
+
/**
|
|
7492
|
+
* 一次性加载所有缓存(只读一次文件)
|
|
7493
|
+
*/
|
|
7494
|
+
async loadAllCache() {
|
|
7495
|
+
const filePath = this.fileCompiler.getCachePath();
|
|
7496
|
+
const result = {};
|
|
7497
|
+
let raw = null;
|
|
7498
|
+
if (_fs2.default.existsSync(filePath)) {
|
|
7499
|
+
try {
|
|
7500
|
+
const content = await _fs2.default.promises.readFile(filePath, "utf-8");
|
|
7501
|
+
raw = JSON.parse(content);
|
|
7502
|
+
} catch (e17) {
|
|
7503
|
+
}
|
|
7504
|
+
}
|
|
7505
|
+
this.cachedData = raw || this.getEmptyList();
|
|
7506
|
+
const keys = Object.values(CacheKey);
|
|
7507
|
+
for (const key of keys) {
|
|
7508
|
+
result[key] = this.buildLoadedCache(key, raw);
|
|
7509
|
+
}
|
|
7510
|
+
return result;
|
|
7511
|
+
}
|
|
7512
|
+
/**
|
|
7513
|
+
* 加载指定类型的缓存(watch 等场景使用)
|
|
7514
|
+
*/
|
|
7515
|
+
async loadCache(key) {
|
|
7516
|
+
if (this.cachedData) {
|
|
7517
|
+
return this.buildLoadedCache(key, this.cachedData);
|
|
7518
|
+
}
|
|
7519
|
+
const filePath = this.fileCompiler.getCachePath();
|
|
7520
|
+
if (_fs2.default.existsSync(filePath)) {
|
|
7521
|
+
try {
|
|
7522
|
+
const content = await _fs2.default.promises.readFile(filePath, "utf-8");
|
|
7523
|
+
const data = JSON.parse(content);
|
|
7524
|
+
return this.buildLoadedCache(key, data);
|
|
7525
|
+
} catch (e18) {
|
|
7526
|
+
}
|
|
7527
|
+
}
|
|
7528
|
+
return this.buildLoadedCache(key, null);
|
|
7529
|
+
}
|
|
7530
|
+
/**
|
|
7531
|
+
* 刷新指定 key 的缓存(统一由 flushAllCache 写入,此方法仅用于外部兼容调用)
|
|
7532
|
+
*/
|
|
7533
|
+
async flushCache(key) {
|
|
7534
|
+
if (!this.fileCompiler.getIsCache()) return;
|
|
7535
|
+
if (!this.pendingUpdates.has(key)) return;
|
|
7575
7536
|
const updates = this.pendingUpdates.get(key);
|
|
7576
|
-
if (updates.length
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7537
|
+
if (!updates.length) return;
|
|
7538
|
+
if (!this.cachedData) {
|
|
7539
|
+
const filePath = this.fileCompiler.getCachePath();
|
|
7540
|
+
if (_fs2.default.existsSync(filePath)) {
|
|
7541
|
+
try {
|
|
7542
|
+
const content = await _fs2.default.promises.readFile(filePath, "utf-8");
|
|
7543
|
+
this.cachedData = JSON.parse(content);
|
|
7544
|
+
} catch (e19) {
|
|
7545
|
+
}
|
|
7546
|
+
}
|
|
7580
7547
|
}
|
|
7581
|
-
|
|
7548
|
+
const activeFiles = new Set(updates.map((u) => u.unit.file));
|
|
7549
|
+
let entries = (this.cachedData || this.getEmptyList())[key] || [];
|
|
7550
|
+
entries = entries.filter((c) => activeFiles.has(c.file));
|
|
7551
|
+
updates.forEach(({ unit, meta }) => {
|
|
7552
|
+
const idx = entries.findIndex((c) => c.file === unit.file);
|
|
7553
|
+
if (idx > -1) {
|
|
7554
|
+
entries[idx] = meta;
|
|
7555
|
+
} else {
|
|
7556
|
+
entries.push(meta);
|
|
7557
|
+
}
|
|
7558
|
+
});
|
|
7559
|
+
(this.cachedData || this.getEmptyList())[key] = entries;
|
|
7582
7560
|
this.pendingUpdates.set(key, []);
|
|
7561
|
+
await this.saveCache(this.buildLoadedCache(key, this.cachedData));
|
|
7562
|
+
}
|
|
7563
|
+
getEmptyList() {
|
|
7564
|
+
return {
|
|
7565
|
+
["sfc" /* SFC */]: [],
|
|
7566
|
+
["script" /* SCRIPT */]: [],
|
|
7567
|
+
["style" /* STYLE */]: [],
|
|
7568
|
+
["copied" /* ASSET */]: []
|
|
7569
|
+
};
|
|
7583
7570
|
}
|
|
7584
7571
|
/**
|
|
7585
|
-
*
|
|
7572
|
+
* 保存缓存数据到文件(watch 等场景使用)
|
|
7586
7573
|
*/
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
if (
|
|
7590
|
-
|
|
7591
|
-
}
|
|
7592
|
-
|
|
7593
|
-
|
|
7574
|
+
async saveCache(data) {
|
|
7575
|
+
if (!this.fileCompiler.getIsCache() || !data) return;
|
|
7576
|
+
if (this.cachedData) {
|
|
7577
|
+
this.cachedData[data.key] = data.target;
|
|
7578
|
+
}
|
|
7579
|
+
await fileLock.updateFile(this.fileCompiler.getCachePath(), (currentData) => {
|
|
7580
|
+
const merged = currentData || this.getEmptyList();
|
|
7581
|
+
merged[data.key] = data.target;
|
|
7582
|
+
return merged;
|
|
7583
|
+
});
|
|
7584
|
+
}
|
|
7585
|
+
buildLoadedCache(key, raw) {
|
|
7586
|
+
const emptySource = {
|
|
7587
|
+
["sfc" /* SFC */]: [],
|
|
7588
|
+
["script" /* SCRIPT */]: [],
|
|
7589
|
+
["style" /* STYLE */]: [],
|
|
7590
|
+
["copied" /* ASSET */]: []
|
|
7591
|
+
};
|
|
7592
|
+
const source = raw || emptySource;
|
|
7593
|
+
return {
|
|
7594
|
+
key,
|
|
7595
|
+
target: source[key] || [],
|
|
7596
|
+
source
|
|
7597
|
+
};
|
|
7594
7598
|
}
|
|
7595
7599
|
}, _class9);
|
|
7596
7600
|
|
|
7597
7601
|
// src/compiler/shared/file-compiler/cleanup-manager.ts
|
|
7598
7602
|
|
|
7599
7603
|
var CleanupManager = class {
|
|
7600
|
-
constructor(fileCompiler) {
|
|
7604
|
+
constructor(fileCompiler, cacheManager) {
|
|
7601
7605
|
this.fileCompiler = fileCompiler;
|
|
7606
|
+
this.cacheManager = cacheManager;
|
|
7602
7607
|
}
|
|
7603
7608
|
/**
|
|
7604
|
-
*
|
|
7609
|
+
* 删除指定路径对应的构建产物和缓存
|
|
7605
7610
|
*/
|
|
7606
7611
|
async removeOutputPath(targetPath, type) {
|
|
7607
7612
|
const absPath = this.fileCompiler.getAbsPath(targetPath);
|
|
7608
|
-
await this.
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
u.file.startsWith(absPath + _path2.default.sep)
|
|
7614
|
-
);
|
|
7613
|
+
const cache = await this.cacheManager.loadCache(type);
|
|
7614
|
+
await this.removeMatchedFromCache(type, cache, (m) => {
|
|
7615
|
+
return m.file === absPath || m.file.startsWith(absPath + _path2.default.sep);
|
|
7616
|
+
});
|
|
7617
|
+
await this.cacheManager.saveCache(cache);
|
|
7615
7618
|
}
|
|
7616
7619
|
/**
|
|
7617
|
-
*
|
|
7620
|
+
* 删除匹配的输出文件,并从内存缓存中移除对应条目(不写磁盘)
|
|
7618
7621
|
*/
|
|
7619
|
-
async
|
|
7620
|
-
const cache = await this.fileCompiler.loadCache(key);
|
|
7622
|
+
async removeMatchedFromCache(key, cache, filter) {
|
|
7621
7623
|
if (!cache.target.length) return;
|
|
7622
7624
|
const toRemove = cache.target.filter(filter);
|
|
7623
7625
|
if (!toRemove.length) return;
|
|
7624
|
-
|
|
7625
|
-
let meta;
|
|
7626
|
-
switch (key) {
|
|
7627
|
-
case "sfc" /* SFC */: {
|
|
7628
|
-
meta = m;
|
|
7629
|
-
const { jsx, css } = meta.output;
|
|
7630
|
-
await this.fileCompiler.removeOutputFile(jsx.file);
|
|
7631
|
-
if (_optionalChain([css, 'optionalAccess', _283 => _283.file])) {
|
|
7632
|
-
await this.fileCompiler.removeOutputFile(css.file);
|
|
7633
|
-
}
|
|
7634
|
-
break;
|
|
7635
|
-
}
|
|
7636
|
-
case "script" /* SCRIPT */: {
|
|
7637
|
-
meta = m;
|
|
7638
|
-
await this.fileCompiler.removeOutputFile(meta.output.script.file);
|
|
7639
|
-
break;
|
|
7640
|
-
}
|
|
7641
|
-
case "style" /* STYLE */: {
|
|
7642
|
-
meta = m;
|
|
7643
|
-
await this.fileCompiler.removeOutputFile(meta.output.style.file);
|
|
7644
|
-
break;
|
|
7645
|
-
}
|
|
7646
|
-
// 静态资产缓存直接删除对应文件
|
|
7647
|
-
default: {
|
|
7648
|
-
await this.fileCompiler.removeOutputFile(m.file, true);
|
|
7649
|
-
break;
|
|
7650
|
-
}
|
|
7651
|
-
}
|
|
7652
|
-
};
|
|
7653
|
-
await Promise.all(toRemove.map(removeFn));
|
|
7626
|
+
await Promise.all(toRemove.map((m) => this.removeCacheMeta(key, m)));
|
|
7654
7627
|
const removedFiles = new Set(toRemove.map((m) => m.file));
|
|
7655
7628
|
cache.target = cache.target.filter((m) => !removedFiles.has(m.file));
|
|
7656
|
-
|
|
7629
|
+
}
|
|
7630
|
+
/**
|
|
7631
|
+
* 删除单个缓存元数据对应的输出文件(不操作缓存)
|
|
7632
|
+
*/
|
|
7633
|
+
async removeCacheMeta(key, meta) {
|
|
7634
|
+
switch (key) {
|
|
7635
|
+
case "sfc" /* SFC */: {
|
|
7636
|
+
const sfcMeta = meta;
|
|
7637
|
+
const { jsx, css } = sfcMeta.output;
|
|
7638
|
+
await this.fileCompiler.removeOutputFile(jsx.file);
|
|
7639
|
+
if (_optionalChain([css, 'optionalAccess', _282 => _282.file])) {
|
|
7640
|
+
await this.fileCompiler.removeOutputFile(css.file);
|
|
7641
|
+
}
|
|
7642
|
+
break;
|
|
7643
|
+
}
|
|
7644
|
+
case "script" /* SCRIPT */: {
|
|
7645
|
+
const scriptMeta = meta;
|
|
7646
|
+
await this.fileCompiler.removeOutputFile(scriptMeta.output.script.file);
|
|
7647
|
+
break;
|
|
7648
|
+
}
|
|
7649
|
+
case "style" /* STYLE */: {
|
|
7650
|
+
const styleMeta = meta;
|
|
7651
|
+
await this.fileCompiler.removeOutputFile(styleMeta.output.style.file);
|
|
7652
|
+
break;
|
|
7653
|
+
}
|
|
7654
|
+
// 静态资产缓存直接删除对应文件
|
|
7655
|
+
default: {
|
|
7656
|
+
await this.fileCompiler.removeOutputFile(meta.file, true);
|
|
7657
|
+
break;
|
|
7658
|
+
}
|
|
7659
|
+
}
|
|
7657
7660
|
}
|
|
7658
7661
|
};
|
|
7659
7662
|
|
|
@@ -7689,7 +7692,7 @@ var CompilationUnitProcessor = class {
|
|
|
7689
7692
|
const isScriptFile = key === "script" /* SCRIPT */;
|
|
7690
7693
|
const isStyleFile = key === "style" /* STYLE */;
|
|
7691
7694
|
if (isSFC || isScriptFile) {
|
|
7692
|
-
unit.hasRoute = _optionalChain([result, 'optionalAccess',
|
|
7695
|
+
unit.hasRoute = _optionalChain([result, 'optionalAccess', _283 => _283.hasRoute]);
|
|
7693
7696
|
}
|
|
7694
7697
|
const resolveFileInfo = () => {
|
|
7695
7698
|
if (isSFC) {
|
|
@@ -7709,7 +7712,7 @@ var CompilationUnitProcessor = class {
|
|
|
7709
7712
|
const { script } = result.fileInfo;
|
|
7710
7713
|
unit.output = {
|
|
7711
7714
|
script: {
|
|
7712
|
-
file: _optionalChain([script, 'optionalAccess',
|
|
7715
|
+
file: _optionalChain([script, 'optionalAccess', _284 => _284.file]),
|
|
7713
7716
|
code
|
|
7714
7717
|
}
|
|
7715
7718
|
};
|
|
@@ -7758,12 +7761,12 @@ var CompilationUnitProcessor = class {
|
|
|
7758
7761
|
|
|
7759
7762
|
|
|
7760
7763
|
var FileProcessor = (_class10 = class {
|
|
7761
|
-
constructor(fileCompiler, compilationUnitProcessor, cacheManager) {;_class10.prototype.
|
|
7764
|
+
constructor(fileCompiler, compilationUnitProcessor, cacheManager) {;_class10.prototype.__init16.call(this);
|
|
7762
7765
|
this.fileCompiler = fileCompiler;
|
|
7763
7766
|
this.compilationUnitProcessor = compilationUnitProcessor;
|
|
7764
7767
|
this.cacheManager = cacheManager;
|
|
7765
7768
|
}
|
|
7766
|
-
|
|
7769
|
+
__init16() {this.skippedCount = 0}
|
|
7767
7770
|
/**
|
|
7768
7771
|
* Process a single Vue file (this method is called directly in CLI Watch mode)
|
|
7769
7772
|
*/
|
|
@@ -7785,8 +7788,8 @@ var FileProcessor = (_class10 = class {
|
|
|
7785
7788
|
async processFile(key, filePath, existingCache) {
|
|
7786
7789
|
const absPath = this.fileCompiler.getAbsPath(filePath);
|
|
7787
7790
|
const fileMeta = await this.fileCompiler.getFileMeta(absPath);
|
|
7788
|
-
const cache = (this.fileCompiler.getIsCache() ? existingCache : void 0) || await this.
|
|
7789
|
-
const record = _optionalChain([cache, 'optionalAccess',
|
|
7791
|
+
const cache = (this.fileCompiler.getIsCache() ? existingCache : void 0) || await this.cacheManager.loadCache(key);
|
|
7792
|
+
const record = _optionalChain([cache, 'optionalAccess', _285 => _285.target, 'access', _286 => _286.find, 'call', _287 => _287((c) => c.file === absPath)]);
|
|
7790
7793
|
const { shouldCompile, hash } = await this.fileCompiler.checkCacheStatus(
|
|
7791
7794
|
fileMeta,
|
|
7792
7795
|
record,
|
|
@@ -7808,10 +7811,10 @@ var FileProcessor = (_class10 = class {
|
|
|
7808
7811
|
hash: hash || this.fileCompiler.genHash(source)
|
|
7809
7812
|
};
|
|
7810
7813
|
const processed = await this.compilationUnitProcessor.resolve(initUnit, key);
|
|
7811
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
7814
|
+
if (_optionalChain([processed, 'optionalAccess', _288 => _288.output])) {
|
|
7812
7815
|
await this.compilationUnitProcessor.saveCompiledFiles(processed, key);
|
|
7813
7816
|
if (key === "sfc" /* SFC */ || key === "script" /* SCRIPT */) {
|
|
7814
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
7817
|
+
if (_optionalChain([processed, 'optionalAccess', _289 => _289.hasRoute])) {
|
|
7815
7818
|
await this.addRouterToPackageJson();
|
|
7816
7819
|
await this.updateEntryWithRouterProvider();
|
|
7817
7820
|
}
|
|
@@ -7825,13 +7828,13 @@ var FileProcessor = (_class10 = class {
|
|
|
7825
7828
|
*/
|
|
7826
7829
|
async addRouterToPackageJson() {
|
|
7827
7830
|
const { output } = this.fileCompiler.options;
|
|
7828
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
7831
|
+
if (_optionalChain([output, 'optionalAccess', _290 => _290.bootstrapVite]) === false) {
|
|
7829
7832
|
return;
|
|
7830
7833
|
}
|
|
7831
7834
|
const { router } = RUNTIME_PACKAGES;
|
|
7832
7835
|
const filePath = this.fileCompiler.getOutputPkgPath();
|
|
7833
7836
|
const packageJson = await this.fileCompiler.resolvePackageFile(filePath);
|
|
7834
|
-
if (_optionalChain([packageJson, 'optionalAccess',
|
|
7837
|
+
if (_optionalChain([packageJson, 'optionalAccess', _291 => _291.dependencies, 'optionalAccess', _292 => _292[router.name]])) {
|
|
7835
7838
|
return;
|
|
7836
7839
|
}
|
|
7837
7840
|
if (!packageJson.dependencies) {
|
|
@@ -7850,14 +7853,14 @@ var FileProcessor = (_class10 = class {
|
|
|
7850
7853
|
const { exclude, output, router } = this.fileCompiler.options;
|
|
7851
7854
|
const inputPath = this.fileCompiler.getInputPath();
|
|
7852
7855
|
const outputPath = this.fileCompiler.getOuputPath(true);
|
|
7853
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
7856
|
+
if (_optionalChain([output, 'optionalAccess', _293 => _293.bootstrapVite]) === false || _optionalChain([router, 'optionalAccess', _294 => _294.autoUpdateEntry]) === false || !_optionalChain([router, 'optionalAccess', _295 => _295.configFile])) {
|
|
7854
7857
|
return;
|
|
7855
7858
|
}
|
|
7856
7859
|
const getMainFile = async (filename) => {
|
|
7857
7860
|
const filePath = _path2.default.resolve(outputPath, filename);
|
|
7858
7861
|
try {
|
|
7859
7862
|
return { filePath, content: await _fs2.default.promises.readFile(filePath, "utf-8") };
|
|
7860
|
-
} catch (
|
|
7863
|
+
} catch (e20) {
|
|
7861
7864
|
return;
|
|
7862
7865
|
}
|
|
7863
7866
|
};
|
|
@@ -7871,7 +7874,7 @@ var FileProcessor = (_class10 = class {
|
|
|
7871
7874
|
const prepareRouterEntry = () => {
|
|
7872
7875
|
const importPath = this.fileCompiler.resolveRelativePath(inputPath, router.configFile);
|
|
7873
7876
|
let content = fileData.content;
|
|
7874
|
-
if (_optionalChain([exclude, 'optionalAccess',
|
|
7877
|
+
if (_optionalChain([exclude, 'optionalAccess', _296 => _296.includes, 'call', _297 => _297(router.configFile)]) || _optionalChain([exclude, 'optionalAccess', _298 => _298.includes, 'call', _299 => _299(importPath)])) {
|
|
7875
7878
|
return content;
|
|
7876
7879
|
}
|
|
7877
7880
|
const routerModule = "RouterInstance";
|
|
@@ -7910,64 +7913,160 @@ ${routerImport}`);
|
|
|
7910
7913
|
resetSkippedCount() {
|
|
7911
7914
|
this.skippedCount = 0;
|
|
7912
7915
|
}
|
|
7916
|
+
/**
|
|
7917
|
+
* 扫描项目中的编译文件和资产文件
|
|
7918
|
+
* @param recursive 是否递归扫描子目录
|
|
7919
|
+
* @param ignoreAssets 需要忽略的资产文件列表
|
|
7920
|
+
*/
|
|
7921
|
+
scanFiles() {
|
|
7922
|
+
const { fileCompiler } = this;
|
|
7923
|
+
const rootPath = fileCompiler.getProjectRoot();
|
|
7924
|
+
const inputPath = fileCompiler.getInputPath();
|
|
7925
|
+
const scriptExt = /\.(js|ts|jsx|tsx)$/i;
|
|
7926
|
+
const styleExt = /\.(css|less|sass|scss)$/i;
|
|
7927
|
+
const result = {
|
|
7928
|
+
assets: [],
|
|
7929
|
+
script: [],
|
|
7930
|
+
style: [],
|
|
7931
|
+
vue: []
|
|
7932
|
+
};
|
|
7933
|
+
const getInputStat = (path8) => {
|
|
7934
|
+
if (!_fs2.default.existsSync(path8)) return;
|
|
7935
|
+
return _fs2.default.statSync(path8);
|
|
7936
|
+
};
|
|
7937
|
+
const resolveDirectory = (file, walk, fallback) => {
|
|
7938
|
+
const directory = _fs2.default.readdirSync(file);
|
|
7939
|
+
directory.forEach((p) => {
|
|
7940
|
+
const fullPath = _path2.default.resolve(file, p);
|
|
7941
|
+
if (fileCompiler.shouldSkipPath(fullPath)) {
|
|
7942
|
+
return;
|
|
7943
|
+
}
|
|
7944
|
+
const stat = _fs2.default.statSync(fullPath);
|
|
7945
|
+
if (stat.isDirectory() && fileCompiler.options.recursive !== false) {
|
|
7946
|
+
walk(fullPath);
|
|
7947
|
+
return;
|
|
7948
|
+
}
|
|
7949
|
+
fallback(fullPath);
|
|
7950
|
+
});
|
|
7951
|
+
};
|
|
7952
|
+
const scanCompilationFiles = (file, res) => {
|
|
7953
|
+
const stat = getInputStat(file);
|
|
7954
|
+
if (!stat) return;
|
|
7955
|
+
const classifyFile = (filePath) => {
|
|
7956
|
+
const fileExt = _path2.default.extname(filePath);
|
|
7957
|
+
if (fileExt === ".vue") {
|
|
7958
|
+
res.vue.push(filePath);
|
|
7959
|
+
return;
|
|
7960
|
+
}
|
|
7961
|
+
if (scriptExt.test(fileExt)) {
|
|
7962
|
+
res.script.push(filePath);
|
|
7963
|
+
return;
|
|
7964
|
+
}
|
|
7965
|
+
if (styleExt.test(fileExt)) {
|
|
7966
|
+
res.style.push(filePath);
|
|
7967
|
+
}
|
|
7968
|
+
};
|
|
7969
|
+
if (stat.isFile()) {
|
|
7970
|
+
classifyFile(file);
|
|
7971
|
+
return;
|
|
7972
|
+
}
|
|
7973
|
+
resolveDirectory(
|
|
7974
|
+
file,
|
|
7975
|
+
(path8) => scanCompilationFiles(path8, res),
|
|
7976
|
+
(path8) => classifyFile(path8)
|
|
7977
|
+
);
|
|
7978
|
+
};
|
|
7979
|
+
const isAssetFile = (input) => {
|
|
7980
|
+
const fileExt = _path2.default.extname(input).toLowerCase();
|
|
7981
|
+
const resolvedPath = normalizePath(fileCompiler.relativePath(input));
|
|
7982
|
+
const baseName = _path2.default.basename(input).toLowerCase();
|
|
7983
|
+
const exclusions = fileCompiler.getIgnoreAssets();
|
|
7984
|
+
if (!_optionalChain([fileCompiler, 'access', _300 => _300.options, 'access', _301 => _301.output, 'optionalAccess', _302 => _302.ignoreAssets])) {
|
|
7985
|
+
const shouldExclude = Array.from(exclusions).some((pattern) => {
|
|
7986
|
+
if (pattern.endsWith(".")) {
|
|
7987
|
+
return baseName.startsWith(pattern);
|
|
7988
|
+
}
|
|
7989
|
+
if (pattern.startsWith(".")) {
|
|
7990
|
+
return fileExt === pattern;
|
|
7991
|
+
}
|
|
7992
|
+
return resolvedPath === pattern || baseName === pattern;
|
|
7993
|
+
});
|
|
7994
|
+
if (shouldExclude) return false;
|
|
7995
|
+
} else {
|
|
7996
|
+
if (exclusions.has(resolvedPath) || exclusions.has(baseName) || fileExt === ".vue") {
|
|
7997
|
+
return false;
|
|
7998
|
+
}
|
|
7999
|
+
}
|
|
8000
|
+
const isInsideSrc = input.startsWith(inputPath + _path2.default.sep);
|
|
8001
|
+
if (isInsideSrc && (scriptExt.test(fileExt) || styleExt.test(fileExt))) {
|
|
8002
|
+
return false;
|
|
8003
|
+
}
|
|
8004
|
+
return true;
|
|
8005
|
+
};
|
|
8006
|
+
const scanAssetFiles = (input, res) => {
|
|
8007
|
+
const stat = getInputStat(input);
|
|
8008
|
+
if (!stat || fileCompiler.shouldSkipPath(input)) {
|
|
8009
|
+
return;
|
|
8010
|
+
}
|
|
8011
|
+
if (stat.isFile()) {
|
|
8012
|
+
if (isAssetFile(input)) {
|
|
8013
|
+
res.assets.push(input);
|
|
8014
|
+
}
|
|
8015
|
+
return;
|
|
8016
|
+
}
|
|
8017
|
+
resolveDirectory(
|
|
8018
|
+
input,
|
|
8019
|
+
(path8) => scanAssetFiles(path8, res),
|
|
8020
|
+
(path8) => {
|
|
8021
|
+
if (isAssetFile(path8)) {
|
|
8022
|
+
res.assets.push(path8);
|
|
8023
|
+
}
|
|
8024
|
+
}
|
|
8025
|
+
);
|
|
8026
|
+
};
|
|
8027
|
+
scanCompilationFiles(inputPath, result);
|
|
8028
|
+
scanAssetFiles(rootPath, result);
|
|
8029
|
+
return result;
|
|
8030
|
+
}
|
|
7913
8031
|
}, _class10);
|
|
7914
8032
|
|
|
7915
8033
|
// src/compiler/shared/file-compiler/pipeline-manager.ts
|
|
7916
|
-
|
|
7917
8034
|
var PipelineManager = (_class11 = class {
|
|
7918
|
-
constructor(fileCompiler, fileProcessor) {;_class11.prototype.
|
|
8035
|
+
constructor(fileCompiler, fileProcessor, cleanupManager) {;_class11.prototype.__init17.call(this);
|
|
7919
8036
|
this.fileCompiler = fileCompiler;
|
|
7920
8037
|
this.fileProcessor = fileProcessor;
|
|
7921
|
-
this.cleanupManager =
|
|
8038
|
+
this.cleanupManager = cleanupManager;
|
|
7922
8039
|
}
|
|
7923
|
-
|
|
7924
|
-
|
|
8040
|
+
__init17() {this.skippedCount = 0}
|
|
7925
8041
|
/**
|
|
7926
8042
|
* 运行 SFC 编译管线
|
|
7927
8043
|
*/
|
|
7928
|
-
async
|
|
7929
|
-
return this.
|
|
8044
|
+
async runSFC(files, cacheMap) {
|
|
8045
|
+
return this.runCore(files, "sfc" /* SFC */, cacheMap);
|
|
7930
8046
|
}
|
|
7931
8047
|
/**
|
|
7932
8048
|
* 运行 Script 编译管线
|
|
7933
8049
|
*/
|
|
7934
|
-
async
|
|
7935
|
-
return this.
|
|
8050
|
+
async runScript(files, cacheMap) {
|
|
8051
|
+
return this.runCore(files, "script" /* SCRIPT */, cacheMap);
|
|
7936
8052
|
}
|
|
7937
8053
|
/**
|
|
7938
8054
|
* 运行 Style 编译管线
|
|
7939
8055
|
*/
|
|
7940
|
-
async
|
|
7941
|
-
return this.
|
|
8056
|
+
async runStyle(files, cacheMap) {
|
|
8057
|
+
return this.runCore(files, "style" /* STYLE */, cacheMap);
|
|
7942
8058
|
}
|
|
7943
8059
|
/**
|
|
7944
8060
|
* 核心编译管线
|
|
7945
8061
|
*/
|
|
7946
|
-
async
|
|
7947
|
-
const
|
|
7948
|
-
const
|
|
7949
|
-
|
|
7950
|
-
const files = this.fileCompiler.scanFiles(inputPath, (p) => {
|
|
7951
|
-
const ext = _path2.default.extname(p);
|
|
7952
|
-
if (key === "sfc" /* SFC */) {
|
|
7953
|
-
return ext === ".vue";
|
|
7954
|
-
}
|
|
7955
|
-
if (key === "script" /* SCRIPT */) {
|
|
7956
|
-
return scriptExtRegex.test(ext);
|
|
7957
|
-
}
|
|
7958
|
-
if (key === "style" /* STYLE */) {
|
|
7959
|
-
return styleExtRegex.test(ext);
|
|
7960
|
-
}
|
|
7961
|
-
return false;
|
|
7962
|
-
});
|
|
7963
|
-
const absFiles = new Set(files.map((f) => this.fileCompiler.getAbsPath(f)));
|
|
7964
|
-
await this.cleanupManager.cleanupOldOutput(key, (c) => !absFiles.has(c.file));
|
|
8062
|
+
async runCore(files, key, cacheMap) {
|
|
8063
|
+
const absPaths = new Set(files.map((f) => this.fileCompiler.getAbsPath(f)));
|
|
8064
|
+
const cache = cacheMap[key];
|
|
8065
|
+
await this.cleanupManager.removeMatchedFromCache(key, cache, (c) => !absPaths.has(c.file));
|
|
7965
8066
|
if (!files.length) return 0;
|
|
7966
|
-
const cache = await this.fileCompiler.loadCache(key);
|
|
7967
8067
|
const compiled = await Promise.all(
|
|
7968
|
-
files.map(
|
|
8068
|
+
files.map((f) => this.fileProcessor.processFile(key, f, cache))
|
|
7969
8069
|
);
|
|
7970
|
-
await this.fileCompiler.flushCache(key);
|
|
7971
8070
|
return compiled.filter(Boolean).length;
|
|
7972
8071
|
}
|
|
7973
8072
|
/**
|
|
@@ -7990,12 +8089,12 @@ var _child_process = require('child_process');
|
|
|
7990
8089
|
|
|
7991
8090
|
|
|
7992
8091
|
var ViteBootstrapper = (_class12 = class {
|
|
7993
|
-
constructor(fileCompiler, options) {;_class12.prototype.
|
|
8092
|
+
constructor(fileCompiler, options) {;_class12.prototype.__init18.call(this);_class12.prototype.__init19.call(this);
|
|
7994
8093
|
this.fileCompiler = fileCompiler;
|
|
7995
8094
|
this.options = options;
|
|
7996
8095
|
}
|
|
7997
|
-
|
|
7998
|
-
|
|
8096
|
+
__init18() {this.spinner = _ora2.default.call(void 0, )}
|
|
8097
|
+
__init19() {this.defaultConfig = {
|
|
7999
8098
|
template: "react-ts",
|
|
8000
8099
|
viteVersion: "@latest"
|
|
8001
8100
|
}}
|
|
@@ -8017,29 +8116,19 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
8017
8116
|
const { output } = this.options;
|
|
8018
8117
|
const workspaceDir = this.fileCompiler.getWorkspaceDir();
|
|
8019
8118
|
await _fs2.default.promises.mkdir(workspaceDir, { recursive: true });
|
|
8020
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
8119
|
+
if (_optionalChain([output, 'optionalAccess', _303 => _303.bootstrapVite]) === false) {
|
|
8021
8120
|
return false;
|
|
8022
8121
|
}
|
|
8023
8122
|
if (this.isSingleFile()) {
|
|
8024
|
-
console.info("
|
|
8123
|
+
console.info(_kleur2.default.dim("Skip Vite init for single file"));
|
|
8124
|
+
console.info();
|
|
8025
8125
|
return;
|
|
8026
8126
|
}
|
|
8027
8127
|
const outputPkgPath = this.fileCompiler.getOutputPkgPath();
|
|
8028
8128
|
if (_fs2.default.existsSync(outputPkgPath)) {
|
|
8029
8129
|
return;
|
|
8030
8130
|
}
|
|
8031
|
-
|
|
8032
|
-
this.spinner.start("Bootstrapping Vite React environment...");
|
|
8033
|
-
await this.resolveViteCreateApp();
|
|
8034
|
-
} catch (err) {
|
|
8035
|
-
console.error(
|
|
8036
|
-
_kleur2.default.red("\u2716"),
|
|
8037
|
-
"Failed to bootstrap Vite environment. Please check npm/network.\n",
|
|
8038
|
-
err
|
|
8039
|
-
);
|
|
8040
|
-
this.spinner.stop();
|
|
8041
|
-
return;
|
|
8042
|
-
}
|
|
8131
|
+
await this.resolveViteCreateApp();
|
|
8043
8132
|
const removeVuePackages = (deps) => {
|
|
8044
8133
|
for (const name in deps) {
|
|
8045
8134
|
const isVueLike = VUE_PACKAGES.some((n) => name.includes(n));
|
|
@@ -8067,9 +8156,9 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
8067
8156
|
const newDevDeps = resolveDeps(sourcePkg.devDependencies, newPkg.devDependencies, true);
|
|
8068
8157
|
newPkg.dependencies = newDeps;
|
|
8069
8158
|
newPkg.devDependencies = newDevDeps;
|
|
8070
|
-
newPkg = _optionalChain([output, 'optionalAccess',
|
|
8159
|
+
newPkg = _optionalChain([output, 'optionalAccess', _304 => _304.packageJson, 'optionalCall', _305 => _305(newPkg)]) || newPkg;
|
|
8071
8160
|
await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
|
|
8072
|
-
this.spinner.succeed("
|
|
8161
|
+
this.spinner.succeed("Initialized Vite React environment");
|
|
8073
8162
|
return true;
|
|
8074
8163
|
}
|
|
8075
8164
|
/**
|
|
@@ -8078,12 +8167,12 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
8078
8167
|
async resolveViteCreateApp() {
|
|
8079
8168
|
const { output } = this.options;
|
|
8080
8169
|
const { viteVersion, template: tmpl } = this.defaultConfig;
|
|
8081
|
-
const bootstrapVite = _optionalChain([output, 'optionalAccess',
|
|
8170
|
+
const bootstrapVite = _optionalChain([output, 'optionalAccess', _306 => _306.bootstrapVite]);
|
|
8082
8171
|
const outDirName = this.fileCompiler.getOutDirName();
|
|
8083
8172
|
const configObject = typeof bootstrapVite === "object" ? bootstrapVite : null;
|
|
8084
|
-
const viteVer = _optionalChain([configObject, 'optionalAccess',
|
|
8085
|
-
const reactVer = _optionalChain([configObject, 'optionalAccess',
|
|
8086
|
-
const template = _optionalChain([configObject, 'optionalAccess',
|
|
8173
|
+
const viteVer = _optionalChain([configObject, 'optionalAccess', _307 => _307.vite]) || viteVersion;
|
|
8174
|
+
const reactVer = _optionalChain([configObject, 'optionalAccess', _308 => _308.react]);
|
|
8175
|
+
const template = _optionalChain([configObject, 'optionalAccess', _309 => _309.template]) || tmpl;
|
|
8087
8176
|
const cmd = `npm create vite${viteVer} ${outDirName} -- --template ${template}`;
|
|
8088
8177
|
_child_process.execSync.call(void 0, cmd, {
|
|
8089
8178
|
cwd: this.fileCompiler.getWorkspaceDir(),
|
|
@@ -8139,13 +8228,13 @@ var SetupManager = class {
|
|
|
8139
8228
|
fileCompiler.manager = {};
|
|
8140
8229
|
const manager = fileCompiler.manager;
|
|
8141
8230
|
manager.cacheManager = new CacheManager(fileCompiler);
|
|
8142
|
-
manager.cleanupManager = new CleanupManager(fileCompiler);
|
|
8143
8231
|
}
|
|
8144
8232
|
/**
|
|
8145
8233
|
* 创建依赖基础管理器的管理器
|
|
8146
8234
|
*/
|
|
8147
8235
|
setupManagedByBase(fileCompiler) {
|
|
8148
8236
|
const manager = fileCompiler.manager;
|
|
8237
|
+
manager.cleanupManager = new CleanupManager(fileCompiler, manager.cacheManager);
|
|
8149
8238
|
manager.fileProcessor = new FileProcessor(
|
|
8150
8239
|
fileCompiler,
|
|
8151
8240
|
new CompilationUnitProcessor(fileCompiler),
|
|
@@ -8158,47 +8247,78 @@ var SetupManager = class {
|
|
|
8158
8247
|
setupCompositeManager(fileCompiler) {
|
|
8159
8248
|
const manager = fileCompiler.manager;
|
|
8160
8249
|
manager.viteBootstrapper = new ViteBootstrapper(fileCompiler, fileCompiler.options);
|
|
8161
|
-
manager.pipelineManager = new PipelineManager(
|
|
8162
|
-
|
|
8250
|
+
manager.pipelineManager = new PipelineManager(
|
|
8251
|
+
fileCompiler,
|
|
8252
|
+
manager.fileProcessor,
|
|
8253
|
+
manager.cleanupManager
|
|
8254
|
+
);
|
|
8255
|
+
manager.assetManager = new AssetManager(
|
|
8256
|
+
fileCompiler,
|
|
8257
|
+
manager.cleanupManager,
|
|
8258
|
+
manager.cacheManager
|
|
8259
|
+
);
|
|
8163
8260
|
}
|
|
8164
8261
|
};
|
|
8165
8262
|
|
|
8166
8263
|
// src/compiler/shared/file-compiler/index.ts
|
|
8167
8264
|
var FileCompiler = (_class13 = class extends BaseCompiler {
|
|
8168
8265
|
|
|
8169
|
-
|
|
8266
|
+
__init20() {this.spinner = _ora2.default.call(void 0, )}
|
|
8170
8267
|
constructor(options = {}) {
|
|
8171
|
-
super(options);_class13.prototype.
|
|
8268
|
+
super(options);_class13.prototype.__init20.call(this);;
|
|
8172
8269
|
new SetupManager(() => this);
|
|
8173
8270
|
}
|
|
8271
|
+
printTitle() {
|
|
8272
|
+
const purple = "\x1B[38;2;153;50;204m";
|
|
8273
|
+
const reset = "\x1B[0m";
|
|
8274
|
+
console.info();
|
|
8275
|
+
console.info();
|
|
8276
|
+
console.info(`${purple}${_kleur2.default.bold("VUREACT")} v${this.version}${reset}`);
|
|
8277
|
+
console.info();
|
|
8278
|
+
}
|
|
8279
|
+
updateSpinner(text) {
|
|
8280
|
+
this.spinner.stop();
|
|
8281
|
+
this.spinner.start(text);
|
|
8282
|
+
}
|
|
8174
8283
|
/** 执行完整的编译流程 */
|
|
8175
8284
|
async execute() {
|
|
8176
|
-
|
|
8177
|
-
const startTime = performance.now();
|
|
8178
|
-
const rmWorkspace = async () => {
|
|
8179
|
-
await this.rmFile(this.getWorkspaceDir());
|
|
8180
|
-
};
|
|
8285
|
+
this.printTitle();
|
|
8181
8286
|
try {
|
|
8182
8287
|
if (!this.getIsCache()) {
|
|
8183
|
-
await
|
|
8288
|
+
await this.rmFile(this.getCachePath());
|
|
8184
8289
|
}
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8290
|
+
} catch (err) {
|
|
8291
|
+
console.warn(_kleur2.default.yellow("\u26A0"), "Failed to clear cache");
|
|
8292
|
+
console.info();
|
|
8293
|
+
}
|
|
8294
|
+
const { viteBootstrapper, fileProcessor, cacheManager, pipelineManager, assetManager } = this.manager;
|
|
8295
|
+
let startTime = 0;
|
|
8296
|
+
try {
|
|
8297
|
+
this.updateSpinner("Initializing Vite React env...");
|
|
8298
|
+
await viteBootstrapper.bootstrapIfNeeded();
|
|
8299
|
+
const cacheMap = await cacheManager.loadAllCache();
|
|
8300
|
+
startTime = performance.now();
|
|
8301
|
+
this.updateSpinner("Scanning files...");
|
|
8302
|
+
const scanFiles = fileProcessor.scanFiles();
|
|
8303
|
+
this.updateSpinner("Compiling Vue to React...");
|
|
8304
|
+
const sfcCount = await pipelineManager.runSFC(scanFiles.vue, cacheMap);
|
|
8305
|
+
const scriptCount = await pipelineManager.runScript(scanFiles.script, cacheMap);
|
|
8306
|
+
const styleCount = await pipelineManager.runStyle(scanFiles.style, cacheMap);
|
|
8307
|
+
this.updateSpinner("Copying assets...");
|
|
8308
|
+
const assetCount = await assetManager.runAsset(scanFiles.assets, cacheMap);
|
|
8309
|
+
this.updateSpinner("Almost done...");
|
|
8310
|
+
await cacheManager.flushAllCache();
|
|
8311
|
+
await _optionalChain([this, 'access', _310 => _310.options, 'access', _311 => _311.onSuccess, 'optionalCall', _312 => _312()]);
|
|
8191
8312
|
const endTime = calcElapsedTime(startTime);
|
|
8192
8313
|
this.printCoreLogs();
|
|
8193
8314
|
this.showCompileStats(endTime, sfcCount, scriptCount, styleCount, assetCount);
|
|
8194
8315
|
} catch (error) {
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
console.error(_kleur2.default.red("\u2716"), `Build failed in ${endTime}`);
|
|
8316
|
+
this.spinner.stop();
|
|
8317
|
+
console.error(_kleur2.default.red("\u2716"), `Build failed in ${calcElapsedTime(startTime)}`);
|
|
8198
8318
|
console.error(error);
|
|
8319
|
+
await this.rmFile(this.getWorkspaceDir());
|
|
8199
8320
|
process.exit(-1);
|
|
8200
8321
|
} finally {
|
|
8201
|
-
this.spinner.stop();
|
|
8202
8322
|
this.resetSkippedCount();
|
|
8203
8323
|
}
|
|
8204
8324
|
}
|
|
@@ -8235,62 +8355,40 @@ var FileCompiler = (_class13 = class extends BaseCompiler {
|
|
|
8235
8355
|
async processAsset(filePath, existingCache) {
|
|
8236
8356
|
return this.manager.assetManager.processAsset(filePath, existingCache);
|
|
8237
8357
|
}
|
|
8238
|
-
/** 批量保存缓存 */
|
|
8239
|
-
async flushCache(key) {
|
|
8240
|
-
await this.manager.cacheManager.flushCache(key);
|
|
8241
|
-
}
|
|
8242
8358
|
/** 删除指定路径对应的输出文件和缓存 */
|
|
8243
8359
|
async removeOutputPath(targetPath, type) {
|
|
8244
8360
|
return await this.manager.cleanupManager.removeOutputPath(targetPath, type);
|
|
8245
8361
|
}
|
|
8246
|
-
async runPipelineWithSpinner(name) {
|
|
8247
|
-
const options = {
|
|
8248
|
-
["sfc" /* SFC */]: {
|
|
8249
|
-
text: "Compiling Vue files...",
|
|
8250
|
-
pipeline: () => this.manager.pipelineManager.runSfcPipeline()
|
|
8251
|
-
},
|
|
8252
|
-
["script" /* SCRIPT */]: {
|
|
8253
|
-
text: "Compiling script files...",
|
|
8254
|
-
pipeline: () => this.manager.pipelineManager.runScriptPipeline()
|
|
8255
|
-
},
|
|
8256
|
-
["style" /* STYLE */]: {
|
|
8257
|
-
text: "Compiling style files...",
|
|
8258
|
-
pipeline: () => this.manager.pipelineManager.runStylePipeline()
|
|
8259
|
-
},
|
|
8260
|
-
["copied" /* ASSET */]: {
|
|
8261
|
-
text: "Copying assets...",
|
|
8262
|
-
pipeline: () => this.manager.assetManager.runAssetPipeline()
|
|
8263
|
-
}
|
|
8264
|
-
};
|
|
8265
|
-
const { text, pipeline } = options[name];
|
|
8266
|
-
try {
|
|
8267
|
-
this.spinner.start(text);
|
|
8268
|
-
return await pipeline();
|
|
8269
|
-
} catch (err) {
|
|
8270
|
-
throw err;
|
|
8271
|
-
} finally {
|
|
8272
|
-
this.spinner.stop();
|
|
8273
|
-
}
|
|
8274
|
-
}
|
|
8275
8362
|
showCompileStats(endTime, sfcCount, scriptCount, styleCount, assetCount) {
|
|
8276
8363
|
this.spinner.succeed(`Build completed in ${endTime}`);
|
|
8277
|
-
console.info();
|
|
8278
8364
|
if (sfcCount || scriptCount || styleCount || assetCount) {
|
|
8279
8365
|
const stats = [];
|
|
8280
|
-
if (sfcCount) stats.push(`${sfcCount} SFC(s)`);
|
|
8281
|
-
if (scriptCount) stats.push(`${scriptCount} script(s)`);
|
|
8282
|
-
if (styleCount) stats.push(`${styleCount} style(s)`);
|
|
8283
|
-
if (assetCount) stats.push(`${assetCount} asset(s)`);
|
|
8284
|
-
this.spinner.succeed(
|
|
8366
|
+
if (sfcCount) stats.push(`${sfcCount} ${_kleur2.default.dim("SFC(s)")}`);
|
|
8367
|
+
if (scriptCount) stats.push(`${scriptCount} ${_kleur2.default.dim("script(s)")}`);
|
|
8368
|
+
if (styleCount) stats.push(`${styleCount} ${_kleur2.default.dim("style(s)")}`);
|
|
8369
|
+
if (assetCount) stats.push(`${assetCount} ${_kleur2.default.dim("asset(s)")}`);
|
|
8370
|
+
this.spinner.succeed(`${_kleur2.default.bold("Processed")}: ${stats.join(", ")}`);
|
|
8285
8371
|
}
|
|
8286
8372
|
const skippedCount = this.manager.pipelineManager.getSkippedCount() + this.manager.assetManager.getSkippedCount();
|
|
8287
8373
|
if (skippedCount) {
|
|
8288
|
-
console.info(
|
|
8374
|
+
console.info();
|
|
8375
|
+
console.info(
|
|
8376
|
+
_kleur2.default.gray(`\u21B7 ${_kleur2.default.bold("Cached")}: ${_kleur2.default.white(skippedCount)} unchanged file(s)`)
|
|
8377
|
+
);
|
|
8289
8378
|
this.resetSkippedCount();
|
|
8290
8379
|
}
|
|
8291
8380
|
const dir = normalizePath(this.relativePath(this.getOuputPath()));
|
|
8292
8381
|
console.info();
|
|
8293
|
-
console.info(`\u{1F4E6} Output: ${dir}`);
|
|
8382
|
+
console.info(`\u{1F4E6} ${_kleur2.default.bold("Output")}: ${_kleur2.default.cyan(dir)}`);
|
|
8383
|
+
console.info();
|
|
8384
|
+
console.info(` > cd ${dir}`);
|
|
8385
|
+
console.info(` > npm install`);
|
|
8386
|
+
console.info(` > npm run dev`);
|
|
8387
|
+
console.info();
|
|
8388
|
+
console.info(
|
|
8389
|
+
_kleur2.default.dim("\u2B50 If you like VuReact, give us a star on GitHub:"),
|
|
8390
|
+
_kleur2.default.gray(_kleur2.default.underline("https://github.com/vureact-js/core"))
|
|
8391
|
+
);
|
|
8294
8392
|
console.info();
|
|
8295
8393
|
}
|
|
8296
8394
|
resetSkippedCount() {
|
|
@@ -8327,4 +8425,4 @@ var VuReact = class extends FileCompiler {
|
|
|
8327
8425
|
|
|
8328
8426
|
|
|
8329
8427
|
|
|
8330
|
-
exports.getDirname = getDirname; exports.normalizePath = normalizePath; exports.calcElapsedTime = calcElapsedTime; exports.generateComponent = generateComponent; exports.generateOnlyScript = generateOnlyScript; exports.generate = generate; exports.parseOnlyScript = parseOnlyScript; exports.parseSFC = parseSFC; exports.parse = parse; exports.transform = transform; exports.version = version; exports.bin = bin; exports.
|
|
8428
|
+
exports.getDirname = getDirname; exports.normalizePath = normalizePath; exports.calcElapsedTime = calcElapsedTime; exports.generateComponent = generateComponent; exports.generateOnlyScript = generateOnlyScript; exports.generate = generate; exports.parseOnlyScript = parseOnlyScript; exports.parseSFC = parseSFC; exports.parse = parse; exports.transform = transform; exports.version = version; exports.bin = bin; exports.Helper = Helper; exports.BaseCompiler = BaseCompiler; exports.CacheKey = CacheKey; exports.FileCompiler = FileCompiler; exports.defineConfig = defineConfig; exports.VuReact = VuReact;
|