@umijs/mfsu 4.0.25 → 4.0.26
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/mfsu/mfsu.d.ts +1 -1
- package/dist/mfsu/mfsu.js +1 -1
- package/dist/mfsu/strategyStaticAnalyze.d.ts +2 -1
- package/dist/mfsu/strategyStaticAnalyze.js +4 -1
- package/dist/staticDepInfo/staticDepInfo.d.ts +1 -0
- package/dist/staticDepInfo/staticDepInfo.js +9 -18
- package/dist/utils/webpackUtils.d.ts +2 -0
- package/dist/utils/webpackUtils.js +47 -0
- package/package.json +4 -4
package/dist/mfsu/mfsu.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export declare class MFSU {
|
|
|
53
53
|
getCacheFilePath(): string;
|
|
54
54
|
}
|
|
55
55
|
export interface IMFSUStrategy {
|
|
56
|
-
init(): void;
|
|
56
|
+
init(webpackConfig: Configuration): void;
|
|
57
57
|
shouldBuild(): string | boolean;
|
|
58
58
|
getBabelPlugin(): any[];
|
|
59
59
|
getBuildDepPlugConfig(): IBuildDepPluginOpts;
|
package/dist/mfsu/mfsu.js
CHANGED
|
@@ -181,7 +181,7 @@ promise new Promise(resolve => {
|
|
|
181
181
|
]);
|
|
182
182
|
import_utils.lodash.set(opts.config, "experiments.topLevelAwait", true);
|
|
183
183
|
this.depConfig = opts.depConfig;
|
|
184
|
-
this.strategy.init();
|
|
184
|
+
this.strategy.init(opts.config);
|
|
185
185
|
}
|
|
186
186
|
async buildDeps() {
|
|
187
187
|
try {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IBuildDepPluginOpts } from '../webpackPlugins/buildDepPlugin';
|
|
2
2
|
import type { IMFSUStrategy, MFSU } from './mfsu';
|
|
3
|
+
import type { Configuration } from 'webpack';
|
|
3
4
|
export declare class StaticAnalyzeStrategy implements IMFSUStrategy {
|
|
4
5
|
private readonly mfsu;
|
|
5
6
|
private staticDepInfo;
|
|
@@ -7,7 +8,7 @@ export declare class StaticAnalyzeStrategy implements IMFSUStrategy {
|
|
|
7
8
|
mfsu: MFSU;
|
|
8
9
|
srcCodeCache: any;
|
|
9
10
|
});
|
|
10
|
-
init(): void;
|
|
11
|
+
init(webpackConfig: Configuration): void;
|
|
11
12
|
getDepModules(): Record<string, {
|
|
12
13
|
file: string;
|
|
13
14
|
version: string;
|
|
@@ -29,6 +29,7 @@ var import_utils = require("@umijs/utils");
|
|
|
29
29
|
var import_checkMatch = require("../babelPlugins/awaitImport/checkMatch");
|
|
30
30
|
var import_MFImport = __toESM(require("../babelPlugins/awaitImport/MFImport"));
|
|
31
31
|
var import_staticDepInfo = require("../staticDepInfo/staticDepInfo");
|
|
32
|
+
var import_webpackUtils = require("../utils/webpackUtils");
|
|
32
33
|
var StaticAnalyzeStrategy = class {
|
|
33
34
|
constructor({ mfsu, srcCodeCache }) {
|
|
34
35
|
this.mfsu = mfsu;
|
|
@@ -37,7 +38,9 @@ var StaticAnalyzeStrategy = class {
|
|
|
37
38
|
srcCodeCache
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
init() {
|
|
41
|
+
init(webpackConfig) {
|
|
42
|
+
const config = (0, import_webpackUtils.extractBabelPluginImportOptions)(webpackConfig);
|
|
43
|
+
this.staticDepInfo.setBabelPluginImportConfig(config);
|
|
41
44
|
this.staticDepInfo.init();
|
|
42
45
|
}
|
|
43
46
|
getDepModules() {
|
|
@@ -46,24 +46,7 @@ var StaticDepInfo = class {
|
|
|
46
46
|
this.produced.push({ changes: info.events });
|
|
47
47
|
this.currentDep = this._getDependencies(info.code, info.imports);
|
|
48
48
|
});
|
|
49
|
-
this.runtimeSimulations = [
|
|
50
|
-
{
|
|
51
|
-
packageName: "antd",
|
|
52
|
-
handleImports: (0, import_babel_plugin_import.default)({
|
|
53
|
-
libraryName: "antd",
|
|
54
|
-
style: true,
|
|
55
|
-
libraryDirectory: "es"
|
|
56
|
-
})
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
packageName: "@alipay/bigfish/antd",
|
|
60
|
-
handleImports: (0, import_babel_plugin_import.default)({
|
|
61
|
-
libraryName: "@alipay/bigfish/antd",
|
|
62
|
-
style: true,
|
|
63
|
-
libraryDirectory: "es"
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
];
|
|
49
|
+
this.runtimeSimulations = [];
|
|
67
50
|
}
|
|
68
51
|
getProducedEvent() {
|
|
69
52
|
return this.produced;
|
|
@@ -233,6 +216,14 @@ var StaticDepInfo = class {
|
|
|
233
216
|
}
|
|
234
217
|
async allRuntimeHelpers() {
|
|
235
218
|
}
|
|
219
|
+
setBabelPluginImportConfig(config) {
|
|
220
|
+
for (const [key, c] of config.entries()) {
|
|
221
|
+
this.runtimeSimulations.push({
|
|
222
|
+
packageName: key,
|
|
223
|
+
handleImports: (0, import_babel_plugin_import.default)(c)
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
236
227
|
};
|
|
237
228
|
// Annotate the CommonJS export names for ESM import in node:
|
|
238
229
|
0 && (module.exports = {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/webpackUtils.ts
|
|
20
|
+
var webpackUtils_exports = {};
|
|
21
|
+
__export(webpackUtils_exports, {
|
|
22
|
+
extractBabelPluginImportOptions: () => extractBabelPluginImportOptions
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(webpackUtils_exports);
|
|
25
|
+
var import_utils = require("@umijs/utils");
|
|
26
|
+
var { property, compact, flatMap } = import_utils.lodash;
|
|
27
|
+
function extractBabelPluginImportOptions(webpackConfig) {
|
|
28
|
+
var _a;
|
|
29
|
+
const rules = ((_a = webpackConfig.module) == null ? void 0 : _a.rules) || [];
|
|
30
|
+
const uses = compact(flatMap(rules, property(["use"]))).filter((u) => {
|
|
31
|
+
var _a2;
|
|
32
|
+
return ((_a2 = u == null ? void 0 : u.loader) == null ? void 0 : _a2.indexOf("babel-loader")) >= 0;
|
|
33
|
+
});
|
|
34
|
+
const pluginConfigs = compact(flatMap(uses, property(["options", "plugins"]))).filter((p) => {
|
|
35
|
+
var _a2, _b;
|
|
36
|
+
return Array.isArray(p) && ((_b = (_a2 = p[0]) == null ? void 0 : _a2.indexOf) == null ? void 0 : _b.call(_a2, "babel-plugin-import")) >= 0;
|
|
37
|
+
});
|
|
38
|
+
const configs = /* @__PURE__ */ new Map();
|
|
39
|
+
for (const c of pluginConfigs) {
|
|
40
|
+
!configs.has(c[1].libraryName) && configs.set(c[1].libraryName, c[1]);
|
|
41
|
+
}
|
|
42
|
+
return configs;
|
|
43
|
+
}
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
extractBabelPluginImportOptions
|
|
47
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/mfsu",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.26",
|
|
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.26",
|
|
27
|
+
"@umijs/bundler-utils": "4.0.26",
|
|
28
|
+
"@umijs/utils": "4.0.26",
|
|
29
29
|
"enhanced-resolve": "5.9.3",
|
|
30
30
|
"is-equal": "^1.6.4"
|
|
31
31
|
},
|