@umijs/mfsu 4.0.15 → 4.0.18
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.d.ts +2 -2
- package/dist/dep/dep.js +3 -3
- package/dist/depBuilder/depBuilder.d.ts +4 -0
- package/dist/depBuilder/depBuilder.js +40 -4
- package/dist/mfsu/mfsu.d.ts +3 -1
- package/dist/mfsu/mfsu.js +5 -16
- package/dist/mfsu/strategyStaticAnalyze.js +1 -1
- package/dist/webpackPlugins/buildDepPlugin.js +5 -1
- package/package.json +4 -4
package/dist/dep/dep.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ export declare class Dep {
|
|
|
6
6
|
shortFile: string;
|
|
7
7
|
normalizedFile: string;
|
|
8
8
|
filePath: string;
|
|
9
|
-
|
|
9
|
+
excludeNodeNatives: boolean;
|
|
10
10
|
constructor(opts: {
|
|
11
11
|
file: string;
|
|
12
12
|
version: string;
|
|
13
13
|
cwd: string;
|
|
14
|
-
|
|
14
|
+
excludeNodeNatives: boolean;
|
|
15
15
|
});
|
|
16
16
|
buildExposeContent(): Promise<string>;
|
|
17
17
|
getRealFile(): Promise<string | null>;
|
package/dist/dep/dep.js
CHANGED
|
@@ -69,12 +69,12 @@ var Dep = class {
|
|
|
69
69
|
this.shortFile = this.file;
|
|
70
70
|
this.normalizedFile = this.shortFile.replace(/\//g, "_").replace(/:/g, "_");
|
|
71
71
|
this.filePath = `${import_constants.MF_VA_PREFIX}${this.normalizedFile}.js`;
|
|
72
|
-
this.
|
|
72
|
+
this.excludeNodeNatives = opts.excludeNodeNatives;
|
|
73
73
|
}
|
|
74
74
|
async buildExposeContent() {
|
|
75
75
|
const isNodeNatives = !!process.binding("natives")[this.file];
|
|
76
76
|
if (isNodeNatives) {
|
|
77
|
-
return (0, import_trimFileContent.trimFileContent)(this.
|
|
77
|
+
return (0, import_trimFileContent.trimFileContent)(this.excludeNodeNatives ? `
|
|
78
78
|
const _ = require('${this.file}');
|
|
79
79
|
module.exports = _;
|
|
80
80
|
` : `
|
|
@@ -103,7 +103,7 @@ export * from '${this.file}';
|
|
|
103
103
|
return Object.keys(opts.deps).map((file) => {
|
|
104
104
|
return new Dep(__spreadProps(__spreadValues({}, opts.deps[file]), {
|
|
105
105
|
cwd: opts.cwd,
|
|
106
|
-
|
|
106
|
+
excludeNodeNatives: opts.mfsu.opts.excludeNodeNatives
|
|
107
107
|
}));
|
|
108
108
|
});
|
|
109
109
|
}
|
|
@@ -97,6 +97,38 @@ var DepBuilder = class {
|
|
|
97
97
|
import_utils.logger.event(`[mfsu] compiled with esbuild successfully in ${+new Date() - date} ms`);
|
|
98
98
|
opts.onBuildComplete();
|
|
99
99
|
}
|
|
100
|
+
async buildWithWorker(opts) {
|
|
101
|
+
const worker = this.opts.mfsu.opts.startBuildWorker(opts.deps);
|
|
102
|
+
worker.postMessage(opts.deps);
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
const onMessage = ({
|
|
105
|
+
progress,
|
|
106
|
+
done,
|
|
107
|
+
error
|
|
108
|
+
}) => {
|
|
109
|
+
if (done) {
|
|
110
|
+
opts.onBuildComplete();
|
|
111
|
+
worker.off("message", onMessage);
|
|
112
|
+
resolve();
|
|
113
|
+
}
|
|
114
|
+
if (error) {
|
|
115
|
+
worker.off("message", onMessage);
|
|
116
|
+
opts.onBuildComplete();
|
|
117
|
+
import_utils.logger.error("[MFSU][eager] build failed", error);
|
|
118
|
+
reject(error);
|
|
119
|
+
}
|
|
120
|
+
if (progress) {
|
|
121
|
+
this.opts.mfsu.onProgress(progress);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
worker.on("message", onMessage);
|
|
125
|
+
worker.once("error", (e) => {
|
|
126
|
+
import_utils.logger.error("[MFSU][eager] worker got Error", e);
|
|
127
|
+
opts.onBuildComplete();
|
|
128
|
+
reject(e);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
100
132
|
async build(opts) {
|
|
101
133
|
this.isBuilding = true;
|
|
102
134
|
const onBuildComplete = () => {
|
|
@@ -105,14 +137,18 @@ var DepBuilder = class {
|
|
|
105
137
|
this.completeFns = [];
|
|
106
138
|
};
|
|
107
139
|
try {
|
|
108
|
-
|
|
109
|
-
const newOpts = __spreadProps(__spreadValues({}, opts), {
|
|
140
|
+
const buildOpts = __spreadProps(__spreadValues({}, opts), {
|
|
110
141
|
onBuildComplete
|
|
111
142
|
});
|
|
143
|
+
if (this.opts.mfsu.opts.strategy === "eager") {
|
|
144
|
+
await this.buildWithWorker(buildOpts);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
await this.writeMFFiles({ deps: opts.deps });
|
|
112
148
|
if (this.opts.mfsu.opts.buildDepWithESBuild) {
|
|
113
|
-
await this.buildWithESBuild(
|
|
149
|
+
await this.buildWithESBuild(buildOpts);
|
|
114
150
|
} else {
|
|
115
|
-
await this.buildWithWebpack(
|
|
151
|
+
await this.buildWithWebpack(buildOpts);
|
|
116
152
|
}
|
|
117
153
|
} catch (e) {
|
|
118
154
|
onBuildComplete();
|
package/dist/mfsu/mfsu.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { NextFunction, Request, Response } from '@umijs/bundler-utils/compiled/express';
|
|
2
3
|
import webpack, { Configuration } from 'webpack';
|
|
4
|
+
import type { Worker } from 'worker_threads';
|
|
3
5
|
import { DepBuilder } from '../depBuilder/depBuilder';
|
|
4
6
|
import { DepModule } from '../depInfo';
|
|
5
7
|
import { Mode } from '../types';
|
|
@@ -24,7 +26,7 @@ interface IOpts {
|
|
|
24
26
|
shared?: any;
|
|
25
27
|
remoteName?: string;
|
|
26
28
|
remoteAliases?: string[];
|
|
27
|
-
|
|
29
|
+
startBuildWorker: (dep: any[]) => Worker;
|
|
28
30
|
}
|
|
29
31
|
export declare class MFSU {
|
|
30
32
|
opts: IOpts;
|
package/dist/mfsu/mfsu.js
CHANGED
|
@@ -2,22 +2,8 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
7
|
var __export = (target, all) => {
|
|
22
8
|
for (var name in all)
|
|
23
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -71,7 +57,10 @@ var MFSU = class {
|
|
|
71
57
|
this.opts.getCacheDependency = this.opts.getCacheDependency || (() => ({}));
|
|
72
58
|
this.onProgress = (progress) => {
|
|
73
59
|
var _a, _b;
|
|
74
|
-
this.progress =
|
|
60
|
+
this.progress = {
|
|
61
|
+
...this.progress,
|
|
62
|
+
...progress
|
|
63
|
+
};
|
|
75
64
|
(_b = (_a = this.opts).onMFSUProgress) == null ? void 0 : _b.call(_a, this.progress);
|
|
76
65
|
};
|
|
77
66
|
this.opts.cwd = this.opts.cwd || process.cwd();
|
|
@@ -184,7 +173,7 @@ promise new Promise(resolve => {
|
|
|
184
173
|
// inject this script with the src set to the versioned remoteEntry.js
|
|
185
174
|
document.head.appendChild(script);
|
|
186
175
|
})
|
|
187
|
-
`.trimLeft() : `${mfName}@${
|
|
176
|
+
`.trimLeft() : `${mfName}@${publicPath}${import_constants.REMOTE_FILE_FULL}`
|
|
188
177
|
}
|
|
189
178
|
}),
|
|
190
179
|
new import_buildDepPlugin.BuildDepPlugin(this.strategy.getBuildDepPlugConfig())
|
|
@@ -100,10 +100,10 @@ var StaticAnalyzeStrategy = class {
|
|
|
100
100
|
const mfsu = this.mfsu;
|
|
101
101
|
return {
|
|
102
102
|
beforeCompile: async () => {
|
|
103
|
-
import_utils.logger.event(`[MFSU][eager] start build deps`);
|
|
104
103
|
if (mfsu.depBuilder.isBuilding) {
|
|
105
104
|
mfsu.buildDepsAgain = true;
|
|
106
105
|
} else {
|
|
106
|
+
import_utils.logger.event(`[MFSU][eager] start build deps`);
|
|
107
107
|
this.staticDepInfo.consumeAllProducedEvents();
|
|
108
108
|
mfsu.buildDeps().then(() => {
|
|
109
109
|
mfsu.onProgress({
|
|
@@ -34,7 +34,11 @@ var BuildDepPlugin = class {
|
|
|
34
34
|
});
|
|
35
35
|
compiler.hooks.beforeCompile.tap(PLUGIN_NAME, () => {
|
|
36
36
|
var _a, _b;
|
|
37
|
-
|
|
37
|
+
if (this.opts.beforeCompile) {
|
|
38
|
+
return (_b = (_a = this.opts).beforeCompile) == null ? void 0 : _b.call(_a);
|
|
39
|
+
} else {
|
|
40
|
+
return Promise.resolve();
|
|
41
|
+
}
|
|
38
42
|
});
|
|
39
43
|
compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {
|
|
40
44
|
if (!stats.hasErrors()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/mfsu",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.18",
|
|
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.18",
|
|
27
|
+
"@umijs/bundler-utils": "4.0.18",
|
|
28
|
+
"@umijs/utils": "4.0.18",
|
|
29
29
|
"enhanced-resolve": "5.9.3",
|
|
30
30
|
"is-equal": "^1.6.4"
|
|
31
31
|
},
|