@umijs/mfsu 4.0.0-canary.20220718.2 → 4.0.0-canary.20220729.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/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 -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 +192 -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 +4 -1
- package/dist/mfsu/mfsu.js +236 -257
- package/dist/mfsu/strategyCompileTime.d.ts +0 -1
- package/dist/mfsu/strategyCompileTime.js +131 -99
- package/dist/mfsu/strategyStaticAnalyze.d.ts +0 -1
- package/dist/mfsu/strategyStaticAnalyze.js +151 -115
- package/dist/moduleGraph.d.ts +0 -1
- package/dist/moduleGraph.js +227 -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 +239 -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 +8 -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,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
|
+
// src/babelPlugins/awaitImport/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
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
|
+
// src/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
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
|
+
});
|
|
@@ -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
|
+
// src/dep/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
|
+
});
|