@umijs/mfsu 4.0.5 → 4.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/babelPlugins/awaitImport/MFImport.d.ts +0 -0
  2. package/dist/babelPlugins/awaitImport/MFImport.js +59 -66
  3. package/dist/babelPlugins/awaitImport/awaitImport.d.ts +1 -1
  4. package/dist/babelPlugins/awaitImport/awaitImport.js +103 -117
  5. package/dist/babelPlugins/awaitImport/checkMatch.d.ts +0 -0
  6. package/dist/babelPlugins/awaitImport/checkMatch.js +18 -3
  7. package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts +0 -0
  8. package/dist/babelPlugins/awaitImport/getAliasedPath.js +54 -35
  9. package/dist/babelPlugins/awaitImport/getRealPath.d.ts +0 -0
  10. package/dist/babelPlugins/awaitImport/getRealPath.js +42 -21
  11. package/dist/babelPlugins/awaitImport/isExternals.d.ts +0 -0
  12. package/dist/babelPlugins/awaitImport/isExternals.js +55 -26
  13. package/dist/babelPlugins/awaitImport/parseSpecifiers.d.ts +0 -0
  14. package/dist/babelPlugins/awaitImport/parseSpecifiers.js +51 -52
  15. package/dist/constants.d.ts +0 -0
  16. package/dist/constants.js +47 -10
  17. package/dist/dep/dep.d.ts +0 -0
  18. package/dist/dep/dep.js +0 -0
  19. package/dist/dep/getCJSExports.d.ts +0 -0
  20. package/dist/dep/getCJSExports.js +60 -53
  21. package/dist/dep/getExposeFromContent.d.ts +0 -0
  22. package/dist/dep/getExposeFromContent.js +71 -59
  23. package/dist/dep/getModuleExports.d.ts +0 -0
  24. package/dist/dep/getModuleExports.js +58 -32
  25. package/dist/depBuilder/depBuilder.d.ts +0 -0
  26. package/dist/depBuilder/depBuilder.js +0 -0
  27. package/dist/depBuilder/getESBuildEntry.d.ts +0 -0
  28. package/dist/depBuilder/getESBuildEntry.js +35 -12
  29. package/dist/depInfo.d.ts +0 -0
  30. package/dist/depInfo.js +0 -0
  31. package/dist/esbuildHandlers/autoCssModules.d.ts +0 -0
  32. package/dist/esbuildHandlers/autoCssModules.js +0 -0
  33. package/dist/esbuildHandlers/awaitImport/index.d.ts +0 -0
  34. package/dist/esbuildHandlers/awaitImport/index.js +82 -70
  35. package/dist/index.d.ts +0 -0
  36. package/dist/index.js +32 -22
  37. package/dist/loader/esbuild.d.ts +0 -0
  38. package/dist/loader/esbuild.js +87 -35
  39. package/dist/mfsu/mfsu.d.ts +1 -1
  40. package/dist/mfsu/mfsu.js +1 -1
  41. package/dist/mfsu/strategyCompileTime.d.ts +0 -0
  42. package/dist/mfsu/strategyCompileTime.js +1 -1
  43. package/dist/mfsu/strategyStaticAnalyze.d.ts +0 -0
  44. package/dist/mfsu/strategyStaticAnalyze.js +1 -2
  45. package/dist/moduleGraph.d.ts +0 -0
  46. package/dist/moduleGraph.js +0 -0
  47. package/dist/staticDepInfo/importParser.d.ts +0 -0
  48. package/dist/staticDepInfo/importParser.js +28 -6
  49. package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts +0 -0
  50. package/dist/staticDepInfo/simulations/babel-plugin-import.js +0 -0
  51. package/dist/staticDepInfo/staticDepInfo.d.ts +0 -0
  52. package/dist/staticDepInfo/staticDepInfo.js +8 -0
  53. package/dist/types.d.ts +0 -0
  54. package/dist/types.js +33 -8
  55. package/dist/utils/makeArray.d.ts +0 -0
  56. package/dist/utils/makeArray.js +29 -5
  57. package/dist/utils/trimFileContent.d.ts +0 -0
  58. package/dist/utils/trimFileContent.js +29 -5
  59. package/dist/webpackPlugins/buildDepPlugin.d.ts +0 -0
  60. package/dist/webpackPlugins/buildDepPlugin.js +49 -25
  61. package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts +0 -0
  62. package/dist/webpackPlugins/depChunkIdPrefixPlugin.js +44 -19
  63. package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts +0 -0
  64. package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +46 -27
  65. package/dist/webpackPlugins/writeCachePlugin.d.ts +0 -0
  66. package/dist/webpackPlugins/writeCachePlugin.js +39 -15
  67. package/package.json +6 -6
