@umijs/mfsu 4.0.26 → 4.0.27

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.
@@ -14,7 +14,7 @@ export declare class StaticAnalyzeStrategy implements IMFSUStrategy {
14
14
  version: string;
15
15
  }>;
16
16
  getCacheFilePath(): string;
17
- shouldBuild(): false | "dependencies changed";
17
+ shouldBuild(): false | "cacheDependency has changed" | "dependencies changed";
18
18
  writeCache(): void;
19
19
  getBabelPlugin(): any[];
20
20
  private getMfImportOpts;
@@ -29,6 +29,7 @@ export declare class StaticDepInfo {
29
29
  private readonly include;
30
30
  private currentDep;
31
31
  private builtWithDep;
32
+ private cacheDependency;
32
33
  private produced;
33
34
  private readonly cwd;
34
35
  private readonly runtimeSimulations;
@@ -37,7 +38,7 @@ export declare class StaticDepInfo {
37
38
  changes: unknown[];
38
39
  }[];
39
40
  consumeAllProducedEvents(): void;
40
- shouldBuild(): false | "dependencies changed";
41
+ shouldBuild(): false | "cacheDependency has changed" | "dependencies changed";
41
42
  getDepModules(): Record<string, {
42
43
  file: string;
43
44
  version: string;
@@ -36,6 +36,7 @@ var StaticDepInfo = class {
36
36
  constructor(opts) {
37
37
  this.currentDep = {};
38
38
  this.builtWithDep = {};
39
+ this.cacheDependency = {};
39
40
  this.produced = [];
40
41
  this.mfsu = opts.mfsu;
41
42
  this.include = this.mfsu.opts.include || [];
@@ -55,6 +56,14 @@ var StaticDepInfo = class {
55
56
  this.produced = [];
56
57
  }
57
58
  shouldBuild() {
59
+ const currentCacheDep = this.opts.mfsu.opts.getCacheDependency();
60
+ if (!import_utils.lodash.isEqual(this.cacheDependency, currentCacheDep)) {
61
+ if (process.env.DEBUG_UMI) {
62
+ const reason = (0, import_why.default)(this.cacheDependency, currentCacheDep);
63
+ import_utils.logger.info("[MFSU][eager]: isEqual(cacheDependency,currentCacheDep) === false, because ", reason);
64
+ }
65
+ return "cacheDependency has changed";
66
+ }
58
67
  if (import_utils.lodash.isEqual(this.builtWithDep, this.currentDep)) {
59
68
  return false;
60
69
  } else {
@@ -79,11 +88,14 @@ var StaticDepInfo = class {
79
88
  }
80
89
  snapshot() {
81
90
  this.builtWithDep = this.currentDep;
91
+ this.cacheDependency = this.mfsu.opts.getCacheDependency();
82
92
  }
83
93
  loadCache() {
84
94
  if ((0, import_fs.existsSync)(this.cacheFilePath)) {
85
95
  try {
86
- this.builtWithDep = JSON.parse((0, import_fs.readFileSync)(this.cacheFilePath, "utf-8"));
96
+ const { dep = {}, cacheDependency = {} } = JSON.parse((0, import_fs.readFileSync)(this.cacheFilePath, "utf-8"));
97
+ this.builtWithDep = dep;
98
+ this.cacheDependency = cacheDependency;
87
99
  import_utils.logger.info("[MFSU][eager] restored cache");
88
100
  } catch (e) {
89
101
  import_utils.logger.warn("[MFSU][eager] restore cache failed, fallback to Empty dependency", e);
@@ -92,7 +104,10 @@ var StaticDepInfo = class {
92
104
  }
93
105
  writeCache() {
94
106
  import_utils.fsExtra.mkdirpSync((0, import_path.dirname)(this.cacheFilePath));
95
- const newContent = JSON.stringify(this.builtWithDep, null, 2);
107
+ const newContent = JSON.stringify({
108
+ dep: this.builtWithDep,
109
+ cacheDependency: this.cacheDependency
110
+ }, null, 2);
96
111
  if ((0, import_fs.existsSync)(this.cacheFilePath) && (0, import_fs.readFileSync)(this.cacheFilePath, "utf-8") === newContent) {
97
112
  return;
98
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/mfsu",
3
- "version": "4.0.26",
3
+ "version": "4.0.27",
4
4
  "description": "@umijs/mfsu",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/mfsu#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -23,9 +23,9 @@
23
23
  "test": "umi-scripts jest-turbo"
24
24
  },
25
25
  "dependencies": {
26
- "@umijs/bundler-esbuild": "4.0.26",
27
- "@umijs/bundler-utils": "4.0.26",
28
- "@umijs/utils": "4.0.26",
26
+ "@umijs/bundler-esbuild": "4.0.27",
27
+ "@umijs/bundler-utils": "4.0.27",
28
+ "@umijs/utils": "4.0.27",
29
29
  "enhanced-resolve": "5.9.3",
30
30
  "is-equal": "^1.6.4"
31
31
  },