@modern-js/app-tools 2.58.1-alpha.1 → 2.58.1-alpha.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,8 +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
- analysisCache: true
43
+ analysisCache: true,
44
+ fileCache: false,
45
+ symlinkCache: false
45
46
  }, traceOptions }) => {
46
47
  const base = "/";
47
48
  const startTime = Date.now();
@@ -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",
@@ -157,9 +160,6 @@ async function serializeMap(map) {
157
160
  value: Array.from(value)
158
161
  };
159
162
  }
160
- if (value === null) {
161
- return void 0;
162
- }
163
163
  return value;
164
164
  });
165
165
  }
@@ -175,10 +175,9 @@ function deserializeMap(serializedData) {
175
175
  });
176
176
  }
177
177
  const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions, traceOptions }) => {
178
- const { cacheDir, fileCache: enableFileCache, analysisCache: enableAnalysisCache } = cacheOptions;
178
+ const { cacheDir, fileCache: enableFileCache, analysisCache: enableAnalysisCache, symlinkCache: enableSymlinkCache } = cacheOptions;
179
179
  const analysisCacheFile = import_path.default.join(cacheDir, "analysis-cache.json");
180
180
  const fileCacheFile = import_path.default.join(cacheDir, "file-cache.json");
181
- const statCacheFile = import_path.default.join(cacheDir, "stat-cache.json");
182
181
  const symlinkCacheFile = import_path.default.join(cacheDir, "symlink-cache.json");
183
182
  const cache = /* @__PURE__ */ Object.create(null);
184
183
  if (enableAnalysisCache && await import_utils.fs.pathExists(analysisCacheFile)) {
@@ -189,7 +188,7 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
189
188
  const fileCache2 = (await import_utils.fs.readFile(fileCacheFile)).toString();
190
189
  cache.fileCache = deserializeMap(fileCache2);
191
190
  }
192
- if (await import_utils.fs.pathExists(symlinkCacheFile)) {
191
+ if (enableSymlinkCache && await import_utils.fs.pathExists(symlinkCacheFile)) {
193
192
  const symlinkCache2 = (await import_utils.fs.readFile(symlinkCacheFile)).toString();
194
193
  cache.symlinkCache = deserializeMap(symlinkCache2);
195
194
  }
@@ -199,10 +198,10 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
199
198
  cache,
200
199
  ...traceOptions
201
200
  });
