@umijs/mfsu 4.0.21 → 4.0.23
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/dep/dep.js +4 -1
- package/dist/depInfo.js +9 -3
- package/dist/mfsu/mfsu.d.ts +1 -0
- package/dist/mfsu/mfsu.js +40 -24
- package/dist/staticDepInfo/staticDepInfo.js +6 -2
- package/package.json +4 -4
package/dist/dep/dep.js
CHANGED
|
@@ -67,7 +67,10 @@ export * from '${this.file}';
|
|
|
67
67
|
`);
|
|
68
68
|
}
|
|
69
69
|
const realFile = await this.getRealFile();
|
|
70
|
-
|
|
70
|
+
if (!realFile) {
|
|
71
|
+
import_utils.logger.error(`Can not resolve dependence : '${import_utils.chalk.red(this.file)}', please install it`);
|
|
72
|
+
}
|
|
73
|
+
(0, import_assert.default)(realFile, `dependence not found: ${this.file}`);
|
|
71
74
|
const content = (0, import_fs.readFileSync)(realFile, "utf-8");
|
|
72
75
|
return await (0, import_getExposeFromContent.getExposeFromContent)({
|
|
73
76
|
content,
|
package/dist/depInfo.js
CHANGED
|
@@ -49,9 +49,15 @@ var DepInfo = class {
|
|
|
49
49
|
loadCache() {
|
|
50
50
|
if ((0, import_fs.existsSync)(this.cacheFilePath)) {
|
|
51
51
|
import_utils.logger.info("[MFSU] restore cache");
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
try {
|
|
53
|
+
const { cacheDependency, moduleGraph } = JSON.parse((0, import_fs.readFileSync)(this.cacheFilePath, "utf-8"));
|
|
54
|
+
this.cacheDependency = cacheDependency;
|
|
55
|
+
this.moduleGraph.restore(moduleGraph);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
import_utils.logger.error("[MFSU] restore cache failed", e);
|
|
58
|
+
import_utils.logger.error("please `rm -rf node_modules/.cache`, and try again");
|
|
59
|
+
throw e;
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
writeCache() {
|
package/dist/mfsu/mfsu.d.ts
CHANGED
package/dist/mfsu/mfsu.js
CHANGED
|
@@ -50,6 +50,7 @@ var MFSU = class {
|
|
|
50
50
|
this.buildDepsAgain = false;
|
|
51
51
|
this.progress = { done: false };
|
|
52
52
|
this.publicPath = "/";
|
|
53
|
+
this.lastBuildError = null;
|
|
53
54
|
this.opts = opts;
|
|
54
55
|
this.opts.mfName = this.opts.mfName || import_constants.DEFAULT_MF_NAME;
|
|
55
56
|
this.opts.tmpBase = this.opts.tmpBase || (0, import_path.join)(process.cwd(), import_constants.DEFAULT_TMP_DIR_NAME);
|
|
@@ -183,30 +184,36 @@ promise new Promise(resolve => {
|
|
|
183
184
|
this.strategy.init();
|
|
184
185
|
}
|
|
185
186
|
async buildDeps() {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
deps
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.strategy.writeCache();
|
|
204
|
-
if (this.buildDepsAgain) {
|
|
205
|
-
import_utils.logger.info("[MFSU] buildDepsAgain");
|
|
206
|
-
this.buildDepsAgain = false;
|
|
207
|
-
this.buildDeps().catch((e) => {
|
|
208
|
-
import_utils.printHelp.runtime(e);
|
|
187
|
+
try {
|
|
188
|
+
const shouldBuild = this.strategy.shouldBuild();
|
|
189
|
+
if (!shouldBuild) {
|
|
190
|
+
import_utils.logger.info("[MFSU] skip buildDeps");
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
this.strategy.refresh();
|
|
194
|
+
const staticDeps = this.strategy.getDepModules();
|
|
195
|
+
const deps = import_dep.Dep.buildDeps({
|
|
196
|
+
deps: staticDeps,
|
|
197
|
+
cwd: this.opts.cwd,
|
|
198
|
+
mfsu: this
|
|
199
|
+
});
|
|
200
|
+
import_utils.logger.info(`[MFSU] buildDeps since ${shouldBuild}`);
|
|
201
|
+
import_utils.logger.debug(deps.map((dep) => dep.file).join(", "));
|
|
202
|
+
await this.depBuilder.build({
|
|
203
|
+
deps
|
|
209
204
|
});
|
|
205
|
+
this.lastBuildError = null;
|
|
206
|
+
this.strategy.writeCache();
|
|
207
|
+
if (this.buildDepsAgain) {
|
|
208
|
+
import_utils.logger.info("[MFSU] buildDepsAgain");
|
|
209
|
+
this.buildDepsAgain = false;
|
|
210
|
+
this.buildDeps().catch((e) => {
|
|
211
|
+
import_utils.printHelp.runtime(e);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
} catch (e) {
|
|
215
|
+
this.lastBuildError = e;
|
|
216
|
+
throw e;
|
|
210
217
|
}
|
|
211
218
|
}
|
|
212
219
|
getMiddlewares() {
|
|
@@ -222,7 +229,16 @@ promise new Promise(resolve => {
|
|
|
222
229
|
}
|
|
223
230
|
res.setHeader("content-type", (0, import_mrmime.lookup)((0, import_path.extname)(req.path)) || "text/plain");
|
|
224
231
|
const relativePath = req.path.replace(new RegExp(`^${relativePublicPath}`), "/");
|
|
225
|
-
const
|
|
232
|
+
const realFilePath = (0, import_path.join)(this.opts.tmpBase, relativePath);
|
|
233
|
+
if (!(0, import_fs.existsSync)(realFilePath)) {
|
|
234
|
+
import_utils.logger.error(`MFSU dist file: ${realFilePath} not found`);
|
|
235
|
+
if (this.lastBuildError) {
|
|
236
|
+
import_utils.logger.error(`MFSU latest build error: `, this.lastBuildError);
|
|
237
|
+
}
|
|
238
|
+
res.status(404);
|
|
239
|
+
return res.end();
|
|
240
|
+
}
|
|
241
|
+
const content = (0, import_fs.readFileSync)(realFilePath);
|
|
226
242
|
res.send(content);
|
|
227
243
|
});
|
|
228
244
|
} else {
|
|
@@ -99,8 +99,12 @@ var StaticDepInfo = class {
|
|
|
99
99
|
}
|
|
100
100
|
loadCache() {
|
|
101
101
|
if ((0, import_fs.existsSync)(this.cacheFilePath)) {
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
try {
|
|
103
|
+
this.builtWithDep = JSON.parse((0, import_fs.readFileSync)(this.cacheFilePath, "utf-8"));
|
|
104
|
+
import_utils.logger.info("[MFSU][eager] restored cache");
|
|
105
|
+
} catch (e) {
|
|
106
|
+
import_utils.logger.warn("[MFSU][eager] restore cache failed, fallback to Empty dependency", e);
|
|
107
|
+
}
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
110
|
writeCache() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/mfsu",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.23",
|
|
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.
|
|
27
|
-
"@umijs/bundler-utils": "4.0.
|
|
28
|
-
"@umijs/utils": "4.0.
|
|
26
|
+
"@umijs/bundler-esbuild": "4.0.23",
|
|
27
|
+
"@umijs/bundler-utils": "4.0.23",
|
|
28
|
+
"@umijs/utils": "4.0.23",
|
|
29
29
|
"enhanced-resolve": "5.9.3",
|
|
30
30
|
"is-equal": "^1.6.4"
|
|
31
31
|
},
|