@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.
Files changed (104) hide show
  1. package/compiled/is-absolute-url/LICENSE +9 -0
  2. package/compiled/is-absolute-url/index.d.ts +22 -0
  3. package/compiled/is-absolute-url/index.js +1 -0
  4. package/compiled/is-absolute-url/package.json +1 -0
  5. package/dist/babelPlugins/awaitImport/MFImport.d.ts +0 -1
  6. package/dist/babelPlugins/awaitImport/MFImport.js +59 -66
  7. package/dist/babelPlugins/awaitImport/awaitImport.d.ts +0 -1
  8. package/dist/babelPlugins/awaitImport/awaitImport.js +103 -117
  9. package/dist/babelPlugins/awaitImport/checkMatch.d.ts +0 -1
  10. package/dist/babelPlugins/awaitImport/checkMatch.js +129 -132
  11. package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts +0 -1
  12. package/dist/babelPlugins/awaitImport/getAliasedPath.js +54 -35
  13. package/dist/babelPlugins/awaitImport/getRealPath.d.ts +0 -1
  14. package/dist/babelPlugins/awaitImport/getRealPath.js +42 -21
  15. package/dist/babelPlugins/awaitImport/isExternals.d.ts +0 -1
  16. package/dist/babelPlugins/awaitImport/isExternals.js +55 -26
  17. package/dist/babelPlugins/awaitImport/parseSpecifiers.d.ts +0 -1
  18. package/dist/babelPlugins/awaitImport/parseSpecifiers.js +51 -52
  19. package/dist/constants.d.ts +0 -1
  20. package/dist/constants.js +47 -10
  21. package/dist/dep/dep.d.ts +0 -1
  22. package/dist/dep/dep.js +112 -83
  23. package/dist/dep/getCJSExports.d.ts +0 -1
  24. package/dist/dep/getCJSExports.js +60 -53
  25. package/dist/dep/getExposeFromContent.d.ts +0 -1
  26. package/dist/dep/getExposeFromContent.js +71 -61
  27. package/dist/dep/getModuleExports.d.ts +0 -1
  28. package/dist/dep/getModuleExports.js +58 -32
  29. package/dist/depBuilder/depBuilder.d.ts +0 -1
  30. package/dist/depBuilder/depBuilder.js +192 -158
  31. package/dist/depBuilder/getESBuildEntry.d.ts +0 -1
  32. package/dist/depBuilder/getESBuildEntry.js +35 -12
  33. package/dist/depInfo.d.ts +0 -1
  34. package/dist/depInfo.js +75 -53
  35. package/dist/esbuildHandlers/autoCssModules.d.ts +0 -1
  36. package/dist/esbuildHandlers/autoCssModules.js +43 -22
  37. package/dist/esbuildHandlers/awaitImport/index.d.ts +0 -1
  38. package/dist/esbuildHandlers/awaitImport/index.js +82 -70
  39. package/dist/index.d.ts +0 -1
  40. package/dist/index.js +32 -22
  41. package/dist/loader/esbuild.d.ts +0 -1
  42. package/dist/loader/esbuild.js +87 -35
  43. package/dist/mfsu/mfsu.d.ts +4 -1
  44. package/dist/mfsu/mfsu.js +236 -257
  45. package/dist/mfsu/strategyCompileTime.d.ts +0 -1
  46. package/dist/mfsu/strategyCompileTime.js +131 -99
  47. package/dist/mfsu/strategyStaticAnalyze.d.ts +0 -1
  48. package/dist/mfsu/strategyStaticAnalyze.js +151 -115
  49. package/dist/moduleGraph.d.ts +0 -1
  50. package/dist/moduleGraph.js +227 -186
  51. package/dist/staticDepInfo/importParser.d.ts +0 -1
  52. package/dist/staticDepInfo/importParser.js +28 -6
  53. package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts +0 -1
  54. package/dist/staticDepInfo/simulations/babel-plugin-import.js +99 -91
  55. package/dist/staticDepInfo/staticDepInfo.d.ts +0 -1
  56. package/dist/staticDepInfo/staticDepInfo.js +239 -197
  57. package/dist/types.d.ts +0 -1
  58. package/dist/types.js +33 -8
  59. package/dist/utils/makeArray.d.ts +0 -1
  60. package/dist/utils/makeArray.js +29 -5
  61. package/dist/utils/trimFileContent.d.ts +0 -1
  62. package/dist/utils/trimFileContent.js +29 -5
  63. package/dist/webpackPlugins/buildDepPlugin.d.ts +0 -1
  64. package/dist/webpackPlugins/buildDepPlugin.js +49 -25
  65. package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts +0 -1
  66. package/dist/webpackPlugins/depChunkIdPrefixPlugin.js +44 -19
  67. package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts +0 -1
  68. package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +46 -27
  69. package/dist/webpackPlugins/writeCachePlugin.d.ts +0 -1
  70. package/dist/webpackPlugins/writeCachePlugin.js +39 -15
  71. package/package.json +8 -6
  72. package/dist/babelPlugins/awaitImport/MFImport.d.ts.map +0 -1
  73. package/dist/babelPlugins/awaitImport/awaitImport.d.ts.map +0 -1
  74. package/dist/babelPlugins/awaitImport/checkMatch.d.ts.map +0 -1
  75. package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts.map +0 -1
  76. package/dist/babelPlugins/awaitImport/getRealPath.d.ts.map +0 -1
  77. package/dist/babelPlugins/awaitImport/isExternals.d.ts.map +0 -1
  78. package/dist/babelPlugins/awaitImport/parseSpecifiers.d.ts.map +0 -1
  79. package/dist/constants.d.ts.map +0 -1
  80. package/dist/dep/dep.d.ts.map +0 -1
  81. package/dist/dep/getCJSExports.d.ts.map +0 -1
  82. package/dist/dep/getExposeFromContent.d.ts.map +0 -1
  83. package/dist/dep/getModuleExports.d.ts.map +0 -1
  84. package/dist/depBuilder/depBuilder.d.ts.map +0 -1
  85. package/dist/depBuilder/getESBuildEntry.d.ts.map +0 -1
  86. package/dist/depInfo.d.ts.map +0 -1
  87. package/dist/esbuildHandlers/autoCssModules.d.ts.map +0 -1
  88. package/dist/esbuildHandlers/awaitImport/index.d.ts.map +0 -1
  89. package/dist/index.d.ts.map +0 -1
  90. package/dist/loader/esbuild.d.ts.map +0 -1
  91. package/dist/mfsu/mfsu.d.ts.map +0 -1
  92. package/dist/mfsu/strategyCompileTime.d.ts.map +0 -1
  93. package/dist/mfsu/strategyStaticAnalyze.d.ts.map +0 -1
  94. package/dist/moduleGraph.d.ts.map +0 -1
  95. package/dist/staticDepInfo/importParser.d.ts.map +0 -1
  96. package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts.map +0 -1
  97. package/dist/staticDepInfo/staticDepInfo.d.ts.map +0 -1
  98. package/dist/types.d.ts.map +0 -1
  99. package/dist/utils/makeArray.d.ts.map +0 -1
  100. package/dist/utils/trimFileContent.d.ts.map +0 -1
  101. package/dist/webpackPlugins/buildDepPlugin.d.ts.map +0 -1
  102. package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts.map +0 -1
  103. package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts.map +0 -1
  104. package/dist/webpackPlugins/writeCachePlugin.d.ts.map +0 -1