File without changes
@@ -1,68 +1,61 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
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
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
27
- function default_1() {
28
- return {
29
- visitor: {
30
- Program: {
31
- exit(path, { opts }) {
32
- let index = path.node.body.length - 1;
33
- while (index >= 0) {
34
- const node = path.node.body[index];
35
- // import x from 'x';
36
- // import * as x from 'x';
37
- // import x, * as xx from 'x';
38
- // import { x } from 'x';
39
- if (t.isImportDeclaration(node)) {
40
- node.source.value = opts.resolveImportSource(node.source.value);
41
- }
42
- // export * from 'x';
43
- else if (t.isExportAllDeclaration(node)) {
44
- node.source.value = opts.resolveImportSource(node.source.value);
45
- }
46
- // export { x } from 'x';
47
- else if (t.isExportNamedDeclaration(node) && node.source) {
48
- node.source.value = opts.resolveImportSource(node.source.value);
49
- }
50
- index -= 1;
51
- }
52
- },
53
- },
54
- CallExpression: {
55
- exit(path, { opts }) {
56
- const { node } = path;
57
- if (t.isImport(node.callee) &&
58
- node.arguments.length === 1 &&
59
- node.arguments[0].type === 'StringLiteral') {
60
- const newValue = opts.resolveImportSource(node.arguments[0].value);
61
- node.arguments[0] = t.stringLiteral(newValue);
62
- }
63
- },
64
- },
65
- },
66
- };
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
+ // MFImport.ts
23
+ var MFImport_exports = {};
24
+ __export(MFImport_exports, {
25
+ default: () => MFImport_default
26
+ });
27
+ module.exports = __toCommonJS(MFImport_exports);
28
+ var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
29
+ function MFImport_default() {
30
+ return {
31
+ visitor: {
32
+ Program: {
33
+ exit(path, { opts }) {
34
+ let index = path.node.body.length - 1;
35
+ while (index >= 0) {
36
+ const node = path.node.body[index];
37
+ if (t.isImportDeclaration(node)) {
38
+ node.source.value = opts.resolveImportSource(node.source.value);
39
+ } else if (t.isExportAllDeclaration(node)) {
40
+ node.source.value = opts.resolveImportSource(node.source.value);
41
+ } else if (t.isExportNamedDeclaration(node) && node.source) {
42
+ node.source.value = opts.resolveImportSource(node.source.value);
43
+ }
44
+ index -= 1;
45
+ }
46
+ }
47
+ },
48
+ CallExpression: {
49
+ exit(path, { opts }) {
50
+ const { node } = path;
51
+ if (t.isImport(node.callee) && node.arguments.length === 1 && node.arguments[0].type === "StringLiteral") {
52
+ const newValue = opts.resolveImportSource(node.arguments[0].value);
53
+ node.arguments[0] = t.stringLiteral(newValue);
54
+ }
55
+ }
56
+ }
57
+ }
58
+ };
67
59
  }
68
- exports.default = default_1;
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {});
@@ -4,7 +4,7 @@ export interface IOpts {
4
4
  onTransformDeps?: Function;
5
5
  onCollect?: Function;
6
6
  exportAllMembers?: Record<string, string[]>;
7
- unMatchLibs?: string[];
7
+ unMatchLibs?: Array<string | RegExp>;
8
8
  remoteName?: string;
9
9
  alias?: Record<string, string>;
10
10
  externals?: any;
@@ -1,120 +1,106 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
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
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
27
- const checkMatch_1 = require("./checkMatch");
28
- function default_1() {
29
- return {
30
- pre() {
31
- // @ts-ignore
32
- this.cache = new Map();
33
- },
34
- post(state) {
35
- var _a, _b;
36
- // @ts-ignore
37
- const { cache } = this;
38
- if (cache.has(state.opts.filename)) {
39
- // @ts-ignore
40
- (_b = (_a = this.opts).onCollect) === null || _b === void 0 ? void 0 : _b.call(_a, {
41
- file: state.opts.filename,
42
- data: cache.get(state.opts.filename),
43
- });
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
+ // awaitImport.ts
23
+ var awaitImport_exports = {};
24
+ __export(awaitImport_exports, {
25
+ default: () => awaitImport_default
26
+ });
27
+ module.exports = __toCommonJS(awaitImport_exports);
28
+ var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
29
+ var import_checkMatch = require("./checkMatch");
30
+ function awaitImport_default() {
31
+ return {
32
+ pre() {
33
+ this.cache = /* @__PURE__ */ new Map();
34
+ },
35
+ post(state) {
36
+ var _a, _b;
37
+ const { cache } = this;
38
+ if (cache.has(state.opts.filename)) {
39
+ (_b = (_a = this.opts).onCollect) == null ? void 0 : _b.call(_a, {
40
+ file: state.opts.filename,
41
+ data: cache.get(state.opts.filename)
42
+ });
43
+ }
44
+ },
45
+ visitor: {
46
+ Program: {
47
+ exit(path, { opts }) {
48
+ let index = path.node.body.length - 1;
49
+ while (index >= 0) {
50
+ const node = path.node.body[index];
51
+ if (t.isImportDeclaration(node)) {
52
+ const { isMatch, replaceValue } = (0, import_checkMatch.checkMatch)({
53
+ cache: this.cache,
54
+ value: node.source.value,
55
+ opts,
56
+ path
57
+ });
58
+ if (isMatch) {
59
+ node.source.value = replaceValue;
60
+ }
61
+ } else if (t.isExportAllDeclaration(node)) {
62
+ const { isMatch, replaceValue } = (0, import_checkMatch.checkMatch)({
63
+ cache: this.cache,
64
+ value: node.source.value,
65
+ opts,
66
+ path
67
+ });
68
+ if (isMatch) {
69
+ node.source.value = replaceValue;
70
+ }
71
+ } else if (t.isExportNamedDeclaration(node) && node.source) {
72
+ const { isMatch, replaceValue } = (0, import_checkMatch.checkMatch)({
73
+ cache: this.cache,
74
+ value: node.source.value,
75
+ opts,
76
+ path
77
+ });
78
+ if (isMatch) {
79
+ node.source.value = replaceValue;
80
+ }
81
+ }
82
+ index -= 1;
83
+ }
84
+ }
85
+ },
86
+ CallExpression: {
87
+ exit(path, { opts }) {
88
+ const { node } = path;
89
+ if (t.isImport(node.callee) && node.arguments.length === 1 && node.arguments[0].type === "StringLiteral") {
90
+ const { isMatch, replaceValue } = (0, import_checkMatch.checkMatch)({
91
+ cache: this.cache,
92
+ value: node.arguments[0].value,
93
+ opts,
94
+ path
95
+ });
96
+ if (isMatch) {
97
+ node.arguments[0] = t.stringLiteral(replaceValue);
44
98
  }
45
- },
46
- visitor: {
47
- Program: {
48
- exit(path, { opts }) {
49
- let index = path.node.body.length - 1;
50
- while (index >= 0) {
51
- const node = path.node.body[index];
52
- // import x from 'x';
53
- // import * as x from 'x';
54
- // import x, * as xx from 'x';
55
- // import { x } from 'x';
56
- if (t.isImportDeclaration(node)) {
57
- const { isMatch, replaceValue } = (0, checkMatch_1.checkMatch)({
58
- // @ts-ignore
59
- cache: this.cache,
60
- value: node.source.value,
61
- opts,
62
- path,
63
- });
64
- if (isMatch) {
65
- node.source.value = replaceValue;
66
- }
67
- }
68
- // export * from 'x';
69
- else if (t.isExportAllDeclaration(node)) {
70
- const { isMatch, replaceValue } = (0, checkMatch_1.checkMatch)({
71
- // @ts-ignore
72
- cache: this.cache,
73
- value: node.source.value,
74
- opts,
75
- path,
76
- });
77
- if (isMatch) {
78
- node.source.value = replaceValue;
79
- }
80
- }
81
- // export { x } from 'x';
82
- else if (t.isExportNamedDeclaration(node) && node.source) {
83
- const { isMatch, replaceValue } = (0, checkMatch_1.checkMatch)({
84
- // @ts-ignore
85
- cache: this.cache,
86
- value: node.source.value,
87
- opts,
88
- path,
89
- });
90
- if (isMatch) {
91
- node.source.value = replaceValue;
92
- }
93
- }
94
- index -= 1;
95
- }
96
- },
97
- },
98
- CallExpression: {
99
- exit(path, { opts }) {
100
- const { node } = path;
101
- if (t.isImport(node.callee) &&
102
- node.arguments.length === 1 &&
103
- node.arguments[0].type === 'StringLiteral') {
104
- const { isMatch, replaceValue } = (0, checkMatch_1.checkMatch)({
105
- // @ts-ignore
106
- cache: this.cache,
107
- value: node.arguments[0].value,
108
- opts,
109
- path,
110
- });
111
- if (isMatch) {
112
- node.arguments[0] = t.stringLiteral(replaceValue);
113
- }
114
- }
115
- },
116
- },
117
- },
118
- };
99
+ }
100
+ }
101
+ }
102
+ }
103
+ };
119
104
  }
120
- exports.default = default_1;
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {});
File without changes
@@ -17,8 +17,22 @@ function isUmiLocalDev(path) {
17
17
  ? (0, utils_1.winPath)(path).startsWith((0, utils_1.winPath)((0, path_1.join)(rootPath, './packages')))
18
18
  : false;
19
19
  }
20
+ function genUnMatchLibsRegex(libs) {
21
+ if (!libs) {
22
+ return null;
23
+ }
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;
33
+ }
20
34
  function checkMatch({ value, path, opts, isExportAll, depth, cache, filename, }) {
21
- var _a, _b;
35
+ var _a;
22
36
  let isMatch;
23
37
  let replaceValue = '';
24
38
  depth = depth || 1;
@@ -27,9 +41,10 @@ function checkMatch({ value, path, opts, isExportAll, depth, cache, filename, })
27
41
  const remoteName = opts.remoteName || 'mf';
28
42
  // FIXME: hard code for vite mode
29
43
  value = value.replace(/^@fs\//, '/');
44
+ const unMatchLibsRegex = genUnMatchLibsRegex(opts.unMatchLibs);
30
45
  if (
31
46
  // unMatch specified libs
32
- ((_a = opts.unMatchLibs) === null || _a === void 0 ? void 0 : _a.includes(value)) ||
47
+ (unMatchLibsRegex === null || unMatchLibsRegex === void 0 ? void 0 : unMatchLibsRegex.test(value)) ||
33
48
  // do not match bundler-webpack/client/client/client.js
34
49
  value.includes('client/client/client.js') ||
35
50
  // already handled
@@ -77,7 +92,7 @@ function checkMatch({ value, path, opts, isExportAll, depth, cache, filename, })
77
92
  }
78
93
  // @ts-ignore
79
94
  const file = (path === null || path === void 0 ? void 0 : path.hub.file.opts.filename) || filename;
80
- (_b = opts.onTransformDeps) === null || _b === void 0 ? void 0 : _b.call(opts, {
95
+ (_a = opts.onTransformDeps) === null || _a === void 0 ? void 0 : _a.call(opts, {
81
96
  sourceValue: value,
82
97
  replaceValue,
83
98
  isMatch,
File without changes
@@ -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
+ // 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
+ });
File without changes
@@ -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
+ // 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
+ });
File without changes