@modern-js/app-tools 2.58.1-alpha.0 → 2.58.1-alpha.2

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.
@@ -41,11 +41,13 @@ var import_nft = require("@vercel/nft");
41
41
  const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = import_utils2.traceFiles, entryFilter, modifyPackageJson, copyWholePackage, cacheOptions = {
42
42
  cacheDir: ".modern-js/deploy",
43
43
  fileCache: true,
44
- analysisCache: true
44
+ analysisCache: true,
45
+ symlinkCache: true
45
46
  }, traceOptions }) => {
46
47
  const base = "/";
47
48
  const startTime = Date.now();
48
49
  const entryFiles = await (0, import_utils2.findEntryFiles)(serverRootDir, entryFilter);
50
+ console.time("traceFiles");
49
51
  const fileTrace = await traceFiles({
50
52
  entryFiles: entryFiles.concat(includeEntries),
51
53
  serverRootDir,
@@ -56,6 +58,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
56
58
  base,
57
59
  traceOptions
58
60
  });
61
+ console.timeEnd("traceFiles");
59
62
  const currentProjectModules = import_node_path.default.join(appDir, "node_modules");
60
63
  const dependencySearchRoot = import_node_path.default.resolve(appDir, "../../../../../../");
61
64
  const tracedFiles = Object.fromEntries(await Promise.all([
@@ -238,7 +241,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
238
241
  const finalPkgJson = (modifyPackageJson === null || modifyPackageJson === void 0 ? void 0 : modifyPackageJson(newPkgJson)) || newPkgJson;
239
242
  await import_utils.fs.writeJSON(outputPkgPath, finalPkgJson);
240
243
  const endTime = Date.now();
241
- console.log("handleDependencies cost:", endTime - startTime);
244
+ console.log("handleDependencies cost:", `${endTime - startTime}ms`);
242
245
  };
243
246
  // Annotate the CommonJS export names for ESM import in node:
244
247
  0 && (module.exports = {
@@ -145,6 +145,9 @@ async function serializeMap(map) {
145
145
  resolvedMap.set(key, value instanceof Promise ? await Promise.resolve(value) : value);
146
146
  }));
147
147
  return JSON.stringify(resolvedMap, (key, value) => {
148
+ if (value === null) {
149
+ return void 0;
150
+ }
148
151
  if (value instanceof Map) {
149
152
  return {
150
153
  dataType: "Map",
@@ -172,9 +175,10 @@ function deserializeMap(serializedData) {
172
175
  });
173
176
  }
174
177
  const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions, traceOptions }) => {
175
- const { cacheDir, fileCache: enableFileCache, analysisCache: enableAnalysisCache } = cacheOptions;
178
+ const { cacheDir, fileCache: enableFileCache, analysisCache: enableAnalysisCache, symlinkCache: enableSymlinkCache } = cacheOptions;
176
179
  const analysisCacheFile = import_path.default.join(cacheDir, "analysis-cache.json");
177
180
  const fileCacheFile = import_path.default.join(cacheDir, "file-cache.json");
181
+ const symlinkCacheFile = import_path.default.join(cacheDir, "symlink-cache.json");
178
182
  const cache = /* @__PURE__ */ Object.create(null);
179
183
  if (enableAnalysisCache && await import_utils.fs.pathExists(analysisCacheFile)) {
180
184
  const analysisCache2 = (await import_utils.fs.readFile(analysisCacheFile)).toString();
@@ -184,14 +188,18 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
184
188
  const fileCache2 = (await import_utils.fs.readFile(fileCacheFile)).toString();
185
189
  cache.fileCache = deserializeMap(fileCache2);
186
190
  }
191
+ if (enableSymlinkCache && await import_utils.fs.pathExists(symlinkCacheFile)) {
192
+ const symlinkCache2 = (await import_utils.fs.readFile(symlinkCacheFile)).toString();
193
+ cache.symlinkCache = deserializeMap(symlinkCache2);
194
+ }
187
195
  const res = await (0, import_nft.nodeFileTrace)(entryFiles, {
188
196
  base,
189
197
  processCwd: serverRootDir,
190
198
  cache,
191
199
  ...traceOptions
192
200
  });
193
- const { analysisCache, fileCache } = cache;
194
- if (analysisCache || fileCache) {
201
+ const { analysisCache, fileCache, symlinkCache } = cache;
202
+ if (analysisCache || fileCache || symlinkCache) {
195
203
  await import_utils.fs.ensureDir(cacheDir);
196
204
  if (analysisCache) {
197
205
  const newAnalysisCache = new Map(analysisCache);
@@ -200,7 +208,10 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
200
208
  newAnalysisCache.delete(key);
201
209
  }
202
210
  }
203
- import_utils.fs.writeFile(analysisCacheFile, await serializeMap(newAnalysisCache));
211
+ (async () => {
212
+ await import_utils.fs.writeFile(analysisCacheFile, await serializeMap(newAnalysisCache));
213
+ console.log("write analysis cache finish");
214
+ })();
204
215
  }
205
216
  if (fileCache) {
206
217
  const newFileCache = new Map(fileCache);
@@ -209,9 +220,22 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
209
220
  newFileCache.delete(key);
210
221
  }
211
222
  }
212
- console.time("111");
213
- import_utils.fs.writeFile(fileCacheFile, await serializeMap(newFileCache));
214
- console.timeEnd("111");
223
+ (async () => {
224
+ await import_utils.fs.writeFile(fileCacheFile, await serializeMap(newFileCache));
225
+ console.log("write file cache finish");
226
+ })();
227
+ }
228
+ if (symlinkCache) {
229
+ const newSymlinkCache = new Map(symlinkCache);
230
+ for (const key of newSymlinkCache.keys()) {
231
+ if (!key.includes("node_modules/")) {
232
+ newSymlinkCache.delete(key);
233
+ }
234
+ }
235
+ (async () => {
236
+ await import_utils.fs.writeFile(symlinkCacheFile, await serializeMap(newSymlinkCache));
237
+ console.log("write symlink cache finish");
238
+ })();
215
239
  }
216
240
  }
217
241
  console.log("ffffffff", __filename);
@@ -20,7 +20,8 @@ var handleDependencies = function() {
20
20
  appDir = param.appDir, serverRootDir = param.serverRootDir, includeEntries = param.includeEntries, _param_traceFiles = param.traceFiles, traceFiles = _param_traceFiles === void 0 ? defaultTraceFiles : _param_traceFiles, entryFilter = param.entryFilter, modifyPackageJson = param.modifyPackageJson, copyWholePackage = param.copyWholePackage, _param_cacheOptions = param.cacheOptions, cacheOptions = _param_cacheOptions === void 0 ? {
21
21
  cacheDir: ".modern-js/deploy",
22
22
  fileCache: true,
23
- analysisCache: true
23
+ analysisCache: true,
24
+ symlinkCache: true
24
25
  } : _param_cacheOptions, traceOptions = param.traceOptions;
25
26
  base = "/";
26
27
  startTime = Date.now();
@@ -30,6 +31,7 @@ var handleDependencies = function() {
30
31
  ];
31
32
  case 1:
32
33
  entryFiles = _state.sent();
34
+ console.time("traceFiles");
33
35
  return [
34
36
  4,
35
37
  traceFiles({
@@ -44,6 +46,7 @@ var handleDependencies = function() {
44
46
  ];
45
47
  case 2:
46
48
  fileTrace = _state.sent();
49
+ console.timeEnd("traceFiles");
47
50
  currentProjectModules = path.join(appDir, "node_modules");
48
51
  dependencySearchRoot = path.resolve(appDir, "../../../../../../");
49
52
  _ = Object.fromEntries;
@@ -609,7 +612,7 @@ var handleDependencies = function() {
609
612
  case 24:
610
613
  _state.sent();
611
614
  endTime = Date.now();
612
- console.log("handleDependencies cost:", endTime - startTime);
615
+ console.log("handleDependencies cost:", "".concat(endTime - startTime, "ms"));
613
616
  return [
614
617
  2
615
618
  ];
@@ -415,6 +415,9 @@ function _serializeMap() {
415
415
  return [
416
416
  2,
417
417
  JSON.stringify(resolvedMap, function(key, value) {
418
+ if (value === null) {
419
+ return void 0;
420
+ }
418
421
  if (_instanceof(value, Map)) {
419
422
  return {
420
423
  dataType: "Map",
@@ -448,14 +451,15 @@ function deserializeMap(serializedData) {
448
451
  }
449
452
  var traceFiles = function() {
450
453
  var _ref = _async_to_generator(function(param) {
451
- var entryFiles, serverRootDir, _param_base, base, cacheOptions, traceOptions, cacheDir, enableFileCache, enableAnalysisCache, analysisCacheFile, fileCacheFile, cache, _tmp, analysisCache, _tmp1, fileCache, res, analysisCache1, fileCache1, newAnalysisCache, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, key, _, _tmp2, newFileCache, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, key1, _1, _tmp3;
454
+ var entryFiles, serverRootDir, _param_base, base, cacheOptions, traceOptions, cacheDir, enableFileCache, enableAnalysisCache, enableSymlinkCache, analysisCacheFile, fileCacheFile, symlinkCacheFile, cache, _tmp, analysisCache, _tmp1, fileCache, _tmp2, symlinkCache, res, analysisCache1, fileCache1, symlinkCache1, newAnalysisCache, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, key, newFileCache, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, key1, newSymlinkCache, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, key2;
452
455
  return _ts_generator(this, function(_state) {
453
456
  switch (_state.label) {
454
457
  case 0:
455
458
  entryFiles = param.entryFiles, serverRootDir = param.serverRootDir, _param_base = param.base, base = _param_base === void 0 ? "/" : _param_base, cacheOptions = param.cacheOptions, traceOptions = param.traceOptions;
456
- cacheDir = cacheOptions.cacheDir, enableFileCache = cacheOptions.fileCache, enableAnalysisCache = cacheOptions.analysisCache;
459
+ cacheDir = cacheOptions.cacheDir, enableFileCache = cacheOptions.fileCache, enableAnalysisCache = cacheOptions.analysisCache, enableSymlinkCache = cacheOptions.symlinkCache;
457
460
  analysisCacheFile = path.join(cacheDir, "analysis-cache.json");
458
461
  fileCacheFile = path.join(cacheDir, "file-cache.json");
462
+ symlinkCacheFile = path.join(cacheDir, "symlink-cache.json");
459
463
  cache = /* @__PURE__ */ Object.create(null);
460
464
  _tmp = enableAnalysisCache;
461
465
  if (!_tmp)
@@ -513,6 +517,34 @@ var traceFiles = function() {
513
517
  cache.fileCache = deserializeMap(fileCache);
514
518
  _state.label = 8;
515
519
  case 8:
520
+ _tmp2 = enableSymlinkCache;
521
+ if (!_tmp2)
522
+ return [
523
+ 3,
524
+ 10
525
+ ];
526
+ return [
527
+ 4,
528
+ fse.pathExists(symlinkCacheFile)
529
+ ];
530
+ case 9:
531
+ _tmp2 = _state.sent();
532
+ _state.label = 10;
533
+ case 10:
534
+ if (!_tmp2)
535
+ return [
536
+ 3,
537
+ 12
538
+ ];
539
+ return [
540
+ 4,
541
+ fse.readFile(symlinkCacheFile)
542
+ ];
543
+ case 11:
544
+ symlinkCache = _state.sent().toString();
545
+ cache.symlinkCache = deserializeMap(symlinkCache);
546
+ _state.label = 12;
547
+ case 12:
516
548
  return [
517
549
  4,
518
550
  nodeFileTrace(entryFiles, _object_spread({
@@ -521,106 +553,184 @@ var traceFiles = function() {
521
553
  cache
522
554
  }, traceOptions))
523
555
  ];
524
- case 9:
556
+ case 13:
525
557
  res = _state.sent();
526
- analysisCache1 = cache.analysisCache, fileCache1 = cache.fileCache;
527
- if (!(analysisCache1 || fileCache1))
558
+ analysisCache1 = cache.analysisCache, fileCache1 = cache.fileCache, symlinkCache1 = cache.symlinkCache;
559
+ if (!(analysisCache1 || fileCache1 || symlinkCache1))
528
560
  return [
529
561
  3,
530
- 14
562
+ 15
531
563
  ];
532
564
  return [
533
565
  4,
534
566
  fse.ensureDir(cacheDir)
535
567
  ];
536
- case 10:
568
+ case 14:
537
569
  _state.sent();
538
- if (!analysisCache1)
539
- return [
540
- 3,
541
- 12
542
- ];
543
- newAnalysisCache = new Map(analysisCache1);
544
- _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
545
- try {
546
- for (_iterator = newAnalysisCache.keys()[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
547
- key = _step.value;
548
- if (!key.includes("node_modules/")) {
549
- newAnalysisCache.delete(key);
550
- }
551
- }
552
- } catch (err) {
553
- _didIteratorError = true;
554
- _iteratorError = err;
555
- } finally {
570
+ if (analysisCache1) {
571
+ newAnalysisCache = new Map(analysisCache1);
572
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
556
573
  try {
557
- if (!_iteratorNormalCompletion && _iterator.return != null) {
558
- _iterator.return();
574
+ for (_iterator = newAnalysisCache.keys()[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
575
+ key = _step.value;
576
+ if (!key.includes("node_modules/")) {
577
+ newAnalysisCache.delete(key);
578
+ }
559
579
  }
580
+ } catch (err) {
581
+ _didIteratorError = true;
582
+ _iteratorError = err;
560
583
  } finally {
561
- if (_didIteratorError) {
562
- throw _iteratorError;
584
+ try {
585
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
586
+ _iterator.return();
587
+ }
588
+ } finally {
589
+ if (_didIteratorError) {
590
+ throw _iteratorError;
591
+ }
563
592
  }
564
593
  }
594
+ _async_to_generator(function() {
595
+ var _, _tmp3;
596
+ return _ts_generator(this, function(_state2) {
597
+ switch (_state2.label) {
598
+ case 0:
599
+ _ = fse.writeFile;
600
+ _tmp3 = [
601
+ analysisCacheFile
602
+ ];
603
+ return [
604
+ 4,
605
+ serializeMap(newAnalysisCache)
606
+ ];
607
+ case 1:
608
+ return [
609
+ 4,
610
+ _.apply(fse, _tmp3.concat([
611
+ _state2.sent()
612
+ ]))
613
+ ];
614
+ case 2:
615
+ _state2.sent();
616
+ console.log("write analysis cache finish");
617
+ return [
618
+ 2
619
+ ];
620
+ }
621
+ });
622
+ })();
565
623
  }
566
- _ = fse.writeFile;
567
- _tmp2 = [
568
- analysisCacheFile
569
- ];
570
- return [
571
- 4,
572
- serializeMap(newAnalysisCache)
573
- ];
574
- case 11:
575
- _.apply(fse, _tmp2.concat([
576
- _state.sent()
577
- ]));
578
- _state.label = 12;
579
- case 12:
580
- if (!fileCache1)
581
- return [
582
- 3,
583
- 14
584
- ];
585
- newFileCache = new Map(fileCache1);
586
- _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
587
- try {
588
- for (_iterator1 = newFileCache.keys()[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
589
- key1 = _step1.value;
590
- if (!key1.includes("node_modules/")) {
591
- newFileCache.delete(key1);
624
+ if (fileCache1) {
625
+ newFileCache = new Map(fileCache1);
626
+ _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
627
+ try {
628
+ for (_iterator1 = newFileCache.keys()[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
629
+ key1 = _step1.value;
630
+ if (!key1.includes("node_modules/")) {
631
+ newFileCache.delete(key1);
632
+ }
633
+ }
634
+ } catch (err) {
635
+ _didIteratorError1 = true;
636
+ _iteratorError1 = err;
637
+ } finally {
638
+ try {
639
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
640
+ _iterator1.return();
641
+ }
642
+ } finally {
643
+ if (_didIteratorError1) {
644
+ throw _iteratorError1;
645
+ }
592
646
  }
593
647
  }
594
- } catch (err) {
595
- _didIteratorError1 = true;
596
- _iteratorError1 = err;
597
- } finally {
648
+ _async_to_generator(function() {
649
+ var _, _tmp3;
650
+ return _ts_generator(this, function(_state2) {
651
+ switch (_state2.label) {
652
+ case 0:
653
+ _ = fse.writeFile;
654
+ _tmp3 = [
655
+ fileCacheFile
656
+ ];
657
+ return [
658
+ 4,
659
+ serializeMap(newFileCache)
660
+ ];
661
+ case 1:
662
+ return [
663
+ 4,
664
+ _.apply(fse, _tmp3.concat([
665
+ _state2.sent()
666
+ ]))
667
+ ];
668
+ case 2:
669
+ _state2.sent();
670
+ console.log("write file cache finish");
671
+ return [
672
+ 2
673
+ ];
674
+ }
675
+ });
676
+ })();
677
+ }
678
+ if (symlinkCache1) {
679
+ newSymlinkCache = new Map(symlinkCache1);
680
+ _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
598
681
  try {
599
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
600
- _iterator1.return();
682
+ for (_iterator2 = newSymlinkCache.keys()[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
683
+ key2 = _step2.value;
684
+ if (!key2.includes("node_modules/")) {
685
+ newSymlinkCache.delete(key2);
686
+ }
601
687
  }
688
+ } catch (err) {
689
+ _didIteratorError2 = true;
690
+ _iteratorError2 = err;
602
691
  } finally {
603
- if (_didIteratorError1) {
604
- throw _iteratorError1;
692
+ try {
693
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
694
+ _iterator2.return();
695
+ }
696
+ } finally {
697
+ if (_didIteratorError2) {
698
+ throw _iteratorError2;
699
+ }
605
700
  }
606
701
  }
702
+ _async_to_generator(function() {
703
+ var _, _tmp3;
704
+ return _ts_generator(this, function(_state2) {
705
+ switch (_state2.label) {
706
+ case 0:
707
+ _ = fse.writeFile;
708
+ _tmp3 = [
709
+ symlinkCacheFile
710
+ ];
711
+ return [
712
+ 4,
713
+ serializeMap(newSymlinkCache)
714
+ ];
715
+ case 1:
716
+ return [
717
+ 4,
718
+ _.apply(fse, _tmp3.concat([
719
+ _state2.sent()
720
+ ]))
721
+ ];
722
+ case 2:
723
+ _state2.sent();
724
+ console.log("write symlink cache finish");
725
+ return [
726
+ 2
727
+ ];
728
+ }
729
+ });
730
+ })();
607
731
  }
608
- console.time("111");
609
- _1 = fse.writeFile;
610
- _tmp3 = [
611
- fileCacheFile
612
- ];
613
- return [
614
- 4,
615
- serializeMap(newFileCache)
616
- ];
617
- case 13:
618
- _1.apply(fse, _tmp3.concat([
619
- _state.sent()
620
- ]));
621
- console.timeEnd("111");
622
- _state.label = 14;
623
- case 14:
732
+ _state.label = 15;
733
+ case 15:
624
734
  console.log("ffffffff", __filename);
625
735
  return [
626
736
  2,
@@ -7,11 +7,13 @@ import { nodeFileTrace } from "@vercel/nft";
7
7
  const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = defaultTraceFiles, entryFilter, modifyPackageJson, copyWholePackage, cacheOptions = {
8
8
  cacheDir: ".modern-js/deploy",
9
9
  fileCache: true,
10
- analysisCache: true
10
+ analysisCache: true,
11
+ symlinkCache: true
11
12
  }, traceOptions }) => {
12
13
  const base = "/";
13
14
  const startTime = Date.now();
14
15
  const entryFiles = await findEntryFiles(serverRootDir, entryFilter);
16
+ console.time("traceFiles");
15
17
  const fileTrace = await traceFiles({
16
18
  entryFiles: entryFiles.concat(includeEntries),
17
19
  serverRootDir,
@@ -22,6 +24,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
22
24
  base,
23
25
  traceOptions
24
26
  });
27
+ console.timeEnd("traceFiles");
25
28
  const currentProjectModules = path.join(appDir, "node_modules");
26
29
  const dependencySearchRoot = path.resolve(appDir, "../../../../../../");
27
30
  const tracedFiles = Object.fromEntries(await Promise.all([
@@ -204,7 +207,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
204
207
  const finalPkgJson = (modifyPackageJson === null || modifyPackageJson === void 0 ? void 0 : modifyPackageJson(newPkgJson)) || newPkgJson;
205
208
  await fse.writeJSON(outputPkgPath, finalPkgJson);
206
209
  const endTime = Date.now();
207
- console.log("handleDependencies cost:", endTime - startTime);
210
+ console.log("handleDependencies cost:", `${endTime - startTime}ms`);
208
211
  };
209
212
  export {
210
213
  handleDependencies,
@@ -104,6 +104,9 @@ async function serializeMap(map) {
104
104
  resolvedMap.set(key, value instanceof Promise ? await Promise.resolve(value) : value);
105
105
  }));
106
106
  return JSON.stringify(resolvedMap, (key, value) => {
107
+ if (value === null) {
108
+ return void 0;
109
+ }
107
110
  if (value instanceof Map) {
108
111
  return {
109
112
  dataType: "Map",
@@ -131,9 +134,10 @@ function deserializeMap(serializedData) {
131
134
  });
132
135
  }
133
136
  const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions, traceOptions }) => {
134
- const { cacheDir, fileCache: enableFileCache, analysisCache: enableAnalysisCache } = cacheOptions;
137
+ const { cacheDir, fileCache: enableFileCache, analysisCache: enableAnalysisCache, symlinkCache: enableSymlinkCache } = cacheOptions;
135
138
  const analysisCacheFile = path.join(cacheDir, "analysis-cache.json");
136
139
  const fileCacheFile = path.join(cacheDir, "file-cache.json");
140
+ const symlinkCacheFile = path.join(cacheDir, "symlink-cache.json");
137
141
  const cache = /* @__PURE__ */ Object.create(null);
138
142
  if (enableAnalysisCache && await fse.pathExists(analysisCacheFile)) {
139
143
  const analysisCache2 = (await fse.readFile(analysisCacheFile)).toString();
@@ -143,14 +147,18 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
143
147
  const fileCache2 = (await fse.readFile(fileCacheFile)).toString();
144
148
  cache.fileCache = deserializeMap(fileCache2);
145
149
  }
150
+ if (enableSymlinkCache && await fse.pathExists(symlinkCacheFile)) {
151
+ const symlinkCache2 = (await fse.readFile(symlinkCacheFile)).toString();
152
+ cache.symlinkCache = deserializeMap(symlinkCache2);
153
+ }
146
154
  const res = await nodeFileTrace(entryFiles, {
147
155
  base,
148
156
  processCwd: serverRootDir,
149
157
  cache,
150
158
  ...traceOptions
151
159
  });
152
- const { analysisCache, fileCache } = cache;
153
- if (analysisCache || fileCache) {
160
+ const { analysisCache, fileCache, symlinkCache } = cache;
161
+ if (analysisCache || fileCache || symlinkCache) {
154
162
  await fse.ensureDir(cacheDir);
155
163
  if (analysisCache) {
156
164
  const newAnalysisCache = new Map(analysisCache);
@@ -159,7 +167,10 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
159
167
  newAnalysisCache.delete(key);
160
168
  }
161
169
  }
162
- fse.writeFile(analysisCacheFile, await serializeMap(newAnalysisCache));
170
+ (async () => {
171
+ await fse.writeFile(analysisCacheFile, await serializeMap(newAnalysisCache));
172
+ console.log("write analysis cache finish");
173
+ })();
163
174
  }
164
175
  if (fileCache) {
165
176
  const newFileCache = new Map(fileCache);
@@ -168,9 +179,22 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
168
179
  newFileCache.delete(key);
169
180
  }
170
181
  }
171
- console.time("111");
172
- fse.writeFile(fileCacheFile, await serializeMap(newFileCache));
173
- console.timeEnd("111");
182
+ (async () => {
183
+ await fse.writeFile(fileCacheFile, await serializeMap(newFileCache));
184
+ console.log("write file cache finish");
185
+ })();
186
+ }
187
+ if (symlinkCache) {
188
+ const newSymlinkCache = new Map(symlinkCache);
189
+ for (const key of newSymlinkCache.keys()) {
190
+ if (!key.includes("node_modules/")) {
191
+ newSymlinkCache.delete(key);
192
+ }
193
+ }
194
+ (async () => {
195
+ await fse.writeFile(symlinkCacheFile, await serializeMap(newSymlinkCache));
196
+ console.log("write symlink cache finish");
197
+ })();
174
198
  }
175
199
  }
176
200
  console.log("ffffffff", __filename);
@@ -36,6 +36,7 @@ export declare const findPackageParents: (pkg: TracedPackage, version: string, t
36
36
  export interface CacheOptions {
37
37
  fileCache: boolean;
38
38
  analysisCache: boolean;
39
+ symlinkCache: boolean;
39
40
  cacheDir: string;
40
41
  }
41
42
  export declare const traceFiles: ({ entryFiles, serverRootDir, base, cacheOptions, traceOptions, }: {
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.58.1-alpha.0",
18
+ "version": "2.58.1-alpha.2",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -92,16 +92,16 @@
92
92
  "@modern-js/core": "2.58.0",
93
93
  "@modern-js/node-bundle-require": "2.58.0",
94
94
  "@modern-js/plugin": "2.58.0",
95
+ "@modern-js/prod-server": "2.58.0",
95
96
  "@modern-js/plugin-i18n": "2.58.0",
96
97
  "@modern-js/plugin-lint": "2.58.0",
97
98
  "@modern-js/server-core": "2.58.0",
98
- "@modern-js/rsbuild-plugin-esbuild": "2.58.0",
99
- "@modern-js/types": "2.58.0",
100
99
  "@modern-js/server": "2.58.0",
101
- "@modern-js/utils": "2.58.0",
102
- "@modern-js/uni-builder": "2.58.0",
103
- "@modern-js/prod-server": "2.58.0",
104
100
  "@modern-js/server-utils": "2.58.0",
101
+ "@modern-js/uni-builder": "2.58.0",
102
+ "@modern-js/types": "2.58.0",
103
+ "@modern-js/utils": "2.58.0",
104
+ "@modern-js/rsbuild-plugin-esbuild": "2.58.0",
105
105
  "@modern-js/plugin-data-loader": "2.58.0"
106
106
  },
107
107
  "devDependencies": {