@@ -1,145 +1,142 @@
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/;
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
- const rootPath = (0, utils_1.isLocalDev)();
16
- return rootPath
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
- if (!libs) {
22
- return null;
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
- const deps = libs.map((lib) => {
25
- if (typeof lib === 'string') {
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({ value, path, opts, isExportAll, depth, cache, filename, }) {
35
- var _a;
36
- let isMatch;
37
- let replaceValue = '';
38
- depth = depth || 1;
39
- (0, assert_1.default)(depth <= 10, `endless loop detected in checkMatch, please check your alias config.`);
40
- opts = opts || {};
41
- const remoteName = opts.remoteName || 'mf';
42
- // FIXME: hard code for vite mode
43
- value = value.replace(/^@fs\//, '/');
44
- const unMatchLibsRegex = genUnMatchLibsRegex(opts.unMatchLibs);
45
- if (
46
- // unMatch specified libs
47
- (unMatchLibsRegex === null || unMatchLibsRegex === void 0 ? void 0 : unMatchLibsRegex.test(value)) ||
48
- // do not match bundler-webpack/client/client/client.js
49
- value.includes('client/client/client.js') ||
50
- // already handled
51
- value.startsWith(`${remoteName}/`) ||
52
- // don't match dynamic path
53
- // e.g. @umijs/deps/compiled/babel/svgr-webpack.js?-svgo,+titleProp,+ref!./umi.svg
54
- (0, utils_1.winPath)(value).includes('babel/svgr-webpack') ||
55
- // don't match webpack loader
56
- // e.g. !!dumi-raw-code-loader!/path/to/VerticalProgress/index.module.less?dumi-raw-code
57
- value.startsWith('!!') ||
58
- // don't match externals
59
- (0, isExternals_1.isExternals)({ value, externals: opts.externals }) ||
60
- // relative import
61
- value.startsWith('.')) {
62
- isMatch = false;
63
- }
64
- else if ((0, path_1.isAbsolute)(value)) {
65
- isMatch = RE_NODE_MODULES.test(value) || isUmiLocalDev(value);
66
- }
67
- else {
68
- const aliasedPath = (0, getAliasedPath_1.getAliasedPath)({
69
- value,
70
- alias: opts.alias || {},
71
- });
72
- if (aliasedPath) {
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
- if (isMatch) {
91
- replaceValue = `${remoteName}/${(0, utils_1.winPath)(value)}`;
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
- // @ts-ignore
94
- const file = (path === null || path === void 0 ? void 0 : path.hub.file.opts.filename) || filename;
95
- (_a = opts.onTransformDeps) === null || _a === void 0 ? void 0 : _a.call(opts, {
96
- sourceValue: value,
97
- replaceValue,
98
- isMatch,
99
- file,
117
+ mod[isMatch ? "matched" : "unMatched"].add({
118
+ sourceValue: value,
119
+ replaceValue,
120
+ file
100
121
  });
101
- if (cache) {
102
- let mod;
103
- if (cache.has(file)) {
104
- mod = cache.get(file);
105
- }
106
- else {
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
- const alias = opts.alias || {};
138
- for (const key of Object.keys(alias)) {
139
- if (value.startsWith(key)) {
140
- return value.replace(key, alias[key]);
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
- return value;
135
+ }
136
+ return value;
144
137
  }
145
- exports.getPath = getPath;
138
+ // Annotate the CommonJS export names for ESM import in node:
139
+ 0 && (module.exports = {
140
+ checkMatch,
141
+ getPath
142
+ });
@@ -5,4 +5,3 @@ declare type Opts = {
5
5
  export declare function getAliasedPath({ value, alias }: Opts): string | undefined;
6
6
  export declare function getAliasedPathWithLoopDetect({ value, alias }: Opts): string;
7
7
  export {};
8
- //# sourceMappingURL=getAliasedPath.d.ts.map
@@ -1,44 +1,63 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAliasedPathWithLoopDetect = exports.getAliasedPath = void 0;
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
+ getAliasedPath: () => getAliasedPath,
23
+ getAliasedPathWithLoopDetect: () => getAliasedPathWithLoopDetect
24
+ });
25
+ module.exports = __toCommonJS(getAliasedPath_exports);
4
26
  function getAliasedPath({ value, alias }) {
5
- const importValue = value;
6
- // equal alias
7
- if (alias[value]) {
8
- return alias[value];
27
+ const importValue = value;
28
+ if (alias[value]) {
29
+ return alias[value];
30
+ }
31
+ for (const key of Object.keys(alias)) {
32
+ const aliasValue = alias[key];
33
+ if (key.endsWith("$")) {
34
+ if (importValue === key.slice(0, -1))
35
+ return aliasValue;
36
+ else
37
+ continue;
9
38
  }
10
- for (const key of Object.keys(alias)) {
11
- const aliasValue = alias[key];
12
- // exact alias
13
- // ref: https://webpack.js.org/configuration/resolve/#resolvealias
14
- // e.g. foo$: path/to/foo
15
- if (key.endsWith('$')) {
16
- if (importValue === key.slice(0, -1))
17
- return aliasValue;
18
- else
19
- continue;
20
- }
21
- // e.g. foo: path/to/foo.js
22
- if (importValue.startsWith(addLastSlash(key))) {
23
- return importValue.replace(key, aliasValue);
24
- }
39
+ if (importValue.startsWith(addLastSlash(key))) {
40
+ return importValue.replace(key, aliasValue);
25
41
  }
42
+ }
26
43
  }
27
- exports.getAliasedPath = getAliasedPath;
28
44
  function addLastSlash(path) {
29
- return path.endsWith('/') ? path : `${path}/`;
45
+ return path.endsWith("/") ? path : `${path}/`;
30
46
  }
31
47
  function getAliasedPathWithLoopDetect({ value, alias }) {
32
- let needUnAlias = value;
33
- for (let i = 0; i < 10; i++) {
34
- let unAliased = getAliasedPath({ value: needUnAlias, alias });
35
- if (unAliased) {
36
- needUnAlias = unAliased;
37
- }
38
- else {
39
- return needUnAlias;
40
- }
48
+ let needUnAlias = value;
49
+ for (let i = 0; i < 10; i++) {
50
+ let unAliased = getAliasedPath({ value: needUnAlias, alias });
51
+ if (unAliased) {
52
+ needUnAlias = unAliased;
53
+ } else {
54
+ return needUnAlias;
41
55
  }
42
- throw Error(`endless loop detected in resolve alias for '${value}', please check your alias config.`);
56
+ }
57
+ throw Error(`endless loop detected in resolve alias for '${value}', please check your alias config.`);
43
58
  }
44
- exports.getAliasedPathWithLoopDetect = getAliasedPathWithLoopDetect;
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ getAliasedPath,
62
+ getAliasedPathWithLoopDetect
63
+ });
@@ -2,4 +2,3 @@ export declare function getRealPath(opts: {
2
2
  file: string;
3
3
  dep: string;
4
4
  }): string | null;
5
- //# sourceMappingURL=getRealPath.d.ts.map
@@ -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
+ });
@@ -9,4 +9,3 @@ export declare function isExternal({ value, external, }: {
9
9
  external: IExternal;
10
10
  }): boolean;
11
11
  export {};
12
- //# sourceMappingURL=isExternals.d.ts.map
@@ -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,2 +1 @@
1
1
  export declare function parseSpecifiers(specifiers: any[]): any;
2
- //# sourceMappingURL=parseSpecifiers.d.ts.map