@plumeria/utils 19.2.6 → 19.2.8
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/dist/parser.js +54 -13
- package/package.json +1 -1
package/dist/parser.js
CHANGED
|
@@ -1133,7 +1133,46 @@ function stripFileContributions(filePath, cached) {
|
|
|
1133
1133
|
}
|
|
1134
1134
|
}
|
|
1135
1135
|
}
|
|
1136
|
+
const propEntryKeys = new WeakMap();
|
|
1137
|
+
const propEntryKey = (entry) => JSON.stringify([
|
|
1138
|
+
entry.filePath,
|
|
1139
|
+
entry.spanStart,
|
|
1140
|
+
entry.key,
|
|
1141
|
+
entry.conditions,
|
|
1142
|
+
]);
|
|
1143
|
+
const statMemo = new Map();
|
|
1144
|
+
let scanning = false;
|
|
1145
|
+
function statFile(filePath) {
|
|
1146
|
+
if (!scanning)
|
|
1147
|
+
return fs.statSync(filePath);
|
|
1148
|
+
const memo = statMemo.get(filePath);
|
|
1149
|
+
if (memo) {
|
|
1150
|
+
if (memo instanceof Error)
|
|
1151
|
+
throw memo;
|
|
1152
|
+
return memo;
|
|
1153
|
+
}
|
|
1154
|
+
try {
|
|
1155
|
+
const stats = fs.statSync(filePath);
|
|
1156
|
+
statMemo.set(filePath, stats);
|
|
1157
|
+
return stats;
|
|
1158
|
+
}
|
|
1159
|
+
catch (e) {
|
|
1160
|
+
statMemo.set(filePath, e);
|
|
1161
|
+
throw e;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1136
1164
|
function scanAll(scanCwd = process.cwd()) {
|
|
1165
|
+
scanning = true;
|
|
1166
|
+
statMemo.clear();
|
|
1167
|
+
try {
|
|
1168
|
+
return runScan(scanCwd);
|
|
1169
|
+
}
|
|
1170
|
+
finally {
|
|
1171
|
+
scanning = false;
|
|
1172
|
+
statMemo.clear();
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
function runScan(scanCwd = process.cwd()) {
|
|
1137
1176
|
const cwd = path.resolve(scanCwd);
|
|
1138
1177
|
if (hasComputedOnce &&
|
|
1139
1178
|
process.env.NODE_ENV === 'production' &&
|
|
@@ -1635,10 +1674,8 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
1635
1674
|
}
|
|
1636
1675
|
}
|
|
1637
1676
|
}
|
|
1638
|
-
if (isFirstPass)
|
|
1639
|
-
extractAndCacheExports(filePath, ast, mtimeMs);
|
|
1677
|
+
if (isFirstPass)
|
|
1640
1678
|
continue;
|
|
1641
|
-
}
|
|
1642
1679
|
jsxPhaseQueue.push({
|
|
1643
1680
|
filePath,
|
|
1644
1681
|
ast,
|
|
@@ -2067,15 +2104,18 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
2067
2104
|
globalTable[compKey][propName] = [];
|
|
2068
2105
|
}
|
|
2069
2106
|
const entries = localComponentPropsTable[compKey][propName];
|
|
2107
|
+
const collected = globalTable[compKey][propName];
|
|
2108
|
+
let taken = propEntryKeys.get(collected);
|
|
2109
|
+
if (!taken) {
|
|
2110
|
+
taken = new Set(collected.map(propEntryKey));
|
|
2111
|
+
propEntryKeys.set(collected, taken);
|
|
2112
|
+
}
|
|
2070
2113
|
for (const entry of entries) {
|
|
2071
|
-
const
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
if (!exists) {
|
|
2077
|
-
globalTable[compKey][propName].push(entry);
|
|
2078
|
-
}
|
|
2114
|
+
const key = propEntryKey(entry);
|
|
2115
|
+
if (taken.has(key))
|
|
2116
|
+
continue;
|
|
2117
|
+
taken.add(key);
|
|
2118
|
+
collected.push(entry);
|
|
2079
2119
|
}
|
|
2080
2120
|
}
|
|
2081
2121
|
}
|
|
@@ -2123,7 +2163,8 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
2123
2163
|
}
|
|
2124
2164
|
for (const props of Object.values(localTables.componentPropsTable ?? {})) {
|
|
2125
2165
|
for (const entries of Object.values(props))
|
|
2126
|
-
entries.sort((a, b) => a.filePath
|
|
2166
|
+
entries.sort((a, b) => (a.filePath < b.filePath ? -1 : a.filePath > b.filePath ? 1 : 0) ||
|
|
2167
|
+
a.spanStart - b.spanStart);
|
|
2127
2168
|
}
|
|
2128
2169
|
hasComputedOnce = true;
|
|
2129
2170
|
return snapshotTables();
|
|
@@ -2306,7 +2347,7 @@ function resolveExport(filePath, exportName, visited = new Set()) {
|
|
|
2306
2347
|
visited.add(key);
|
|
2307
2348
|
{
|
|
2308
2349
|
try {
|
|
2309
|
-
const stats =
|
|
2350
|
+
const stats = statFile(filePath);
|
|
2310
2351
|
if ((!fileCache[filePath]?.exports ||
|
|
2311
2352
|
fileCache[filePath].exportsMtimeMs !== stats.mtimeMs) &&
|
|
2312
2353
|
stats.isFile()) {
|