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