@umijs/mfsu 4.0.0-canary.20220323.1 → 4.0.0-canary.20220412.2
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.js +2 -3
- package/dist/depBuilder/depBuilder.js +3 -0
- package/dist/mfsu.d.ts +5 -3
- package/dist/mfsu.js +17 -5
- package/package.json +5 -5
- package/dist/babelPlugins/autoExport.d.ts +0 -7
- package/dist/babelPlugins/autoExport.js +0 -65
- package/dist/esbuildHandlers/autoExport.d.ts +0 -6
- package/dist/esbuildHandlers/autoExport.js +0 -9
package/dist/dep/dep.js
CHANGED
|
@@ -24,9 +24,8 @@ const getExposeFromContent_1 = require("./getExposeFromContent");
|
|
|
24
24
|
const resolver = enhanced_resolve_1.default.create({
|
|
25
25
|
mainFields: ['module', 'browser', 'main'],
|
|
26
26
|
extensions: ['.js', '.json', '.mjs'],
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
exportsFields: [],
|
|
27
|
+
exportsFields: ['exports'],
|
|
28
|
+
conditionNames: ['import', 'module', 'require', 'node'],
|
|
30
29
|
});
|
|
31
30
|
function resolve(context, path) {
|
|
32
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -151,6 +151,9 @@ class DepBuilder {
|
|
|
151
151
|
depConfig.plugins.push(new stripSourceMapUrlPlugin_1.StripSourceMapUrlPlugin({
|
|
152
152
|
webpack: this.opts.mfsu.opts.implementor,
|
|
153
153
|
}));
|
|
154
|
+
depConfig.plugins.push(new this.opts.mfsu.opts.implementor.ProgressPlugin((percent, msg) => {
|
|
155
|
+
this.opts.mfsu.onProgress({ percent, status: msg });
|
|
156
|
+
}));
|
|
154
157
|
const exposes = opts.deps.reduce((memo, dep) => {
|
|
155
158
|
memo[`./${dep.file}`] = (0, path_1.join)(this.opts.mfsu.opts.tmpBase, dep.filePath);
|
|
156
159
|
return memo;
|
package/dist/mfsu.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { NextFunction, Request, Response } from '@umijs/bundler-utils/compiled/express';
|
|
2
2
|
import webpack, { Configuration } from 'webpack';
|
|
3
|
-
import autoExport from './babelPlugins/autoExport';
|
|
4
3
|
import awaitImport from './babelPlugins/awaitImport/awaitImport';
|
|
5
4
|
import { DepBuilder } from './depBuilder/depBuilder';
|
|
6
5
|
import { DepInfo } from './depInfo';
|
|
@@ -10,6 +9,7 @@ interface IOpts {
|
|
|
10
9
|
excludeNodeNatives?: boolean;
|
|
11
10
|
exportAllMembers?: Record<string, string[]>;
|
|
12
11
|
getCacheDependency?: Function;
|
|
12
|
+
onMFSUProgress?: Function;
|
|
13
13
|
mfName?: string;
|
|
14
14
|
mode?: Mode;
|
|
15
15
|
tmpBase?: string;
|
|
@@ -27,6 +27,8 @@ export declare class MFSU {
|
|
|
27
27
|
depBuilder: DepBuilder;
|
|
28
28
|
depConfig: Configuration | null;
|
|
29
29
|
buildDepsAgain: boolean;
|
|
30
|
+
progress: any;
|
|
31
|
+
onProgress: Function;
|
|
30
32
|
constructor(opts: IOpts);
|
|
31
33
|
asyncImport(content: string): string;
|
|
32
34
|
setWebpackConfig(opts: {
|
|
@@ -36,7 +38,7 @@ export declare class MFSU {
|
|
|
36
38
|
buildDeps(): Promise<void>;
|
|
37
39
|
getMiddlewares(): ((req: Request, res: Response, next: NextFunction) => void)[];
|
|
38
40
|
private getAwaitImportCollectOpts;
|
|
39
|
-
getBabelPlugins(): (
|
|
41
|
+
getBabelPlugins(): ({
|
|
40
42
|
onTransformDeps: () => void;
|
|
41
43
|
onCollect: ({ file, data, }: {
|
|
42
44
|
file: string;
|
|
@@ -54,7 +56,7 @@ export declare class MFSU {
|
|
|
54
56
|
remoteName: string | undefined;
|
|
55
57
|
alias: Record<string, string>;
|
|
56
58
|
externals: (Function | Record<string, string>)[];
|
|
57
|
-
} | typeof awaitImport)[]
|
|
59
|
+
} | typeof awaitImport)[][];
|
|
58
60
|
getEsbuildLoaderHandler(): any[];
|
|
59
61
|
}
|
|
60
62
|
export {};
|
package/dist/mfsu.js
CHANGED
|
@@ -21,14 +21,12 @@ const path_1 = require("path");
|
|
|
21
21
|
const mrmime_1 = require("../compiled/mrmime");
|
|
22
22
|
// @ts-ignore
|
|
23
23
|
const webpack_virtual_modules_1 = __importDefault(require("../compiled/webpack-virtual-modules"));
|
|
24
|
-
const autoExport_1 = __importDefault(require("./babelPlugins/autoExport"));
|
|
25
24
|
const awaitImport_1 = __importDefault(require("./babelPlugins/awaitImport/awaitImport"));
|
|
26
25
|
const getRealPath_1 = require("./babelPlugins/awaitImport/getRealPath");
|
|
27
26
|
const constants_1 = require("./constants");
|
|
28
27
|
const dep_1 = require("./dep/dep");
|
|
29
28
|
const depBuilder_1 = require("./depBuilder/depBuilder");
|
|
30
29
|
const depInfo_1 = require("./depInfo");
|
|
31
|
-
const autoExport_2 = __importDefault(require("./esbuildHandlers/autoExport"));
|
|
32
30
|
const awaitImport_2 = __importDefault(require("./esbuildHandlers/awaitImport"));
|
|
33
31
|
const types_1 = require("./types");
|
|
34
32
|
const makeArray_1 = require("./utils/makeArray");
|
|
@@ -39,12 +37,18 @@ class MFSU {
|
|
|
39
37
|
this.externals = [];
|
|
40
38
|
this.depConfig = null;
|
|
41
39
|
this.buildDepsAgain = false;
|
|
40
|
+
this.progress = { done: false };
|
|
42
41
|
this.opts = opts;
|
|
43
42
|
this.opts.mfName = this.opts.mfName || constants_1.DEFAULT_MF_NAME;
|
|
44
43
|
this.opts.tmpBase =
|
|
45
44
|
this.opts.tmpBase || (0, path_1.join)(process.cwd(), constants_1.DEFAULT_TMP_DIR_NAME);
|
|
46
45
|
this.opts.mode = this.opts.mode || types_1.Mode.development;
|
|
47
46
|
this.opts.getCacheDependency = this.opts.getCacheDependency || (() => ({}));
|
|
47
|
+
this.onProgress = (progress) => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
this.progress = Object.assign(Object.assign({}, this.progress), progress);
|
|
50
|
+
(_b = (_a = this.opts).onMFSUProgress) === null || _b === void 0 ? void 0 : _b.call(_a, this.progress);
|
|
51
|
+
};
|
|
48
52
|
this.opts.cwd = this.opts.cwd || process.cwd();
|
|
49
53
|
this.depInfo = new depInfo_1.DepInfo({ mfsu: this });
|
|
50
54
|
this.depBuilder = new depBuilder_1.DepBuilder({ mfsu: this });
|
|
@@ -166,8 +170,17 @@ promise new Promise(resolve => {
|
|
|
166
170
|
this.buildDepsAgain = true;
|
|
167
171
|
}
|
|
168
172
|
else {
|
|
169
|
-
this.buildDeps()
|
|
173
|
+
this.buildDeps()
|
|
174
|
+
.then(() => {
|
|
175
|
+
this.onProgress({
|
|
176
|
+
done: true,
|
|
177
|
+
});
|
|
178
|
+
})
|
|
179
|
+
.catch((e) => {
|
|
170
180
|
utils_1.logger.error(e);
|
|
181
|
+
this.onProgress({
|
|
182
|
+
done: true,
|
|
183
|
+
});
|
|
171
184
|
});
|
|
172
185
|
}
|
|
173
186
|
},
|
|
@@ -273,13 +286,12 @@ promise new Promise(resolve => {
|
|
|
273
286
|
};
|
|
274
287
|
}
|
|
275
288
|
getBabelPlugins() {
|
|
276
|
-
return [
|
|
289
|
+
return [[awaitImport_1.default, this.getAwaitImportCollectOpts()]];
|
|
277
290
|
}
|
|
278
291
|
getEsbuildLoaderHandler() {
|
|
279
292
|
const cache = new Map();
|
|
280
293
|
const checkOpts = this.getAwaitImportCollectOpts();
|
|
281
294
|
return [
|
|
282
|
-
autoExport_2.default,
|
|
283
295
|
(0, awaitImport_2.default)({
|
|
284
296
|
cache,
|
|
285
297
|
opts: checkOpts,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/mfsu",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20220412.2",
|
|
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",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"test": "jest -c ../../jest.turbo.config.ts"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@umijs/bundler-esbuild": "4.0.0-canary.
|
|
26
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
27
|
-
"@umijs/utils": "4.0.0-canary.
|
|
25
|
+
"@umijs/bundler-esbuild": "4.0.0-canary.20220412.2",
|
|
26
|
+
"@umijs/bundler-utils": "4.0.0-canary.20220412.2",
|
|
27
|
+
"@umijs/utils": "4.0.0-canary.20220412.2",
|
|
28
28
|
"enhanced-resolve": "5.9.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"mrmime": "1.0.0",
|
|
32
|
-
"webpack": "5.
|
|
32
|
+
"webpack": "5.72.0",
|
|
33
33
|
"webpack-virtual-modules": "0.4.3"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
27
|
-
function default_1() {
|
|
28
|
-
return {
|
|
29
|
-
visitor: {
|
|
30
|
-
Program(path) {
|
|
31
|
-
let hasExport = false;
|
|
32
|
-
path.node.body.forEach((node) => {
|
|
33
|
-
if (
|
|
34
|
-
// esm
|
|
35
|
-
t.isExportNamedDeclaration(node) ||
|
|
36
|
-
t.isExportDefaultDeclaration(node) ||
|
|
37
|
-
t.isExportAllDeclaration(node) ||
|
|
38
|
-
// cjs
|
|
39
|
-
(t.isExpressionStatement(node) &&
|
|
40
|
-
t.isAssignmentExpression(node.expression) &&
|
|
41
|
-
t.isMemberExpression(node.expression.left) &&
|
|
42
|
-
// exports.xxx =
|
|
43
|
-
(t.isIdentifier(node.expression.left.object, {
|
|
44
|
-
name: 'exports',
|
|
45
|
-
}) ||
|
|
46
|
-
// module.exports =
|
|
47
|
-
(t.isIdentifier(node.expression.left.object, {
|
|
48
|
-
name: 'module',
|
|
49
|
-
}) &&
|
|
50
|
-
t.isIdentifier(node.expression.left.property, {
|
|
51
|
-
name: 'exports',
|
|
52
|
-
}))))) {
|
|
53
|
-
hasExport = true;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
if (!hasExport) {
|
|
57
|
-
path.node.body.push(t.exportNamedDeclaration(t.variableDeclaration('const', [
|
|
58
|
-
t.variableDeclarator(t.identifier('__mfsu'), t.numericLiteral(1)),
|
|
59
|
-
])));
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
exports.default = default_1;
|