@umijs/mfsu 4.0.0-canary.20220318.1 → 4.0.0-canary.20220323.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/depBuilder/depBuilder.js +17 -10
- package/dist/depInfo.d.ts +1 -1
- package/dist/depInfo.js +10 -5
- package/dist/mfsu.d.ts +1 -0
- package/dist/mfsu.js +26 -11
- package/package.json +4 -4
|
@@ -73,17 +73,24 @@ class DepBuilder {
|
|
|
73
73
|
build(opts) {
|
|
74
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
75
|
this.isBuilding = true;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
const onBuildComplete = () => {
|
|
77
|
+
this.isBuilding = false;
|
|
78
|
+
this.completeFns.forEach((fn) => fn());
|
|
79
|
+
this.completeFns = [];
|
|
80
|
+
};
|
|
81
|
+
try {
|
|
82
|
+
yield this.writeMFFiles({ deps: opts.deps });
|
|
83
|
+
const newOpts = Object.assign(Object.assign({}, opts), { onBuildComplete });
|
|
84
|
+
if (this.opts.mfsu.opts.buildDepWithESBuild) {
|
|
85
|
+
yield this.buildWithESBuild(newOpts);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
yield this.buildWithWebpack(newOpts);
|
|
89
|
+
}
|
|
84
90
|
}
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
catch (e) {
|
|
92
|
+
onBuildComplete();
|
|
93
|
+
throw e;
|
|
87
94
|
}
|
|
88
95
|
});
|
|
89
96
|
}
|
package/dist/depInfo.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class DepInfo {
|
|
|
9
9
|
moduleGraph: ModuleGraph;
|
|
10
10
|
cacheDependency: object;
|
|
11
11
|
constructor(opts: IOpts);
|
|
12
|
-
shouldBuild():
|
|
12
|
+
shouldBuild(): false | "cacheDependency has changed" | "moduleGraph has changed";
|
|
13
13
|
snapshot(): void;
|
|
14
14
|
loadCache(): void;
|
|
15
15
|
writeCache(): void;
|
package/dist/depInfo.js
CHANGED
|
@@ -14,10 +14,10 @@ class DepInfo {
|
|
|
14
14
|
}
|
|
15
15
|
shouldBuild() {
|
|
16
16
|
if (!utils_1.lodash.isEqual(this.cacheDependency, this.opts.mfsu.opts.getCacheDependency())) {
|
|
17
|
-
return
|
|
17
|
+
return 'cacheDependency has changed';
|
|
18
18
|
}
|
|
19
19
|
if (this.moduleGraph.hasDepChanged()) {
|
|
20
|
-
return
|
|
20
|
+
return 'moduleGraph has changed';
|
|
21
21
|
}
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
@@ -35,11 +35,16 @@ class DepInfo {
|
|
|
35
35
|
}
|
|
36
36
|
writeCache() {
|
|
37
37
|
utils_1.fsExtra.mkdirpSync((0, path_1.dirname)(this.cacheFilePath));
|
|
38
|
-
|
|
39
|
-
(0, fs_1.writeFileSync)(this.cacheFilePath, JSON.stringify({
|
|
38
|
+
const newContent = JSON.stringify({
|
|
40
39
|
cacheDependency: this.cacheDependency,
|
|
41
40
|
moduleGraph: this.moduleGraph.toJSON(),
|
|
42
|
-
}, null, 2)
|
|
41
|
+
}, null, 2);
|
|
42
|
+
if ((0, fs_1.existsSync)(this.cacheFilePath) &&
|
|
43
|
+
(0, fs_1.readFileSync)(this.cacheFilePath, 'utf-8') === newContent) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
utils_1.logger.info('MFSU write cache');
|
|
47
|
+
(0, fs_1.writeFileSync)(this.cacheFilePath, newContent, 'utf-8');
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
50
|
exports.DepInfo = DepInfo;
|
package/dist/mfsu.d.ts
CHANGED
package/dist/mfsu.js
CHANGED
|
@@ -33,12 +33,12 @@ const awaitImport_2 = __importDefault(require("./esbuildHandlers/awaitImport"));
|
|
|
33
33
|
const types_1 = require("./types");
|
|
34
34
|
const makeArray_1 = require("./utils/makeArray");
|
|
35
35
|
const buildDepPlugin_1 = require("./webpackPlugins/buildDepPlugin");
|
|
36
|
-
const writeCachePlugin_1 = require("./webpackPlugins/writeCachePlugin");
|
|
37
36
|
class MFSU {
|
|
38
37
|
constructor(opts) {
|
|
39
38
|
this.alias = {};
|
|
40
39
|
this.externals = [];
|
|
41
40
|
this.depConfig = null;
|
|
41
|
+
this.buildDepsAgain = false;
|
|
42
42
|
this.opts = opts;
|
|
43
43
|
this.opts.mfName = this.opts.mfName || constants_1.DEFAULT_MF_NAME;
|
|
44
44
|
this.opts.tmpBase =
|
|
@@ -162,16 +162,21 @@ promise new Promise(resolve => {
|
|
|
162
162
|
}),
|
|
163
163
|
new buildDepPlugin_1.BuildDepPlugin({
|
|
164
164
|
onCompileDone: () => {
|
|
165
|
-
this.
|
|
166
|
-
|
|
167
|
-
}
|
|
165
|
+
if (this.depBuilder.isBuilding) {
|
|
166
|
+
this.buildDepsAgain = true;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this.buildDeps().catch((e) => {
|
|
170
|
+
utils_1.logger.error(e);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
168
173
|
},
|
|
169
174
|
}),
|
|
170
|
-
new
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}),
|
|
175
|
+
// new WriteCachePlugin({
|
|
176
|
+
// onWriteCache: lodash.debounce(() => {
|
|
177
|
+
// this.depInfo.writeCache();
|
|
178
|
+
// }, 300),
|
|
179
|
+
// }),
|
|
175
180
|
]);
|
|
176
181
|
// ensure topLevelAwait enabled
|
|
177
182
|
utils_1.lodash.set(opts.config, 'experiments.topLevelAwait', true);
|
|
@@ -183,7 +188,8 @@ promise new Promise(resolve => {
|
|
|
183
188
|
}
|
|
184
189
|
buildDeps() {
|
|
185
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
|
|
191
|
+
const shouldBuild = this.depInfo.shouldBuild();
|
|
192
|
+
if (!shouldBuild) {
|
|
187
193
|
utils_1.logger.info('MFSU skip buildDeps');
|
|
188
194
|
return;
|
|
189
195
|
}
|
|
@@ -193,11 +199,20 @@ promise new Promise(resolve => {
|
|
|
193
199
|
cwd: this.opts.cwd,
|
|
194
200
|
mfsu: this,
|
|
195
201
|
});
|
|
196
|
-
utils_1.logger.info(
|
|
202
|
+
utils_1.logger.info(`MFSU buildDeps since ${shouldBuild}`);
|
|
197
203
|
utils_1.logger.debug(deps.map((dep) => dep.file).join(', '));
|
|
198
204
|
yield this.depBuilder.build({
|
|
199
205
|
deps,
|
|
200
206
|
});
|
|
207
|
+
// Write cache
|
|
208
|
+
this.depInfo.writeCache();
|
|
209
|
+
if (this.buildDepsAgain) {
|
|
210
|
+
utils_1.logger.info('MFSU buildDepsAgain');
|
|
211
|
+
this.buildDepsAgain = false;
|
|
212
|
+
this.buildDeps().catch((e) => {
|
|
213
|
+
utils_1.logger.error(e);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
201
216
|
});
|
|
202
217
|
}
|
|
203
218
|
getMiddlewares() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/mfsu",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20220323.1",
|
|
4
4
|
"description": "@umijs/mfsu",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/mfsu#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"test": "jest -c ../../jest.turbo.config.ts"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@umijs/bundler-esbuild": "4.0.0-canary.
|
|
26
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
27
|
-
"@umijs/utils": "4.0.0-canary.
|
|
25
|
+
"@umijs/bundler-esbuild": "4.0.0-canary.20220323.1",
|
|
26
|
+
"@umijs/bundler-utils": "4.0.0-canary.20220323.1",
|
|
27
|
+
"@umijs/utils": "4.0.0-canary.20220323.1",
|
|
28
28
|
"enhanced-resolve": "5.9.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|