202
- const { analysisCache, fileCache, statCache, symlinkCache } = cache;
203
- if (analysisCache || fileCache || statCache || symlinkCache) {
201
+ const { analysisCache, fileCache, symlinkCache } = cache;
202
+ if (analysisCache || fileCache || symlinkCache) {
204
203
  await import_utils.fs.ensureDir(cacheDir);
205
- if (analysisCache) {
204
+ if (analysisCache && enableAnalysisCache) {
206
205
  const newAnalysisCache = new Map(analysisCache);
207
206
  for (const key of newAnalysisCache.keys()) {
208
207
  if (!key.includes("node_modules/")) {
@@ -214,7 +213,7 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
214
213
  console.log("write analysis cache finish");
215
214
  })();
216
215
  }
217
- if (fileCache) {
216
+ if (fileCache && enableFileCache) {
218
217
  const newFileCache = new Map(fileCache);
219
218
  for (const key of newFileCache.keys()) {
220
219
  if (!key.includes("node_modules/")) {
@@ -226,7 +225,7 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
226
225
  console.log("write file cache finish");
227
226
  })();
228
227
  }
229
- if (symlinkCache) {
228
+ if (symlinkCache && enableSymlinkCache) {
230
229
  const newSymlinkCache = new Map(symlinkCache);
231
230
  for (const key of newSymlinkCache.keys()) {
232
231
  if (!key.includes("node_modules/")) {
@@ -19,8 +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
- analysisCache: true
22
+ analysisCache: true,
23
+ fileCache: false,
24
+ symlinkCache: false
24
25
  } : _param_cacheOptions, traceOptions = param.traceOptions;
25
26
  base = "/";
26
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 = // function serializeMap(map: Map<string, any>) {
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) {
@@ -415,6 +398,9 @@ function _serializeMap() {
415
398
  return [
416
399
  2,
417
400
  JSON.stringify(resolvedMap, function(key, value) {
401
+ if (value === null) {
402
+ return void 0;
403
+ }
418
404
  if (_instanceof(value, Map)) {
419
405
  return {
420
406
  dataType: "Map",
@@ -427,9 +413,6 @@ function _serializeMap() {
427
413
  value: Array.from(value)
428
414
  };
429
415
  }
430
- if (value === null) {
431
- return void 0;
432
- }
433
416
  return value;
434
417
  })
435
418
  ];
@@ -451,15 +434,14 @@ function deserializeMap(serializedData) {
451
434
  }
452
435
  var traceFiles = function() {
453
436
  var _ref = _async_to_generator(function(param) {
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;
437
+ 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;
455
438
  return _ts_generator(this, function(_state) {
456
439
  switch (_state.label) {
457
440
  case 0:
458
441
  entryFiles = param.entryFiles, serverRootDir = param.serverRootDir, _param_base = param.base, base = _param_base === void 0 ? "/" : _param_base, cacheOptions = param.cacheOptions, traceOptions = param.traceOptions;
459
- cacheDir = cacheOptions.cacheDir, enableFileCache = cacheOptions.fileCache, enableAnalysisCache = cacheOptions.analysisCache;
442
+ cacheDir = cacheOptions.cacheDir, enableFileCache = cacheOptions.fileCache, enableAnalysisCache = cacheOptions.analysisCache, enableSymlinkCache = cacheOptions.symlinkCache;
460
443
  analysisCacheFile = path.join(cacheDir, "analysis-cache.json");
461
444
  fileCacheFile = path.join(cacheDir, "file-cache.json");
462
- statCacheFile = path.join(cacheDir, "stat-cache.json");
463
445
  symlinkCacheFile = path.join(cacheDir, "symlink-cache.json");
464
446
  cache = /* @__PURE__ */ Object.create(null);
465
447
  _tmp = enableAnalysisCache;
@@ -518,25 +500,34 @@ var traceFiles = function() {
518
500
  cache.fileCache = deserializeMap(fileCache);
519
501
  _state.label = 8;
520
502
  case 8:
503
+ _tmp2 = enableSymlinkCache;
504
+ if (!_tmp2)
505
+ return [
506
+ 3,
507
+ 10
508
+ ];
521
509
  return [
522
510
  4,
523
511
  fse.pathExists(symlinkCacheFile)
524
512
  ];
525
513
  case 9:
526
- if (!_state.sent())
514
+ _tmp2 = _state.sent();
515
+ _state.label = 10;
516
+ case 10:
517
+ if (!_tmp2)
527
518
  return [
528
519
  3,
529
- 11
520
+ 12
530
521
  ];
531
522
  return [
532
523
  4,
533
524
  fse.readFile(symlinkCacheFile)
534
525
  ];
535
- case 10:
526
+ case 11:
536
527
  symlinkCache = _state.sent().toString();
537
528
  cache.symlinkCache = deserializeMap(symlinkCache);
538
- _state.label = 11;
539
- case 11:
529
+ _state.label = 12;
530
+ case 12:
540
531
  return [
541
532
  4,
542
533
  nodeFileTrace(entryFiles, _object_spread({
@@ -545,21 +536,21 @@ var traceFiles = function() {
545
536
  cache
546
537
  }, traceOptions))
547
538
  ];
548
- case 12:
539
+ case 13:
549
540
  res = _state.sent();
550
- analysisCache1 = cache.analysisCache, fileCache1 = cache.fileCache, statCache = cache.statCache, symlinkCache1 = cache.symlinkCache;
551
- if (!(analysisCache1 || fileCache1 || statCache || symlinkCache1))
541
+ analysisCache1 = cache.analysisCache, fileCache1 = cache.fileCache, symlinkCache1 = cache.symlinkCache;
542
+ if (!(analysisCache1 || fileCache1 || symlinkCache1))
552
543
  return [
553
544
  3,
554
- 14
545
+ 15
555
546
  ];
556
547
  return [
557
548
  4,
558
549
  fse.ensureDir(cacheDir)
559
550
  ];
560
- case 13:
551
+ case 14:
561
552
  _state.sent();
562
- if (analysisCache1) {
553
+ if (analysisCache1 && enableAnalysisCache) {
563
554
  newAnalysisCache = new Map(analysisCache1);
564
555
  _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
565
556
  try {
@@ -584,12 +575,12 @@ var traceFiles = function() {
584
575
  }
585
576
  }
586
577
  _async_to_generator(function() {
587
- var _, _tmp2;
578
+ var _, _tmp3;
588
579
  return _ts_generator(this, function(_state2) {
589
580
  switch (_state2.label) {
590
581
  case 0:
591
582
  _ = fse.writeFile;
592
- _tmp2 = [
583
+ _tmp3 = [
593
584
  analysisCacheFile
594
585
  ];
595
586
  return [
@@ -599,7 +590,7 @@ var traceFiles = function() {
599
590
  case 1:
600
591
  return [
601
592
  4,
602
- _.apply(fse, _tmp2.concat([
593
+ _.apply(fse, _tmp3.concat([
603
594
  _state2.sent()
604
595
  ]))
605
596
  ];
@@ -613,7 +604,7 @@ var traceFiles = function() {
613
604
  });
614
605
  })();
615
606
  }
616
- if (fileCache1) {
607
+ if (fileCache1 && enableFileCache) {
617
608
  newFileCache = new Map(fileCache1);
618
609
  _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
619
610
  try {
@@ -638,12 +629,12 @@ var traceFiles = function() {
638
629
  }
639
630
  }
640
631
  _async_to_generator(function() {
641
- var _, _tmp2;
632
+ var _, _tmp3;
642
633
  return _ts_generator(this, function(_state2) {
643
634
  switch (_state2.label) {
644
635
  case 0:
645
636
  _ = fse.writeFile;
646
- _tmp2 = [
637
+ _tmp3 = [
647
638
  fileCacheFile
648
639
  ];
649
640
  return [
@@ -653,7 +644,7 @@ var traceFiles = function() {
653
644
  case 1:
654
645
  return [
655
646
  4,
656
- _.apply(fse, _tmp2.concat([
647
+ _.apply(fse, _tmp3.concat([
657
648
  _state2.sent()
658
649
  ]))
659
650
  ];
@@ -667,7 +658,7 @@ var traceFiles = function() {
667
658
  });
668
659
  })();
669
660
  }
670
- if (symlinkCache1) {
661
+ if (symlinkCache1 && enableSymlinkCache) {
671
662
  newSymlinkCache = new Map(symlinkCache1);
672
663
  _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
673
664
  try {
@@ -692,12 +683,12 @@ var traceFiles = function() {
692
683
  }
693
684
  }
694
685
  _async_to_generator(function() {
695
- var _, _tmp2;
686
+ var _, _tmp3;
696
687
  return _ts_generator(this, function(_state2) {
697
688
  switch (_state2.label) {
698
689
  case 0:
699
690
  _ = fse.writeFile;
700
- _tmp2 = [
691
+ _tmp3 = [
701
692
  symlinkCacheFile
702
693
  ];
703
694
  return [
@@ -707,7 +698,7 @@ var traceFiles = function() {
707
698
  case 1:
708
699
  return [
709
700
  4,
710
- _.apply(fse, _tmp2.concat([
701
+ _.apply(fse, _tmp3.concat([
711
702
  _state2.sent()
712
703
  ]))
713
704
  ];
@@ -721,8 +712,8 @@ var traceFiles = function() {
721
712
  });
722
713
  })();
723
714
  }
724
- _state.label = 14;
725
- case 14:
715
+ _state.label = 15;
716
+ case 15:
726
717
  console.log("ffffffff", __filename);
727
718
  return [
728
719
  2,
@@ -6,8 +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
- analysisCache: true
9
+ analysisCache: true,
10
+ fileCache: false,
11
+ symlinkCache: false
11
12
  }, traceOptions }) => {
12
13
  const base = "/";
13
14
  const startTime = Date.now();
@@ -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",
@@ -116,9 +119,6 @@ async function serializeMap(map) {
116
119
  value: Array.from(value)
117
120
  };
118
121
  }
119
- if (value === null) {
120
- return void 0;
121
- }
122
122
  return value;
123
123
  });
124
124
  }
@@ -134,10 +134,9 @@ function deserializeMap(serializedData) {
134
134
  });
135
135
  }
136
136
  const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions, traceOptions }) => {
137
- const { cacheDir, fileCache: enableFileCache, analysisCache: enableAnalysisCache } = cacheOptions;
137
+ const { cacheDir, fileCache: enableFileCache, analysisCache: enableAnalysisCache, symlinkCache: enableSymlinkCache } = cacheOptions;
138
138
  const analysisCacheFile = path.join(cacheDir, "analysis-cache.json");
139
139
  const fileCacheFile = path.join(cacheDir, "file-cache.json");
140
- const statCacheFile = path.join(cacheDir, "stat-cache.json");
141
140
  const symlinkCacheFile = path.join(cacheDir, "symlink-cache.json");
142
141
  const cache = /* @__PURE__ */ Object.create(null);
143
142
  if (enableAnalysisCache && await fse.pathExists(analysisCacheFile)) {
@@ -148,7 +147,7 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
148
147
  const fileCache2 = (await fse.readFile(fileCacheFile)).toString();
149
148
  cache.fileCache = deserializeMap(fileCache2);
150
149
  }
151
- if (await fse.pathExists(symlinkCacheFile)) {
150
+ if (enableSymlinkCache && await fse.pathExists(symlinkCacheFile)) {
152
151
  const symlinkCache2 = (await fse.readFile(symlinkCacheFile)).toString();
153
152
  cache.symlinkCache = deserializeMap(symlinkCache2);
154
153
  }
@@ -158,10 +157,10 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
158
157
  cache,
159
158
  ...traceOptions
160
159
  });
161
- const { analysisCache, fileCache, statCache, symlinkCache } = cache;
162
- if (analysisCache || fileCache || statCache || symlinkCache) {
160
+ const { analysisCache, fileCache, symlinkCache } = cache;
161
+ if (analysisCache || fileCache || symlinkCache) {
163
162
  await fse.ensureDir(cacheDir);
164
- if (analysisCache) {
163
+ if (analysisCache && enableAnalysisCache) {
165
164
  const newAnalysisCache = new Map(analysisCache);
166
165
  for (const key of newAnalysisCache.keys()) {
167
166
  if (!key.includes("node_modules/")) {
@@ -173,7 +172,7 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
173
172
  console.log("write analysis cache finish");
174
173
  })();
175
174
  }
176
- if (fileCache) {
175
+ if (fileCache && enableFileCache) {
177
176
  const newFileCache = new Map(fileCache);
178
177
  for (const key of newFileCache.keys()) {
179
178
  if (!key.includes("node_modules/")) {
@@ -185,7 +184,7 @@ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", cacheOptions,
185
184
  console.log("write file cache finish");
186
185
  })();
187
186
  }
188
- if (symlinkCache) {
187
+ if (symlinkCache && enableSymlinkCache) {
189
188
  const newSymlinkCache = new Map(symlinkCache);
190
189
  for (const key of newSymlinkCache.keys()) {
191
190
  if (!key.includes("node_modules/")) {
@@ -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.1",
18
+ "version": "2.58.1-alpha.3",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -90,19 +90,19 @@
90
90
  "pkg-types": "^1.1.0",
91
91
  "std-env": "^3.7.0",
92
92
  "@modern-js/node-bundle-require": "2.58.0",
93
- "@modern-js/plugin": "2.58.0",
94
93
  "@modern-js/core": "2.58.0",
94
+ "@modern-js/plugin": "2.58.0",
95
95
  "@modern-js/plugin-i18n": "2.58.0",
96
- "@modern-js/server": "2.58.0",
97
- "@modern-js/prod-server": "2.58.0",
98
- "@modern-js/server-core": "2.58.0",
99
96
  "@modern-js/plugin-lint": "2.58.0",
97
+ "@modern-js/server-core": "2.58.0",
98
+ "@modern-js/server-utils": "2.58.0",
99
+ "@modern-js/server": "2.58.0",
100
100
  "@modern-js/types": "2.58.0",
101
101
  "@modern-js/utils": "2.58.0",
102
+ "@modern-js/prod-server": "2.58.0",
102
103
  "@modern-js/uni-builder": "2.58.0",
103
104
  "@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"
105
+ "@modern-js/plugin-data-loader": "2.58.0"
106
106
  },
107
107
  "devDependencies": {
108
108
  "@rsbuild/plugin-swc": "1.0.1-beta.10",