@umijs/mfsu 4.0.0-beta.9 → 4.0.0-canary-20240513.3

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.
Files changed (74) hide show
  1. package/compiled/is-absolute-url/LICENSE +9 -0
  2. package/compiled/is-absolute-url/index.d.ts +20 -0
  3. package/compiled/is-absolute-url/index.js +1 -0
  4. package/compiled/is-absolute-url/package.json +1 -0
  5. package/compiled/mrmime/package.json +1 -1
  6. package/compiled/webpack-virtual-modules/index.js +1 -1
  7. package/compiled/webpack-virtual-modules/package.json +1 -1
  8. package/dist/babelPlugins/awaitImport/MFImport.d.ts +24 -0
  9. package/dist/babelPlugins/awaitImport/MFImport.js +66 -0
  10. package/dist/babelPlugins/awaitImport/awaitImport.d.ts +1 -1
  11. package/dist/babelPlugins/awaitImport/awaitImport.js +111 -112
  12. package/dist/babelPlugins/awaitImport/checkMatch.d.ts +3 -1
  13. package/dist/babelPlugins/awaitImport/checkMatch.js +166 -109
  14. package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts +2 -2
  15. package/dist/babelPlugins/awaitImport/getAliasedPath.js +44 -33
  16. package/dist/babelPlugins/awaitImport/getRealPath.js +42 -21
  17. package/dist/babelPlugins/awaitImport/isExternals.js +55 -26
  18. package/dist/babelPlugins/awaitImport/parseSpecifiers.js +62 -47
  19. package/dist/constants.d.ts +1 -0
  20. package/dist/constants.js +50 -10
  21. package/dist/dep/dep.d.ts +7 -3
  22. package/dist/dep/dep.js +117 -95
  23. package/dist/dep/getCJSExports.js +83 -47
  24. package/dist/dep/getExposeFromContent.js +99 -74
  25. package/dist/dep/getModuleExports.js +58 -43
  26. package/dist/depBuilder/depBuilder.d.ts +6 -1
  27. package/dist/depBuilder/depBuilder.js +222 -159
  28. package/dist/depBuilder/getESBuildEntry.d.ts +1 -0
  29. package/dist/depBuilder/getESBuildEntry.js +50 -14
  30. package/dist/depInfo.d.ts +20 -5
  31. package/dist/depInfo.js +90 -39
  32. package/dist/esbuildHandlers/autoCssModules.d.ts +2 -0
  33. package/dist/esbuildHandlers/autoCssModules.js +48 -0
  34. package/dist/esbuildHandlers/awaitImport/index.d.ts +15 -0
  35. package/dist/esbuildHandlers/awaitImport/index.js +86 -0
  36. package/dist/index.d.ts +3 -1
  37. package/dist/index.js +35 -13
  38. package/dist/loader/esbuild.d.ts +5 -0
  39. package/dist/loader/esbuild.js +79 -0
  40. package/dist/mfsu/mfsu.d.ts +69 -0
  41. package/dist/mfsu/mfsu.js +319 -0
  42. package/dist/mfsu/strategyCompileTime.d.ts +20 -0
  43. package/dist/mfsu/strategyCompileTime.js +142 -0
  44. package/dist/mfsu/strategyStaticAnalyze.d.ts +24 -0
  45. package/dist/mfsu/strategyStaticAnalyze.js +196 -0
  46. package/dist/moduleGraph.d.ts +5 -8
  47. package/dist/moduleGraph.js +228 -178
  48. package/dist/staticDepInfo/importParser.d.ts +4 -0
  49. package/dist/staticDepInfo/importParser.js +28 -0
  50. package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts +15 -0
  51. package/dist/staticDepInfo/simulations/babel-plugin-import.js +118 -0
  52. package/dist/staticDepInfo/staticDepInfo.d.ts +61 -0
  53. package/dist/staticDepInfo/staticDepInfo.js +274 -0
  54. package/dist/types.d.ts +12 -0
  55. package/dist/types.js +33 -8
  56. package/dist/utils/makeArray.js +29 -5
  57. package/dist/utils/resolveUtils.d.ts +1 -0
  58. package/dist/utils/resolveUtils.js +104 -0
  59. package/dist/utils/trimFileContent.js +29 -5
  60. package/dist/utils/webpackUtils.d.ts +3 -0
  61. package/dist/utils/webpackUtils.js +80 -0
  62. package/dist/webpackPlugins/buildDepPlugin.d.ts +4 -3
  63. package/dist/webpackPlugins/buildDepPlugin.js +61 -17
  64. package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts +1 -1
  65. package/dist/webpackPlugins/depChunkIdPrefixPlugin.js +47 -19
  66. package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +55 -27
  67. package/dist/webpackPlugins/writeCachePlugin.js +45 -15
  68. package/package.json +23 -19
  69. package/vendors/importParser/_importParser.js +683 -0
  70. package/vendors/importParser/importParser.jison +105 -0
  71. package/dist/babelPlugins/autoExport.d.ts +0 -7
  72. package/dist/babelPlugins/autoExport.js +0 -61
  73. package/dist/mfsu.d.ts +0 -54
  74. package/dist/mfsu.js +0 -179
