@umijs/mfsu 4.0.43 → 4.0.44
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/babelPlugins/awaitImport/MFImport.js +4 -1
- package/dist/babelPlugins/awaitImport/awaitImport.js +4 -1
- package/dist/babelPlugins/awaitImport/parseSpecifiers.js +26 -18
- package/dist/dep/dep.js +13 -4
- package/dist/dep/getCJSExports.js +48 -25
- package/dist/dep/getExposeFromContent.js +11 -3
- package/dist/depInfo.js +15 -6
- package/dist/esbuildHandlers/autoCssModules.js +4 -1
- package/dist/mfsu/mfsu.js +39 -18
- package/dist/mfsu/strategyCompileTime.js +7 -2
- package/dist/mfsu/strategyStaticAnalyze.js +16 -4
- package/dist/moduleGraph.js +3 -1
- package/dist/staticDepInfo/simulations/babel-plugin-import.js +12 -3
- package/dist/staticDepInfo/staticDepInfo.js +37 -12
- package/dist/utils/resolveUtils.js +14 -3
- package/dist/utils/webpackUtils.js +18 -9
- package/dist/webpackPlugins/writeCachePlugin.js +6 -3
- package/package.json +4 -4
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/babelPlugins/awaitImport/MFImport.ts
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/babelPlugins/awaitImport/awaitImport.ts
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/babelPlugins/awaitImport/parseSpecifiers.ts
|
|
@@ -28,25 +31,30 @@ module.exports = __toCommonJS(parseSpecifiers_exports);
|
|
|
28
31
|
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
29
32
|
var DEFAULT = "default";
|
|
30
33
|
function parseSpecifiers(specifiers) {
|
|
31
|
-
return specifiers.reduce(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
return specifiers.reduce(
|
|
35
|
+
(memo, s) => {
|
|
36
|
+
if (t.isImportDefaultSpecifier(s)) {
|
|
37
|
+
memo.properties.push(t.objectProperty(t.identifier(DEFAULT), s.local));
|
|
38
|
+
} else if (t.isExportDefaultSpecifier(s)) {
|
|
39
|
+
memo.properties.push(
|
|
40
|
+
t.objectProperty(t.identifier(DEFAULT), s.exported)
|
|
41
|
+
);
|
|
42
|
+
} else if (t.isExportSpecifier(s)) {
|
|
43
|
+
if (t.isIdentifier(s.exported, { name: DEFAULT })) {
|
|
44
|
+
memo.defaultIdentifier = s.local.name;
|
|
45
|
+
memo.properties.push(t.objectProperty(s.local, s.local));
|
|
46
|
+
} else {
|
|
47
|
+
memo.properties.push(t.objectProperty(s.local, s.exported));
|
|
48
|
+
}
|
|
49
|
+
} else if (t.isImportNamespaceSpecifier(s)) {
|
|
50
|
+
memo.namespaceIdentifier = s.local;
|
|
40
51
|
} else {
|
|
41
|
-
memo.properties.push(t.objectProperty(s.
|
|
52
|
+
memo.properties.push(t.objectProperty(s.imported, s.local));
|
|
42
53
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
return memo;
|
|
49
|
-
}, { properties: [], namespaceIdentifier: null, defaultIdentifier: null });
|
|
54
|
+
return memo;
|
|
55
|
+
},
|
|
56
|
+
{ properties: [], namespaceIdentifier: null, defaultIdentifier: null }
|
|
57
|
+
);
|
|
50
58
|
}
|
|
51
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
60
|
0 && (module.exports = {
|
package/dist/dep/dep.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/dep/dep.ts
|
|
@@ -47,18 +50,24 @@ var Dep = class {
|
|
|
47
50
|
async buildExposeContent() {
|
|
48
51
|
const isNodeNatives = !!process.binding("natives")[this.file];
|
|
49
52
|
if (isNodeNatives) {
|
|
50
|
-
return (0, import_trimFileContent.trimFileContent)(
|
|
53
|
+
return (0, import_trimFileContent.trimFileContent)(
|
|
54
|
+
this.excludeNodeNatives ? `
|
|
51
55
|
const _ = require('${this.file}');
|
|
52
56
|
module.exports = _;
|
|
53
57
|
` : `
|
|
54
58
|
import _ from '${this.file}';
|
|
55
59
|
export default _;
|
|
56
60
|
export * from '${this.file}';
|
|
57
|
-
`
|
|
61
|
+
`
|
|
62
|
+
);
|
|
58
63
|
}
|
|
59
64
|
const realFile = await this.getRealFile();
|
|
60
65
|
if (!realFile) {
|
|
61
|
-
import_utils.logger.error(
|
|
66
|
+
import_utils.logger.error(
|
|
67
|
+
`Can not resolve dependence : '${import_utils.chalk.red(
|
|
68
|
+
this.file
|
|
69
|
+
)}', please install it`
|
|
70
|
+
);
|
|
62
71
|
}
|
|
63
72
|
(0, import_assert.default)(realFile, `dependence not found: ${this.file}`);
|
|
64
73
|
const content = (0, import_fs.readFileSync)(realFile, "utf-8");
|
|
@@ -23,33 +23,56 @@ __export(getCJSExports_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(getCJSExports_exports);
|
|
25
25
|
function getCJSExports({ content }) {
|
|
26
|
-
return matchAll(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
return matchAll(
|
|
27
|
+
/Object\.defineProperty\(\s*exports\s*\,\s*[\"|\'](\w+)[\"|\']/g,
|
|
28
|
+
content
|
|
29
|
+
).concat(
|
|
30
|
+
matchAll(
|
|
31
|
+
/exports(?:\.|\[(?:\'|\"))(\w+)(?:\s*|(?:\'|\")\])\s*\=/g,
|
|
32
|
+
content
|
|
33
|
+
)
|
|
34
|
+
).concat(
|
|
35
|
+
matchAll(/__webpack_exports__\[(?:\"|\')(\w+)(?:\"|\')\]\s*\=/g, content)
|
|
36
|
+
).concat(
|
|
37
|
+
matchAll(
|
|
38
|
+
/__webpack_require__\.d\(\s*__webpack_exports__\s*,\s*(?:\"|\')(\w+)(?:\"|\')\s*,/g,
|
|
39
|
+
content
|
|
40
|
+
)
|
|
41
|
+
).concat(
|
|
42
|
+
...matchAll(
|
|
43
|
+
/__webpack_require__\.d\(\s*__webpack_exports__\s*,\s*(\{)/g,
|
|
44
|
+
content
|
|
45
|
+
).map((matchResult) => {
|
|
46
|
+
const { index } = matchResult;
|
|
47
|
+
let idx = index;
|
|
48
|
+
let deep = 0;
|
|
49
|
+
let isMeetSymbol = false;
|
|
50
|
+
let symbolBeginIndex = index;
|
|
51
|
+
while (idx < content.length) {
|
|
52
|
+
if (!deep && isMeetSymbol) {
|
|
53
|
+
break;
|
|
40
54
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
if (content[idx] === "{") {
|
|
56
|
+
if (!isMeetSymbol) {
|
|
57
|
+
isMeetSymbol = true;
|
|
58
|
+
symbolBeginIndex = idx;
|
|
59
|
+
}
|
|
60
|
+
deep++;
|
|
61
|
+
}
|
|
62
|
+
if (content[idx] === "}") {
|
|
63
|
+
deep--;
|
|
64
|
+
}
|
|
65
|
+
idx++;
|
|
45
66
|
}
|
|
46
|
-
idx
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
67
|
+
let result = content.slice(symbolBeginIndex, idx);
|
|
68
|
+
return [
|
|
69
|
+
...matchAll(
|
|
70
|
+
/(?:\"|\')(\w+)(?:\"|\')\s*\:\s*(?:function|\()/g,
|
|
71
|
+
result
|
|
72
|
+
)
|
|
73
|
+
];
|
|
74
|
+
})
|
|
75
|
+
).map((result) => result[1]);
|
|
53
76
|
}
|
|
54
77
|
function matchAll(regexp, str) {
|
|
55
78
|
const result = [];
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/dep/getExposeFromContent.ts
|
|
@@ -34,12 +37,17 @@ async function getExposeFromContent(opts) {
|
|
|
34
37
|
if (opts.filePath && /\.(css|less|scss|sass|stylus|styl)$/.test(opts.filePath)) {
|
|
35
38
|
return `import '${importPath}';`;
|
|
36
39
|
}
|
|
37
|
-
if (opts.filePath && /\.(json|svg|png|jpe?g|avif|gif|webp|ico|eot|woff|woff2|ttf|txt|text|mdx?)$/.test(
|
|
40
|
+
if (opts.filePath && /\.(json|svg|png|jpe?g|avif|gif|webp|ico|eot|woff|woff2|ttf|txt|text|mdx?)$/.test(
|
|
41
|
+
opts.filePath
|
|
42
|
+
)) {
|
|
38
43
|
return `
|
|
39
44
|
import _ from '${importPath}';
|
|
40
45
|
export default _;`.trim();
|
|
41
46
|
}
|
|
42
|
-
(0, import_assert.default)(
|
|
47
|
+
(0, import_assert.default)(
|
|
48
|
+
/(js|jsx|mjs|ts|tsx)$/.test(opts.filePath),
|
|
49
|
+
`file type not supported for ${(0, import_path.basename)(opts.filePath)}.`
|
|
50
|
+
);
|
|
43
51
|
const { exports, isCJS } = await (0, import_getModuleExports.getModuleExports)({
|
|
44
52
|
content: opts.content,
|
|
45
53
|
filePath: opts.filePath
|
package/dist/depInfo.js
CHANGED
|
@@ -34,7 +34,10 @@ var DepInfo = class {
|
|
|
34
34
|
this.cacheFilePath = (0, import_path.join)(this.opts.mfsu.opts.tmpBase, "MFSU_CACHE.json");
|
|
35
35
|
}
|
|
36
36
|
shouldBuild() {
|
|
37
|
-
if (!import_utils.lodash.isEqual(
|
|
37
|
+
if (!import_utils.lodash.isEqual(
|
|
38
|
+
this.cacheDependency,
|
|
39
|
+
this.opts.mfsu.opts.getCacheDependency()
|
|
40
|
+
)) {
|
|
38
41
|
return "cacheDependency has changed";
|
|
39
42
|
}
|
|
40
43
|
if (this.moduleGraph.hasDepChanged()) {
|
|
@@ -50,7 +53,9 @@ var DepInfo = class {
|
|
|
50
53
|
if ((0, import_fs.existsSync)(this.cacheFilePath)) {
|
|
51
54
|
import_utils.logger.info("[MFSU] restore cache");
|
|
52
55
|
try {
|
|
53
|
-
const { cacheDependency, moduleGraph } = JSON.parse(
|
|
56
|
+
const { cacheDependency, moduleGraph } = JSON.parse(
|
|
57
|
+
(0, import_fs.readFileSync)(this.cacheFilePath, "utf-8")
|
|
58
|
+
);
|
|
54
59
|
this.cacheDependency = cacheDependency;
|
|
55
60
|
this.moduleGraph.restore(moduleGraph);
|
|
56
61
|
} catch (e) {
|
|
@@ -62,10 +67,14 @@ var DepInfo = class {
|
|
|
62
67
|
}
|
|
63
68
|
writeCache() {
|
|
64
69
|
import_utils.fsExtra.mkdirpSync((0, import_path.dirname)(this.cacheFilePath));
|
|
65
|
-
const newContent = JSON.stringify(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
const newContent = JSON.stringify(
|
|
71
|
+
{
|
|
72
|
+
cacheDependency: this.cacheDependency,
|
|
73
|
+
moduleGraph: this.moduleGraph.toJSON()
|
|
74
|
+
},
|
|
75
|
+
null,
|
|
76
|
+
2
|
|
77
|
+
);
|
|
69
78
|
if ((0, import_fs.existsSync)(this.cacheFilePath) && (0, import_fs.readFileSync)(this.cacheFilePath, "utf-8") === newContent) {
|
|
70
79
|
return;
|
|
71
80
|
}
|
|
@@ -32,7 +32,10 @@ function autoCssModulesHandler(opts) {
|
|
|
32
32
|
if (i.d < 0 && (0, import_utils.isStyleFile)({ filename: i.n })) {
|
|
33
33
|
const importSegment = code.substring(i.ss + offset, i.s + offset);
|
|
34
34
|
if (~importSegment.indexOf(" from")) {
|
|
35
|
-
code = `${code.substring(
|
|
35
|
+
code = `${code.substring(
|
|
36
|
+
0,
|
|
37
|
+
i.e + offset
|
|
38
|
+
)}${CSS_MODULES_QUERY}${code.substring(i.e + offset)}`;
|
|
36
39
|
offset += QUERY_LENGTH;
|
|
37
40
|
}
|
|
38
41
|
}
|
package/dist/mfsu/mfsu.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/mfsu/mfsu.ts
|
|
@@ -76,7 +79,9 @@ var MFSU = class {
|
|
|
76
79
|
srcCodeCache: opts.srcCodeCache
|
|
77
80
|
});
|
|
78
81
|
} else {
|
|
79
|
-
import_utils.logger.warn(
|
|
82
|
+
import_utils.logger.warn(
|
|
83
|
+
"fallback to MFSU normal strategy, due to srcCache is not provided"
|
|
84
|
+
);
|
|
80
85
|
this.strategy = new import_strategyCompileTime.StrategyCompileTime({ mfsu: this });
|
|
81
86
|
}
|
|
82
87
|
} else {
|
|
@@ -96,7 +101,10 @@ var MFSU = class {
|
|
|
96
101
|
const entry = {};
|
|
97
102
|
const virtualModules = {};
|
|
98
103
|
const entryObject = import_utils.lodash.isString(opts.config.entry) ? { default: [opts.config.entry] } : opts.config.entry;
|
|
99
|
-
(0, import_assert.default)(
|
|
104
|
+
(0, import_assert.default)(
|
|
105
|
+
import_utils.lodash.isPlainObject(entryObject),
|
|
106
|
+
`webpack config 'entry' value must be a string or an object.`
|
|
107
|
+
);
|
|
100
108
|
for (const key of Object.keys(entryObject)) {
|
|
101
109
|
if (key === this.opts.remoteName) {
|
|
102
110
|
entry[key] = entryObject[key];
|
|
@@ -110,7 +118,10 @@ var MFSU = class {
|
|
|
110
118
|
const resolver = (0, import_webpackUtils.getResolver)(opts.config);
|
|
111
119
|
for (let entry2 of entryFiles) {
|
|
112
120
|
const realEntry = resolver(entry2);
|
|
113
|
-
(0, import_assert.default)(
|
|
121
|
+
(0, import_assert.default)(
|
|
122
|
+
realEntry,
|
|
123
|
+
`entry file not found (${entry2}), please configure the specific entry path. (e.g. 'src/index.tsx')`
|
|
124
|
+
);
|
|
114
125
|
entry2 = realEntry;
|
|
115
126
|
const content = (0, import_fs.readFileSync)(entry2, "utf-8");
|
|
116
127
|
const [_imports, exports] = await (0, import_bundler_utils.parseModule)({ content, path: entry2 });
|
|
@@ -121,7 +132,9 @@ var MFSU = class {
|
|
|
121
132
|
hasDefaultExport = true;
|
|
122
133
|
virtualContent.push(`export default k${index}.${exportName}`);
|
|
123
134
|
} else {
|
|
124
|
-
virtualContent.push(
|
|
135
|
+
virtualContent.push(
|
|
136
|
+
`export const ${exportName} = k${index}.${exportName}`
|
|
137
|
+
);
|
|
125
138
|
}
|
|
126
139
|
}
|
|
127
140
|
} else {
|
|
@@ -139,13 +152,14 @@ var MFSU = class {
|
|
|
139
152
|
opts.config.plugins = opts.config.plugins || [];
|
|
140
153
|
let publicPath = resolvePublicPath(opts.config);
|
|
141
154
|
this.publicPath = publicPath;
|
|
142
|
-
opts.config.plugins.push(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
155
|
+
opts.config.plugins.push(
|
|
156
|
+
...[
|
|
157
|
+
new import_webpack_virtual_modules.default(virtualModules),
|
|
158
|
+
new this.opts.implementor.container.ModuleFederationPlugin({
|
|
159
|
+
name: "__",
|
|
160
|
+
shared: this.opts.shared || {},
|
|
161
|
+
remotes: {
|
|
162
|
+
[mfName]: this.opts.runtimePublicPath ? `
|
|
149
163
|
promise new Promise(resolve => {
|
|
150
164
|
const remoteUrlWithVersion = (window.publicPath || '/') + '${import_constants.REMOTE_FILE_FULL}';
|
|
151
165
|
const script = document.createElement('script');
|
|
@@ -169,10 +183,11 @@ promise new Promise(resolve => {
|
|
|
169
183
|
document.head.appendChild(script);
|
|
170
184
|
})
|
|
171
185
|
`.trimLeft() : `${mfName}@${publicPath}${import_constants.REMOTE_FILE_FULL}`
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
}
|
|
187
|
+
}),
|
|
188
|
+
new import_buildDepPlugin.BuildDepPlugin(this.strategy.getBuildDepPlugConfig())
|
|
189
|
+
]
|
|
190
|
+
);
|
|
176
191
|
import_utils.lodash.set(opts.config, "experiments.topLevelAwait", true);
|
|
177
192
|
this.depConfig = opts.depConfig;
|
|
178
193
|
this.strategy.init(opts.config);
|
|
@@ -221,8 +236,14 @@ promise new Promise(resolve => {
|
|
|
221
236
|
if (!req.path.includes(import_constants.REMOTE_FILE)) {
|
|
222
237
|
res.setHeader("cache-control", "max-age=31536000,immutable");
|
|
223
238
|
}
|
|
224
|
-
res.setHeader(
|
|
225
|
-
|
|
239
|
+
res.setHeader(
|
|
240
|
+
"content-type",
|
|
241
|
+
(0, import_mrmime.lookup)((0, import_path.extname)(req.path)) || "text/plain"
|
|
242
|
+
);
|
|
243
|
+
const relativePath = req.path.replace(
|
|
244
|
+
new RegExp(`^${relativePublicPath}`),
|
|
245
|
+
"/"
|
|
246
|
+
);
|
|
226
247
|
const realFilePath = (0, import_path.join)(this.opts.tmpBase, relativePath);
|
|
227
248
|
if (!(0, import_fs.existsSync)(realFilePath)) {
|
|
228
249
|
import_utils.logger.error(`MFSU dist file: ${realFilePath} not found`);
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/mfsu/strategyCompileTime.ts
|
|
@@ -84,7 +87,9 @@ var StrategyCompileTime = class {
|
|
|
84
87
|
const mfsu = this.mfsu;
|
|
85
88
|
const userUnMatches = mfsuOpts.unMatchLibs || [];
|
|
86
89
|
const sharedUnMatches = Object.keys(mfsuOpts.shared || {});
|
|
87
|
-
const remoteAliasUnMatches = (mfsuOpts.remoteAliases || []).map(
|
|
90
|
+
const remoteAliasUnMatches = (mfsuOpts.remoteAliases || []).map(
|
|
91
|
+
(str) => new RegExp(`^${str}`)
|
|
92
|
+
);
|
|
88
93
|
const unMatches = [
|
|
89
94
|
...userUnMatches,
|
|
90
95
|
...sharedUnMatches,
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/mfsu/strategyStaticAnalyze.ts
|
|
@@ -63,7 +66,9 @@ var StaticAnalyzeStrategy = class {
|
|
|
63
66
|
const mfsuOpts = this.mfsu.opts;
|
|
64
67
|
const userUnMatches = mfsuOpts.unMatchLibs || [];
|
|
65
68
|
const sharedUnMatches = Object.keys(mfsuOpts.shared || {});
|
|
66
|
-
const remoteAliasUnMatches = (mfsuOpts.remoteAliases || []).map(
|
|
69
|
+
const remoteAliasUnMatches = (mfsuOpts.remoteAliases || []).map(
|
|
70
|
+
(str) => new RegExp(`^${str}`)
|
|
71
|
+
);
|
|
67
72
|
const unMatches = [
|
|
68
73
|
...userUnMatches,
|
|
69
74
|
...sharedUnMatches,
|
|
@@ -121,7 +126,12 @@ var StaticAnalyzeStrategy = class {
|
|
|
121
126
|
}
|
|
122
127
|
},
|
|
123
128
|
onFileChange: async (c) => {
|
|
124
|
-
import_utils.logger.debug(
|
|
129
|
+
import_utils.logger.debug(
|
|
130
|
+
"webpack found changes modified:",
|
|
131
|
+
c.modifiedFiles,
|
|
132
|
+
"removed:",
|
|
133
|
+
c.removedFiles
|
|
134
|
+
);
|
|
125
135
|
const srcPath = this.staticDepInfo.opts.srcCodeCache.getSrcPath();
|
|
126
136
|
const fileEvents = [
|
|
127
137
|
...this.staticDepInfo.opts.srcCodeCache.replayChangeEvents(),
|
|
@@ -144,7 +154,9 @@ var StaticAnalyzeStrategy = class {
|
|
|
144
154
|
}
|
|
145
155
|
const start = Date.now();
|
|
146
156
|
try {
|
|
147
|
-
await this.staticDepInfo.opts.srcCodeCache.handleFileChangeEvents(
|
|
157
|
+
await this.staticDepInfo.opts.srcCodeCache.handleFileChangeEvents(
|
|
158
|
+
fileEvents
|
|
159
|
+
);
|
|
148
160
|
} catch (e) {
|
|
149
161
|
import_utils.logger.error("MFSU[eager] analyze dependencies failed with error", e);
|
|
150
162
|
}
|
package/dist/moduleGraph.js
CHANGED
|
@@ -99,7 +99,9 @@ var ModuleGraph = class {
|
|
|
99
99
|
});
|
|
100
100
|
this.fileToModules.forEach((value, key) => {
|
|
101
101
|
fileModules[key] = {
|
|
102
|
-
importedModules: Array.from(value.importedModules).map(
|
|
102
|
+
importedModules: Array.from(value.importedModules).map(
|
|
103
|
+
(item) => item.file
|
|
104
|
+
)
|
|
103
105
|
};
|
|
104
106
|
if (value.isRoot) {
|
|
105
107
|
fileModules[key].isRoot = true;
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/staticDepInfo/simulations/babel-plugin-import.ts
|
|
@@ -83,7 +86,11 @@ function createHandle(importOptions) {
|
|
|
83
86
|
continue;
|
|
84
87
|
}
|
|
85
88
|
const transformedName = transformName(importVariableName);
|
|
86
|
-
const importFsPath = (0, import_path.join)(
|
|
89
|
+
const importFsPath = (0, import_path.join)(
|
|
90
|
+
libraryName,
|
|
91
|
+
libraryDirectory,
|
|
92
|
+
transformedName
|
|
93
|
+
);
|
|
87
94
|
addToMatches(importFsPath);
|
|
88
95
|
}
|
|
89
96
|
return retMatched;
|
|
@@ -96,7 +103,9 @@ function transCamel(_str, symbol) {
|
|
|
96
103
|
return str.replace(/([A-Z])/g, ($1) => `${symbol}${$1.toLowerCase()}`);
|
|
97
104
|
}
|
|
98
105
|
function errorLogForSpaceImport(libraryName) {
|
|
99
|
-
import_utils.logger.error(
|
|
106
|
+
import_utils.logger.error(
|
|
107
|
+
`"import * as ant from 'antd'" or "export * from '${libraryName}'" are not allowed in mfsu#strategy='eager'`
|
|
108
|
+
);
|
|
100
109
|
import_utils.logger.error(`solutions:`);
|
|
101
110
|
import_utils.logger.error(` change to "import { Xxx } from '${libraryName}'" or`);
|
|
102
111
|
import_utils.logger.error(` "export { Xxx } from '${libraryName}'" syntax`);
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/staticDepInfo/staticDepInfo.ts
|
|
@@ -41,7 +44,10 @@ var StaticDepInfo = class {
|
|
|
41
44
|
this.mfsu = opts.mfsu;
|
|
42
45
|
this.include = this.mfsu.opts.include || [];
|
|
43
46
|
this.opts = opts;
|
|
44
|
-
this.cacheFilePath = (0, import_path.join)(
|
|
47
|
+
this.cacheFilePath = (0, import_path.join)(
|
|
48
|
+
this.opts.mfsu.opts.tmpBase,
|
|
49
|
+
"MFSU_CACHE_v4.json"
|
|
50
|
+
);
|
|
45
51
|
this.cwd = this.mfsu.opts.cwd;
|
|
46
52
|
opts.srcCodeCache.register((info) => {
|
|
47
53
|
this.currentDep = this._getDependencies(info.code, info.imports);
|
|
@@ -59,7 +65,10 @@ var StaticDepInfo = class {
|
|
|
59
65
|
if (!import_utils.lodash.isEqual(this.cacheDependency, currentCacheDep)) {
|
|
60
66
|
if (process.env.DEBUG_UMI) {
|
|
61
67
|
const reason = (0, import_why.default)(this.cacheDependency, currentCacheDep);
|
|
62
|
-
import_utils.logger.info(
|
|
68
|
+
import_utils.logger.info(
|
|
69
|
+
"[MFSU][eager]: isEqual(cacheDependency,currentCacheDep) === false, because ",
|
|
70
|
+
reason
|
|
71
|
+
);
|
|
63
72
|
}
|
|
64
73
|
return "cacheDependency has changed";
|
|
65
74
|
}
|
|
@@ -68,7 +77,10 @@ var StaticDepInfo = class {
|
|
|
68
77
|
} else {
|
|
69
78
|
if (process.env.DEBUG_UMI) {
|
|
70
79
|
const reason = (0, import_why.default)(this.builtWithDep, this.currentDep);
|
|
71
|
-
import_utils.logger.info(
|
|
80
|
+
import_utils.logger.info(
|
|
81
|
+
"[MFSU][eager]: isEqual(oldDep,newDep) === false, because ",
|
|
82
|
+
reason
|
|
83
|
+
);
|
|
72
84
|
}
|
|
73
85
|
return "dependencies changed";
|
|
74
86
|
}
|
|
@@ -92,21 +104,30 @@ var StaticDepInfo = class {
|
|
|
92
104
|
loadCache() {
|
|
93
105
|
if ((0, import_fs.existsSync)(this.cacheFilePath)) {
|
|
94
106
|
try {
|
|
95
|
-
const { dep = {}, cacheDependency = {} } = JSON.parse(
|
|
107
|
+
const { dep = {}, cacheDependency = {} } = JSON.parse(
|
|
108
|
+
(0, import_fs.readFileSync)(this.cacheFilePath, "utf-8")
|
|
109
|
+
);
|
|
96
110
|
this.builtWithDep = dep;
|
|
97
111
|
this.cacheDependency = cacheDependency;
|
|
98
112
|
import_utils.logger.info("[MFSU][eager] restored cache");
|
|
99
113
|
} catch (e) {
|
|
100
|
-
import_utils.logger.warn(
|
|
114
|
+
import_utils.logger.warn(
|
|
115
|
+
"[MFSU][eager] restore cache failed, fallback to Empty dependency",
|
|
116
|
+
e
|
|
117
|
+
);
|
|
101
118
|
}
|
|
102
119
|
}
|
|
103
120
|
}
|
|
104
121
|
writeCache() {
|
|
105
122
|
import_utils.fsExtra.mkdirpSync((0, import_path.dirname)(this.cacheFilePath));
|
|
106
|
-
const newContent = JSON.stringify(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
123
|
+
const newContent = JSON.stringify(
|
|
124
|
+
{
|
|
125
|
+
dep: this.builtWithDep,
|
|
126
|
+
cacheDependency: this.cacheDependency
|
|
127
|
+
},
|
|
128
|
+
null,
|
|
129
|
+
2
|
|
130
|
+
);
|
|
110
131
|
if ((0, import_fs.existsSync)(this.cacheFilePath) && (0, import_fs.readFileSync)(this.cacheFilePath, "utf-8") === newContent) {
|
|
111
132
|
return;
|
|
112
133
|
}
|
|
@@ -129,7 +150,9 @@ var StaticDepInfo = class {
|
|
|
129
150
|
const mfsuOpts = this.mfsu.opts;
|
|
130
151
|
const userUnMatches = mfsuOpts.unMatchLibs || [];
|
|
131
152
|
const sharedUnMatches = Object.keys(mfsuOpts.shared || {});
|
|
132
|
-
const remoteAliasUnMatches = (mfsuOpts.remoteAliases || []).map(
|
|
153
|
+
const remoteAliasUnMatches = (mfsuOpts.remoteAliases || []).map(
|
|
154
|
+
(str) => new RegExp(`^${str}`)
|
|
155
|
+
);
|
|
133
156
|
const unMatches = [
|
|
134
157
|
...userUnMatches,
|
|
135
158
|
...sharedUnMatches,
|
|
@@ -144,7 +167,9 @@ var StaticDepInfo = class {
|
|
|
144
167
|
};
|
|
145
168
|
const matched = {};
|
|
146
169
|
const unMatched = /* @__PURE__ */ new Set();
|
|
147
|
-
const pkgNames = this.runtimeSimulations.map(
|
|
170
|
+
const pkgNames = this.runtimeSimulations.map(
|
|
171
|
+
({ packageName }) => packageName
|
|
172
|
+
);
|
|
148
173
|
const groupedMockImports = {};
|
|
149
174
|
for (const imp of imports) {
|
|
150
175
|
if (!imp.n) {
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/utils/resolveUtils.ts
|
|
@@ -52,7 +55,11 @@ var cjsResolver = import_enhanced_resolve.default.create({
|
|
|
52
55
|
});
|
|
53
56
|
async function resolveWith(resolver, context, path) {
|
|
54
57
|
return new Promise((resolve2, reject) => {
|
|
55
|
-
resolver(
|
|
58
|
+
resolver(
|
|
59
|
+
context,
|
|
60
|
+
path,
|
|
61
|
+
(err, result) => err ? reject(err) : resolve2(result)
|
|
62
|
+
);
|
|
56
63
|
});
|
|
57
64
|
}
|
|
58
65
|
async function tryResolvers(rs, context, path) {
|
|
@@ -72,7 +79,11 @@ async function tryResolvers(rs, context, path) {
|
|
|
72
79
|
return result;
|
|
73
80
|
}
|
|
74
81
|
async function resolve(context, path) {
|
|
75
|
-
return await tryResolvers(
|
|
82
|
+
return await tryResolvers(
|
|
83
|
+
[browserResolver, esmResolver, cjsResolver],
|
|
84
|
+
context,
|
|
85
|
+
path
|
|
86
|
+
);
|
|
76
87
|
}
|
|
77
88
|
async function resolveFromContexts(contexts, path) {
|
|
78
89
|
for (const context of contexts) {
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/utils/webpackUtils.ts
|
|
@@ -33,14 +36,20 @@ var { property, compact, flatMap } = import_utils.lodash;
|
|
|
33
36
|
function extractBabelPluginImportOptions(webpackConfig) {
|
|
34
37
|
var _a;
|
|
35
38
|
const rules = ((_a = webpackConfig.module) == null ? void 0 : _a.rules) || [];
|
|
36
|
-
const uses = compact(flatMap(rules, property(["use"]))).filter(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
const uses = compact(flatMap(rules, property(["use"]))).filter(
|
|
40
|
+
(u) => {
|
|
41
|
+
var _a2;
|
|
42
|
+
return ((_a2 = u == null ? void 0 : u.loader) == null ? void 0 : _a2.indexOf("babel-loader")) >= 0;
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
const pluginConfigs = compact(
|
|
46
|
+
flatMap(uses, property(["options", "plugins"]))
|
|
47
|
+
).filter(
|
|
48
|
+
(p) => {
|
|
49
|
+
var _a2, _b;
|
|
50
|
+
return Array.isArray(p) && ((_b = (_a2 = p[0]) == null ? void 0 : _a2.indexOf) == null ? void 0 : _b.call(_a2, "babel-plugin-import")) >= 0;
|
|
51
|
+
}
|
|
52
|
+
);
|
|
44
53
|
const configs = /* @__PURE__ */ new Map();
|
|
45
54
|
for (const c of pluginConfigs) {
|
|
46
55
|
!configs.has(c[1].libraryName) && configs.set(c[1].libraryName, c[1]);
|
|
@@ -28,9 +28,12 @@ var WriteCachePlugin = class {
|
|
|
28
28
|
this.opts = opts;
|
|
29
29
|
}
|
|
30
30
|
apply(compiler) {
|
|
31
|
-
compiler.cache.hooks.store.tap(
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
compiler.cache.hooks.store.tap(
|
|
32
|
+
{ name: PLUGIN_NAME, stage: 10 },
|
|
33
|
+
() => {
|
|
34
|
+
this.opts.onWriteCache();
|
|
35
|
+
}
|
|
36
|
+
);
|
|
34
37
|
}
|
|
35
38
|
};
|
|
36
39
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/mfsu",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.44",
|
|
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.44",
|
|
27
|
+
"@umijs/bundler-utils": "4.0.44",
|
|
28
|
+
"@umijs/utils": "4.0.44",
|
|
29
29
|
"enhanced-resolve": "5.9.3",
|
|
30
30
|
"is-equal": "^1.6.4"
|
|
31
31
|
},
|