@umijs/mfsu 4.0.0-beta.16 → 4.0.0-beta.17
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 +1 -0
- package/dist/depInfo.js +2 -0
- package/dist/mfsu.js +29 -6
- package/dist/moduleGraph.d.ts +1 -0
- package/dist/moduleGraph.js +4 -1
- package/package.json +4 -4
|
@@ -98,6 +98,7 @@ class DepBuilder {
|
|
|
98
98
|
writeMFFiles(opts) {
|
|
99
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
100
|
const tmpBase = this.opts.mfsu.opts.tmpBase;
|
|
101
|
+
utils_1.fsExtra.mkdirpSync(tmpBase);
|
|
101
102
|
// expose files
|
|
102
103
|
for (const dep of opts.deps) {
|
|
103
104
|
const content = yield dep.buildExposeContent();
|
package/dist/depInfo.js
CHANGED
|
@@ -27,6 +27,7 @@ class DepInfo {
|
|
|
27
27
|
}
|
|
28
28
|
loadCache() {
|
|
29
29
|
if ((0, fs_1.existsSync)(this.cacheFilePath)) {
|
|
30
|
+
utils_1.logger.info('MFSU restore cache');
|
|
30
31
|
const { cacheDependency, moduleGraph } = JSON.parse((0, fs_1.readFileSync)(this.cacheFilePath, 'utf-8'));
|
|
31
32
|
this.cacheDependency = cacheDependency;
|
|
32
33
|
this.moduleGraph.restore(moduleGraph);
|
|
@@ -34,6 +35,7 @@ class DepInfo {
|
|
|
34
35
|
}
|
|
35
36
|
writeCache() {
|
|
36
37
|
utils_1.fsExtra.mkdirpSync((0, path_1.dirname)(this.cacheFilePath));
|
|
38
|
+
utils_1.logger.info('MFSU write cache');
|
|
37
39
|
(0, fs_1.writeFileSync)(this.cacheFilePath, JSON.stringify({
|
|
38
40
|
cacheDependency: this.cacheDependency,
|
|
39
41
|
moduleGraph: this.moduleGraph.toJSON(),
|
package/dist/mfsu.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.MFSU = void 0;
|
|
16
16
|
const bundler_utils_1 = require("@umijs/bundler-utils");
|
|
17
17
|
const utils_1 = require("@umijs/utils");
|
|
18
|
+
const assert_1 = __importDefault(require("assert"));
|
|
18
19
|
const fs_1 = require("fs");
|
|
19
20
|
const path_1 = require("path");
|
|
20
21
|
const mrmime_1 = require("../compiled/mrmime");
|
|
@@ -66,13 +67,29 @@ class MFSU {
|
|
|
66
67
|
// entry
|
|
67
68
|
const entry = {};
|
|
68
69
|
const virtualModules = {};
|
|
69
|
-
|
|
70
|
+
// ensure entry object type
|
|
71
|
+
const entryObject = utils_1.lodash.isString(opts.config.entry)
|
|
72
|
+
? { default: [opts.config.entry] }
|
|
73
|
+
: opts.config.entry;
|
|
74
|
+
(0, assert_1.default)(utils_1.lodash.isPlainObject(entryObject), `webpack config 'entry' value must be a string or an object.`);
|
|
75
|
+
for (const key of Object.keys(entryObject)) {
|
|
70
76
|
const virtualPath = `./mfsu-virtual-entry/${key}.js`;
|
|
71
77
|
const virtualContent = [];
|
|
72
78
|
let index = 1;
|
|
73
79
|
let hasDefaultExport = false;
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
const entryFiles = utils_1.lodash.isArray(entryObject[key])
|
|
81
|
+
? entryObject[key]
|
|
82
|
+
: [entryObject[key]];
|
|
83
|
+
for (let entry of entryFiles) {
|
|
84
|
+
// ensure entry is a file
|
|
85
|
+
if ((0, fs_1.statSync)(entry).isDirectory()) {
|
|
86
|
+
const realEntry = (0, utils_1.tryPaths)([
|
|
87
|
+
(0, path_1.join)(entry, 'index.tsx'),
|
|
88
|
+
(0, path_1.join)(entry, 'index.ts'),
|
|
89
|
+
]);
|
|
90
|
+
(0, assert_1.default)(realEntry, `entry file not found, please configure the specific entry path. (e.g. 'src/index.tsx')`);
|
|
91
|
+
entry = realEntry;
|
|
92
|
+
}
|
|
76
93
|
const content = (0, fs_1.readFileSync)(entry, 'utf-8');
|
|
77
94
|
const [_imports, exports] = yield (0, bundler_utils_1.parseModule)({ content, path: entry });
|
|
78
95
|
if (exports.length) {
|
|
@@ -149,11 +166,13 @@ promise new Promise(resolve => {
|
|
|
149
166
|
},
|
|
150
167
|
}),
|
|
151
168
|
new writeCachePlugin_1.WriteCachePlugin({
|
|
152
|
-
onWriteCache: () => {
|
|
169
|
+
onWriteCache: utils_1.lodash.debounce(() => {
|
|
153
170
|
this.depInfo.writeCache();
|
|
154
|
-
},
|
|
171
|
+
}, 300),
|
|
155
172
|
}),
|
|
156
173
|
]);
|
|
174
|
+
// ensure topLevelAwait enabled
|
|
175
|
+
utils_1.lodash.set(opts.config, 'experiments.topLevelAwait', true);
|
|
157
176
|
/**
|
|
158
177
|
* depConfig
|
|
159
178
|
*/
|
|
@@ -162,14 +181,18 @@ promise new Promise(resolve => {
|
|
|
162
181
|
}
|
|
163
182
|
buildDeps() {
|
|
164
183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
-
if (!this.depInfo.shouldBuild())
|
|
184
|
+
if (!this.depInfo.shouldBuild()) {
|
|
185
|
+
utils_1.logger.info('MFSU skip buildDeps');
|
|
166
186
|
return;
|
|
187
|
+
}
|
|
167
188
|
this.depInfo.snapshot();
|
|
168
189
|
const deps = dep_1.Dep.buildDeps({
|
|
169
190
|
deps: this.depInfo.moduleGraph.depSnapshotModules,
|
|
170
191
|
cwd: this.opts.cwd,
|
|
171
192
|
mfsu: this,
|
|
172
193
|
});
|
|
194
|
+
utils_1.logger.info('MFSU buildDeps');
|
|
195
|
+
utils_1.logger.debug(deps.map((dep) => dep.file).join(', '));
|
|
173
196
|
yield this.depBuilder.build({
|
|
174
197
|
deps,
|
|
175
198
|
});
|
package/dist/moduleGraph.d.ts
CHANGED
package/dist/moduleGraph.js
CHANGED
|
@@ -38,8 +38,10 @@ class ModuleGraph {
|
|
|
38
38
|
}
|
|
39
39
|
if (info.isRoot)
|
|
40
40
|
mod.isRoot = true;
|
|
41
|
-
if (importer)
|
|
41
|
+
if (importer) {
|
|
42
42
|
mod.importers.add(importer);
|
|
43
|
+
importer.importedModules.add(mod);
|
|
44
|
+
}
|
|
43
45
|
mod.isDependency = isDependency;
|
|
44
46
|
if (info.version !== undefined) {
|
|
45
47
|
mod.version = info.version;
|
|
@@ -73,6 +75,7 @@ class ModuleGraph {
|
|
|
73
75
|
importedModules: Array.from(value.importedModules).map((item) => item.file),
|
|
74
76
|
};
|
|
75
77
|
if (value.isRoot) {
|
|
78
|
+
fileModules[key].isRoot = true;
|
|
76
79
|
roots.push(key);
|
|
77
80
|
}
|
|
78
81
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/mfsu",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.17",
|
|
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",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"dev": "pnpm build -- --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@umijs/bundler-esbuild": "4.0.0-beta.
|
|
25
|
-
"@umijs/bundler-utils": "4.0.0-beta.
|
|
26
|
-
"@umijs/utils": "4.0.0-beta.
|
|
24
|
+
"@umijs/bundler-esbuild": "4.0.0-beta.17",
|
|
25
|
+
"@umijs/bundler-utils": "4.0.0-beta.17",
|
|
26
|
+
"@umijs/utils": "4.0.0-beta.17"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/express": "4.17.13",
|