@@ -1,119 +1,176 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPath = exports.checkMatch = void 0;
7
- const utils_1 = require("@umijs/utils");
8
- const assert_1 = __importDefault(require("assert"));
9
- const path_1 = require("path");
10
- const getAliasedPath_1 = require("./getAliasedPath");
11
- const isExternals_1 = require("./isExternals");
12
- // const UNMATCH_LIBS = ['umi', 'dumi', '@alipay/bigfish'];
13
- const RE_NODE_MODULES = /node_modules/;
14
- const RE_UMI_LOCAL_DEV = /umi(-next)?\/packages\//;
15
- function checkMatch({ value, path, opts, isExportAll, depth, cache, }) {
16
- var _a, _b;
17
- let isMatch;
18
- let replaceValue = '';
19
- depth = depth || 1;
20
- (0, assert_1.default)(depth <= 10, `endless loop detected in checkMatch, please check your alias config.`);
21
- opts = opts || {};
22
- const remoteName = opts.remoteName || 'mf';
23
- if (
24
- // unMatch specified libs
25
- ((_a = opts.unMatchLibs) === null || _a === void 0 ? void 0 : _a.includes(value)) ||
26
- // already handled
27
- value.startsWith(`${remoteName}/`) ||
28
- // don't match dynamic path
29
- // e.g. @umijs/deps/compiled/babel/svgr-webpack.js?-svgo,+titleProp,+ref!./umi.svg
30
- (0, utils_1.winPath)(value).includes('babel/svgr-webpack') ||
31
- // don't match webpack loader
32
- // e.g. !!dumi-raw-code-loader!/path/to/VerticalProgress/index.module.less?dumi-raw-code
33
- value.startsWith('!!') ||
34
- // don't match externals
35
- (0, isExternals_1.isExternals)({ value, externals: opts.externals }) ||
36
- // relative import
37
- value.startsWith('.')) {
38
- isMatch = false;
39
- }
40
- else if ((0, path_1.isAbsolute)(value)) {
41
- isMatch = RE_NODE_MODULES.test(value) || RE_UMI_LOCAL_DEV.test(value);
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(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/babelPlugins/awaitImport/checkMatch.ts
30
+ var checkMatch_exports = {};
31
+ __export(checkMatch_exports, {
32
+ checkMatch: () => checkMatch,
33
+ getPath: () => getPath
34
+ });
35
+ module.exports = __toCommonJS(checkMatch_exports);
36
+ var import_utils = require("@umijs/utils");
37
+ var import_assert = __toESM(require("assert"));
38
+ var import_path = require("path");
39
+ var import_isExternals = require("./isExternals");
40
+ var RE_NODE_MODULES = /node_modules/;
41
+ function isUmiLocalDev(path) {
42
+ const rootPath = (0, import_utils.isLocalDev)();
43
+ if (rootPath) {
44
+ const winP = (0, import_utils.winPath)(path);
45
+ const pkgP = (0, import_utils.winPath)((0, import_path.join)(rootPath, "./packages"));
46
+ const libP = (0, import_utils.winPath)((0, import_path.join)(rootPath, "./libs"));
47
+ return winP.startsWith(pkgP) || winP.startsWith(libP);
48
+ } else {
49
+ return false;
50
+ }
51
+ }
52
+ function genUnMatchLibsRegex(libs) {
53
+ if (!libs) {
54
+ return null;
55
+ }
56
+ const deps = libs.map((lib) => {
57
+ if (typeof lib === "string") {
58
+ return `^${lib}$`;
59
+ } else if (lib instanceof RegExp) {
60
+ return lib.source;
42
61
  }
43
- else {
44
- const aliasedPath = (0, getAliasedPath_1.getAliasedPath)({
45
- value,
46
- alias: opts.alias || {},
47
- });
48
- if (aliasedPath) {
49
- return checkMatch({
50
- value: aliasedPath,
51
- path,
52
- opts,
53
- isExportAll,
54
- depth: depth + 1,
55
- cache,
56
- });
57
- }
58
- else {
59
- isMatch = true;
60
- }
62
+ });
63
+ return deps.length ? new RegExp(deps.join("|")) : null;
64
+ }
65
+ function checkMatch({
66
+ value,
67
+ path,
68
+ opts,
69
+ isExportAll,
70
+ depth,
71
+ cache,
72
+ filename
73
+ }) {
74
+ var _a;
75
+ let isMatch;
76
+ let replaceValue = "";
77
+ depth = depth || 1;
78
+ (0, import_assert.default)(
79
+ depth <= 10,
80
+ `endless loop detected in checkMatch, please check your alias config.`
81
+ );
82
+ opts = opts || {};
83
+ const remoteName = opts.remoteName || "mf";
84
+ value = value.replace(/^@fs\//, "/");
85
+ const unMatchLibsRegex = genUnMatchLibsRegex(opts.unMatchLibs);
86
+ const mfPathInitial = `${remoteName}/`;
87
+ if (
88
+ // unMatch specified libs
89
+ (unMatchLibsRegex == null ? void 0 : unMatchLibsRegex.test(value)) || // do not match bundler-webpack/client/client/client.js
90
+ value.includes("client/client/client.js") || // don't match dynamic path
91
+ // e.g. @umijs/deps/compiled/babel/svgr-webpack.js?-svgo,+titleProp,+ref!./umi.svg
92
+ (0, import_utils.winPath)(value).includes("babel/svgr-webpack") || // don't match webpack loader
93
+ // e.g. !!dumi-raw-code-loader!/path/to/VerticalProgress/index.module.less?dumi-raw-code
94
+ value.startsWith("!!") || // don't match externals
95
+ (0, import_isExternals.isExternals)({ value, externals: opts.externals }) || // relative import
96
+ value.startsWith(".")
97
+ ) {
98
+ isMatch = false;
99
+ } else if (value.startsWith(mfPathInitial)) {
100
+ isMatch = true;
101
+ } else if ((0, import_path.isAbsolute)(value)) {
102
+ isMatch = RE_NODE_MODULES.test(value) || isUmiLocalDev(value);
103
+ } else {
104
+ const aliasedPath = import_utils.aliasUtils.getAliasValue({
105
+ imported: value,
106
+ alias: opts.alias || {}
107
+ });
108
+ if (aliasedPath) {
109
+ return checkMatch({
110
+ value: aliasedPath,
111
+ path,
112
+ opts,
113
+ isExportAll,
114
+ depth: depth + 1,
115
+ cache,
116
+ filename
117
+ });
118
+ } else {
119
+ isMatch = true;
61
120
  }
62
- if (isMatch && isExportAll) {
63
- isMatch = !!(opts.exportAllMembers && value in opts.exportAllMembers);
121
+ }
122
+ if (isMatch && isExportAll) {
123
+ isMatch = !!(opts.exportAllMembers && value in opts.exportAllMembers);
124
+ }
125
+ if (isMatch) {
126
+ if (value.startsWith(mfPathInitial)) {
127
+ replaceValue = value;
128
+ value = value.replace(mfPathInitial, "");
129
+ } else {
130
+ replaceValue = `${remoteName}/${(0, import_utils.winPath)(value)}`;
64
131
  }
65
- if (isMatch) {
66
- replaceValue = `${remoteName}/${value}`;
132
+ }
133
+ const file = (path == null ? void 0 : path.hub.file.opts.filename) || filename;
134
+ (_a = opts.onTransformDeps) == null ? void 0 : _a.call(opts, {
135
+ sourceValue: value,
136
+ replaceValue,
137
+ isMatch,
138
+ file
139
+ });
140
+ if (cache) {
141
+ let mod;
142
+ if (cache.has(file)) {
143
+ mod = cache.get(file);
144
+ } else {
145
+ mod = {
146
+ matched: /* @__PURE__ */ new Set(),
147
+ unMatched: /* @__PURE__ */ new Set()
148
+ };
149
+ cache.set(file, mod);
67
150
  }
68
- // @ts-ignore
69
- const file = path === null || path === void 0 ? void 0 : path.hub.file.opts.filename;
70
- (_b = opts.onTransformDeps) === null || _b === void 0 ? void 0 : _b.call(opts, {
71
- sourceValue: value,
72
- replaceValue,
73
- isMatch,
74
- file,
151
+ mod[isMatch ? "matched" : "unMatched"].add({
152
+ sourceValue: value,
153
+ replaceValue,
154
+ file
75
155
  });
76
- if (cache) {
77
- let mod;
78
- if (cache.has(file)) {
79
- mod = cache.get(file);
80
- }
81
- else {
82
- mod = {
83
- matched: new Set(),
84
- unMatched: new Set(),
85
- };
86
- cache.set(file, mod);
87
- }
88
- mod[isMatch ? 'matched' : 'unMatched'].add({
89
- sourceValue: value,
90
- replaceValue,
91
- file,
92
- });
93
- }
94
- // console.log(
95
- // '> check',
96
- // // @ts-ignore
97
- // path.hub.file.opts.filename,
98
- // value,
99
- // cache,
100
- // 'isMatch',
101
- // isMatch,
102
- // );
103
- return {
104
- isMatch,
105
- replaceValue,
106
- };
156
+ }
157
+ return {
158
+ isMatch,
159
+ replaceValue,
160
+ value
161
+ };
107
162
  }
108
- exports.checkMatch = checkMatch;
109
- // TODO: REMOVE ME
110
163
  function getPath({ value, opts }) {
111
- const alias = opts.alias || {};
112
- for (const key of Object.keys(alias)) {
113
- if (value.startsWith(key)) {
114
- return value.replace(key, alias[key]);
115
- }
164
+ const alias = opts.alias || {};
165
+ for (const key of Object.keys(alias)) {
166
+ if (value.startsWith(key)) {
167
+ return value.replace(key, alias[key]);
116
168
  }
117
- return value;
169
+ }
170
+ return value;
118
171
  }
119
- exports.getPath = getPath;
172
+ // Annotate the CommonJS export names for ESM import in node:
173
+ 0 && (module.exports = {
174
+ checkMatch,
175
+ getPath
176
+ });
@@ -1,4 +1,4 @@
1
- export declare function getAliasedPath({ value, alias, }: {
1
+ export declare function getAliasedPathWithLoopDetect({ value, alias, }: {
2
2
  value: string;
3
3
  alias: Record<string, string>;
4
- }): string | undefined;
4
+ }): string;
@@ -1,35 +1,46 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAliasedPath = void 0;
4
- const path_1 = require("path");
5
- function getAliasedPath({ value, alias, }) {
6
- const importValue = value;
7
- for (const key of Object.keys(alias)) {
8
- const aliasValue = alias[key];
9
- // exact alias
10
- // ref: https://webpack.js.org/configuration/resolve/#resolvealias
11
- // e.g. foo$: path/to/foo
12
- if (key.endsWith('$')) {
13
- if (importValue === key.slice(0, -1))
14
- return aliasValue;
15
- else
16
- continue;
17
- }
18
- // e.g. foo: path/to/foo
19
- if (importValue === key) {
20
- return aliasValue;
21
- }
22
- // e.g. foo: path/to/foo.js
23
- const slashedKey = isJSFile(aliasValue) ? key : addLastSlash(key);
24
- if (importValue.startsWith(slashedKey)) {
25
- return importValue.replace(key, aliasValue);
26
- }
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/babelPlugins/awaitImport/getAliasedPath.ts
20
+ var getAliasedPath_exports = {};
21
+ __export(getAliasedPath_exports, {
22
+ getAliasedPathWithLoopDetect: () => getAliasedPathWithLoopDetect
23
+ });
24
+ module.exports = __toCommonJS(getAliasedPath_exports);
25
+ var import_utils = require("@umijs/utils");
26
+ function getAliasedPathWithLoopDetect({
27
+ value,
28
+ alias
29
+ }) {
30
+ let needUnAlias = value;
31
+ for (let i = 0; i < 10; i++) {
32
+ let unAliased = import_utils.aliasUtils.getAliasValue({ imported: needUnAlias, alias });
33
+ if (unAliased) {
34
+ needUnAlias = unAliased;
35
+ } else {
36
+ return needUnAlias;
27
37
  }
38
+ }
39
+ throw Error(
40
+ `endless loop detected in resolve alias for '${value}', please check your alias config.`
41
+ );
28
42
  }
29
- exports.getAliasedPath = getAliasedPath;
30
- function isJSFile(path) {
31
- return ['.js', '.jsx', '.ts', '.tsx'].includes((0, path_1.extname)(path));
32
- }
33
- function addLastSlash(path) {
34
- return path.endsWith('/') ? path : `${path}/`;
35
- }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ getAliasedPathWithLoopDetect
46
+ });
@@ -1,24 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRealPath = void 0;
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
6
- const FILE_EXT_NAMES = ['.tsx', '.ts', '.jsx', '.mjs', '.js'];
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/babelPlugins/awaitImport/getRealPath.ts
20
+ var getRealPath_exports = {};
21
+ __export(getRealPath_exports, {
22
+ getRealPath: () => getRealPath
23
+ });
24
+ module.exports = __toCommonJS(getRealPath_exports);
25
+ var import_fs = require("fs");
26
+ var import_path = require("path");
27
+ var FILE_EXT_NAMES = [".tsx", ".ts", ".jsx", ".mjs", ".js"];
7
28
  function getRealPath(opts) {
8
- const target = (0, path_1.isAbsolute)(opts.dep)
9
- ? opts.dep
10
- : (0, path_1.join)((0, path_1.dirname)(opts.file), opts.dep);
11
- if (FILE_EXT_NAMES.includes((0, path_1.extname)(target))) {
12
- return target;
13
- }
14
- else {
15
- for (const fileExtName of FILE_EXT_NAMES) {
16
- const targetWithExtName = `${target}${fileExtName}`;
17
- if ((0, fs_1.existsSync)(targetWithExtName)) {
18
- return targetWithExtName;
19
- }
20
- }
21
- return null;
29
+ const target = (0, import_path.isAbsolute)(opts.dep) ? opts.dep : (0, import_path.join)((0, import_path.dirname)(opts.file), opts.dep);
30
+ if (FILE_EXT_NAMES.includes((0, import_path.extname)(target))) {
31
+ return target;
32
+ } else {
33
+ for (const fileExtName of FILE_EXT_NAMES) {
34
+ const targetWithExtName = `${target}${fileExtName}`;
35
+ if ((0, import_fs.existsSync)(targetWithExtName)) {
36
+ return targetWithExtName;
37
+ }
22
38
  }
39
+ return null;
40
+ }
23
41
  }
24
- exports.getRealPath = getRealPath;
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ getRealPath
45
+ });
@@ -1,29 +1,58 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isExternal = exports.isExternals = void 0;
4
- function isExternals({ value, externals, }) {
5
- const externalsArr = Array.isArray(externals) ? externals : [externals];
6
- for (const external of externalsArr) {
7
- if (isExternal({ value, external })) {
8
- return true;
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
+ // src/babelPlugins/awaitImport/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
- return false;
35
+ }
36
+ return false;
12
37
  }
13
- exports.isExternals = isExternals;
14
- function isExternal({ value, external, }) {
15
- if (typeof external === 'object') {
16
- return !!external[value];
17
- }
18
- else if (typeof external === 'function') {
19
- let ret = false;
20
- external({}, value, (_, b) => {
21
- ret = !!b;
22
- });
23
- return ret;
24
- }
25
- else {
26
- return false;
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
- exports.isExternal = isExternal;
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ isExternal,
57
+ isExternals
58
+ });
@@ -1,51 +1,66 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- 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;
20
18
  };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.parseSpecifiers = void 0;
23
- const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
24
- const DEFAULT = 'default';
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/babelPlugins/awaitImport/parseSpecifiers.ts
30
+ var parseSpecifiers_exports = {};
31
+ __export(parseSpecifiers_exports, {
32
+ parseSpecifiers: () => parseSpecifiers
33
+ });
34
+ module.exports = __toCommonJS(parseSpecifiers_exports);
35
+ var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
36
+ var DEFAULT = "default";
25
37
  function parseSpecifiers(specifiers) {
26
- return specifiers.reduce((memo, s) => {
27
- if (t.isImportDefaultSpecifier(s)) {
28
- memo.properties.push(t.objectProperty(t.identifier(DEFAULT), s.local));
29
- }
30
- else if (t.isExportDefaultSpecifier(s)) {
31
- memo.properties.push(t.objectProperty(t.identifier(DEFAULT), s.exported));
38
+ return specifiers.reduce(
39
+ (memo, s) => {
40
+ if (t.isImportDefaultSpecifier(s)) {
41
+ memo.properties.push(t.objectProperty(t.identifier(DEFAULT), s.local));
42
+ } else if (t.isExportDefaultSpecifier(s)) {
43
+ memo.properties.push(
44
+ t.objectProperty(t.identifier(DEFAULT), s.exported)
45
+ );
46
+ } else if (t.isExportSpecifier(s)) {
47
+ if (t.isIdentifier(s.exported, { name: DEFAULT })) {
48
+ memo.defaultIdentifier = s.local.name;
49
+ memo.properties.push(t.objectProperty(s.local, s.local));
50
+ } else {
51
+ memo.properties.push(t.objectProperty(s.local, s.exported));
32
52
  }
33
- else if (t.isExportSpecifier(s)) {
34
- if (t.isIdentifier(s.exported, { name: DEFAULT })) {
35
- memo.defaultIdentifier = s.local.name;
36
- memo.properties.push(t.objectProperty(s.local, s.local));
37
- }
38
- else {
39
- memo.properties.push(t.objectProperty(s.local, s.exported));
40
- }
41
- }
42
- else if (t.isImportNamespaceSpecifier(s)) {
43
- memo.namespaceIdentifier = s.local;
44
- }
45
- else {
46
- memo.properties.push(t.objectProperty(s.imported, s.local));
47
- }
48
- return memo;
49
- }, { properties: [], namespaceIdentifier: null, defaultIdentifier: null });
53
+ } else if (t.isImportNamespaceSpecifier(s)) {
54
+ memo.namespaceIdentifier = s.local;
55
+ } else {
56
+ memo.properties.push(t.objectProperty(s.imported, s.local));
57
+ }
58
+ return memo;
59
+ },
60
+ { properties: [], namespaceIdentifier: null, defaultIdentifier: null }
61
+ );
50
62
  }
51
- exports.parseSpecifiers = parseSpecifiers;
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ parseSpecifiers
66
+ });
@@ -5,3 +5,4 @@ export declare const DEFAULT_MF_NAME = "mf";
5
5
  export declare const DEFAULT_TMP_DIR_NAME = ".mfsu";
6
6
  export declare const REMOTE_FILE = "remoteEntry.js";
7
7
  export declare const REMOTE_FILE_FULL: string;
8
+ export declare const VIRTUAL_ENTRY_DIR = "mfsu-virtual-entry";