@umijs/mfsu 4.0.7 → 4.0.10
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/compiled/is-absolute-url/LICENSE +9 -0
- package/compiled/is-absolute-url/index.d.ts +22 -0
- package/compiled/is-absolute-url/index.js +1 -0
- package/compiled/is-absolute-url/package.json +1 -0
- package/dist/babelPlugins/awaitImport/MFImport.js +59 -66
- package/dist/babelPlugins/awaitImport/awaitImport.d.ts +1 -1
- package/dist/babelPlugins/awaitImport/awaitImport.js +103 -117
- package/dist/babelPlugins/awaitImport/checkMatch.js +131 -119
- package/dist/babelPlugins/awaitImport/getAliasedPath.js +54 -35
- package/dist/babelPlugins/awaitImport/getRealPath.js +42 -21
- package/dist/babelPlugins/awaitImport/isExternals.js +55 -26
- package/dist/babelPlugins/awaitImport/parseSpecifiers.js +51 -52
- package/dist/constants.js +47 -10
- package/dist/dep/dep.js +112 -83
- package/dist/dep/getCJSExports.js +60 -53
- package/dist/dep/getExposeFromContent.js +71 -59
- package/dist/dep/getModuleExports.js +58 -32
- package/dist/depBuilder/depBuilder.js +191 -158
- package/dist/depBuilder/getESBuildEntry.js +35 -12
- package/dist/depInfo.js +75 -53
- package/dist/esbuildHandlers/autoCssModules.js +43 -22
- package/dist/esbuildHandlers/awaitImport/index.js +82 -70
- package/dist/index.js +32 -22
- package/dist/loader/esbuild.js +87 -35
- package/dist/mfsu/mfsu.d.ts +5 -1
- package/dist/mfsu/mfsu.js +236 -257
- package/dist/mfsu/strategyCompileTime.js +131 -99
- package/dist/mfsu/strategyStaticAnalyze.js +151 -115
- package/dist/moduleGraph.js +227 -186
- package/dist/staticDepInfo/importParser.js +28 -6
- package/dist/staticDepInfo/simulations/babel-plugin-import.js +99 -91
- package/dist/staticDepInfo/staticDepInfo.js +239 -197
- package/dist/types.js +33 -8
- package/dist/utils/makeArray.js +29 -5
- package/dist/utils/trimFileContent.js +29 -5
- package/dist/webpackPlugins/buildDepPlugin.js +49 -25
- package/dist/webpackPlugins/depChunkIdPrefixPlugin.js +44 -19
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +46 -27
- package/dist/webpackPlugins/writeCachePlugin.js +39 -15
- package/package.json +8 -6
|
@@ -1,100 +1,132 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
10
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/mfsu/strategyCompileTime.ts
|
|
23
|
+
var strategyCompileTime_exports = {};
|
|
24
|
+
__export(strategyCompileTime_exports, {
|
|
25
|
+
StrategyCompileTime: () => StrategyCompileTime
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(strategyCompileTime_exports);
|
|
28
|
+
var import_utils = require("@umijs/utils");
|
|
29
|
+
var import_awaitImport = __toESM(require("../babelPlugins/awaitImport/awaitImport"));
|
|
30
|
+
var import_getRealPath = require("../babelPlugins/awaitImport/getRealPath");
|
|
31
|
+
var import_dep = require("../dep/dep");
|
|
32
|
+
var import_depInfo = require("../depInfo");
|
|
33
|
+
var StrategyCompileTime = class {
|
|
34
|
+
constructor({ mfsu }) {
|
|
35
|
+
this.mfsu = mfsu;
|
|
36
|
+
this.depInfo = new import_depInfo.DepInfo({ mfsu });
|
|
37
|
+
}
|
|
38
|
+
getDepModules() {
|
|
39
|
+
return this.depInfo.getDepModules();
|
|
40
|
+
}
|
|
41
|
+
getCacheFilePath() {
|
|
42
|
+
return this.depInfo.getCacheFilePath();
|
|
43
|
+
}
|
|
44
|
+
init() {
|
|
45
|
+
}
|
|
46
|
+
shouldBuild() {
|
|
47
|
+
return this.depInfo.shouldBuild();
|
|
48
|
+
}
|
|
49
|
+
loadCache() {
|
|
50
|
+
this.depInfo.loadCache();
|
|
51
|
+
}
|
|
52
|
+
writeCache() {
|
|
53
|
+
this.depInfo.writeCache();
|
|
54
|
+
}
|
|
55
|
+
refresh() {
|
|
56
|
+
this.depInfo.snapshot();
|
|
57
|
+
}
|
|
58
|
+
getBabelPlugin() {
|
|
59
|
+
return [import_awaitImport.default, this.getAwaitImportCollectOpts()];
|
|
60
|
+
}
|
|
61
|
+
getBuildDepPlugConfig() {
|
|
62
|
+
const mfsu = this.mfsu;
|
|
63
|
+
return {
|
|
64
|
+
onCompileDone: () => {
|
|
65
|
+
if (mfsu.depBuilder.isBuilding) {
|
|
66
|
+
mfsu.buildDepsAgain = true;
|
|
67
|
+
} else {
|
|
68
|
+
mfsu.buildDeps().then(() => {
|
|
69
|
+
mfsu.onProgress({
|
|
70
|
+
done: true
|
|
71
|
+
});
|
|
72
|
+
}).catch((e) => {
|
|
73
|
+
import_utils.printHelp.runtime(e);
|
|
74
|
+
mfsu.onProgress({
|
|
75
|
+
done: true
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
getAwaitImportCollectOpts() {
|
|
83
|
+
const mfsuOpts = this.mfsu.opts;
|
|
84
|
+
const mfsu = this.mfsu;
|
|
85
|
+
const userUnMatches = mfsuOpts.unMatchLibs || [];
|
|
86
|
+
const sharedUnMatches = Object.keys(mfsuOpts.shared || {});
|
|
87
|
+
const remoteAliasUnMatches = (mfsuOpts.remoteAliases || []).map((str) => new RegExp(`^${str}`));
|
|
88
|
+
const unMatches = [
|
|
89
|
+
...userUnMatches,
|
|
90
|
+
...sharedUnMatches,
|
|
91
|
+
...remoteAliasUnMatches
|
|
92
|
+
];
|
|
93
|
+
return {
|
|
94
|
+
onTransformDeps: () => {
|
|
95
|
+
},
|
|
96
|
+
onCollect: ({
|
|
97
|
+
file,
|
|
98
|
+
data
|
|
99
|
+
}) => {
|
|
100
|
+
this.depInfo.moduleGraph.onFileChange({
|
|
101
|
+
file,
|
|
102
|
+
deps: [
|
|
103
|
+
...Array.from(data.matched).map((item) => ({
|
|
104
|
+
file: item.sourceValue,
|
|
105
|
+
isDependency: true,
|
|
106
|
+
version: import_dep.Dep.getDepVersion({
|
|
107
|
+
dep: item.sourceValue,
|
|
108
|
+
cwd: mfsuOpts.cwd
|
|
109
|
+
})
|
|
110
|
+
})),
|
|
111
|
+
...Array.from(data.unMatched).map((item) => ({
|
|
112
|
+
file: (0, import_getRealPath.getRealPath)({
|
|
113
|
+
file,
|
|
114
|
+
dep: item.sourceValue
|
|
115
|
+
}),
|
|
116
|
+
isDependency: false
|
|
117
|
+
}))
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
exportAllMembers: mfsuOpts.exportAllMembers,
|
|
122
|
+
unMatchLibs: unMatches,
|
|
123
|
+
remoteName: mfsuOpts.mfName,
|
|
124
|
+
alias: mfsu.alias,
|
|
125
|
+
externals: mfsu.externals
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
+
0 && (module.exports = {
|
|
131
|
+
StrategyCompileTime
|
|
132
|
+
});
|
|
@@ -1,121 +1,157 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
10
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/mfsu/strategyStaticAnalyze.ts
|
|
23
|
+
var strategyStaticAnalyze_exports = {};
|
|
24
|
+
__export(strategyStaticAnalyze_exports, {
|
|
25
|
+
StaticAnalyzeStrategy: () => StaticAnalyzeStrategy
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(strategyStaticAnalyze_exports);
|
|
28
|
+
var import_utils = require("@umijs/utils");
|
|
29
|
+
var import_checkMatch = require("../babelPlugins/awaitImport/checkMatch");
|
|
30
|
+
var import_MFImport = __toESM(require("../babelPlugins/awaitImport/MFImport"));
|
|
31
|
+
var import_staticDepInfo = require("../staticDepInfo/staticDepInfo");
|
|
32
|
+
var StaticAnalyzeStrategy = class {
|
|
33
|
+
constructor({ mfsu, srcCodeCache }) {
|
|
34
|
+
this.mfsu = mfsu;
|
|
35
|
+
this.staticDepInfo = new import_staticDepInfo.StaticDepInfo({
|
|
36
|
+
mfsu,
|
|
37
|
+
srcCodeCache
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
init() {
|
|
41
|
+
this.staticDepInfo.init();
|
|
42
|
+
}
|
|
43
|
+
getDepModules() {
|
|
44
|
+
return this.staticDepInfo.getDepModules();
|
|
45
|
+
}
|
|
46
|
+
getCacheFilePath() {
|
|
47
|
+
return this.staticDepInfo.getCacheFilePath();
|
|
48
|
+
}
|
|
49
|
+
shouldBuild() {
|
|
50
|
+
return this.staticDepInfo.shouldBuild();
|
|
51
|
+
}
|
|
52
|
+
writeCache() {
|
|
53
|
+
this.staticDepInfo.writeCache();
|
|
54
|
+
}
|
|
55
|
+
getBabelPlugin() {
|
|
56
|
+
return [import_MFImport.default, this.getMfImportOpts()];
|
|
57
|
+
}
|
|
58
|
+
getMfImportOpts() {
|
|
59
|
+
const mfsu = this.mfsu;
|
|
60
|
+
const mfsuOpts = this.mfsu.opts;
|
|
61
|
+
const userUnMatches = mfsuOpts.unMatchLibs || [];
|
|
62
|
+
const sharedUnMatches = Object.keys(mfsuOpts.shared || {});
|
|
63
|
+
const remoteAliasUnMatches = (mfsuOpts.remoteAliases || []).map((str) => new RegExp(`^${str}`));
|
|
64
|
+
const unMatches = [
|
|
65
|
+
...userUnMatches,
|
|
66
|
+
...sharedUnMatches,
|
|
67
|
+
...remoteAliasUnMatches
|
|
68
|
+
];
|
|
69
|
+
return {
|
|
70
|
+
resolveImportSource: (source) => {
|
|
71
|
+
const match = (0, import_checkMatch.checkMatch)({
|
|
72
|
+
value: source,
|
|
73
|
+
filename: "_.js",
|
|
74
|
+
opts: {
|
|
53
75
|
exportAllMembers: mfsuOpts.exportAllMembers,
|
|
54
|
-
unMatchLibs:
|
|
76
|
+
unMatchLibs: unMatches,
|
|
55
77
|
remoteName: mfsuOpts.mfName,
|
|
56
78
|
alias: mfsu.alias,
|
|
57
|
-
externals: mfsu.externals
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
79
|
+
externals: mfsu.externals
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
if (!match.isMatch) {
|
|
83
|
+
return source;
|
|
84
|
+
}
|
|
85
|
+
const depMat = this.staticDepInfo.getDependencies();
|
|
86
|
+
const m = depMat[match.value];
|
|
87
|
+
if (m) {
|
|
88
|
+
return m.replaceValue;
|
|
89
|
+
}
|
|
90
|
+
return match.value;
|
|
91
|
+
},
|
|
92
|
+
exportAllMembers: mfsuOpts.exportAllMembers,
|
|
93
|
+
unMatchLibs: mfsuOpts.unMatchLibs,
|
|
94
|
+
remoteName: mfsuOpts.mfName,
|
|
95
|
+
alias: mfsu.alias,
|
|
96
|
+
externals: mfsu.externals
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
getBuildDepPlugConfig() {
|
|
100
|
+
const mfsu = this.mfsu;
|
|
101
|
+
return {
|
|
102
|
+
beforeCompile: async () => {
|
|
103
|
+
import_utils.logger.event(`[MFSU][eager] start build deps`);
|
|
104
|
+
if (mfsu.depBuilder.isBuilding) {
|
|
105
|
+
mfsu.buildDepsAgain = true;
|
|
106
|
+
} else {
|
|
107
|
+
this.staticDepInfo.consumeAllProducedEvents();
|
|
108
|
+
mfsu.buildDeps().then(() => {
|
|
109
|
+
mfsu.onProgress({
|
|
110
|
+
done: true
|
|
111
|
+
});
|
|
112
|
+
}).catch((e) => {
|
|
113
|
+
import_utils.printHelp.runtime(e);
|
|
114
|
+
mfsu.onProgress({
|
|
115
|
+
done: true
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
onFileChange: async (c) => {
|
|
121
|
+
import_utils.logger.debug("webpack found changes modified:", c.modifiedFiles, "removed:", c.removedFiles);
|
|
122
|
+
if (!c.modifiedFiles || c.modifiedFiles.size === 0) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const start = Date.now();
|
|
126
|
+
let event = this.staticDepInfo.getProducedEvent();
|
|
127
|
+
while (event.length === 0) {
|
|
128
|
+
await sleep(200);
|
|
129
|
+
event = this.staticDepInfo.getProducedEvent();
|
|
130
|
+
if (Date.now() - start > 5e3) {
|
|
131
|
+
import_utils.logger.warn("webpack wait mfsu deps too long");
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
onCompileDone: () => {
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
loadCache() {
|
|
141
|
+
this.staticDepInfo.loadCache();
|
|
142
|
+
}
|
|
143
|
+
refresh() {
|
|
144
|
+
this.staticDepInfo.snapshot();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
115
147
|
function sleep(ms) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
148
|
+
return new Promise((resolve) => {
|
|
149
|
+
setTimeout(() => {
|
|
150
|
+
resolve();
|
|
151
|
+
}, ms);
|
|
152
|
+
});
|
|
121
153
|
}
|
|
154
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
155
|
+
0 && (module.exports = {
|
|
156
|
+
StaticAnalyzeStrategy
|
|
157
|
+
});
|