@modern-js/app-tools 2.58.1-alpha.2 → 2.58.1-alpha.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/plugins/deploy/dependencies/index.js +2 -2
- package/dist/cjs/plugins/deploy/dependencies/utils.js +30 -49
- package/dist/esm/plugins/deploy/dependencies/index.js +2 -2
- package/dist/esm/plugins/deploy/dependencies/utils.js +142 -247
- package/dist/esm-node/plugins/deploy/dependencies/index.js +2 -2
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +30 -49
- package/package.json +7 -7
@@ -40,9 +40,9 @@ var import_utils2 = require("./utils");
|
|
40
40
|
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
|
-
fileCache: true,
|
44
43
|
analysisCache: true,
|
45
|
-
|
44
|
+
fileCache: false,
|
45
|
+
symlinkCache: false
|
46
46
|
}, traceOptions }) => {
|
47
47
|
const base = "/";
|
48
48
|
const startTime = Date.now();
|
@@ -174,71 +174,52 @@ function deserializeMap(serializedData) {
|
|
174
174
|
return value;
|
175
175
|
});
|
176
176
|
}
|
177
|
+
const loadCache = async (filePath, enabled) => {
|
178
|
+
if (enabled && await import_utils.fs.pathExists(filePath)) {
|
179
|
+
console.log("load cache:", filePath);
|
180
|
+
const data = (await import_utils.fs.readFile(filePath)).toString();
|
181
|
+
return deserializeMap(data);
|
182
|
+
}
|
183
|
+
return void 0;
|
184
|
+
};
|
185
|
+
const writeCache = async (filePath, cacheMap) => {
|
186
|
+
const newCacheMap = /* @__PURE__ */ new Map();
|
187
|
+
for (const [key, value] of cacheMap.entries()) {
|
188
|
+
if (key.includes("node_modules/")) {
|
189
|
+
newCacheMap.set(key, value);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
await import_utils.fs.writeFile(filePath, await serializeMap(newCacheMap));
|
193
|
+
console.log(`write ${import_path.default.basename(filePath)} finish`);
|
194
|
+
};
|
177
195
|
const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions, traceOptions }) => {
|
178
|
-
const { cacheDir, fileCache
|
196
|
+
const { cacheDir, fileCache, analysisCache, symlinkCache } = cacheOptions;
|
179
197
|
const analysisCacheFile = import_path.default.join(cacheDir, "analysis-cache.json");
|
180
198
|
const fileCacheFile = import_path.default.join(cacheDir, "file-cache.json");
|
181
199
|
const symlinkCacheFile = import_path.default.join(cacheDir, "symlink-cache.json");
|
182
|
-
const cache =
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
}
|
187
|
-
if (enableFileCache && await import_utils.fs.pathExists(fileCacheFile)) {
|
188
|
-
const fileCache2 = (await import_utils.fs.readFile(fileCacheFile)).toString();
|
189
|
-
cache.fileCache = deserializeMap(fileCache2);
|
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
|
-
}
|
200
|
+
const cache = {
|
201
|
+
analysisCache: await loadCache(analysisCacheFile, analysisCache),
|
202
|
+
fileCache: await loadCache(fileCacheFile, fileCache),
|
203
|
+
symlinkCache: await loadCache(symlinkCacheFile, symlinkCache)
|
204
|
+
};
|
195
205
|
const res = await (0, import_nft.nodeFileTrace)(entryFiles, {
|
196
206
|
base,
|
197
207
|
processCwd: serverRootDir,
|
198
208
|
cache,
|
199
209
|
...traceOptions
|
200
210
|
});
|
201
|
-
const { analysisCache, fileCache, symlinkCache } = cache;
|
202
211
|
if (analysisCache || fileCache || symlinkCache) {
|
203
212
|
await import_utils.fs.ensureDir(cacheDir);
|
204
|
-
if (analysisCache) {
|
205
|
-
|
206
|
-
for (const key of newAnalysisCache.keys()) {
|
207
|
-
if (!key.includes("node_modules/")) {
|
208
|
-
newAnalysisCache.delete(key);
|
209
|
-
}
|
210
|
-
}
|
211
|
-
(async () => {
|
212
|
-
await import_utils.fs.writeFile(analysisCacheFile, await serializeMap(newAnalysisCache));
|
213
|
-
console.log("write analysis cache finish");
|
214
|
-
})();
|
213
|
+
if (cache.analysisCache && analysisCache) {
|
214
|
+
await writeCache(analysisCacheFile, cache.analysisCache);
|
215
215
|
}
|
216
|
-
if (fileCache) {
|
217
|
-
|
218
|
-
for (const key of newFileCache.keys()) {
|
219
|
-
if (!key.includes("node_modules/")) {
|
220
|
-
newFileCache.delete(key);
|
221
|
-
}
|
222
|
-
}
|
223
|
-
(async () => {
|
224
|
-
await import_utils.fs.writeFile(fileCacheFile, await serializeMap(newFileCache));
|
225
|
-
console.log("write file cache finish");
|
226
|
-
})();
|
216
|
+
if (cache.fileCache && fileCache) {
|
217
|
+
await writeCache(fileCacheFile, cache.fileCache);
|
227
218
|
}
|
228
|
-
if (symlinkCache) {
|
229
|
-
|
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
|
-
})();
|
219
|
+
if (cache.symlinkCache && symlinkCache) {
|
220
|
+
await writeCache(symlinkCacheFile, cache.symlinkCache);
|
239
221
|
}
|
240
222
|
}
|
241
|
-
console.log("ffffffff", __filename);
|
242
223
|
return res;
|
243
224
|
};
|
244
225
|
const resolveTracedPath = async (base, p) => import_utils.fs.realpath(import_path.default.resolve(base, p));
|
@@ -19,9 +19,9 @@ var handleDependencies = function() {
|
|
19
19
|
case 0:
|
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
|
-
fileCache: true,
|
23
22
|
analysisCache: true,
|
24
|
-
|
23
|
+
fileCache: false,
|
24
|
+
symlinkCache: false
|
25
25
|
} : _param_cacheOptions, traceOptions = param.traceOptions;
|
26
26
|
base = "/";
|
27
27
|
startTime = Date.now();
|
@@ -341,24 +341,7 @@ function serializeMap(map) {
|
|
341
341
|
return _serializeMap.apply(this, arguments);
|
342
342
|
}
|
343
343
|
function _serializeMap() {
|
344
|
-
_serializeMap =
|
345
|
-
// return JSON.stringify(map, (key, value) => {
|
346
|
-
// if (value instanceof Map) {
|
347
|
-
// return {
|
348
|
-
// dataType: 'Map',
|
349
|
-
// value: [...value.entries()],
|
350
|
-
// };
|
351
|
-
// }
|
352
|
-
// if (value instanceof Set) {
|
353
|
-
// return {
|
354
|
-
// dataType: 'Set',
|
355
|
-
// value: [...value],
|
356
|
-
// };
|
357
|
-
// }
|
358
|
-
// return value;
|
359
|
-
// });
|
360
|
-
// }
|
361
|
-
_async_to_generator(function(map) {
|
344
|
+
_serializeMap = _async_to_generator(function(map) {
|
362
345
|
var resolvedMap;
|
363
346
|
return _ts_generator(this, function(_state) {
|
364
347
|
switch (_state.label) {
|
@@ -449,19 +432,13 @@ function deserializeMap(serializedData) {
|
|
449
432
|
return value;
|
450
433
|
});
|
451
434
|
}
|
452
|
-
var
|
453
|
-
var _ref = _async_to_generator(function(
|
454
|
-
var
|
435
|
+
var loadCache = function() {
|
436
|
+
var _ref = _async_to_generator(function(filePath, enabled) {
|
437
|
+
var _tmp, data;
|
455
438
|
return _ts_generator(this, function(_state) {
|
456
439
|
switch (_state.label) {
|
457
440
|
case 0:
|
458
|
-
|
459
|
-
cacheDir = cacheOptions.cacheDir, enableFileCache = cacheOptions.fileCache, enableAnalysisCache = cacheOptions.analysisCache, enableSymlinkCache = cacheOptions.symlinkCache;
|
460
|
-
analysisCacheFile = path.join(cacheDir, "analysis-cache.json");
|
461
|
-
fileCacheFile = path.join(cacheDir, "file-cache.json");
|
462
|
-
symlinkCacheFile = path.join(cacheDir, "symlink-cache.json");
|
463
|
-
cache = /* @__PURE__ */ Object.create(null);
|
464
|
-
_tmp = enableAnalysisCache;
|
441
|
+
_tmp = enabled;
|
465
442
|
if (!_tmp)
|
466
443
|
return [
|
467
444
|
3,
|
@@ -469,7 +446,7 @@ var traceFiles = function() {
|
|
469
446
|
];
|
470
447
|
return [
|
471
448
|
4,
|
472
|
-
fse.pathExists(
|
449
|
+
fse.pathExists(filePath)
|
473
450
|
];
|
474
451
|
case 1:
|
475
452
|
_tmp = _state.sent();
|
@@ -480,71 +457,116 @@ var traceFiles = function() {
|
|
480
457
|
3,
|
481
458
|
4
|
482
459
|
];
|
460
|
+
console.log("load cache:", filePath);
|
483
461
|
return [
|
484
462
|
4,
|
485
|
-
fse.readFile(
|
463
|
+
fse.readFile(filePath)
|
486
464
|
];
|
487
465
|
case 3:
|
488
|
-
|
489
|
-
|
490
|
-
|
466
|
+
data = _state.sent().toString();
|
467
|
+
return [
|
468
|
+
2,
|
469
|
+
deserializeMap(data)
|
470
|
+
];
|
491
471
|
case 4:
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
472
|
+
return [
|
473
|
+
2,
|
474
|
+
void 0
|
475
|
+
];
|
476
|
+
}
|
477
|
+
});
|
478
|
+
});
|
479
|
+
return function loadCache2(filePath, enabled) {
|
480
|
+
return _ref.apply(this, arguments);
|
481
|
+
};
|
482
|
+
}();
|
483
|
+
var writeCache = function() {
|
484
|
+
var _ref = _async_to_generator(function(filePath, cacheMap) {
|
485
|
+
var newCacheMap, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, key, value, _, _tmp;
|
486
|
+
return _ts_generator(this, function(_state) {
|
487
|
+
switch (_state.label) {
|
488
|
+
case 0:
|
489
|
+
newCacheMap = /* @__PURE__ */ new Map();
|
490
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
491
|
+
try {
|
492
|
+
for (_iterator = cacheMap.entries()[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
493
|
+
_step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
494
|
+
if (key.includes("node_modules/")) {
|
495
|
+
newCacheMap.set(key, value);
|
496
|
+
}
|
497
|
+
}
|
498
|
+
} catch (err) {
|
499
|
+
_didIteratorError = true;
|
500
|
+
_iteratorError = err;
|
501
|
+
} finally {
|
502
|
+
try {
|
503
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
504
|
+
_iterator.return();
|
505
|
+
}
|
506
|
+
} finally {
|
507
|
+
if (_didIteratorError) {
|
508
|
+
throw _iteratorError;
|
509
|
+
}
|
510
|
+
}
|
511
|
+
}
|
512
|
+
_ = fse.writeFile;
|
513
|
+
_tmp = [
|
514
|
+
filePath
|
515
|
+
];
|
498
516
|
return [
|
499
517
|
4,
|
500
|
-
|
518
|
+
serializeMap(newCacheMap)
|
501
519
|
];
|
502
|
-
case
|
503
|
-
_tmp1 = _state.sent();
|
504
|
-
_state.label = 6;
|
505
|
-
case 6:
|
506
|
-
if (!_tmp1)
|
507
|
-
return [
|
508
|
-
3,
|
509
|
-
8
|
510
|
-
];
|
520
|
+
case 1:
|
511
521
|
return [
|
512
522
|
4,
|
513
|
-
fse.
|
523
|
+
_.apply(fse, _tmp.concat([
|
524
|
+
_state.sent()
|
525
|
+
]))
|
514
526
|
];
|
515
|
-
case
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
527
|
+
case 2:
|
528
|
+
_state.sent();
|
529
|
+
console.log("write ".concat(path.basename(filePath), " finish"));
|
530
|
+
return [
|
531
|
+
2
|
532
|
+
];
|
533
|
+
}
|
534
|
+
});
|
535
|
+
});
|
536
|
+
return function writeCache2(filePath, cacheMap) {
|
537
|
+
return _ref.apply(this, arguments);
|
538
|
+
};
|
539
|
+
}();
|
540
|
+
var traceFiles = function() {
|
541
|
+
var _ref = _async_to_generator(function(param) {
|
542
|
+
var entryFiles, serverRootDir, _param_base, base, cacheOptions, traceOptions, cacheDir, fileCache, analysisCache, symlinkCache, analysisCacheFile, fileCacheFile, symlinkCacheFile, cache, _tmp, res;
|
543
|
+
return _ts_generator(this, function(_state) {
|
544
|
+
switch (_state.label) {
|
545
|
+
case 0:
|
546
|
+
entryFiles = param.entryFiles, serverRootDir = param.serverRootDir, _param_base = param.base, base = _param_base === void 0 ? "/" : _param_base, cacheOptions = param.cacheOptions, traceOptions = param.traceOptions;
|
547
|
+
cacheDir = cacheOptions.cacheDir, fileCache = cacheOptions.fileCache, analysisCache = cacheOptions.analysisCache, symlinkCache = cacheOptions.symlinkCache;
|
548
|
+
analysisCacheFile = path.join(cacheDir, "analysis-cache.json");
|
549
|
+
fileCacheFile = path.join(cacheDir, "file-cache.json");
|
550
|
+
symlinkCacheFile = path.join(cacheDir, "symlink-cache.json");
|
551
|
+
_tmp = {};
|
526
552
|
return [
|
527
553
|
4,
|
528
|
-
|
554
|
+
loadCache(analysisCacheFile, analysisCache)
|
529
555
|
];
|
530
|
-
case
|
531
|
-
|
532
|
-
_state.label = 10;
|
533
|
-
case 10:
|
534
|
-
if (!_tmp2)
|
535
|
-
return [
|
536
|
-
3,
|
537
|
-
12
|
538
|
-
];
|
556
|
+
case 1:
|
557
|
+
_tmp.analysisCache = _state.sent();
|
539
558
|
return [
|
540
559
|
4,
|
541
|
-
|
560
|
+
loadCache(fileCacheFile, fileCache)
|
542
561
|
];
|
543
|
-
case
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
562
|
+
case 2:
|
563
|
+
_tmp.fileCache = _state.sent();
|
564
|
+
return [
|
565
|
+
4,
|
566
|
+
loadCache(symlinkCacheFile, symlinkCache)
|
567
|
+
];
|
568
|
+
case 3:
|
569
|
+
cache = (_tmp.symlinkCache = _state.sent(), _tmp);
|
548
570
|
return [
|
549
571
|
4,
|
550
572
|
nodeFileTrace(entryFiles, _object_spread({
|
@@ -553,185 +575,58 @@ var traceFiles = function() {
|
|
553
575
|
cache
|
554
576
|
}, traceOptions))
|
555
577
|
];
|
556
|
-
case
|
578
|
+
case 4:
|
557
579
|
res = _state.sent();
|
558
|
-
|
559
|
-
if (!(analysisCache1 || fileCache1 || symlinkCache1))
|
580
|
+
if (!(analysisCache || fileCache || symlinkCache))
|
560
581
|
return [
|
561
582
|
3,
|
562
|
-
|
583
|
+
11
|
563
584
|
];
|
564
585
|
return [
|
565
586
|
4,
|
566
587
|
fse.ensureDir(cacheDir)
|
567
588
|
];
|
568
|
-
case
|
589
|
+
case 5:
|
569
590
|
_state.sent();
|
570
|
-
if (
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
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
|
-
})();
|
623
|
-
}
|
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
|
-
}
|
646
|
-
}
|
647
|
-
}
|
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;
|
681
|
-
try {
|
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
|
-
}
|
687
|
-
}
|
688
|
-
} catch (err) {
|
689
|
-
_didIteratorError2 = true;
|
690
|
-
_iteratorError2 = err;
|
691
|
-
} finally {
|
692
|
-
try {
|
693
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
694
|
-
_iterator2.return();
|
695
|
-
}
|
696
|
-
} finally {
|
697
|
-
if (_didIteratorError2) {
|
698
|
-
throw _iteratorError2;
|
699
|
-
}
|
700
|
-
}
|
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
|
-
})();
|
731
|
-
}
|
732
|
-
_state.label = 15;
|
733
|
-
case 15:
|
734
|
-
console.log("ffffffff", __filename);
|
591
|
+
if (!(cache.analysisCache && analysisCache))
|
592
|
+
return [
|
593
|
+
3,
|
594
|
+
7
|
595
|
+
];
|
596
|
+
return [
|
597
|
+
4,
|
598
|
+
writeCache(analysisCacheFile, cache.analysisCache)
|
599
|
+
];
|
600
|
+
case 6:
|
601
|
+
_state.sent();
|
602
|
+
_state.label = 7;
|
603
|
+
case 7:
|
604
|
+
if (!(cache.fileCache && fileCache))
|
605
|
+
return [
|
606
|
+
3,
|
607
|
+
9
|
608
|
+
];
|
609
|
+
return [
|
610
|
+
4,
|
611
|
+
writeCache(fileCacheFile, cache.fileCache)
|
612
|
+
];
|
613
|
+
case 8:
|
614
|
+
_state.sent();
|
615
|
+
_state.label = 9;
|
616
|
+
case 9:
|
617
|
+
if (!(cache.symlinkCache && symlinkCache))
|
618
|
+
return [
|
619
|
+
3,
|
620
|
+
11
|
621
|
+
];
|
622
|
+
return [
|
623
|
+
4,
|
624
|
+
writeCache(symlinkCacheFile, cache.symlinkCache)
|
625
|
+
];
|
626
|
+
case 10:
|
627
|
+
_state.sent();
|
628
|
+
_state.label = 11;
|
629
|
+
case 11:
|
735
630
|
return [
|
736
631
|
2,
|
737
632
|
res
|
@@ -6,9 +6,9 @@ import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles as defaul
|
|
6
6
|
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
|
-
fileCache: true,
|
10
9
|
analysisCache: true,
|
11
|
-
|
10
|
+
fileCache: false,
|
11
|
+
symlinkCache: false
|
12
12
|
}, traceOptions }) => {
|
13
13
|
const base = "/";
|
14
14
|
const startTime = Date.now();
|
@@ -133,71 +133,52 @@ function deserializeMap(serializedData) {
|
|
133
133
|
return value;
|
134
134
|
});
|
135
135
|
}
|
136
|
+
const loadCache = async (filePath, enabled) => {
|
137
|
+
if (enabled && await fse.pathExists(filePath)) {
|
138
|
+
console.log("load cache:", filePath);
|
139
|
+
const data = (await fse.readFile(filePath)).toString();
|
140
|
+
return deserializeMap(data);
|
141
|
+
}
|
142
|
+
return void 0;
|
143
|
+
};
|
144
|
+
const writeCache = async (filePath, cacheMap) => {
|
145
|
+
const newCacheMap = /* @__PURE__ */ new Map();
|
146
|
+
for (const [key, value] of cacheMap.entries()) {
|
147
|
+
if (key.includes("node_modules/")) {
|
148
|
+
newCacheMap.set(key, value);
|
149
|
+
}
|
150
|
+
}
|
151
|
+
await fse.writeFile(filePath, await serializeMap(newCacheMap));
|
152
|
+
console.log(`write ${path.basename(filePath)} finish`);
|
153
|
+
};
|
136
154
|
const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions, traceOptions }) => {
|
137
|
-
const { cacheDir, fileCache
|
155
|
+
const { cacheDir, fileCache, analysisCache, symlinkCache } = cacheOptions;
|
138
156
|
const analysisCacheFile = path.join(cacheDir, "analysis-cache.json");
|
139
157
|
const fileCacheFile = path.join(cacheDir, "file-cache.json");
|
140
158
|
const symlinkCacheFile = path.join(cacheDir, "symlink-cache.json");
|
141
|
-
const cache =
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
}
|
146
|
-
if (enableFileCache && await fse.pathExists(fileCacheFile)) {
|
147
|
-
const fileCache2 = (await fse.readFile(fileCacheFile)).toString();
|
148
|
-
cache.fileCache = deserializeMap(fileCache2);
|
149
|
-
}
|
150
|
-
if (enableSymlinkCache && await fse.pathExists(symlinkCacheFile)) {
|
151
|
-
const symlinkCache2 = (await fse.readFile(symlinkCacheFile)).toString();
|
152
|
-
cache.symlinkCache = deserializeMap(symlinkCache2);
|
153
|
-
}
|
159
|
+
const cache = {
|
160
|
+
analysisCache: await loadCache(analysisCacheFile, analysisCache),
|
161
|
+
fileCache: await loadCache(fileCacheFile, fileCache),
|
162
|
+
symlinkCache: await loadCache(symlinkCacheFile, symlinkCache)
|
163
|
+
};
|
154
164
|
const res = await nodeFileTrace(entryFiles, {
|
155
165
|
base,
|
156
166
|
processCwd: serverRootDir,
|
157
167
|
cache,
|
158
168
|
...traceOptions
|
159
169
|
});
|
160
|
-
const { analysisCache, fileCache, symlinkCache } = cache;
|
161
170
|
if (analysisCache || fileCache || symlinkCache) {
|
162
171
|
await fse.ensureDir(cacheDir);
|
163
|
-
if (analysisCache) {
|
164
|
-
|
165
|
-
for (const key of newAnalysisCache.keys()) {
|
166
|
-
if (!key.includes("node_modules/")) {
|
167
|
-
newAnalysisCache.delete(key);
|
168
|
-
}
|
169
|
-
}
|
170
|
-
(async () => {
|
171
|
-
await fse.writeFile(analysisCacheFile, await serializeMap(newAnalysisCache));
|
172
|
-
console.log("write analysis cache finish");
|
173
|
-
})();
|
172
|
+
if (cache.analysisCache && analysisCache) {
|
173
|
+
await writeCache(analysisCacheFile, cache.analysisCache);
|
174
174
|
}
|
175
|
-
if (fileCache) {
|
176
|
-
|
177
|
-
for (const key of newFileCache.keys()) {
|
178
|
-
if (!key.includes("node_modules/")) {
|
179
|
-
newFileCache.delete(key);
|
180
|
-
}
|
181
|
-
}
|
182
|
-
(async () => {
|
183
|
-
await fse.writeFile(fileCacheFile, await serializeMap(newFileCache));
|
184
|
-
console.log("write file cache finish");
|
185
|
-
})();
|
175
|
+
if (cache.fileCache && fileCache) {
|
176
|
+
await writeCache(fileCacheFile, cache.fileCache);
|
186
177
|
}
|
187
|
-
if (symlinkCache) {
|
188
|
-
|
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
|
-
})();
|
178
|
+
if (cache.symlinkCache && symlinkCache) {
|
179
|
+
await writeCache(symlinkCacheFile, cache.symlinkCache);
|
198
180
|
}
|
199
181
|
}
|
200
|
-
console.log("ffffffff", __filename);
|
201
182
|
return res;
|
202
183
|
};
|
203
184
|
const resolveTracedPath = async (base, p) => fse.realpath(path.resolve(base, p));
|
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.4",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -89,19 +89,19 @@
|
|
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",
|
93
|
+
"@modern-js/core": "2.58.0",
|
94
|
+
"@modern-js/plugin-lint": "2.58.0",
|
94
95
|
"@modern-js/plugin": "2.58.0",
|
95
96
|
"@modern-js/prod-server": "2.58.0",
|
96
97
|
"@modern-js/plugin-i18n": "2.58.0",
|
97
|
-
"@modern-js/plugin-
|
98
|
-
"@modern-js/server-core": "2.58.0",
|
98
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.58.0",
|
99
99
|
"@modern-js/server": "2.58.0",
|
100
|
-
"@modern-js/server-
|
101
|
-
"@modern-js/uni-builder": "2.58.0",
|
100
|
+
"@modern-js/server-core": "2.58.0",
|
102
101
|
"@modern-js/types": "2.58.0",
|
102
|
+
"@modern-js/server-utils": "2.58.0",
|
103
103
|
"@modern-js/utils": "2.58.0",
|
104
|
-
"@modern-js/
|
104
|
+
"@modern-js/uni-builder": "2.58.0",
|
105
105
|
"@modern-js/plugin-data-loader": "2.58.0"
|
106
106
|
},
|
107
107
|
"devDependencies": {
|