@umijs/mfsu 4.0.0-canary.20220718.2 → 4.0.0-canary.20220720.1
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.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/MFImport.js +59 -66
- package/dist/babelPlugins/awaitImport/awaitImport.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/awaitImport.js +103 -117
- package/dist/babelPlugins/awaitImport/checkMatch.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/checkMatch.js +129 -132
- package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/getAliasedPath.js +54 -35
- package/dist/babelPlugins/awaitImport/getRealPath.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/getRealPath.js +42 -21
- package/dist/babelPlugins/awaitImport/isExternals.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/isExternals.js +55 -26
- package/dist/babelPlugins/awaitImport/parseSpecifiers.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/parseSpecifiers.js +51 -52
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +47 -10
- package/dist/dep/dep.d.ts +0 -1
- package/dist/dep/dep.js +112 -83
- package/dist/dep/getCJSExports.d.ts +0 -1
- package/dist/dep/getCJSExports.js +60 -53
- package/dist/dep/getExposeFromContent.d.ts +0 -1
- package/dist/dep/getExposeFromContent.js +71 -61
- package/dist/dep/getModuleExports.d.ts +0 -1
- package/dist/dep/getModuleExports.js +58 -32
- package/dist/depBuilder/depBuilder.d.ts +0 -1
- package/dist/depBuilder/depBuilder.js +184 -158
- package/dist/depBuilder/getESBuildEntry.d.ts +0 -1
- package/dist/depBuilder/getESBuildEntry.js +35 -12
- package/dist/depInfo.d.ts +0 -1
- package/dist/depInfo.js +75 -53
- package/dist/esbuildHandlers/autoCssModules.d.ts +0 -1
- package/dist/esbuildHandlers/autoCssModules.js +43 -22
- package/dist/esbuildHandlers/awaitImport/index.d.ts +0 -1
- package/dist/esbuildHandlers/awaitImport/index.js +82 -70
- package/dist/index.d.ts +0 -1
- package/dist/index.js +32 -22
- package/dist/loader/esbuild.d.ts +0 -1
- package/dist/loader/esbuild.js +87 -35
- package/dist/mfsu/mfsu.d.ts +0 -1
- package/dist/mfsu/mfsu.js +229 -257
- package/dist/mfsu/strategyCompileTime.d.ts +0 -1
- package/dist/mfsu/strategyCompileTime.js +123 -99
- package/dist/mfsu/strategyStaticAnalyze.d.ts +0 -1
- package/dist/mfsu/strategyStaticAnalyze.js +135 -117
- package/dist/moduleGraph.d.ts +0 -1
- package/dist/moduleGraph.js +217 -186
- package/dist/staticDepInfo/importParser.d.ts +0 -1
- package/dist/staticDepInfo/importParser.js +28 -6
- package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts +0 -1
- package/dist/staticDepInfo/simulations/babel-plugin-import.js +99 -91
- package/dist/staticDepInfo/staticDepInfo.d.ts +0 -1
- package/dist/staticDepInfo/staticDepInfo.js +230 -197
- package/dist/types.d.ts +0 -1
- package/dist/types.js +33 -8
- package/dist/utils/makeArray.d.ts +0 -1
- package/dist/utils/makeArray.js +29 -5
- package/dist/utils/trimFileContent.d.ts +0 -1
- package/dist/utils/trimFileContent.js +29 -5
- package/dist/webpackPlugins/buildDepPlugin.d.ts +0 -1
- package/dist/webpackPlugins/buildDepPlugin.js +49 -25
- package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts +0 -1
- package/dist/webpackPlugins/depChunkIdPrefixPlugin.js +44 -19
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts +0 -1
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +46 -27
- package/dist/webpackPlugins/writeCachePlugin.d.ts +0 -1
- package/dist/webpackPlugins/writeCachePlugin.js +39 -15
- package/package.json +6 -6
- package/dist/babelPlugins/awaitImport/MFImport.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/awaitImport.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/checkMatch.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/getRealPath.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/isExternals.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/parseSpecifiers.d.ts.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/dep/dep.d.ts.map +0 -1
- package/dist/dep/getCJSExports.d.ts.map +0 -1
- package/dist/dep/getExposeFromContent.d.ts.map +0 -1
- package/dist/dep/getModuleExports.d.ts.map +0 -1
- package/dist/depBuilder/depBuilder.d.ts.map +0 -1
- package/dist/depBuilder/getESBuildEntry.d.ts.map +0 -1
- package/dist/depInfo.d.ts.map +0 -1
- package/dist/esbuildHandlers/autoCssModules.d.ts.map +0 -1
- package/dist/esbuildHandlers/awaitImport/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/loader/esbuild.d.ts.map +0 -1
- package/dist/mfsu/mfsu.d.ts.map +0 -1
- package/dist/mfsu/strategyCompileTime.d.ts.map +0 -1
- package/dist/mfsu/strategyStaticAnalyze.d.ts.map +0 -1
- package/dist/moduleGraph.d.ts.map +0 -1
- package/dist/staticDepInfo/importParser.d.ts.map +0 -1
- package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts.map +0 -1
- package/dist/staticDepInfo/staticDepInfo.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/makeArray.d.ts.map +0 -1
- package/dist/utils/trimFileContent.d.ts.map +0 -1
- package/dist/webpackPlugins/buildDepPlugin.d.ts.map +0 -1
- package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts.map +0 -1
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts.map +0 -1
- package/dist/webpackPlugins/writeCachePlugin.d.ts.map +0 -1
|
@@ -1,68 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
|
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 });
|
|
10
|
+
};
|
|
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;
|
|
24
18
|
};
|
|
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
|
-
};
|
|
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
|
+
// MFImport.ts
|
|
23
|
+
var MFImport_exports = {};
|
|
24
|
+
__export(MFImport_exports, {
|
|
25
|
+
default: () => MFImport_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(MFImport_exports);
|
|
28
|
+
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
29
|
+
function MFImport_default() {
|
|
30
|
+
return {
|
|
31
|
+
visitor: {
|
|
32
|
+
Program: {
|
|
33
|
+
exit(path, { opts }) {
|
|
34
|
+
let index = path.node.body.length - 1;
|
|
35
|
+
while (index >= 0) {
|
|
36
|
+
const node = path.node.body[index];
|
|
37
|
+
if (t.isImportDeclaration(node)) {
|
|
38
|
+
node.source.value = opts.resolveImportSource(node.source.value);
|
|
39
|
+
} else if (t.isExportAllDeclaration(node)) {
|
|
40
|
+
node.source.value = opts.resolveImportSource(node.source.value);
|
|
41
|
+
} else if (t.isExportNamedDeclaration(node) && node.source) {
|
|
42
|
+
node.source.value = opts.resolveImportSource(node.source.value);
|
|
43
|
+
}
|
|
44
|
+
index -= 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
CallExpression: {
|
|
49
|
+
exit(path, { opts }) {
|
|
50
|
+
const { node } = path;
|
|
51
|
+
if (t.isImport(node.callee) && node.arguments.length === 1 && node.arguments[0].type === "StringLiteral") {
|
|
52
|
+
const newValue = opts.resolveImportSource(node.arguments[0].value);
|
|
53
|
+
node.arguments[0] = t.stringLiteral(newValue);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
67
59
|
}
|
|
68
|
-
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {});
|
|
@@ -1,120 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
|
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 });
|
|
10
|
+
};
|
|
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;
|
|
24
18
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
+
// awaitImport.ts
|
|
23
|
+
var awaitImport_exports = {};
|
|
24
|
+
__export(awaitImport_exports, {
|
|
25
|
+
default: () => awaitImport_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(awaitImport_exports);
|
|
28
|
+
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
29
|
+
var import_checkMatch = require("./checkMatch");
|
|
30
|
+
function awaitImport_default() {
|
|
31
|
+
return {
|
|
32
|
+
pre() {
|
|
33
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
34
|
+
},
|
|
35
|
+
post(state) {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
const { cache } = this;
|
|
38
|
+
if (cache.has(state.opts.filename)) {
|
|
39
|
+
(_b = (_a = this.opts).onCollect) == null ? void 0 : _b.call(_a, {
|
|
40
|
+
file: state.opts.filename,
|
|
41
|
+
data: cache.get(state.opts.filename)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
visitor: {
|
|
46
|
+
Program: {
|
|
47
|
+
exit(path, { opts }) {
|
|
48
|
+
let index = path.node.body.length - 1;
|
|
49
|
+
while (index >= 0) {
|
|
50
|
+
const node = path.node.body[index];
|
|
51
|
+
if (t.isImportDeclaration(node)) {
|
|
52
|
+
const { isMatch, replaceValue } = (0, import_checkMatch.checkMatch)({
|
|
53
|
+
cache: this.cache,
|
|
54
|
+
value: node.source.value,
|
|
55
|
+
opts,
|
|
56
|
+
path
|
|
57
|
+
});
|
|
58
|
+
if (isMatch) {
|
|
59
|
+
node.source.value = replaceValue;
|
|
60
|
+
}
|
|
61
|
+
} else if (t.isExportAllDeclaration(node)) {
|
|
62
|
+
const { isMatch, replaceValue } = (0, import_checkMatch.checkMatch)({
|
|
63
|
+
cache: this.cache,
|
|
64
|
+
value: node.source.value,
|
|
65
|
+
opts,
|
|
66
|
+
path
|
|
67
|
+
});
|
|
68
|
+
if (isMatch) {
|
|
69
|
+
node.source.value = replaceValue;
|
|
70
|
+
}
|
|
71
|
+
} else if (t.isExportNamedDeclaration(node) && node.source) {
|
|
72
|
+
const { isMatch, replaceValue } = (0, import_checkMatch.checkMatch)({
|
|
73
|
+
cache: this.cache,
|
|
74
|
+
value: node.source.value,
|
|
75
|
+
opts,
|
|
76
|
+
path
|
|
77
|
+
});
|
|
78
|
+
if (isMatch) {
|
|
79
|
+
node.source.value = replaceValue;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
index -= 1;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
CallExpression: {
|
|
87
|
+
exit(path, { opts }) {
|
|
88
|
+
const { node } = path;
|
|
89
|
+
if (t.isImport(node.callee) && node.arguments.length === 1 && node.arguments[0].type === "StringLiteral") {
|
|
90
|
+
const { isMatch, replaceValue } = (0, import_checkMatch.checkMatch)({
|
|
91
|
+
cache: this.cache,
|
|
92
|
+
value: node.arguments[0].value,
|
|
93
|
+
opts,
|
|
94
|
+
path
|
|
95
|
+
});
|
|
96
|
+
if (isMatch) {
|
|
97
|
+
node.arguments[0] = t.stringLiteral(replaceValue);
|
|
44
98
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
while (index >= 0) {
|
|
51
|
-
const node = path.node.body[index];
|
|
52
|
-
// import x from 'x';
|
|
53
|
-
// import * as x from 'x';
|
|
54
|
-
// import x, * as xx from 'x';
|
|
55
|
-
// import { x } from 'x';
|
|
56
|
-
if (t.isImportDeclaration(node)) {
|
|
57
|
-
const { isMatch, replaceValue } = (0, checkMatch_1.checkMatch)({
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
cache: this.cache,
|
|
60
|
-
value: node.source.value,
|
|
61
|
-
opts,
|
|
62
|
-
path,
|
|
63
|
-
});
|
|
64
|
-
if (isMatch) {
|
|
65
|
-
node.source.value = replaceValue;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// export * from 'x';
|
|
69
|
-
else if (t.isExportAllDeclaration(node)) {
|
|
70
|
-
const { isMatch, replaceValue } = (0, checkMatch_1.checkMatch)({
|
|
71
|
-
// @ts-ignore
|
|
72
|
-
cache: this.cache,
|
|
73
|
-
value: node.source.value,
|
|
74
|
-
opts,
|
|
75
|
-
path,
|
|
76
|
-
});
|
|
77
|
-
if (isMatch) {
|
|
78
|
-
node.source.value = replaceValue;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// export { x } from 'x';
|
|
82
|
-
else if (t.isExportNamedDeclaration(node) && node.source) {
|
|
83
|
-
const { isMatch, replaceValue } = (0, checkMatch_1.checkMatch)({
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
cache: this.cache,
|
|
86
|
-
value: node.source.value,
|
|
87
|
-
opts,
|
|
88
|
-
path,
|
|
89
|
-
});
|
|
90
|
-
if (isMatch) {
|
|
91
|
-
node.source.value = replaceValue;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
index -= 1;
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
CallExpression: {
|
|
99
|
-
exit(path, { opts }) {
|
|
100
|
-
const { node } = path;
|
|
101
|
-
if (t.isImport(node.callee) &&
|
|
102
|
-
node.arguments.length === 1 &&
|
|
103
|
-
node.arguments[0].type === 'StringLiteral') {
|
|
104
|
-
const { isMatch, replaceValue } = (0, checkMatch_1.checkMatch)({
|
|
105
|
-
// @ts-ignore
|
|
106
|
-
cache: this.cache,
|
|
107
|
-
value: node.arguments[0].value,
|
|
108
|
-
opts,
|
|
109
|
-
path,
|
|
110
|
-
});
|
|
111
|
-
if (isMatch) {
|
|
112
|
-
node.arguments[0] = t.stringLiteral(replaceValue);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
119
104
|
}
|
|
120
|
-
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {});
|
|
@@ -1,145 +1,142 @@
|
|
|
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
|
-
|
|
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
|
+
// checkMatch.ts
|
|
23
|
+
var checkMatch_exports = {};
|
|
24
|
+
__export(checkMatch_exports, {
|
|
25
|
+
checkMatch: () => checkMatch,
|
|
26
|
+
getPath: () => getPath
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(checkMatch_exports);
|
|
29
|
+
var import_utils = require("@umijs/utils");
|
|
30
|
+
var import_assert = __toESM(require("assert"));
|
|
31
|
+
var import_path = require("path");
|
|
32
|
+
var import_getAliasedPath = require("./getAliasedPath");
|
|
33
|
+
var import_isExternals = require("./isExternals");
|
|
34
|
+
var RE_NODE_MODULES = /node_modules/;
|
|
14
35
|
function isUmiLocalDev(path) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
? (0, utils_1.winPath)(path).startsWith((0, utils_1.winPath)((0, path_1.join)(rootPath, './packages')))
|
|
18
|
-
: false;
|
|
36
|
+
const rootPath = (0, import_utils.isLocalDev)();
|
|
37
|
+
return rootPath ? (0, import_utils.winPath)(path).startsWith((0, import_utils.winPath)((0, import_path.join)(rootPath, "./packages"))) : false;
|
|
19
38
|
}
|
|
20
39
|
function genUnMatchLibsRegex(libs) {
|
|
21
|
-
|
|
22
|
-
|
|
40
|
+
if (!libs) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const deps = libs.map((lib) => {
|
|
44
|
+
if (typeof lib === "string") {
|
|
45
|
+
return `^${lib}$`;
|
|
46
|
+
} else if (lib instanceof RegExp) {
|
|
47
|
+
return lib.source;
|
|
23
48
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return `^${lib}$`;
|
|
27
|
-
}
|
|
28
|
-
else if (lib instanceof RegExp) {
|
|
29
|
-
return lib.source;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
return deps.length ? new RegExp(deps.join('|')) : null;
|
|
49
|
+
});
|
|
50
|
+
return deps.length ? new RegExp(deps.join("|")) : null;
|
|
33
51
|
}
|
|
34
|
-
function checkMatch({
|
|
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
|
-
return checkMatch({
|
|
74
|
-
value: aliasedPath,
|
|
75
|
-
path,
|
|
76
|
-
opts,
|
|
77
|
-
isExportAll,
|
|
78
|
-
depth: depth + 1,
|
|
79
|
-
cache,
|
|
80
|
-
filename,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
isMatch = true;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (isMatch && isExportAll) {
|
|
88
|
-
isMatch = !!(opts.exportAllMembers && value in opts.exportAllMembers);
|
|
52
|
+
function checkMatch({
|
|
53
|
+
value,
|
|
54
|
+
path,
|
|
55
|
+
opts,
|
|
56
|
+
isExportAll,
|
|
57
|
+
depth,
|
|
58
|
+
cache,
|
|
59
|
+
filename
|
|
60
|
+
}) {
|
|
61
|
+
var _a;
|
|
62
|
+
let isMatch;
|
|
63
|
+
let replaceValue = "";
|
|
64
|
+
depth = depth || 1;
|
|
65
|
+
(0, import_assert.default)(depth <= 10, `endless loop detected in checkMatch, please check your alias config.`);
|
|
66
|
+
opts = opts || {};
|
|
67
|
+
const remoteName = opts.remoteName || "mf";
|
|
68
|
+
value = value.replace(/^@fs\//, "/");
|
|
69
|
+
const unMatchLibsRegex = genUnMatchLibsRegex(opts.unMatchLibs);
|
|
70
|
+
if ((unMatchLibsRegex == null ? void 0 : unMatchLibsRegex.test(value)) || value.includes("client/client/client.js") || value.startsWith(`${remoteName}/`) || (0, import_utils.winPath)(value).includes("babel/svgr-webpack") || value.startsWith("!!") || (0, import_isExternals.isExternals)({ value, externals: opts.externals }) || value.startsWith(".")) {
|
|
71
|
+
isMatch = false;
|
|
72
|
+
} else if ((0, import_path.isAbsolute)(value)) {
|
|
73
|
+
isMatch = RE_NODE_MODULES.test(value) || isUmiLocalDev(value);
|
|
74
|
+
} else {
|
|
75
|
+
const aliasedPath = (0, import_getAliasedPath.getAliasedPath)({
|
|
76
|
+
value,
|
|
77
|
+
alias: opts.alias || {}
|
|
78
|
+
});
|
|
79
|
+
if (aliasedPath) {
|
|
80
|
+
return checkMatch({
|
|
81
|
+
value: aliasedPath,
|
|
82
|
+
path,
|
|
83
|
+
opts,
|
|
84
|
+
isExportAll,
|
|
85
|
+
depth: depth + 1,
|
|
86
|
+
cache,
|
|
87
|
+
filename
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
isMatch = true;
|
|
89
91
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
}
|
|
93
|
+
if (isMatch && isExportAll) {
|
|
94
|
+
isMatch = !!(opts.exportAllMembers && value in opts.exportAllMembers);
|
|
95
|
+
}
|
|
96
|
+
if (isMatch) {
|
|
97
|
+
replaceValue = `${remoteName}/${(0, import_utils.winPath)(value)}`;
|
|
98
|
+
}
|
|
99
|
+
const file = (path == null ? void 0 : path.hub.file.opts.filename) || filename;
|
|
100
|
+
(_a = opts.onTransformDeps) == null ? void 0 : _a.call(opts, {
|
|
101
|
+
sourceValue: value,
|
|
102
|
+
replaceValue,
|
|
103
|
+
isMatch,
|
|
104
|
+
file
|
|
105
|
+
});
|
|
106
|
+
if (cache) {
|
|
107
|
+
let mod;
|
|
108
|
+
if (cache.has(file)) {
|
|
109
|
+
mod = cache.get(file);
|
|
110
|
+
} else {
|
|
111
|
+
mod = {
|
|
112
|
+
matched: /* @__PURE__ */ new Set(),
|
|
113
|
+
unMatched: /* @__PURE__ */ new Set()
|
|
114
|
+
};
|
|
115
|
+
cache.set(file, mod);
|
|
92
116
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
replaceValue,
|
|
98
|
-
isMatch,
|
|
99
|
-
file,
|
|
117
|
+
mod[isMatch ? "matched" : "unMatched"].add({
|
|
118
|
+
sourceValue: value,
|
|
119
|
+
replaceValue,
|
|
120
|
+
file
|
|
100
121
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
mod = {
|
|
108
|
-
matched: new Set(),
|
|
109
|
-
unMatched: new Set(),
|
|
110
|
-
};
|
|
111
|
-
cache.set(file, mod);
|
|
112
|
-
}
|
|
113
|
-
mod[isMatch ? 'matched' : 'unMatched'].add({
|
|
114
|
-
sourceValue: value,
|
|
115
|
-
replaceValue,
|
|
116
|
-
file,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
// console.log(
|
|
120
|
-
// '> check',
|
|
121
|
-
// // @ts-ignore
|
|
122
|
-
// path.hub.file.opts.filename,
|
|
123
|
-
// value,
|
|
124
|
-
// cache,
|
|
125
|
-
// 'isMatch',
|
|
126
|
-
// isMatch,
|
|
127
|
-
// );
|
|
128
|
-
return {
|
|
129
|
-
isMatch,
|
|
130
|
-
replaceValue,
|
|
131
|
-
value,
|
|
132
|
-
};
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
isMatch,
|
|
125
|
+
replaceValue,
|
|
126
|
+
value
|
|
127
|
+
};
|
|
133
128
|
}
|
|
134
|
-
exports.checkMatch = checkMatch;
|
|
135
|
-
// TODO: REMOVE ME
|
|
136
129
|
function getPath({ value, opts }) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
130
|
+
const alias = opts.alias || {};
|
|
131
|
+
for (const key of Object.keys(alias)) {
|
|
132
|
+
if (value.startsWith(key)) {
|
|
133
|
+
return value.replace(key, alias[key]);
|
|
142
134
|
}
|
|
143
|
-
|
|
135
|
+
}
|
|
136
|
+
return value;
|
|
144
137
|
}
|
|
145
|
-
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
checkMatch,
|
|
141
|
+
getPath
|
|
142
|
+
});
|