@umijs/mfsu 4.0.28 → 4.0.30
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 +3 -2
- package/dist/mfsu/mfsu.d.ts +1 -1
- package/dist/mfsu/mfsu.js +3 -1
- package/dist/mfsu/strategyStaticAnalyze.d.ts +1 -1
- package/dist/mfsu/strategyStaticAnalyze.js +28 -22
- package/dist/staticDepInfo/staticDepInfo.d.ts +3 -1
- package/dist/staticDepInfo/staticDepInfo.js +0 -1
- package/dist/webpackPlugins/buildDepPlugin.js +2 -0
- package/package.json +4 -4
|
@@ -30,6 +30,7 @@ var import_constants = require("../constants");
|
|
|
30
30
|
var import_depChunkIdPrefixPlugin = require("../webpackPlugins/depChunkIdPrefixPlugin");
|
|
31
31
|
var import_stripSourceMapUrlPlugin = require("../webpackPlugins/stripSourceMapUrlPlugin");
|
|
32
32
|
var import_getESBuildEntry = require("./getESBuildEntry");
|
|
33
|
+
var MF_ENTRY = "mf_index.js";
|
|
33
34
|
var DepBuilder = class {
|
|
34
35
|
constructor(opts) {
|
|
35
36
|
this.completeFns = [];
|
|
@@ -154,13 +155,13 @@ var DepBuilder = class {
|
|
|
154
155
|
const content = await dep.buildExposeContent();
|
|
155
156
|
(0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, dep.filePath), content, "utf-8");
|
|
156
157
|
}
|
|
157
|
-
(0, import_fs.writeFileSync)((0, import_path.join)(tmpBase,
|
|
158
|
+
(0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, MF_ENTRY), '"\u{1F61B}"', "utf-8");
|
|
158
159
|
}
|
|
159
160
|
getWebpackConfig(opts) {
|
|
160
161
|
var _a, _b;
|
|
161
162
|
const mfName = this.opts.mfsu.opts.mfName;
|
|
162
163
|
const depConfig = import_utils.lodash.cloneDeep(this.opts.mfsu.depConfig);
|
|
163
|
-
depConfig.entry = (0, import_path.join)(this.opts.mfsu.opts.tmpBase,
|
|
164
|
+
depConfig.entry = (0, import_path.join)(this.opts.mfsu.opts.tmpBase, MF_ENTRY);
|
|
164
165
|
depConfig.output.path = this.opts.mfsu.opts.tmpBase;
|
|
165
166
|
depConfig.output.publicPath = "auto";
|
|
166
167
|
depConfig.devtool = false;
|
package/dist/mfsu/mfsu.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare class MFSU {
|
|
|
47
47
|
depConfig: Configuration;
|
|
48
48
|
}): Promise<void>;
|
|
49
49
|
buildDeps(): Promise<void>;
|
|
50
|
-
getMiddlewares(): ((req: Request, res: Response, next: NextFunction) => void)[];
|
|
50
|
+
getMiddlewares(): (((req: Request, res: Response, next: NextFunction) => void) | import("@umijs/bundler-utils/compiled/express/serve-static").RequestHandler<Response<any, Record<string, any>>>)[];
|
|
51
51
|
getBabelPlugins(): any[][];
|
|
52
52
|
getEsbuildLoaderHandler(): any[];
|
|
53
53
|
getCacheFilePath(): string;
|
package/dist/mfsu/mfsu.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(mfsu_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(mfsu_exports);
|
|
28
28
|
var import_bundler_utils = require("@umijs/bundler-utils");
|
|
29
|
+
var import_express = __toESM(require("@umijs/bundler-utils/compiled/express"));
|
|
29
30
|
var import_utils = require("@umijs/utils");
|
|
30
31
|
var import_assert = __toESM(require("assert"));
|
|
31
32
|
var import_fs = require("fs");
|
|
@@ -244,7 +245,8 @@ promise new Promise(resolve => {
|
|
|
244
245
|
} else {
|
|
245
246
|
next();
|
|
246
247
|
}
|
|
247
|
-
}
|
|
248
|
+
},
|
|
249
|
+
import_express.default.static(this.opts.tmpBase)
|
|
248
250
|
];
|
|
249
251
|
}
|
|
250
252
|
getBabelPlugins() {
|
|
@@ -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;
|
|
@@ -122,21 +122,30 @@ var StaticAnalyzeStrategy = class {
|
|
|
122
122
|
},
|
|
123
123
|
onFileChange: async (c) => {
|
|
124
124
|
import_utils.logger.debug("webpack found changes modified:", c.modifiedFiles, "removed:", c.removedFiles);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
const fileEvents = [
|
|
126
|
+
...this.staticDepInfo.opts.srcCodeCache.replayChangeEvents(),
|
|
127
|
+
...extractJSCodeFiles(c.modifiedFiles).map((f) => {
|
|
128
|
+
return {
|
|
129
|
+
event: "change",
|
|
130
|
+
path: f
|
|
131
|
+
};
|
|
132
|
+
}),
|
|
133
|
+
...extractJSCodeFiles(c.removedFiles).map((f) => {
|
|
134
|
+
return {
|
|
135
|
+
event: "unlink",
|
|
136
|
+
path: f
|
|
137
|
+
};
|
|
138
|
+
})
|
|
139
|
+
];
|
|
140
|
+
import_utils.logger.debug("all file events", fileEvents);
|
|
141
|
+
if (fileEvents.length === 0) {
|
|
129
142
|
return;
|
|
130
143
|
}
|
|
131
144
|
const start = Date.now();
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (Date.now() - start > 5e3) {
|
|
137
|
-
import_utils.logger.warn("webpack wait mfsu deps too long");
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
145
|
+
try {
|
|
146
|
+
await this.staticDepInfo.opts.srcCodeCache.handleFileChangeEvents(fileEvents);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
import_utils.logger.error("MFSU[eager] analyze dependencies failed with error", e);
|
|
140
149
|
}
|
|
141
150
|
import_utils.logger.debug(`webpack waited ${Date.now() - start} ms`);
|
|
142
151
|
},
|
|
@@ -151,21 +160,18 @@ var StaticAnalyzeStrategy = class {
|
|
|
151
160
|
this.staticDepInfo.snapshot();
|
|
152
161
|
}
|
|
153
162
|
};
|
|
154
|
-
function sleep(ms) {
|
|
155
|
-
return new Promise((resolve) => {
|
|
156
|
-
setTimeout(() => {
|
|
157
|
-
resolve();
|
|
158
|
-
}, ms);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
163
|
var REG_CODE_EXT = /\.(jsx|js|ts|tsx)$/;
|
|
162
|
-
function
|
|
164
|
+
function extractJSCodeFiles(files) {
|
|
165
|
+
const jsFiles = [];
|
|
166
|
+
if (!files) {
|
|
167
|
+
return jsFiles;
|
|
168
|
+
}
|
|
163
169
|
for (let file of files.values()) {
|
|
164
170
|
if (REG_CODE_EXT.test(file)) {
|
|
165
|
-
|
|
171
|
+
jsFiles.push(file);
|
|
166
172
|
}
|
|
167
173
|
}
|
|
168
|
-
return
|
|
174
|
+
return jsFiles;
|
|
169
175
|
}
|
|
170
176
|
// Annotate the CommonJS export names for ESM import in node:
|
|
171
177
|
0 && (module.exports = {
|
|
@@ -13,6 +13,8 @@ declare type MergedCodeInfo = {
|
|
|
13
13
|
declare type AutoUpdateSrcCodeCache = {
|
|
14
14
|
register(listener: (info: MergedCodeInfo) => void): void;
|
|
15
15
|
getMergedCode(): MergedCodeInfo;
|
|
16
|
+
handleFileChangeEvents(events: FileChangeEvent[]): void;
|
|
17
|
+
replayChangeEvents(): FileChangeEvent[];
|
|
16
18
|
};
|
|
17
19
|
interface IOpts {
|
|
18
20
|
mfsu: MFSU;
|
|
@@ -23,7 +25,7 @@ export declare type Match = ReturnType<typeof checkMatch> & {
|
|
|
23
25
|
version: string;
|
|
24
26
|
};
|
|
25
27
|
export declare class StaticDepInfo {
|
|
26
|
-
|
|
28
|
+
opts: IOpts;
|
|
27
29
|
private readonly cacheFilePath;
|
|
28
30
|
private mfsu;
|
|
29
31
|
private readonly include;
|
|
@@ -44,7 +44,6 @@ var StaticDepInfo = class {
|
|
|
44
44
|
this.cacheFilePath = (0, import_path.join)(this.opts.mfsu.opts.tmpBase, "MFSU_CACHE_v4.json");
|
|
45
45
|
this.cwd = this.mfsu.opts.cwd;
|
|
46
46
|
opts.srcCodeCache.register((info) => {
|
|
47
|
-
this.produced.push({ changes: info.events });
|
|
48
47
|
this.currentDep = this._getDependencies(info.code, info.imports);
|
|
49
48
|
});
|
|
50
49
|
this.runtimeSimulations = [];
|
|
@@ -22,6 +22,7 @@ __export(buildDepPlugin_exports, {
|
|
|
22
22
|
BuildDepPlugin: () => BuildDepPlugin
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(buildDepPlugin_exports);
|
|
25
|
+
var import_utils = require("@umijs/utils");
|
|
25
26
|
var PLUGIN_NAME = "MFSUBuildDeps";
|
|
26
27
|
var BuildDepPlugin = class {
|
|
27
28
|
constructor(opts) {
|
|
@@ -30,6 +31,7 @@ var BuildDepPlugin = class {
|
|
|
30
31
|
apply(compiler) {
|
|
31
32
|
compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, (c) => {
|
|
32
33
|
var _a, _b;
|
|
34
|
+
import_utils.logger.debug("webpack watched change", "modified: ", c.modifiedFiles, "removed: ", c.removedFiles);
|
|
33
35
|
return ((_b = (_a = this.opts).onFileChange) == null ? void 0 : _b.call(_a, c)) || Promise.resolve();
|
|
34
36
|
});
|
|
35
37
|
compiler.hooks.beforeCompile.tap(PLUGIN_NAME, () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/mfsu",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.30",
|
|
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.30",
|
|
27
|
+
"@umijs/bundler-utils": "4.0.30",
|
|
28
|
+
"@umijs/utils": "4.0.30",
|
|
29
29
|
"enhanced-resolve": "5.9.3",
|
|
30
30
|
"is-equal": "^1.6.4"
|
|
31
31
|
},
|