@umijs/mfsu 4.0.0-beta.15 → 4.0.0-beta.16
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.
|
@@ -23,6 +23,8 @@ function checkMatch({ value, path, opts, isExportAll, depth, cache, }) {
|
|
|
23
23
|
(0, assert_1.default)(depth <= 10, `endless loop detected in checkMatch, please check your alias config.`);
|
|
24
24
|
opts = opts || {};
|
|
25
25
|
const remoteName = opts.remoteName || 'mf';
|
|
26
|
+
// FIXME: hard code for vite mode
|
|
27
|
+
value = value.replace(/^@fs\//, '/');
|
|
26
28
|
if (
|
|
27
29
|
// unMatch specified libs
|
|
28
30
|
((_a = opts.unMatchLibs) === null || _a === void 0 ? void 0 : _a.includes(value)) ||
|
package/dist/mfsu.d.ts
CHANGED
package/dist/mfsu.js
CHANGED
|
@@ -47,6 +47,12 @@ class MFSU {
|
|
|
47
47
|
this.depBuilder = new depBuilder_1.DepBuilder({ mfsu: this });
|
|
48
48
|
this.depInfo.loadCache();
|
|
49
49
|
}
|
|
50
|
+
// swc don't support top-level await
|
|
51
|
+
// ref: https://github.com/vercel/next.js/issues/31054
|
|
52
|
+
asyncImport(content) {
|
|
53
|
+
return `await import('${content}');`;
|
|
54
|
+
// return `(async () => await import('${content}'))();`;
|
|
55
|
+
}
|
|
50
56
|
setWebpackConfig(opts) {
|
|
51
57
|
var _a;
|
|
52
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -64,22 +70,31 @@ class MFSU {
|
|
|
64
70
|
const virtualPath = `./mfsu-virtual-entry/${key}.js`;
|
|
65
71
|
const virtualContent = [];
|
|
66
72
|
let index = 1;
|
|
73
|
+
let hasDefaultExport = false;
|
|
67
74
|
// @ts-ignore
|
|
68
75
|
for (const entry of opts.config.entry[key]) {
|
|
69
76
|
const content = (0, fs_1.readFileSync)(entry, 'utf-8');
|
|
70
77
|
const [_imports, exports] = yield (0, bundler_utils_1.parseModule)({ content, path: entry });
|
|
71
78
|
if (exports.length) {
|
|
72
|
-
virtualContent.push(`const k${index} =
|
|
79
|
+
virtualContent.push(`const k${index} = ${this.asyncImport(entry)}`);
|
|
73
80
|
for (const exportName of exports) {
|
|
74
|
-
|
|
81
|
+
if (exportName === 'default') {
|
|
82
|
+
hasDefaultExport = true;
|
|
83
|
+
virtualContent.push(`export default k${index}.${exportName}`);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
virtualContent.push(`export const ${exportName} = k${index}.${exportName}`);
|
|
87
|
+
}
|
|
75
88
|
}
|
|
76
89
|
}
|
|
77
90
|
else {
|
|
78
|
-
virtualContent.push(
|
|
91
|
+
virtualContent.push(this.asyncImport(entry));
|
|
79
92
|
}
|
|
80
93
|
index += 1;
|
|
81
94
|
}
|
|
82
|
-
|
|
95
|
+
if (!hasDefaultExport) {
|
|
96
|
+
virtualContent.push(`export default 1;`);
|
|
97
|
+
}
|
|
83
98
|
virtualModules[virtualPath] = virtualContent.join('\n');
|
|
84
99
|
entry[key] = virtualPath;
|
|
85
100
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/mfsu",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.16",
|
|
4
4
|
"description": "@umijs/mfsu",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/mfsu#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"dev": "pnpm build -- --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@umijs/bundler-esbuild": "4.0.0-beta.
|
|
25
|
-
"@umijs/bundler-utils": "4.0.0-beta.
|
|
26
|
-
"@umijs/utils": "4.0.0-beta.
|
|
24
|
+
"@umijs/bundler-esbuild": "4.0.0-beta.16",
|
|
25
|
+
"@umijs/bundler-utils": "4.0.0-beta.16",
|
|
26
|
+
"@umijs/utils": "4.0.0-beta.16"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/express": "4.17.13",
|