@plumeria/utils 19.2.8 → 19.2.9

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.
Files changed (2) hide show
  1. package/dist/parser.js +27 -0
  2. package/package.json +1 -1
package/dist/parser.js CHANGED
@@ -1217,6 +1217,7 @@ function runScan(scanCwd = process.cwd()) {
1217
1217
  if (!currentFiles.has(fp))
1218
1218
  deletedFiles.push(fp);
1219
1219
  }
1220
+ const appeared = files.some((fp) => !knownFiles.has(fp));
1220
1221
  knownFiles = currentFiles;
1221
1222
  const invalidated = new Set();
1222
1223
  const queue = [];
@@ -1258,6 +1259,19 @@ function runScan(scanCwd = process.cwd()) {
1258
1259
  invalidated.add(fp);
1259
1260
  queue.push(fp);
1260
1261
  }
1262
+ if (appeared) {
1263
+ for (const [filePath, cached] of Object.entries(fileCache)) {
1264
+ if (invalidated.has(filePath) ||
1265
+ !currentFiles.has(filePath) ||
1266
+ !cached.unresolvedImports?.length)
1267
+ continue;
1268
+ const resolves = cached.unresolvedImports.some((specifier) => (0, resolver_1.resolveImportPath)(specifier, filePath));
1269
+ if (resolves) {
1270
+ invalidated.add(filePath);
1271
+ queue.push(filePath);
1272
+ }
1273
+ }
1274
+ }
1261
1275
  for (let head = 0; head < queue.length; head++) {
1262
1276
  const fp = queue[head];
1263
1277
  const deps = dependentsMap.get(fp);
@@ -2125,6 +2139,7 @@ function runScan(scanCwd = process.cwd()) {
2125
2139
  dependencies: Array.from(localDependencies),
2126
2140
  exports: fileCache[filePath]?.exports,
2127
2141
  exportsMtimeMs: fileCache[filePath]?.exportsMtimeMs,
2142
+ unresolvedImports: fileCache[filePath]?.unresolvedImports,
2128
2143
  staticTable: localStaticTable,
2129
2144
  keyframesHashTable: localKeyframesHashTable,
2130
2145
  keyframesObjectTable: localKeyframesObjectTable,
@@ -2192,6 +2207,7 @@ function extractAndCacheExports(filePath, ast, mtimeMs) {
2192
2207
  const reExports = {};
2193
2208
  const starExports = [];
2194
2209
  const localDependencies = new Set();
2210
+ const unresolvedImports = [];
2195
2211
  const imports = {};
2196
2212
  for (const node of ast.body) {
2197
2213
  if (node.type === 'ImportDeclaration') {
@@ -2216,6 +2232,9 @@ function extractAndCacheExports(filePath, ast, mtimeMs) {
2216
2232
  if (actualPath) {
2217
2233
  localDependencies.add(actualPath);
2218
2234
  }
2235
+ else if (node.source.value !== '@plumeria/core') {
2236
+ unresolvedImports.push(node.source.value);
2237
+ }
2219
2238
  }
2220
2239
  else if (node.type === 'ExportDeclaration') {
2221
2240
  const decl = node.declaration;
@@ -2244,6 +2263,9 @@ function extractAndCacheExports(filePath, ast, mtimeMs) {
2244
2263
  if (actualPath) {
2245
2264
  localDependencies.add(actualPath);
2246
2265
  }
2266
+ else if (source !== '@plumeria/core') {
2267
+ unresolvedImports.push(source);
2268
+ }
2247
2269
  }
2248
2270
  node.specifiers.forEach((spec) => {
2249
2271
  if (spec.type === 'ExportSpecifier') {
@@ -2274,6 +2296,9 @@ function extractAndCacheExports(filePath, ast, mtimeMs) {
2274
2296
  if (actualPath) {
2275
2297
  localDependencies.add(actualPath);
2276
2298
  }
2299
+ else if (node.source.value !== '@plumeria/core') {
2300
+ unresolvedImports.push(node.source.value);
2301
+ }
2277
2302
  }
2278
2303
  }
2279
2304
  else if (node.type === 'ExportDefaultExpression') {
@@ -2313,6 +2338,7 @@ function extractAndCacheExports(filePath, ast, mtimeMs) {
2313
2338
  mtimeMs: mtimeMs,
2314
2339
  exports: { localExports, reExports, starExports, imports },
2315
2340
  dependencies: newDeps,
2341
+ unresolvedImports,
2316
2342
  staticTable: {},
2317
2343
  keyframesHashTable: {},
2318
2344
  keyframesObjectTable: {},
@@ -2337,6 +2363,7 @@ function extractAndCacheExports(filePath, ast, mtimeMs) {
2337
2363
  imports,
2338
2364
  };
2339
2365
  fileCache[filePath].dependencies = newDeps;
2366
+ fileCache[filePath].unresolvedImports = unresolvedImports;
2340
2367
  }
2341
2368
  fileCache[filePath].exportsMtimeMs = mtimeMs;
2342
2369
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/utils",
3
- "version": "19.2.8",
3
+ "version": "19.2.9",
4
4
  "description": "Plumeria Utils",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",