@umijs/mfsu 4.0.8 → 4.0.11
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/compiled/is-absolute-url/LICENSE +9 -0
- package/compiled/is-absolute-url/index.d.ts +22 -0
- package/compiled/is-absolute-url/index.js +1 -0
- package/compiled/is-absolute-url/package.json +1 -0
- package/dist/babelPlugins/awaitImport/MFImport.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/MFImport.js +1 -1
- package/dist/babelPlugins/awaitImport/awaitImport.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/awaitImport.js +1 -1
- package/dist/babelPlugins/awaitImport/checkMatch.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/checkMatch.js +129 -132
- package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/getAliasedPath.js +1 -1
- package/dist/babelPlugins/awaitImport/getRealPath.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/getRealPath.js +1 -1
- package/dist/babelPlugins/awaitImport/isExternals.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/isExternals.js +1 -1
- package/dist/babelPlugins/awaitImport/parseSpecifiers.d.ts +0 -0
- package/dist/babelPlugins/awaitImport/parseSpecifiers.js +1 -1
- package/dist/constants.d.ts +0 -0
- package/dist/constants.js +1 -1
- package/dist/dep/dep.d.ts +0 -0
- package/dist/dep/dep.js +112 -83
- package/dist/dep/getCJSExports.d.ts +0 -0
- package/dist/dep/getCJSExports.js +1 -1
- package/dist/dep/getExposeFromContent.d.ts +0 -0
- package/dist/dep/getExposeFromContent.js +1 -1
- package/dist/dep/getModuleExports.d.ts +0 -0
- package/dist/dep/getModuleExports.js +1 -1
- package/dist/depBuilder/depBuilder.d.ts +0 -0
- package/dist/depBuilder/depBuilder.js +191 -158
- package/dist/depBuilder/getESBuildEntry.d.ts +0 -0
- package/dist/depBuilder/getESBuildEntry.js +1 -1
- package/dist/depInfo.d.ts +0 -0
- package/dist/depInfo.js +75 -53
- package/dist/esbuildHandlers/autoCssModules.d.ts +0 -0
- package/dist/esbuildHandlers/autoCssModules.js +43 -22
- package/dist/esbuildHandlers/awaitImport/index.d.ts +0 -0
- package/dist/esbuildHandlers/awaitImport/index.js +1 -1
- package/dist/index.d.ts +0 -0
- package/dist/index.js +1 -1
- package/dist/loader/esbuild.d.ts +0 -0
- package/dist/loader/esbuild.js +1 -1
- package/dist/mfsu/mfsu.d.ts +4 -0
- package/dist/mfsu/mfsu.js +236 -257
- package/dist/mfsu/strategyCompileTime.d.ts +0 -0
- package/dist/mfsu/strategyCompileTime.js +131 -99
- package/dist/mfsu/strategyStaticAnalyze.d.ts +0 -0
- package/dist/mfsu/strategyStaticAnalyze.js +151 -115
- package/dist/moduleGraph.d.ts +0 -0
- package/dist/moduleGraph.js +227 -186
- package/dist/staticDepInfo/importParser.d.ts +0 -0
- package/dist/staticDepInfo/importParser.js +1 -1
- package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts +0 -0
- package/dist/staticDepInfo/simulations/babel-plugin-import.js +99 -91
- package/dist/staticDepInfo/staticDepInfo.d.ts +0 -0
- package/dist/staticDepInfo/staticDepInfo.js +239 -197
- package/dist/types.d.ts +0 -0
- package/dist/types.js +1 -1
- package/dist/utils/makeArray.d.ts +0 -0
- package/dist/utils/makeArray.js +1 -1
- package/dist/utils/trimFileContent.d.ts +0 -0
- package/dist/utils/trimFileContent.js +1 -1
- package/dist/webpackPlugins/buildDepPlugin.d.ts +0 -0
- package/dist/webpackPlugins/buildDepPlugin.js +1 -1
- package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts +0 -0
- package/dist/webpackPlugins/depChunkIdPrefixPlugin.js +1 -1
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts +0 -0
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +1 -1
- package/dist/webpackPlugins/writeCachePlugin.d.ts +0 -0
- package/dist/webpackPlugins/writeCachePlugin.js +1 -1
- package/package.json +8 -6
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Check if a URL is absolute.
|
|
3
|
+
|
|
4
|
+
@param url - The URL to check.
|
|
5
|
+
|
|
6
|
+
@example
|
|
7
|
+
```
|
|
8
|
+
import isAbsoluteUrl = require('./is-absolute-url');
|
|
9
|
+
|
|
10
|
+
isAbsoluteUrl('http://sindresorhus.com/foo/bar');
|
|
11
|
+
//=> true
|
|
12
|
+
|
|
13
|
+
isAbsoluteUrl('//sindresorhus.com');
|
|
14
|
+
//=> false
|
|
15
|
+
|
|
16
|
+
isAbsoluteUrl('foo/bar');
|
|
17
|
+
//=> false
|
|
18
|
+
```
|
|
19
|
+
*/
|
|
20
|
+
declare function isAbsoluteUrl(url: string): boolean;
|
|
21
|
+
|
|
22
|
+
export = isAbsoluteUrl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";var e={442:function(e){e.exports=e=>{if(typeof e!=="string"){throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``)}if(/^[a-zA-Z]:\\/.test(e)){return false}return/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e)}}};var r={};function __nccwpck_require__(t){var _=r[t];if(_!==undefined){return _.exports}var a=r[t]={exports:{}};var i=true;try{e[t](a,a.exports,__nccwpck_require__);i=false}finally{if(i)delete r[t]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(442);module.exports=t})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"is-absolute-url","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"license":"MIT"}
|
|
File without changes
|
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
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
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// MFImport.ts
|
|
22
|
+
// src/babelPlugins/awaitImport/MFImport.ts
|
|
23
23
|
var MFImport_exports = {};
|
|
24
24
|
__export(MFImport_exports, {
|
|
25
25
|
default: () => MFImport_default
|
|
File without changes
|
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
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
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// awaitImport.ts
|
|
22
|
+
// src/babelPlugins/awaitImport/awaitImport.ts
|
|
23
23
|
var awaitImport_exports = {};
|
|
24
24
|
__export(awaitImport_exports, {
|
|
25
25
|
default: () => awaitImport_default
|
|
File without changes
|
|
@@ -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
|
+
// src/babelPlugins/awaitImport/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
|
+
});
|
|
File without changes
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// getAliasedPath.ts
|
|
19
|
+
// src/babelPlugins/awaitImport/getAliasedPath.ts
|
|
20
20
|
var getAliasedPath_exports = {};
|
|
21
21
|
__export(getAliasedPath_exports, {
|
|
22
22
|
getAliasedPath: () => getAliasedPath,
|
|
File without changes
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// getRealPath.ts
|
|
19
|
+
// src/babelPlugins/awaitImport/getRealPath.ts
|
|
20
20
|
var getRealPath_exports = {};
|
|
21
21
|
__export(getRealPath_exports, {
|
|
22
22
|
getRealPath: () => getRealPath
|
|
File without changes
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// isExternals.ts
|
|
19
|
+
// src/babelPlugins/awaitImport/isExternals.ts
|
|
20
20
|
var isExternals_exports = {};
|
|
21
21
|
__export(isExternals_exports, {
|
|
22
22
|
isExternal: () => isExternal,
|
|
File without changes
|
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
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
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// parseSpecifiers.ts
|
|
22
|
+
// src/babelPlugins/awaitImport/parseSpecifiers.ts
|
|
23
23
|
var parseSpecifiers_exports = {};
|
|
24
24
|
__export(parseSpecifiers_exports, {
|
|
25
25
|
parseSpecifiers: () => parseSpecifiers
|
package/dist/constants.d.ts
CHANGED
|
File without changes
|
package/dist/constants.js
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// constants.ts
|
|
19
|
+
// src/constants.ts
|
|
20
20
|
var constants_exports = {};
|
|
21
21
|
__export(constants_exports, {
|
|
22
22
|
DEFAULT_MF_NAME: () => DEFAULT_MF_NAME,
|
package/dist/dep/dep.d.ts
CHANGED
|
File without changes
|
package/dist/dep/dep.js
CHANGED
|
@@ -1,96 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
27
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
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));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
|
|
39
|
+
// src/dep/dep.ts
|
|
40
|
+
var dep_exports = {};
|
|
41
|
+
__export(dep_exports, {
|
|
42
|
+
Dep: () => Dep
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(dep_exports);
|
|
45
|
+
var import_utils = require("@umijs/utils");
|
|
46
|
+
var import_assert = __toESM(require("assert"));
|
|
47
|
+
var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
|
|
48
|
+
var import_fs = require("fs");
|
|
49
|
+
var import_path = require("path");
|
|
50
|
+
var import_constants = require("../constants");
|
|
51
|
+
var import_trimFileContent = require("../utils/trimFileContent");
|
|
52
|
+
var import_getExposeFromContent = require("./getExposeFromContent");
|
|
53
|
+
var resolver = import_enhanced_resolve.default.create({
|
|
54
|
+
mainFields: ["module", "browser", "main"],
|
|
55
|
+
extensions: [".wasm", ".mjs", ".js", ".jsx", ".ts", ".tsx", ".json"],
|
|
56
|
+
exportsFields: ["exports"],
|
|
57
|
+
conditionNames: ["import", "module", "require", "node"]
|
|
20
58
|
});
|
|
21
59
|
async function resolve(context, path) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
60
|
+
return new Promise((resolve2, reject) => {
|
|
61
|
+
resolver(context, path, (err, result) => err ? reject(err) : resolve2(result));
|
|
62
|
+
});
|
|
25
63
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (isNodeNatives) {
|
|
41
|
-
return (0, trimFileContent_1.trimFileContent)(this.mfsu.opts.excludeNodeNatives
|
|
42
|
-
? `
|
|
64
|
+
var Dep = class {
|
|
65
|
+
constructor(opts) {
|
|
66
|
+
this.file = (0, import_utils.winPath)(opts.file);
|
|
67
|
+
this.version = opts.version;
|
|
68
|
+
this.cwd = opts.cwd;
|
|
69
|
+
this.shortFile = this.file;
|
|
70
|
+
this.normalizedFile = this.shortFile.replace(/\//g, "_").replace(/:/g, "_");
|
|
71
|
+
this.filePath = `${import_constants.MF_VA_PREFIX}${this.normalizedFile}.js`;
|
|
72
|
+
this.mfsu = opts.mfsu;
|
|
73
|
+
}
|
|
74
|
+
async buildExposeContent() {
|
|
75
|
+
const isNodeNatives = !!process.binding("natives")[this.file];
|
|
76
|
+
if (isNodeNatives) {
|
|
77
|
+
return (0, import_trimFileContent.trimFileContent)(this.mfsu.opts.excludeNodeNatives ? `
|
|
43
78
|
const _ = require('${this.file}');
|
|
44
79
|
module.exports = _;
|
|
45
|
-
`
|
|
46
|
-
: `
|
|
80
|
+
` : `
|
|
47
81
|
import _ from '${this.file}';
|
|
48
82
|
export default _;
|
|
49
83
|
export * from '${this.file}';
|
|
50
84
|
`);
|
|
51
|
-
}
|
|
52
|
-
// none node natives
|
|
53
|
-
const realFile = await this.getRealFile();
|
|
54
|
-
(0, assert_1.default)(realFile, `filePath not found of ${this.file}`);
|
|
55
|
-
const content = (0, fs_1.readFileSync)(realFile, 'utf-8');
|
|
56
|
-
return await (0, getExposeFromContent_1.getExposeFromContent)({
|
|
57
|
-
content,
|
|
58
|
-
filePath: realFile,
|
|
59
|
-
dep: this,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
async getRealFile() {
|
|
63
|
-
try {
|
|
64
|
-
// don't need to handle alias here
|
|
65
|
-
// it's already handled by babel plugin
|
|
66
|
-
return await resolve(this.cwd, this.file);
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
85
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
const realFile = await this.getRealFile();
|
|
87
|
+
(0, import_assert.default)(realFile, `filePath not found of ${this.file}`);
|
|
88
|
+
const content = (0, import_fs.readFileSync)(realFile, "utf-8");
|
|
89
|
+
return await (0, import_getExposeFromContent.getExposeFromContent)({
|
|
90
|
+
content,
|
|
91
|
+
filePath: realFile,
|
|
92
|
+
dep: this
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async getRealFile() {
|
|
96
|
+
try {
|
|
97
|
+
return await resolve(this.cwd, this.file);
|
|
98
|
+
} catch (e) {
|
|
99
|
+
return null;
|
|
80
100
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return require(pkg).version || null;
|
|
101
|
+
}
|
|
102
|
+
static buildDeps(opts) {
|
|
103
|
+
return Object.keys(opts.deps).map((file) => {
|
|
104
|
+
return new Dep(__spreadProps(__spreadValues({}, opts.deps[file]), {
|
|
105
|
+
cwd: opts.cwd,
|
|
106
|
+
mfsu: opts.mfsu
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
static getDepVersion(opts) {
|
|
111
|
+
if (!!process.binding("natives")[opts.dep]) {
|
|
112
|
+
return "*";
|
|
94
113
|
}
|
|
95
|
-
|
|
96
|
-
|
|
114
|
+
const dep = (0, import_path.isAbsolute)(opts.dep) ? opts.dep : (0, import_path.join)(opts.cwd, "node_modules", opts.dep);
|
|
115
|
+
const pkg = import_utils.pkgUp.pkgUpSync({
|
|
116
|
+
cwd: dep
|
|
117
|
+
});
|
|
118
|
+
(0, import_assert.default)(pkg, `package.json not found for ${opts.dep}`);
|
|
119
|
+
return require(pkg).version || null;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {
|
|
124
|
+
Dep
|
|
125
|
+
});
|
|
File without changes
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// getCJSExports.ts
|
|
19
|
+
// src/dep/getCJSExports.ts
|
|
20
20
|
var getCJSExports_exports = {};
|
|
21
21
|
__export(getCJSExports_exports, {
|
|
22
22
|
getCJSExports: () => getCJSExports
|
|
File without changes
|
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
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
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// getExposeFromContent.ts
|
|
22
|
+
// src/dep/getExposeFromContent.ts
|
|
23
23
|
var getExposeFromContent_exports = {};
|
|
24
24
|
__export(getExposeFromContent_exports, {
|
|
25
25
|
getExposeFromContent: () => getExposeFromContent
|