@umijs/mfsu 4.0.7 → 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 +0 -0
  41. package/dist/mfsu/strategyCompileTime.d.ts +0 -0
  42. package/dist/mfsu/strategyCompileTime.js +0 -0
  43. package/dist/mfsu/strategyStaticAnalyze.d.ts +0 -0
  44. package/dist/mfsu/strategyStaticAnalyze.js +0 -0
  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 +0 -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
@@ -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
+ // 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,55 +1,54 @@
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
- exports.parseSpecifiers = void 0;
27
- const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
28
- const DEFAULT = 'default';
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
+ // 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
- return specifiers.reduce((memo, s) => {
31
- if (t.isImportDefaultSpecifier(s)) {
32
- memo.properties.push(t.objectProperty(t.identifier(DEFAULT), s.local));
33
- }
34
- else if (t.isExportDefaultSpecifier(s)) {
35
- memo.properties.push(t.objectProperty(t.identifier(DEFAULT), s.exported));
36
- }
37
- else if (t.isExportSpecifier(s)) {
38
- if (t.isIdentifier(s.exported, { name: DEFAULT })) {
39
- memo.defaultIdentifier = s.local.name;
40
- memo.properties.push(t.objectProperty(s.local, s.local));
41
- }
42
- else {
43
- memo.properties.push(t.objectProperty(s.local, s.exported));
44
- }
45
- }
46
- else if (t.isImportNamespaceSpecifier(s)) {
47
- memo.namespaceIdentifier = s.local;
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
- exports.parseSpecifiers = parseSpecifiers;
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ parseSpecifiers
54
+ });
File without changes
package/dist/constants.js CHANGED
@@ -1,10 +1,47 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REMOTE_FILE_FULL = exports.REMOTE_FILE = exports.DEFAULT_TMP_DIR_NAME = exports.DEFAULT_MF_NAME = exports.MF_STATIC_PREFIX = exports.MF_DEP_PREFIX = exports.MF_VA_PREFIX = void 0;
4
- exports.MF_VA_PREFIX = 'mf-va_';
5
- exports.MF_DEP_PREFIX = 'mf-dep_';
6
- exports.MF_STATIC_PREFIX = 'mf-static/';
7
- exports.DEFAULT_MF_NAME = 'mf';
8
- exports.DEFAULT_TMP_DIR_NAME = '.mfsu';
9
- exports.REMOTE_FILE = 'remoteEntry.js';
10
- exports.REMOTE_FILE_FULL = `${exports.MF_VA_PREFIX}${exports.REMOTE_FILE}`;
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
+ // 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
File without changes
package/dist/dep/dep.js CHANGED
File without changes
File without changes
@@ -1,58 +1,65 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCJSExports = 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
+ // 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
- return matchAll(/Object\.defineProperty\(\s*exports\s*\,\s*[\"|\'](\w+)[\"|\']/g, content)
6
- .concat(
7
- // Support export['default']
8
- // ref: https://unpkg.alibaba-inc.com/browse/echarts-for-react@2.0.16/lib/core.js
9
- matchAll(/exports(?:\.|\[(?:\'|\"))(\w+)(?:\s*|(?:\'|\")\])\s*\=/g, content))
10
- .concat(
11
- // Support __webpack_exports__["default"]
12
- // ref: https://github.com/margox/braft-editor/blob/master/dist/index.js#L8429
13
- matchAll(/__webpack_exports__\[(?:\"|\')(\w+)(?:\"|\')\]\s*\=/g, content))
14
- .concat(
15
- // Support __webpack_require__.d(__webpack_exports, "EditorState")
16
- // ref: https://github.com/margox/braft-editor/blob/master/dist/index.js#L8347
17
- matchAll(/__webpack_require__\.d\(\s*__webpack_exports__\s*,\s*(?:\"|\')(\w+)(?:\"|\')\s*,/g, content))
18
- .concat(
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
- let result = content.slice(symbolBeginIndex, idx);
44
- return [
45
- ...matchAll(/(?:\"|\')(\w+)(?:\"|\')\s*\:\s*(?:function|\()/g, result),
46
- ];
47
- }))
48
- .map((result) => result[1]);
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
- const result = [];
53
- let match;
54
- while ((match = regexp.exec(str)) !== null) {
55
- result.push(match);
56
- }
57
- return result;
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
+ });
File without changes
@@ -1,69 +1,81 @@
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.getExposeFromContent = void 0;
7
- const assert_1 = __importDefault(require("assert"));
8
- const path_1 = require("path");
9
- const getModuleExports_1 = require("./getModuleExports");
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
+ // getExposeFromContent.ts
23
+ var getExposeFromContent_exports = {};
24
+ __export(getExposeFromContent_exports, {
25
+ getExposeFromContent: () => getExposeFromContent
26
+ });
27
+ module.exports = __toCommonJS(getExposeFromContent_exports);
28
+ var import_assert = __toESM(require("assert"));
29
+ var import_path = require("path");
30
+ var import_getModuleExports = require("./getModuleExports");
10
31
  async function getExposeFromContent(opts) {
11
- // Support CSS
12
- if (opts.filePath &&
13
- /\.(css|less|scss|sass|stylus|styl)$/.test(opts.filePath)) {
14
- return `import '${opts.dep.file}';`;
15
- }
16
- // Support Assets Files
17
- if (opts.filePath &&
18
- /\.(json|svg|png|jpe?g|avif|gif|webp|ico|eot|woff|woff2|ttf|txt|text|mdx?)$/.test(opts.filePath)) {
19
- return `
32
+ if (opts.filePath && /\.(css|less|scss|sass|stylus|styl)$/.test(opts.filePath)) {
33
+ return `import '${opts.dep.file}';`;
34
+ }
35
+ if (opts.filePath && /\.(json|svg|png|jpe?g|avif|gif|webp|ico|eot|woff|woff2|ttf|txt|text|mdx?)$/.test(opts.filePath)) {
36
+ return `
20
37
  import _ from '${opts.dep.file}';
21
38
  export default _;`.trim();
39
+ }
40
+ (0, import_assert.default)(/(js|jsx|mjs|ts|tsx)$/.test(opts.filePath), `file type not supported for ${(0, import_path.basename)(opts.filePath)}.`);
41
+ const { exports, isCJS } = await (0, import_getModuleExports.getModuleExports)({
42
+ content: opts.content,
43
+ filePath: opts.filePath
44
+ });
45
+ if (isCJS) {
46
+ return [
47
+ `import _ from '${opts.dep.file}';`,
48
+ `export default _;`,
49
+ `export * from '${opts.dep.file}';`
50
+ ].join("\n");
51
+ } else {
52
+ const ret = [];
53
+ let hasExports = false;
54
+ if (exports.includes("default")) {
55
+ ret.push(`import _ from '${opts.dep.file}';`);
56
+ ret.push(`export default _;`);
57
+ hasExports = true;
22
58
  }
23
- (0, assert_1.default)(/(js|jsx|mjs|ts|tsx)$/.test(opts.filePath), `file type not supported for ${(0, path_1.basename)(opts.filePath)}.`);
24
- const { exports, isCJS } = await (0, getModuleExports_1.getModuleExports)({
25
- content: opts.content,
26
- filePath: opts.filePath,
27
- });
28
- // cjs
29
- if (isCJS) {
30
- return [
31
- `import _ from '${opts.dep.file}';`,
32
- `export default _;`,
33
- `export * from '${opts.dep.file}';`,
34
- ].join('\n');
59
+ if (hasNonDefaultExports(exports) || /export\s*\*\s*from/.test(opts.content)) {
60
+ ret.push(`export * from '${opts.dep.file}';`);
61
+ hasExports = true;
35
62
  }
36
- // esm
37
- else {
38
- const ret = [];
39
- let hasExports = false;
40
- if (exports.includes('default')) {
41
- ret.push(`import _ from '${opts.dep.file}';`);
42
- ret.push(`export default _;`);
43
- hasExports = true;
44
- }
45
- if (hasNonDefaultExports(exports) ||
46
- // export * from 不会有 exports,只会有 imports
47
- /export\s+\*\s+from/.test(opts.content)) {
48
- ret.push(`export * from '${opts.dep.file}';`);
49
- hasExports = true;
50
- }
51
- if (!hasExports) {
52
- // 只有 __esModule 的全量导出
53
- if (exports.includes('__esModule')) {
54
- ret.push(`import _ from '${opts.dep.file}';`);
55
- ret.push(`export default _;`);
56
- ret.push(`export * from '${opts.dep.file}';`);
57
- }
58
- else {
59
- ret.push(`import '${opts.dep.file}';`);
60
- }
61
- }
62
- return ret.join('\n');
63
+ if (!hasExports) {
64
+ if (exports.includes("__esModule")) {
65
+ ret.push(`import _ from '${opts.dep.file}';`);
66
+ ret.push(`export default _;`);
67
+ ret.push(`export * from '${opts.dep.file}';`);
68
+ } else {
69
+ ret.push(`import '${opts.dep.file}';`);
70
+ }
63
71
  }
72
+ return ret.join("\n");
73
+ }
64
74
  }
65
- exports.getExposeFromContent = getExposeFromContent;
66
75
  function hasNonDefaultExports(exports) {
67
- return (exports.filter((exp) => !['__esModule', 'default'].includes(exp))
68
- .length > 0);
76
+ return exports.filter((exp) => !["__esModule", "default"].includes(exp)).length > 0;
69
77
  }
78
+ // Annotate the CommonJS export names for ESM import in node:
79
+ 0 && (module.exports = {
80
+ getExposeFromContent
81
+ });
File without changes
@@ -1,34 +1,60 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getModuleExports = void 0;
4
- const es_module_lexer_1 = require("@umijs/bundler-utils/compiled/es-module-lexer");
5
- const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
6
- const path_1 = require("path");
7
- const getCJSExports_1 = require("./getCJSExports");
8
- async function getModuleExports({ content, filePath, }) {
9
- // Support tsx and jsx
10
- if (filePath && /\.(tsx|jsx)$/.test(filePath)) {
11
- content = (await (0, esbuild_1.transform)(content, {
12
- sourcemap: false,
13
- sourcefile: filePath,
14
- format: 'esm',
15
- target: 'es6',
16
- loader: (0, path_1.extname)(filePath).slice(1),
17
- })).code;
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
+ // getModuleExports.ts
20
+ var getModuleExports_exports = {};
21
+ __export(getModuleExports_exports, {
22
+ getModuleExports: () => getModuleExports
23
+ });
24
+ module.exports = __toCommonJS(getModuleExports_exports);
25
+ var import_es_module_lexer = require("@umijs/bundler-utils/compiled/es-module-lexer");
26
+ var import_esbuild = require("@umijs/bundler-utils/compiled/esbuild");
27
+ var import_path = require("path");
28
+ var import_getCJSExports = require("./getCJSExports");
29
+ async function getModuleExports({
30
+ content,
31
+ filePath
32
+ }) {
33
+ if (filePath && /\.(tsx|jsx)$/.test(filePath)) {
34
+ content = (await (0, import_esbuild.transform)(content, {
35
+ sourcemap: false,
36
+ sourcefile: filePath,
37
+ format: "esm",
38
+ target: "es6",
39
+ loader: (0, import_path.extname)(filePath).slice(1)
40
+ })).code;
41
+ }
42
+ await import_es_module_lexer.init;
43
+ const [imports, exports] = (0, import_es_module_lexer.parse)(content);
44
+ let isCJS = !imports.length && !exports.length;
45
+ let cjsEsmExports = null;
46
+ if (isCJS) {
47
+ cjsEsmExports = (0, import_getCJSExports.getCJSExports)({ content });
48
+ if (cjsEsmExports.includes("__esModule")) {
49
+ isCJS = false;
18
50
  }
19
- await es_module_lexer_1.init;
20
- const [imports, exports] = (0, es_module_lexer_1.parse)(content);
21
- let isCJS = !imports.length && !exports.length;
22
- let cjsEsmExports = null;
23
- if (isCJS) {
24
- cjsEsmExports = (0, getCJSExports_1.getCJSExports)({ content });
25
- if (cjsEsmExports.includes('__esModule')) {
26
- isCJS = false;
27
- }
28
- }
29
- return {
30
- exports: cjsEsmExports || exports,
31
- isCJS,
32
- };
51
+ }
52
+ return {
53
+ exports: cjsEsmExports || exports,
54
+ isCJS
55
+ };
33
56
  }
34
- exports.getModuleExports = getModuleExports;
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ getModuleExports
60
+ });
File without changes
File without changes
File without changes