@umijs/mfsu 4.0.7 → 4.0.8
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 -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.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/checkMatch.js +18 -3
- package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/getAliasedPath.js +54 -35
- package/dist/babelPlugins/awaitImport/getRealPath.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/getRealPath.js +42 -21
- package/dist/babelPlugins/awaitImport/isExternals.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/isExternals.js +55 -26
- package/dist/babelPlugins/awaitImport/parseSpecifiers.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/parseSpecifiers.js +51 -52
- package/dist/constants.d.ts +0 -0
- package/dist/constants.js +47 -10
- package/dist/dep/dep.d.ts +0 -0
- package/dist/dep/dep.js +0 -0
- package/dist/dep/getCJSExports.d.ts +0 -0
- package/dist/dep/getCJSExports.js +60 -53
- package/dist/dep/getExposeFromContent.d.ts +0 -0
- package/dist/dep/getExposeFromContent.js +71 -59
- package/dist/dep/getModuleExports.d.ts +0 -0
- package/dist/dep/getModuleExports.js +58 -32
- package/dist/depBuilder/depBuilder.d.ts +0 -0
- package/dist/depBuilder/depBuilder.js +0 -0
- package/dist/depBuilder/getESBuildEntry.d.ts +0 -0
- package/dist/depBuilder/getESBuildEntry.js +35 -12
- package/dist/depInfo.d.ts +0 -0
- package/dist/depInfo.js +0 -0
- package/dist/esbuildHandlers/autoCssModules.d.ts +0 -0
- package/dist/esbuildHandlers/autoCssModules.js +0 -0
- package/dist/esbuildHandlers/awaitImport/index.d.ts +0 -0
- package/dist/esbuildHandlers/awaitImport/index.js +82 -70
- package/dist/index.d.ts +0 -0
- package/dist/index.js +32 -22
- package/dist/loader/esbuild.d.ts +0 -0
- package/dist/loader/esbuild.js +87 -35
- package/dist/mfsu/mfsu.d.ts +1 -1
- package/dist/mfsu/mfsu.js +0 -0
- package/dist/mfsu/strategyCompileTime.d.ts +0 -0
- package/dist/mfsu/strategyCompileTime.js +0 -0
- package/dist/mfsu/strategyStaticAnalyze.d.ts +0 -0
- package/dist/mfsu/strategyStaticAnalyze.js +0 -0
- package/dist/moduleGraph.d.ts +0 -0
- package/dist/moduleGraph.js +0 -0
- package/dist/staticDepInfo/importParser.d.ts +0 -0
- package/dist/staticDepInfo/importParser.js +28 -6
- package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts +0 -0
- package/dist/staticDepInfo/simulations/babel-plugin-import.js +0 -0
- package/dist/staticDepInfo/staticDepInfo.d.ts +0 -0
- package/dist/staticDepInfo/staticDepInfo.js +0 -0
- package/dist/types.d.ts +0 -0
- package/dist/types.js +33 -8
- package/dist/utils/makeArray.d.ts +0 -0
- package/dist/utils/makeArray.js +29 -5
- package/dist/utils/trimFileContent.d.ts +0 -0
- package/dist/utils/trimFileContent.js +29 -5
- package/dist/webpackPlugins/buildDepPlugin.d.ts +0 -0
- package/dist/webpackPlugins/buildDepPlugin.js +49 -25
- package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts +0 -0
- package/dist/webpackPlugins/depChunkIdPrefixPlugin.js +44 -19
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts +0 -0
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +46 -27
- package/dist/webpackPlugins/writeCachePlugin.d.ts +0 -0
- package/dist/webpackPlugins/writeCachePlugin.js +39 -15
- package/package.json +6 -6
|
@@ -1,29 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// isExternals.ts
|
|
20
|
+
var isExternals_exports = {};
|
|
21
|
+
__export(isExternals_exports, {
|
|
22
|
+
isExternal: () => isExternal,
|
|
23
|
+
isExternals: () => isExternals
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(isExternals_exports);
|
|
26
|
+
function isExternals({
|
|
27
|
+
value,
|
|
28
|
+
externals
|
|
29
|
+
}) {
|
|
30
|
+
const externalsArr = Array.isArray(externals) ? externals : [externals];
|
|
31
|
+
for (const external of externalsArr) {
|
|
32
|
+
if (isExternal({ value, external })) {
|
|
33
|
+
return true;
|
|
10
34
|
}
|
|
11
|
-
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
12
37
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
function isExternal({
|
|
39
|
+
value,
|
|
40
|
+
external
|
|
41
|
+
}) {
|
|
42
|
+
if (typeof external === "object") {
|
|
43
|
+
return !!external[value];
|
|
44
|
+
} else if (typeof external === "function") {
|
|
45
|
+
let ret = false;
|
|
46
|
+
external({}, value, (_, b) => {
|
|
47
|
+
ret = !!b;
|
|
48
|
+
});
|
|
49
|
+
return ret;
|
|
50
|
+
} else {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
28
53
|
}
|
|
29
|
-
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
isExternal,
|
|
57
|
+
isExternals
|
|
58
|
+
});
|
|
File without changes
|
|
@@ -1,55 +1,54 @@
|
|
|
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
|
-
|
|
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
|
+
// parseSpecifiers.ts
|
|
23
|
+
var parseSpecifiers_exports = {};
|
|
24
|
+
__export(parseSpecifiers_exports, {
|
|
25
|
+
parseSpecifiers: () => parseSpecifiers
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(parseSpecifiers_exports);
|
|
28
|
+
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
29
|
+
var DEFAULT = "default";
|
|
29
30
|
function parseSpecifiers(specifiers) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
else {
|
|
50
|
-
memo.properties.push(t.objectProperty(s.imported, s.local));
|
|
51
|
-
}
|
|
52
|
-
return memo;
|
|
53
|
-
}, { properties: [], namespaceIdentifier: null, defaultIdentifier: null });
|
|
31
|
+
return specifiers.reduce((memo, s) => {
|
|
32
|
+
if (t.isImportDefaultSpecifier(s)) {
|
|
33
|
+
memo.properties.push(t.objectProperty(t.identifier(DEFAULT), s.local));
|
|
34
|
+
} else if (t.isExportDefaultSpecifier(s)) {
|
|
35
|
+
memo.properties.push(t.objectProperty(t.identifier(DEFAULT), s.exported));
|
|
36
|
+
} else if (t.isExportSpecifier(s)) {
|
|
37
|
+
if (t.isIdentifier(s.exported, { name: DEFAULT })) {
|
|
38
|
+
memo.defaultIdentifier = s.local.name;
|
|
39
|
+
memo.properties.push(t.objectProperty(s.local, s.local));
|
|
40
|
+
} else {
|
|
41
|
+
memo.properties.push(t.objectProperty(s.local, s.exported));
|
|
42
|
+
}
|
|
43
|
+
} else if (t.isImportNamespaceSpecifier(s)) {
|
|
44
|
+
memo.namespaceIdentifier = s.local;
|
|
45
|
+
} else {
|
|
46
|
+
memo.properties.push(t.objectProperty(s.imported, s.local));
|
|
47
|
+
}
|
|
48
|
+
return memo;
|
|
49
|
+
}, { properties: [], namespaceIdentifier: null, defaultIdentifier: null });
|
|
54
50
|
}
|
|
55
|
-
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
parseSpecifiers
|
|
54
|
+
});
|
package/dist/constants.d.ts
CHANGED
|
File without changes
|
package/dist/constants.js
CHANGED
|
@@ -1,10 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// constants.ts
|
|
20
|
+
var constants_exports = {};
|
|
21
|
+
__export(constants_exports, {
|
|
22
|
+
DEFAULT_MF_NAME: () => DEFAULT_MF_NAME,
|
|
23
|
+
DEFAULT_TMP_DIR_NAME: () => DEFAULT_TMP_DIR_NAME,
|
|
24
|
+
MF_DEP_PREFIX: () => MF_DEP_PREFIX,
|
|
25
|
+
MF_STATIC_PREFIX: () => MF_STATIC_PREFIX,
|
|
26
|
+
MF_VA_PREFIX: () => MF_VA_PREFIX,
|
|
27
|
+
REMOTE_FILE: () => REMOTE_FILE,
|
|
28
|
+
REMOTE_FILE_FULL: () => REMOTE_FILE_FULL
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(constants_exports);
|
|
31
|
+
var MF_VA_PREFIX = "mf-va_";
|
|
32
|
+
var MF_DEP_PREFIX = "mf-dep_";
|
|
33
|
+
var MF_STATIC_PREFIX = "mf-static/";
|
|
34
|
+
var DEFAULT_MF_NAME = "mf";
|
|
35
|
+
var DEFAULT_TMP_DIR_NAME = ".mfsu";
|
|
36
|
+
var REMOTE_FILE = "remoteEntry.js";
|
|
37
|
+
var REMOTE_FILE_FULL = `${MF_VA_PREFIX}${REMOTE_FILE}`;
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
DEFAULT_MF_NAME,
|
|
41
|
+
DEFAULT_TMP_DIR_NAME,
|
|
42
|
+
MF_DEP_PREFIX,
|
|
43
|
+
MF_STATIC_PREFIX,
|
|
44
|
+
MF_VA_PREFIX,
|
|
45
|
+
REMOTE_FILE,
|
|
46
|
+
REMOTE_FILE_FULL
|
|
47
|
+
});
|
package/dist/dep/dep.d.ts
CHANGED
|
File without changes
|
package/dist/dep/dep.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -1,58 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// getCJSExports.ts
|
|
20
|
+
var getCJSExports_exports = {};
|
|
21
|
+
__export(getCJSExports_exports, {
|
|
22
|
+
getCJSExports: () => getCJSExports
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(getCJSExports_exports);
|
|
4
25
|
function getCJSExports({ content }) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// Support __webpack_require__.d(__webpack_exports__, {"default": function() { return /* binding */ clipboard; }});
|
|
20
|
-
// ref: https://unpkg.alibaba-inc.com/browse/clipboard@2.0.8/dist/clipboard.js L26
|
|
21
|
-
...matchAll(/__webpack_require__\.d\(\s*__webpack_exports__\s*,\s*(\{)/g, content).map((matchResult) => {
|
|
22
|
-
const { index } = matchResult;
|
|
23
|
-
let idx = index;
|
|
24
|
-
let deep = 0;
|
|
25
|
-
let isMeetSymbol = false;
|
|
26
|
-
let symbolBeginIndex = index;
|
|
27
|
-
while (idx < content.length) {
|
|
28
|
-
if (!deep && isMeetSymbol) {
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
if (content[idx] === '{') {
|
|
32
|
-
if (!isMeetSymbol) {
|
|
33
|
-
isMeetSymbol = true;
|
|
34
|
-
symbolBeginIndex = idx;
|
|
35
|
-
}
|
|
36
|
-
deep++;
|
|
37
|
-
}
|
|
38
|
-
if (content[idx] === '}') {
|
|
39
|
-
deep--;
|
|
40
|
-
}
|
|
41
|
-
idx++;
|
|
26
|
+
return matchAll(/Object\.defineProperty\(\s*exports\s*\,\s*[\"|\'](\w+)[\"|\']/g, content).concat(matchAll(/exports(?:\.|\[(?:\'|\"))(\w+)(?:\s*|(?:\'|\")\])\s*\=/g, content)).concat(matchAll(/__webpack_exports__\[(?:\"|\')(\w+)(?:\"|\')\]\s*\=/g, content)).concat(matchAll(/__webpack_require__\.d\(\s*__webpack_exports__\s*,\s*(?:\"|\')(\w+)(?:\"|\')\s*,/g, content)).concat(...matchAll(/__webpack_require__\.d\(\s*__webpack_exports__\s*,\s*(\{)/g, content).map((matchResult) => {
|
|
27
|
+
const { index } = matchResult;
|
|
28
|
+
let idx = index;
|
|
29
|
+
let deep = 0;
|
|
30
|
+
let isMeetSymbol = false;
|
|
31
|
+
let symbolBeginIndex = index;
|
|
32
|
+
while (idx < content.length) {
|
|
33
|
+
if (!deep && isMeetSymbol) {
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
if (content[idx] === "{") {
|
|
37
|
+
if (!isMeetSymbol) {
|
|
38
|
+
isMeetSymbol = true;
|
|
39
|
+
symbolBeginIndex = idx;
|
|
42
40
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
deep++;
|
|
42
|
+
}
|
|
43
|
+
if (content[idx] === "}") {
|
|
44
|
+
deep--;
|
|
45
|
+
}
|
|
46
|
+
idx++;
|
|
47
|
+
}
|
|
48
|
+
let result = content.slice(symbolBeginIndex, idx);
|
|
49
|
+
return [
|
|
50
|
+
...matchAll(/(?:\"|\')(\w+)(?:\"|\')\s*\:\s*(?:function|\()/g, result)
|
|
51
|
+
];
|
|
52
|
+
})).map((result) => result[1]);
|
|
49
53
|
}
|
|
50
|
-
exports.getCJSExports = getCJSExports;
|
|
51
54
|
function matchAll(regexp, str) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const result = [];
|
|
56
|
+
let match;
|
|
57
|
+
while ((match = regexp.exec(str)) !== null) {
|
|
58
|
+
result.push(match);
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
58
61
|
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
getCJSExports
|
|
65
|
+
});
|
|
File without changes
|
|
@@ -1,69 +1,81 @@
|
|
|
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
|
-
|
|
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
|
+
// getExposeFromContent.ts
|
|
23
|
+
var getExposeFromContent_exports = {};
|
|
24
|
+
__export(getExposeFromContent_exports, {
|
|
25
|
+
getExposeFromContent: () => getExposeFromContent
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(getExposeFromContent_exports);
|
|
28
|
+
var import_assert = __toESM(require("assert"));
|
|
29
|
+
var import_path = require("path");
|
|
30
|
+
var import_getModuleExports = require("./getModuleExports");
|
|
10
31
|
async function getExposeFromContent(opts) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// Support Assets Files
|
|
17
|
-
if (opts.filePath &&
|
|
18
|
-
/\.(json|svg|png|jpe?g|avif|gif|webp|ico|eot|woff|woff2|ttf|txt|text|mdx?)$/.test(opts.filePath)) {
|
|
19
|
-
return `
|
|
32
|
+
if (opts.filePath && /\.(css|less|scss|sass|stylus|styl)$/.test(opts.filePath)) {
|
|
33
|
+
return `import '${opts.dep.file}';`;
|
|
34
|
+
}
|
|
35
|
+
if (opts.filePath && /\.(json|svg|png|jpe?g|avif|gif|webp|ico|eot|woff|woff2|ttf|txt|text|mdx?)$/.test(opts.filePath)) {
|
|
36
|
+
return `
|
|
20
37
|
import _ from '${opts.dep.file}';
|
|
21
38
|
export default _;`.trim();
|
|
39
|
+
}
|
|
40
|
+
(0, import_assert.default)(/(js|jsx|mjs|ts|tsx)$/.test(opts.filePath), `file type not supported for ${(0, import_path.basename)(opts.filePath)}.`);
|
|
41
|
+
const { exports, isCJS } = await (0, import_getModuleExports.getModuleExports)({
|
|
42
|
+
content: opts.content,
|
|
43
|
+
filePath: opts.filePath
|
|
44
|
+
});
|
|
45
|
+
if (isCJS) {
|
|
46
|
+
return [
|
|
47
|
+
`import _ from '${opts.dep.file}';`,
|
|
48
|
+
`export default _;`,
|
|
49
|
+
`export * from '${opts.dep.file}';`
|
|
50
|
+
].join("\n");
|
|
51
|
+
} else {
|
|
52
|
+
const ret = [];
|
|
53
|
+
let hasExports = false;
|
|
54
|
+
if (exports.includes("default")) {
|
|
55
|
+
ret.push(`import _ from '${opts.dep.file}';`);
|
|
56
|
+
ret.push(`export default _;`);
|
|
57
|
+
hasExports = true;
|
|
22
58
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
filePath: opts.filePath,
|
|
27
|
-
});
|
|
28
|
-
// cjs
|
|
29
|
-
if (isCJS) {
|
|
30
|
-
return [
|
|
31
|
-
`import _ from '${opts.dep.file}';`,
|
|
32
|
-
`export default _;`,
|
|
33
|
-
`export * from '${opts.dep.file}';`,
|
|
34
|
-
].join('\n');
|
|
59
|
+
if (hasNonDefaultExports(exports) || /export\s*\*\s*from/.test(opts.content)) {
|
|
60
|
+
ret.push(`export * from '${opts.dep.file}';`);
|
|
61
|
+
hasExports = true;
|
|
35
62
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
if (hasNonDefaultExports(exports) ||
|
|
46
|
-
// export * from 不会有 exports,只会有 imports
|
|
47
|
-
/export\s+\*\s+from/.test(opts.content)) {
|
|
48
|
-
ret.push(`export * from '${opts.dep.file}';`);
|
|
49
|
-
hasExports = true;
|
|
50
|
-
}
|
|
51
|
-
if (!hasExports) {
|
|
52
|
-
// 只有 __esModule 的全量导出
|
|
53
|
-
if (exports.includes('__esModule')) {
|
|
54
|
-
ret.push(`import _ from '${opts.dep.file}';`);
|
|
55
|
-
ret.push(`export default _;`);
|
|
56
|
-
ret.push(`export * from '${opts.dep.file}';`);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
ret.push(`import '${opts.dep.file}';`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return ret.join('\n');
|
|
63
|
+
if (!hasExports) {
|
|
64
|
+
if (exports.includes("__esModule")) {
|
|
65
|
+
ret.push(`import _ from '${opts.dep.file}';`);
|
|
66
|
+
ret.push(`export default _;`);
|
|
67
|
+
ret.push(`export * from '${opts.dep.file}';`);
|
|
68
|
+
} else {
|
|
69
|
+
ret.push(`import '${opts.dep.file}';`);
|
|
70
|
+
}
|
|
63
71
|
}
|
|
72
|
+
return ret.join("\n");
|
|
73
|
+
}
|
|
64
74
|
}
|
|
65
|
-
exports.getExposeFromContent = getExposeFromContent;
|
|
66
75
|
function hasNonDefaultExports(exports) {
|
|
67
|
-
|
|
68
|
-
.length > 0);
|
|
76
|
+
return exports.filter((exp) => !["__esModule", "default"].includes(exp)).length > 0;
|
|
69
77
|
}
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
getExposeFromContent
|
|
81
|
+
});
|
|
File without changes
|
|
@@ -1,34 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// getModuleExports.ts
|
|
20
|
+
var getModuleExports_exports = {};
|
|
21
|
+
__export(getModuleExports_exports, {
|
|
22
|
+
getModuleExports: () => getModuleExports
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(getModuleExports_exports);
|
|
25
|
+
var import_es_module_lexer = require("@umijs/bundler-utils/compiled/es-module-lexer");
|
|
26
|
+
var import_esbuild = require("@umijs/bundler-utils/compiled/esbuild");
|
|
27
|
+
var import_path = require("path");
|
|
28
|
+
var import_getCJSExports = require("./getCJSExports");
|
|
29
|
+
async function getModuleExports({
|
|
30
|
+
content,
|
|
31
|
+
filePath
|
|
32
|
+
}) {
|
|
33
|
+
if (filePath && /\.(tsx|jsx)$/.test(filePath)) {
|
|
34
|
+
content = (await (0, import_esbuild.transform)(content, {
|
|
35
|
+
sourcemap: false,
|
|
36
|
+
sourcefile: filePath,
|
|
37
|
+
format: "esm",
|
|
38
|
+
target: "es6",
|
|
39
|
+
loader: (0, import_path.extname)(filePath).slice(1)
|
|
40
|
+
})).code;
|
|
41
|
+
}
|
|
42
|
+
await import_es_module_lexer.init;
|
|
43
|
+
const [imports, exports] = (0, import_es_module_lexer.parse)(content);
|
|
44
|
+
let isCJS = !imports.length && !exports.length;
|
|
45
|
+
let cjsEsmExports = null;
|
|
46
|
+
if (isCJS) {
|
|
47
|
+
cjsEsmExports = (0, import_getCJSExports.getCJSExports)({ content });
|
|
48
|
+
if (cjsEsmExports.includes("__esModule")) {
|
|
49
|
+
isCJS = false;
|
|
18
50
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
cjsEsmExports = (0, getCJSExports_1.getCJSExports)({ content });
|
|
25
|
-
if (cjsEsmExports.includes('__esModule')) {
|
|
26
|
-
isCJS = false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
exports: cjsEsmExports || exports,
|
|
31
|
-
isCJS,
|
|
32
|
-
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
exports: cjsEsmExports || exports,
|
|
54
|
+
isCJS
|
|
55
|
+
};
|
|
33
56
|
}
|
|
34
|
-
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
getModuleExports
|
|
60
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|