@modern-js/module-tools 2.0.0-beta.4 → 2.0.0-beta.7

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 (123) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/dist/build.d.ts +3 -0
  3. package/dist/build.js +73 -0
  4. package/dist/build.js.map +1 -0
  5. package/dist/builder/build.js +55 -51
  6. package/dist/builder/build.js.map +1 -1
  7. package/dist/builder/clear.js +17 -24
  8. package/dist/builder/clear.js.map +1 -1
  9. package/dist/builder/copy.d.ts +2 -0
  10. package/dist/builder/copy.js +45 -56
  11. package/dist/builder/copy.js.map +1 -1
  12. package/dist/builder/dts/index.js +8 -3
  13. package/dist/builder/dts/index.js.map +1 -1
  14. package/dist/builder/dts/rollup.js +39 -52
  15. package/dist/builder/dts/rollup.js.map +1 -1
  16. package/dist/builder/dts/tsc.js +28 -35
  17. package/dist/builder/dts/tsc.js.map +1 -1
  18. package/dist/builder/index.js +15 -31
  19. package/dist/builder/index.js.map +1 -1
  20. package/dist/builder/platform.js +74 -68
  21. package/dist/builder/platform.js.map +1 -1
  22. package/dist/cli.js +16 -24
  23. package/dist/cli.js.map +1 -1
  24. package/dist/command.js +47 -60
  25. package/dist/command.js.map +1 -1
  26. package/dist/config/defineConfig.js +7 -3
  27. package/dist/config/defineConfig.js.map +1 -1
  28. package/dist/config/normalize.js +32 -41
  29. package/dist/config/normalize.js.map +1 -1
  30. package/dist/config/schema.d.ts +4 -4
  31. package/dist/config/schema.js +12 -4
  32. package/dist/config/schema.js.map +1 -1
  33. package/dist/constants/build-presets.js +51 -34
  34. package/dist/constants/build-presets.js.map +1 -1
  35. package/dist/constants/build.js +11 -4
  36. package/dist/constants/build.js.map +1 -1
  37. package/dist/constants/colors.js +9 -3
  38. package/dist/constants/colors.js.map +1 -1
  39. package/dist/constants/dts.js +10 -3
  40. package/dist/constants/dts.js.map +1 -1
  41. package/dist/constants/file.js +9 -3
  42. package/dist/constants/file.js.map +1 -1
  43. package/dist/constants/legacy-build-presets.js +31 -22
  44. package/dist/constants/legacy-build-presets.js.map +1 -1
  45. package/dist/constants/log.js +10 -3
  46. package/dist/constants/log.js.map +1 -1
  47. package/dist/dev.d.ts +1 -1
  48. package/dist/dev.js +26 -35
  49. package/dist/dev.js.map +1 -1
  50. package/dist/error.js +12 -3
  51. package/dist/error.js.map +1 -1
  52. package/dist/hooks/build.d.ts +5 -8
  53. package/dist/hooks/build.js +8 -4
  54. package/dist/hooks/build.js.map +1 -1
  55. package/dist/hooks/dev.d.ts +1 -1
  56. package/dist/hooks/dev.js +8 -4
  57. package/dist/hooks/dev.js.map +1 -1
  58. package/dist/hooks/index.d.ts +6 -9
  59. package/dist/hooks/index.js +21 -19
  60. package/dist/hooks/index.js.map +1 -1
  61. package/dist/hooks/misc.js +7 -3
  62. package/dist/hooks/misc.js.map +1 -1
  63. package/dist/index.js +9 -4
  64. package/dist/index.js.map +1 -1
  65. package/dist/locale/en.d.ts +1 -0
  66. package/dist/locale/en.js +11 -4
  67. package/dist/locale/en.js.map +1 -1
  68. package/dist/locale/index.d.ts +2 -0
  69. package/dist/locale/index.js +8 -3
  70. package/dist/locale/index.js.map +1 -1
  71. package/dist/locale/zh.d.ts +1 -0
  72. package/dist/locale/zh.js +11 -4
  73. package/dist/locale/zh.js.map +1 -1
  74. package/dist/plugins.js +7 -3
  75. package/dist/plugins.js.map +1 -1
  76. package/dist/types/color.js +17 -0
  77. package/dist/types/color.js.map +1 -0
  78. package/dist/types/command.d.ts +2 -1
  79. package/dist/types/command.js +17 -0
  80. package/dist/types/command.js.map +1 -0
  81. package/dist/types/config/index.d.ts +3 -6
  82. package/dist/types/config/index.js +3 -3
  83. package/dist/types/config/index.js.map +1 -1
  84. package/dist/types/config/style.js +17 -0
  85. package/dist/types/config/style.js.map +1 -0
  86. package/dist/types/context.js +17 -0
  87. package/dist/types/context.js.map +1 -0
  88. package/dist/types/copy.js +17 -0
  89. package/dist/types/copy.js.map +1 -0
  90. package/dist/types/dts.js +17 -0
  91. package/dist/types/dts.js.map +1 -0
  92. package/dist/types/hooks.d.ts +2 -2
  93. package/dist/types/hooks.js +17 -0
  94. package/dist/types/hooks.js.map +1 -0
  95. package/dist/types/index.js +7 -7
  96. package/dist/types/index.js.map +1 -1
  97. package/dist/types/utils.js +17 -0
  98. package/dist/types/utils.js.map +1 -0
  99. package/dist/utils/builder.js +13 -26
  100. package/dist/utils/builder.js.map +1 -1
  101. package/dist/utils/config.js +33 -38
  102. package/dist/utils/config.js.map +1 -1
  103. package/dist/utils/context.js +14 -22
  104. package/dist/utils/context.js.map +1 -1
  105. package/dist/utils/dts.js +39 -50
  106. package/dist/utils/dts.js.map +1 -1
  107. package/dist/utils/input.js +19 -30
  108. package/dist/utils/input.js.map +1 -1
  109. package/dist/utils/language.js +17 -24
  110. package/dist/utils/language.js.map +1 -1
  111. package/dist/utils/libuild-plugins.js +16 -23
  112. package/dist/utils/libuild-plugins.js.map +1 -1
  113. package/dist/utils/log.js +15 -23
  114. package/dist/utils/log.js.map +1 -1
  115. package/dist/utils/onExit.js +14 -22
  116. package/dist/utils/onExit.js.map +1 -1
  117. package/dist/utils/path.js +11 -25
  118. package/dist/utils/path.js.map +1 -1
  119. package/dist/utils/style.js +20 -25
  120. package/dist/utils/style.js.map +1 -1
  121. package/dist/utils/tspaths-transform.js +7 -3
  122. package/dist/utils/tspaths-transform.js.map +1 -1
  123. package/package.json +13 -15
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,30 +16,11 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
20
- run: () => run
21
- });
22
- module.exports = __toCommonJS(stdin_exports);
23
- var __create = Object.create;
24
- var __defProp2 = Object.defineProperty;
25
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
26
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
27
- var __getProtoOf = Object.getPrototypeOf;
28
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
29
- var __copyProps2 = (to, from, except, desc) => {
30
- if (from && typeof from === "object" || typeof from === "function") {
31
- for (let key of __getOwnPropNames2(from))
32
- if (!__hasOwnProp2.call(to, key) && key !== except)
33
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
34
- }
35
- return to;
36
- };
37
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps2(
38
- isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
21
  mod
40
22
  ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
24
  var __async = (__this, __arguments, generator) => {
42
25
  return new Promise((resolve, reject) => {
43
26
  var fulfilled = (value) => {
@@ -58,6 +41,11 @@ var __async = (__this, __arguments, generator) => {
58
41
  step((generator = generator.apply(__this, __arguments)).next());
59
42
  });
60
43
  };
44
+ var builder_exports = {};
45
+ __export(builder_exports, {
46
+ run: () => run
47
+ });
48
+ module.exports = __toCommonJS(builder_exports);
61
49
  const run = (options, api) => __async(void 0, null, function* () {
62
50
  const { chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
63
51
  const { resolvedBuildConfig, context, cmdOptions } = options;
@@ -77,15 +65,7 @@ const run = (options, api) => __async(void 0, null, function* () {
77
65
  }
78
66
  try {
79
67
  yield pMap(resolvedBuildConfig, (config) => __async(void 0, null, function* () {
80
- const buildConfig = yield runner.beforeBuildTask(
81
- {
82
- config,
83
- options: cmdOptions
84
- },
85
- { onLast: (c) => __async(void 0, null, function* () {
86
- return c.config;
87
- }) }
88
- );
68
+ const buildConfig = yield runner.beforeBuildTask(config);
89
69
  yield runBuildTask(
90
70
  {
91
71
  buildConfig,
@@ -120,5 +100,9 @@ const run = (options, api) => __async(void 0, null, function* () {
120
100
  totalDuration
121
101
  });
122
102
  });
103
+ // Annotate the CommonJS export names for ESM import in node:
104
+ 0 && (module.exports = {
105
+ run
106
+ });
123
107
 
124
108
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM,MAAM,CACjB,SAKA,QACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO;AAC/B,QAAM,EAAE,qBAAqB,SAAS,WAAW,IAAI;AACrD,QAAM,SAAS,IAAI,eAAe;AAElC,MAAI,gBAAgB;AAEpB,MAAI,oBAAoB,WAAW,GAAG;AACpC,UAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO;AAC1C,oBAAgB,KAAK,IAAI;AAEzB,KAAC,WAAW,SAAS,QAAQ,KAAK,gBAAgB;AAElD,UAAM,EAAE,aAAa,IAAI,MAAM,6CAAO;AACtC,UAAM,EAAE,SAAS,KAAK,IAAI,MAAM,6CAAO;AAEvC,UAAM,EAAE,uBAAuB,aAAa,IAAI,MAAM,6CAAO;AAC7D,UAAM,sBAAsB,mBAAmB;AAC/C,UAAM,aAAa;AAEnB,QAAI,WAAW,OAAO;AACpB,cAAQ,KAAK,MAAM,KAAK,UAAU,gCAAgC,CAAC;AAAA,IACrE;AAEA,QAAI;AACF,YAAM,KAAK,qBAAqB,CAAM,WAAU;AAC9C,cAAM,cAAc,MAAM,OAAO;AAAA,UAC/B;AAAA,YACE;AAAA,YACA,SAAS;AAAA,UACX;AAAA,UACA,EAAE,QAAQ,CAAM,MAAE;AAAG,qBAAE;AAAA,aAAO;AAAA,QAChC;AACA,cAAM;AAAA,UACJ;AAAA,YACE;AAAA,YACA,iBAAiB;AAAA,YACjB;AAAA,UACF;AAAA,UACA;AAAA,QACF;AACA,cAAM,OAAO,eAAe,EAAE,QAAQ,WAAW,OAAO,CAAC;AAAA,MAC3D,EAAC;AAED,OAAC,WAAW,SAAS,QAAQ,QAAQ,gBAAgB;AAAA,IACvD,SAAS,GAAT;AACE,YAAM,EAAE,iBAAiB,iBAAiB,IAAI,MAAM,6CAAO;AAC3D,UAAI,gBAAgB,CAAC,GAAG;AACtB,cAAM,IAAI,iBAAiB,CAAC;AAAA,MAC9B,OAAO;AACL,cAAM;AAAA,MACR;AAAA,IACF;AACA,oBAAgB,KAAK,IAAI,IAAI;AAAA,EAC/B,OAAO;AACL,YAAQ;AAAA,MACN,MAAM;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,OAAO,WAAW;AAAA,IACtB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB;AAAA,EACF,CAAC;AACH;","names":[],"sources":["../../src/builder/index.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { ModuleContext } from '../types/context';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n} from '../types';\n\nexport const run = async (\n options: {\n cmdOptions: BuildCommandOptions;\n resolvedBuildConfig: BaseBuildConfig[];\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { chalk } = await import('@modern-js/utils');\n const { resolvedBuildConfig, context, cmdOptions } = options;\n const runner = api.useHookRunners();\n\n let totalDuration = 0;\n\n if (resolvedBuildConfig.length !== 0) {\n const { buildSuccessText } = await import('../constants/log');\n totalDuration = Date.now();\n // eslint-disable-next-line no-console\n !cmdOptions.watch && console.time(buildSuccessText);\n\n const { runBuildTask } = await import('./build');\n const { default: pMap } = await import('../../compiled/p-map');\n\n const { clearBuildConfigPaths, clearDtsTemp } = await import('./clear');\n await clearBuildConfigPaths(resolvedBuildConfig);\n await clearDtsTemp();\n\n if (cmdOptions.watch) {\n console.info(chalk.blue.underline('start build in watch mode...\\n'));\n }\n\n try {\n await pMap(resolvedBuildConfig, async config => {\n const buildConfig = await runner.beforeBuildTask(\n {\n config,\n options: cmdOptions,\n },\n { onLast: async c => c.config },\n );\n await runBuildTask(\n {\n buildConfig,\n buildCmdOptions: cmdOptions,\n context,\n },\n api,\n );\n await runner.afterBuildTask({ status: 'success', config });\n });\n // eslint-disable-next-line no-console\n !cmdOptions.watch && console.timeEnd(buildSuccessText);\n } catch (e) {\n const { isInternalError, ModuleBuildError } = await import('../error');\n if (isInternalError(e)) {\n throw new ModuleBuildError(e);\n } else {\n throw e;\n }\n }\n totalDuration = Date.now() - totalDuration;\n } else {\n console.warn(\n chalk.yellow(\n `No build configuration found! Please configure \\`buildConfig\\` or \\`buildPreset\\``,\n ),\n );\n }\n\n await runner.afterBuild({\n status: 'success',\n config: resolvedBuildConfig,\n commandOptions: cmdOptions,\n totalDuration,\n });\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,MAAM,MAAM,CACjB,SAKA,QACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO;AAC/B,QAAM,EAAE,qBAAqB,SAAS,WAAW,IAAI;AACrD,QAAM,SAAS,IAAI,eAAe;AAElC,MAAI,gBAAgB;AAEpB,MAAI,oBAAoB,WAAW,GAAG;AACpC,UAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO;AAC1C,oBAAgB,KAAK,IAAI;AAEzB,KAAC,WAAW,SAAS,QAAQ,KAAK,gBAAgB;AAElD,UAAM,EAAE,aAAa,IAAI,MAAM,6CAAO;AACtC,UAAM,EAAE,SAAS,KAAK,IAAI,MAAM,6CAAO;AAEvC,UAAM,EAAE,uBAAuB,aAAa,IAAI,MAAM,6CAAO;AAC7D,UAAM,sBAAsB,mBAAmB;AAC/C,UAAM,aAAa;AAEnB,QAAI,WAAW,OAAO;AACpB,cAAQ,KAAK,MAAM,KAAK,UAAU,gCAAgC,CAAC;AAAA,IACrE;AAEA,QAAI;AACF,YAAM,KAAK,qBAAqB,CAAM,WAAU;AAC9C,cAAM,cAAc,MAAM,OAAO,gBAAgB,MAAM;AAEvD,cAAM;AAAA,UACJ;AAAA,YACE;AAAA,YACA,iBAAiB;AAAA,YACjB;AAAA,UACF;AAAA,UACA;AAAA,QACF;AACA,cAAM,OAAO,eAAe,EAAE,QAAQ,WAAW,OAAO,CAAC;AAAA,MAC3D,EAAC;AAED,OAAC,WAAW,SAAS,QAAQ,QAAQ,gBAAgB;AAAA,IACvD,SAAS,GAAP;AACA,YAAM,EAAE,iBAAiB,iBAAiB,IAAI,MAAM,6CAAO;AAC3D,UAAI,gBAAgB,CAAC,GAAG;AACtB,cAAM,IAAI,iBAAiB,CAAC;AAAA,MAC9B,OAAO;AACL,cAAM;AAAA,MACR;AAAA,IACF;AACA,oBAAgB,KAAK,IAAI,IAAI;AAAA,EAC/B,OAAO;AACL,YAAQ;AAAA,MACN,MAAM;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,OAAO,WAAW;AAAA,IACtB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB;AAAA,EACF,CAAC;AACH;;;;;","names":[],"sources":["../../src/builder/index.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { ModuleContext } from '../types/context';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n} from '../types';\n\nexport const run = async (\n options: {\n cmdOptions: BuildCommandOptions;\n resolvedBuildConfig: BaseBuildConfig[];\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { chalk } = await import('@modern-js/utils');\n const { resolvedBuildConfig, context, cmdOptions } = options;\n const runner = api.useHookRunners();\n\n let totalDuration = 0;\n\n if (resolvedBuildConfig.length !== 0) {\n const { buildSuccessText } = await import('../constants/log');\n totalDuration = Date.now();\n // eslint-disable-next-line no-console\n !cmdOptions.watch && console.time(buildSuccessText);\n\n const { runBuildTask } = await import('./build');\n const { default: pMap } = await import('../../compiled/p-map');\n\n const { clearBuildConfigPaths, clearDtsTemp } = await import('./clear');\n await clearBuildConfigPaths(resolvedBuildConfig);\n await clearDtsTemp();\n\n if (cmdOptions.watch) {\n console.info(chalk.blue.underline('start build in watch mode...\\n'));\n }\n\n try {\n await pMap(resolvedBuildConfig, async config => {\n const buildConfig = await runner.beforeBuildTask(config);\n\n await runBuildTask(\n {\n buildConfig,\n buildCmdOptions: cmdOptions,\n context,\n },\n api,\n );\n await runner.afterBuildTask({ status: 'success', config });\n });\n // eslint-disable-next-line no-console\n !cmdOptions.watch && console.timeEnd(buildSuccessText);\n } catch (e) {\n const { isInternalError, ModuleBuildError } = await import('../error');\n if (isInternalError(e)) {\n throw new ModuleBuildError(e);\n } else {\n throw e;\n }\n }\n totalDuration = Date.now() - totalDuration;\n } else {\n console.warn(\n chalk.yellow(\n `No build configuration found! Please configure \\`buildConfig\\` or \\`buildPreset\\``,\n ),\n );\n }\n\n await runner.afterBuild({\n status: 'success',\n config: resolvedBuildConfig,\n commandOptions: cmdOptions,\n totalDuration,\n });\n};\n"]}
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,30 +16,11 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
20
- buildPlatform: () => buildPlatform
21
- });
22
- module.exports = __toCommonJS(stdin_exports);
23
- var __create = Object.create;
24
- var __defProp2 = Object.defineProperty;
25
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
26
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
27
- var __getProtoOf = Object.getPrototypeOf;
28
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
29
- var __copyProps2 = (to, from, except, desc) => {
30
- if (from && typeof from === "object" || typeof from === "function") {
31
- for (let key of __getOwnPropNames2(from))
32
- if (!__hasOwnProp2.call(to, key) && key !== except)
33
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
34
- }
35
- return to;
36
- };
37
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps2(
38
- isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
21
  mod
40
22
  ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
24
  var __async = (__this, __arguments, generator) => {
42
25
  return new Promise((resolve, reject) => {
43
26
  var fulfilled = (value) => {
@@ -58,6 +41,11 @@ var __async = (__this, __arguments, generator) => {
58
41
  step((generator = generator.apply(__this, __arguments)).next());
59
42
  });
60
43
  };
44
+ var platform_exports = {};
45
+ __export(platform_exports, {
46
+ buildPlatform: () => buildPlatform
47
+ });
48
+ module.exports = __toCommonJS(platform_exports);
61
49
  const buildPlatform = (options, api, context) => __async(void 0, null, function* () {
62
50
  const { chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
63
51
  const { blue, gray } = yield Promise.resolve().then(() => __toESM(require("../constants/colors")));
@@ -80,61 +68,79 @@ const buildPlatform = (options, api, context) => __async(void 0, null, function*
80
68
  return;
81
69
  }
82
70
  yield runner.beforeBuildPlatform(platformBuilders);
83
- if (options.platform === true) {
84
- for (const platformBuilder of platformBuilders) {
85
- const currentPlatform = Array.isArray(platformBuilder.platform) ? platformBuilder.platform[0] : platformBuilder.platform;
86
- console.info(
87
- chalk.underline.rgb(...blue)(
88
- `Running [${currentPlatform}] build task:`
89
- )
90
- );
91
- yield runner.buildPlatform({ platform: currentPlatform });
92
- yield platformBuilder.build(currentPlatform, {
93
- isTsProject: context.isTsProject
94
- });
95
- console.info(chalk.rgb(...gray)(`Done for [${currentPlatform}] task`));
96
- }
97
- } else if (Array.isArray(options.platform) && options.platform.length === 1) {
98
- const targetPlatform = options.platform[0];
99
- const selectPlatformBuilder = platformBuilders.find((builder) => {
100
- if (Array.isArray(builder.platform)) {
101
- return builder.platform.includes(targetPlatform);
71
+ let errorMsg = null;
72
+ try {
73
+ if (options.platform === true) {
74
+ for (const platformBuilder of platformBuilders) {
75
+ const currentPlatform = Array.isArray(platformBuilder.platform) ? platformBuilder.platform[0] : platformBuilder.platform;
76
+ console.info(
77
+ chalk.underline.rgb(...blue)(
78
+ `Running [${currentPlatform}] build task:`
79
+ )
80
+ );
81
+ yield runner.buildPlatform({ platform: currentPlatform });
82
+ yield platformBuilder.build(currentPlatform, {
83
+ isTsProject: context.isTsProject
84
+ });
85
+ console.info(chalk.rgb(...gray)(`Done for [${currentPlatform}] task`));
102
86
  }
103
- return builder.platform === targetPlatform;
104
- });
105
- if (!selectPlatformBuilder) {
106
- console.info(`The specified "${targetPlatform}" build does not exist`);
107
- return;
108
- }
109
- console.info(
110
- chalk.underline.rgb(...blue)(`Running [${targetPlatform}] build task:`)
111
- );
112
- yield runner.buildPlatform({ platform: targetPlatform });
113
- yield selectPlatformBuilder.build(targetPlatform, {
114
- isTsProject: context.isTsProject
115
- });
116
- console.info(chalk.rgb(...gray)(`Done for [${targetPlatform}] task`));
117
- } else if (Array.isArray(options.platform) && options.platform.length > 1) {
118
- for (const platform of options.platform) {
119
- const foundBuilder = platformBuilders.find((builder) => {
87
+ } else if (Array.isArray(options.platform) && options.platform.length === 1) {
88
+ const targetPlatform = options.platform[0];
89
+ const selectPlatformBuilder = platformBuilders.find((builder) => {
120
90
  if (Array.isArray(builder.platform)) {
121
- return builder.platform.includes(platform);
91
+ return builder.platform.includes(targetPlatform);
122
92
  }
123
- return builder.platform === platform;
93
+ return builder.platform === targetPlatform;
124
94
  });
125
- if (!foundBuilder) {
126
- console.info(`skip ${platform} build, because it does not exist`);
127
- continue;
95
+ if (!selectPlatformBuilder) {
96
+ console.info(`The specified "${targetPlatform}" build does not exist`);
97
+ return;
128
98
  }
129
99
  console.info(
130
- chalk.underline.rgb(...blue)(`Running [${platform}] build task:`)
100
+ chalk.underline.rgb(...blue)(`Running [${targetPlatform}] build task:`)
131
101
  );
132
- yield runner.buildPlatform({ platform });
133
- yield foundBuilder.build(platform, { isTsProject: context.isTsProject });
134
- console.info(chalk.rgb(...gray)(`Done for [${platform}] task`));
102
+ yield runner.buildPlatform({ platform: targetPlatform });
103
+ yield selectPlatformBuilder.build(targetPlatform, {
104
+ isTsProject: context.isTsProject
105
+ });
106
+ console.info(chalk.rgb(...gray)(`Done for [${targetPlatform}] task`));
107
+ } else if (Array.isArray(options.platform) && options.platform.length > 1) {
108
+ for (const platform of options.platform) {
109
+ const foundBuilder = platformBuilders.find((builder) => {
110
+ if (Array.isArray(builder.platform)) {
111
+ return builder.platform.includes(platform);
112
+ }
113
+ return builder.platform === platform;
114
+ });
115
+ if (!foundBuilder) {
116
+ console.info(`skip ${platform} build, because it does not exist`);
117
+ continue;
118
+ }
119
+ console.info(
120
+ chalk.underline.rgb(...blue)(`Running [${platform}] build task:`)
121
+ );
122
+ yield runner.buildPlatform({ platform });
123
+ yield foundBuilder.build(platform, {
124
+ isTsProject: context.isTsProject
125
+ });
126
+ console.info(chalk.rgb(...gray)(`Done for [${platform}] task`));
127
+ }
128
+ }
129
+ } catch (e) {
130
+ if (e instanceof Error) {
131
+ errorMsg = e;
132
+ } else {
133
+ errorMsg = String(e);
135
134
  }
136
135
  }
137
- yield runner.afterBuildPlatform();
136
+ yield runner.afterBuildPlatform({
137
+ status: errorMsg === null ? "success" : "fail",
138
+ message: errorMsg
139
+ });
140
+ });
141
+ // Annotate the CommonJS export names for ESM import in node:
142
+ 0 && (module.exports = {
143
+ buildPlatform
138
144
  });
139
145
 
140
146
  //# sourceMappingURL=platform.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,gBAAgB,CAC3B,SACA,KACA,YACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO;AAC/B,QAAM,EAAE,MAAM,KAAK,IAAI,MAAM,6CAAO;AACpC,QAAM,SAAS,IAAI,eAAe;AAClC,QAAM,mBAAmB,MAAM,OAAO,sBAAsB;AAC5D,MAAI,iBAAiB,WAAW,GAAG;AACjC,QAAI,QAAQ,aAAa,MAAM;AAC7B,cAAQ,KAAK,oCAAoC;AAAA,IACnD,WACE,MAAM,QAAQ,QAAQ,QAAQ,KAC9B,QAAQ,SAAS,WAAW,GAC5B;AACA,cAAQ;AAAA,QACN,iCAAiC,QAAQ,SAAS;AAAA,MACpD;AAAA,IACF,WAAW,MAAM,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,SAAS,SAAS,GAAG;AACzE,cAAQ;AAAA,QACN,gCAAgC,QAAQ,SAAS,KAAK,GAAG;AAAA,MAC3D;AAAA,IACF,OAAO;AACL,cAAQ,KAAK,oBAAoB,KAAK,UAAU,QAAQ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AAK,QAAQ,SAAS,SAAS,GAAG;AACzE,eAAW,YAAY,QAAQ,UAAU;AACvC,YAAM,eAAe,iBAAiB,KAAK,aAAW;AACpD,YAAI,MAAM,QAAQ,QAAQ,QAAQ,GAAG;AACnC,iBAAO,QAAQ,SAAS,SAAS,QAAQ;AAAA,QAC3C;AAEA,eAAO,QAAQ,aAAa;AAAA,MAC9B,CAAC;AAED,UAAI,CAAC,cAAc;AACjB,gBAAQ,KAAK,QAAQ,2CAA2C;AAChE;AAAA,MACF;AAEA,cAAQ;AAAA,QACN,MAAM,UAAU,IAAI,GAAG,IAAI,EAAE,YAAY,uBAAuB;AAAA,MAClE;AAEA,YAAM,OAAO,cAAc,EAAE,SAAS,CAAC;AACvC,YAAM,aAAa,MAAM,UAAU,EAAE,aAAa,QAAQ,YAAY,CAAC;AAEvE,cAAQ,KAAK,MAAM,IAAI,GAAG,IAAI,EAAE,aAAa,gBAAgB,CAAC;AAAA,IAChE;AAAA,EACF;AAEA,QAAM,OAAO,mBAAmB;AAClC;","names":[],"sources":["../../src/builder/platform.ts"],"sourcesContent":["import { PluginAPI } from '@modern-js/core';\nimport { ModuleContext } from '../types/context';\nimport { BuildCommandOptions, ModuleTools } from '../types';\n\nexport const buildPlatform = async (\n options: BuildCommandOptions,\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n) => {\n const { chalk } = await import('@modern-js/utils');\n const { blue, gray } = await import('../constants/colors');\n const runner = api.useHookRunners();\n const platformBuilders = await runner.registerBuildPlatform();\n if (platformBuilders.length === 0) {\n if (options.platform === true) {\n console.info('No executable platform build tasks');\n } else if (\n Array.isArray(options.platform) &&\n options.platform.length === 1\n ) {\n console.info(\n `No build tasks with platform \"${options.platform[0]}\" found`,\n );\n } else if (Array.isArray(options.platform) && options.platform.length > 1) {\n console.info(\n `No build tasks with platform ${options.platform.join(',')} found`,\n );\n } else {\n console.info('Unknown platform', JSON.stringify(options.platform));\n }\n\n return;\n }\n\n await runner.beforeBuildPlatform(platformBuilders);\n if (options.platform === true) {\n for (const platformBuilder of platformBuilders) {\n const currentPlatform = Array.isArray(platformBuilder.platform)\n ? platformBuilder.platform[0]\n : platformBuilder.platform;\n\n console.info(\n chalk.underline.rgb(...blue)(\n `Running [${currentPlatform}] build task:`,\n ),\n );\n\n await runner.buildPlatform({ platform: currentPlatform });\n await platformBuilder.build(currentPlatform, {\n isTsProject: context.isTsProject,\n });\n\n console.info(chalk.rgb(...gray)(`Done for [${currentPlatform}] task`));\n }\n } else if (Array.isArray(options.platform) && options.platform.length === 1) {\n const targetPlatform = options.platform[0];\n const selectPlatformBuilder = platformBuilders.find(builder => {\n if (Array.isArray(builder.platform)) {\n return builder.platform.includes(targetPlatform);\n }\n\n return builder.platform === targetPlatform;\n });\n\n if (!selectPlatformBuilder) {\n console.info(`The specified \"${targetPlatform}\" build does not exist`);\n return;\n }\n\n console.info(\n chalk.underline.rgb(...blue)(`Running [${targetPlatform}] build task:`),\n );\n\n await runner.buildPlatform({ platform: targetPlatform });\n await selectPlatformBuilder.build(targetPlatform, {\n isTsProject: context.isTsProject,\n });\n\n console.info(chalk.rgb(...gray)(`Done for [${targetPlatform}] task`));\n } else if (Array.isArray(options.platform) && options.platform.length > 1) {\n for (const platform of options.platform) {\n const foundBuilder = platformBuilders.find(builder => {\n if (Array.isArray(builder.platform)) {\n return builder.platform.includes(platform);\n }\n\n return builder.platform === platform;\n });\n\n if (!foundBuilder) {\n console.info(`skip ${platform} build, because it does not exist`);\n continue;\n }\n\n console.info(\n chalk.underline.rgb(...blue)(`Running [${platform}] build task:`),\n );\n\n await runner.buildPlatform({ platform });\n await foundBuilder.build(platform, { isTsProject: context.isTsProject });\n\n console.info(chalk.rgb(...gray)(`Done for [${platform}] task`));\n }\n }\n\n await runner.afterBuildPlatform();\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,gBAAgB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aAAa,gBAAgB,CAAC;AAAA,MAChE;AAAA,IACF;AAAA,EACF,SAAS,GAAP;AACA,QAAI,aAAa,OAAO;AACtB,iBAAW;AAAA,IACb,OAAO;AACL,iBAAW,OAAO,CAAC;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,OAAO,mBAAmB;AAAA,IAC9B,QAAQ,aAAa,OAAO,YAAY;AAAA,IACxC,SAAS;AAAA,EACX,CAAC;AACH;;;;;","names":[],"sources":["../../src/builder/platform.ts"],"sourcesContent":["import { PluginAPI } from '@modern-js/core';\nimport { ModuleContext } from '../types/context';\nimport { BuildCommandOptions, ModuleTools } from '../types';\n\nexport const buildPlatform = async (\n options: BuildCommandOptions,\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n) => {\n const { chalk } = await import('@modern-js/utils');\n const { blue, gray } = await import('../constants/colors');\n const runner = api.useHookRunners();\n const platformBuilders = await runner.registerBuildPlatform();\n if (platformBuilders.length === 0) {\n if (options.platform === true) {\n console.info('No executable platform build tasks');\n } else if (\n Array.isArray(options.platform) &&\n options.platform.length === 1\n ) {\n console.info(\n `No build tasks with platform \"${options.platform[0]}\" found`,\n );\n } else if (Array.isArray(options.platform) && options.platform.length > 1) {\n console.info(\n `No build tasks with platform ${options.platform.join(',')} found`,\n );\n } else {\n console.info('Unknown platform', JSON.stringify(options.platform));\n }\n\n return;\n }\n\n await runner.beforeBuildPlatform(platformBuilders);\n let errorMsg: string | Error | null = null;\n try {\n if (options.platform === true) {\n for (const platformBuilder of platformBuilders) {\n const currentPlatform = Array.isArray(platformBuilder.platform)\n ? platformBuilder.platform[0]\n : platformBuilder.platform;\n\n console.info(\n chalk.underline.rgb(...blue)(\n `Running [${currentPlatform}] build task:`,\n ),\n );\n\n await runner.buildPlatform({ platform: currentPlatform });\n await platformBuilder.build(currentPlatform, {\n isTsProject: context.isTsProject,\n });\n\n console.info(chalk.rgb(...gray)(`Done for [${currentPlatform}] task`));\n }\n } else if (\n Array.isArray(options.platform) &&\n options.platform.length === 1\n ) {\n const targetPlatform = options.platform[0];\n const selectPlatformBuilder = platformBuilders.find(builder => {\n if (Array.isArray(builder.platform)) {\n return builder.platform.includes(targetPlatform);\n }\n\n return builder.platform === targetPlatform;\n });\n\n if (!selectPlatformBuilder) {\n console.info(`The specified \"${targetPlatform}\" build does not exist`);\n return;\n }\n\n console.info(\n chalk.underline.rgb(...blue)(`Running [${targetPlatform}] build task:`),\n );\n\n await runner.buildPlatform({ platform: targetPlatform });\n await selectPlatformBuilder.build(targetPlatform, {\n isTsProject: context.isTsProject,\n });\n\n console.info(chalk.rgb(...gray)(`Done for [${targetPlatform}] task`));\n } else if (Array.isArray(options.platform) && options.platform.length > 1) {\n for (const platform of options.platform) {\n const foundBuilder = platformBuilders.find(builder => {\n if (Array.isArray(builder.platform)) {\n return builder.platform.includes(platform);\n }\n\n return builder.platform === platform;\n });\n\n if (!foundBuilder) {\n console.info(`skip ${platform} build, because it does not exist`);\n continue;\n }\n\n console.info(\n chalk.underline.rgb(...blue)(`Running [${platform}] build task:`),\n );\n\n await runner.buildPlatform({ platform });\n await foundBuilder.build(platform, {\n isTsProject: context.isTsProject,\n });\n\n console.info(chalk.rgb(...gray)(`Done for [${platform}] task`));\n }\n }\n } catch (e) {\n if (e instanceof Error) {\n errorMsg = e;\n } else {\n errorMsg = String(e);\n }\n }\n\n await runner.afterBuildPlatform({\n status: errorMsg === null ? 'success' : 'fail',\n message: errorMsg,\n });\n};\n"]}
package/dist/cli.js CHANGED
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,32 +16,11 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
20
- cli: () => cli
21
- });
22
- module.exports = __toCommonJS(stdin_exports);
23
- var import_hooks = require("./hooks");
24
- var import_plugins = require("./plugins");
25
- var __create = Object.create;
26
- var __defProp2 = Object.defineProperty;
27
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
28
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
29
- var __getProtoOf = Object.getPrototypeOf;
30
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
31
- var __copyProps2 = (to, from, except, desc) => {
32
- if (from && typeof from === "object" || typeof from === "function") {
33
- for (let key of __getOwnPropNames2(from))
34
- if (!__hasOwnProp2.call(to, key) && key !== except)
35
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
36
- }
37
- return to;
38
- };
39
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps2(
40
- isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
41
21
  mod
42
22
  ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
24
  var __async = (__this, __arguments, generator) => {
44
25
  return new Promise((resolve, reject) => {
45
26
  var fulfilled = (value) => {
@@ -60,6 +41,13 @@ var __async = (__this, __arguments, generator) => {
60
41
  step((generator = generator.apply(__this, __arguments)).next());
61
42
  });
62
43
  };
44
+ var cli_exports = {};
45
+ __export(cli_exports, {
46
+ cli: () => cli
47
+ });
48
+ module.exports = __toCommonJS(cli_exports);
49
+ var import_hooks = require("./hooks");
50
+ var import_plugins = require("./plugins");
63
51
  const cli = () => ({
64
52
  name: "@modern-js/module-tools",
65
53
  registerHook: import_hooks.registerHook,
@@ -99,5 +87,9 @@ const setup = (api) => __async(void 0, null, function* () {
99
87
  }
100
88
  };
101
89
  });
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ cli
93
+ });
102
94
 
103
95
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,mBAA6B;AAC7B,qBAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpB,MAAM,MAAM,OAA+B;AAAA,EAChD,MAAM;AAAA,EACN;AAAA,EACA,gBAAY,2BAAW,QAAQ,KAAK,MAAM,CAAC,EAAE,EAAE;AAAA,EAC/C;AACF;AAEA,MAAM,QAAyC,CAAM,QAAO;AAC1D,QAAM,UAAU,MAAY;AAC1B,UAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,UAAM,kBAAkB;AAExB,UAAM,aAAa,IAAI,cAAc;AACrC,UAAM,EAAE,IAAI,OAAO,IAAI,MAAM,6CAAO;AACpC,WAAO,OAAO;AAEd,UAAM,GAAG,SAAS,WAAW,iBAAiB;AAE9C,UAAM,cAAc,IAAI,eAAe;AACvC,UAAM,YAAY,kBAAkB;AAEpC,UAAM,EAAE,gBAAgB,IAAI,MAAM,6CAAO;AACzC,UAAM,gBAAgB,MAAY;AAChC,YAAM,YAAY,SAAS;AAAA,IAC7B,EAAC;AAAA,EACH;AAEA,QAAM,iBAAiB,MAAY;AACjC,UAAM,EAAE,OAAO,IAAI,MAAM,6CAAO;AAChC,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACM,SAAS,IAAa;AAAA,iDAAb,EAAE,QAAQ,GAAG;AAC1B,cAAM,EAAE,cAAc,YAAY,YAAY,cAAc,IAC1D,MAAM,6CAAO;AACf,cAAM,aAAa,SAAS,GAAG;AAC/B,cAAM,WAAW,SAAS,GAAG;AAC7B,cAAM,WAAW,OAAO;AACxB,cAAM,cAAc,OAAO;AAAA,MAC7B;AAAA;AAAA,EACF;AACF;","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import type { CliPlugin } from '@modern-js/core';\nimport type { ModuleTools } from './types';\nimport { registerHook } from './hooks';\nimport { getPlugins } from './plugins';\n\nexport const cli = (): CliPlugin<ModuleTools> => ({\n name: '@modern-js/module-tools',\n registerHook,\n usePlugins: getPlugins(process.argv.slice(2)[0]),\n setup,\n});\n\nconst setup: CliPlugin<ModuleTools>['setup'] = async api => {\n const prepare = async () => {\n const { initLocalLanguage } = await import('./utils/language');\n await initLocalLanguage();\n\n const appContext = api.useAppContext();\n const { fs, dotenv } = await import('@modern-js/utils');\n dotenv.config();\n // remove '/node_modules/.modern-js'\n await fs.emptydir(appContext.internalDirectory);\n\n const hookRunners = api.useHookRunners();\n await hookRunners.addRuntimeExports();\n\n const { addExitListener } = await import('./utils/onExit');\n await addExitListener(async () => {\n await hookRunners.afterDev();\n });\n };\n\n const validateSchema = async () => {\n const { schema } = await import('./config/schema');\n return schema;\n };\n\n return {\n prepare,\n validateSchema,\n async commands({ program }) {\n const { buildCommand, devCommand, newCommand, upgradCommand } =\n await import('./command');\n await buildCommand(program, api);\n await devCommand(program, api);\n await newCommand(program);\n await upgradCommand(program);\n },\n };\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA6B;AAC7B,qBAA2B;AAEpB,MAAM,MAAM,OAA+B;AAAA,EAChD,MAAM;AAAA,EACN;AAAA,EACA,gBAAY,2BAAW,QAAQ,KAAK,MAAM,CAAC,EAAE,EAAE;AAAA,EAC/C;AACF;AAEA,MAAM,QAAyC,CAAM,QAAO;AAC1D,QAAM,UAAU,MAAY;AAC1B,UAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,UAAM,kBAAkB;AAExB,UAAM,aAAa,IAAI,cAAc;AACrC,UAAM,EAAE,IAAI,OAAO,IAAI,MAAM,6CAAO;AACpC,WAAO,OAAO;AAEd,UAAM,GAAG,SAAS,WAAW,iBAAiB;AAE9C,UAAM,cAAc,IAAI,eAAe;AACvC,UAAM,YAAY,kBAAkB;AAEpC,UAAM,EAAE,gBAAgB,IAAI,MAAM,6CAAO;AACzC,UAAM,gBAAgB,MAAY;AAChC,YAAM,YAAY,SAAS;AAAA,IAC7B,EAAC;AAAA,EACH;AAEA,QAAM,iBAAiB,MAAY;AACjC,UAAM,EAAE,OAAO,IAAI,MAAM,6CAAO;AAChC,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACM,SAAS,IAAa;AAAA,iDAAb,EAAE,QAAQ,GAAG;AAC1B,cAAM,EAAE,cAAc,YAAY,YAAY,cAAc,IAC1D,MAAM,6CAAO;AACf,cAAM,aAAa,SAAS,GAAG;AAC/B,cAAM,WAAW,SAAS,GAAG;AAC7B,cAAM,WAAW,OAAO;AACxB,cAAM,cAAc,OAAO;AAAA,MAC7B;AAAA;AAAA,EACF;AACF;;;;;","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import type { CliPlugin } from '@modern-js/core';\nimport type { ModuleTools } from './types';\nimport { registerHook } from './hooks';\nimport { getPlugins } from './plugins';\n\nexport const cli = (): CliPlugin<ModuleTools> => ({\n name: '@modern-js/module-tools',\n registerHook,\n usePlugins: getPlugins(process.argv.slice(2)[0]),\n setup,\n});\n\nconst setup: CliPlugin<ModuleTools>['setup'] = async api => {\n const prepare = async () => {\n const { initLocalLanguage } = await import('./utils/language');\n await initLocalLanguage();\n\n const appContext = api.useAppContext();\n const { fs, dotenv } = await import('@modern-js/utils');\n dotenv.config();\n // remove '/node_modules/.modern-js'\n await fs.emptydir(appContext.internalDirectory);\n\n const hookRunners = api.useHookRunners();\n await hookRunners.addRuntimeExports();\n\n const { addExitListener } = await import('./utils/onExit');\n await addExitListener(async () => {\n await hookRunners.afterDev();\n });\n };\n\n const validateSchema = async () => {\n const { schema } = await import('./config/schema');\n return schema;\n };\n\n return {\n prepare,\n validateSchema,\n async commands({ program }) {\n const { buildCommand, devCommand, newCommand, upgradCommand } =\n await import('./command');\n await buildCommand(program, api);\n await devCommand(program, api);\n await newCommand(program);\n await upgradCommand(program);\n },\n };\n};\n"]}
package/dist/command.js CHANGED
@@ -1,43 +1,17 @@
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
- var stdin_exports = {};
19
- __export(stdin_exports, {
20
- buildCommand: () => buildCommand,
21
- devCommand: () => devCommand,
22
- newCommand: () => newCommand,
23
- upgradCommand: () => upgradCommand
24
- });
25
- module.exports = __toCommonJS(stdin_exports);
26
- var import_utils = require("@modern-js/utils");
27
1
  var __create = Object.create;
28
- var __defProp2 = Object.defineProperty;
2
+ var __defProp = Object.defineProperty;
29
3
  var __defProps = Object.defineProperties;
30
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
31
5
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
32
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
33
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
34
8
  var __getProtoOf = Object.getPrototypeOf;
35
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
36
10
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
37
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
38
12
  var __spreadValues = (a, b) => {
39
13
  for (var prop in b || (b = {}))
40
- if (__hasOwnProp2.call(b, prop))
14
+ if (__hasOwnProp.call(b, prop))
41
15
  __defNormalProp(a, prop, b[prop]);
42
16
  if (__getOwnPropSymbols)
43
17
  for (var prop of __getOwnPropSymbols(b)) {
@@ -47,18 +21,23 @@ var __spreadValues = (a, b) => {
47
21
  return a;
48
22
  };
49
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
50
- var __copyProps2 = (to, from, except, desc) => {
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
51
29
  if (from && typeof from === "object" || typeof from === "function") {
52
- for (let key of __getOwnPropNames2(from))
53
- if (!__hasOwnProp2.call(to, key) && key !== except)
54
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
55
33
  }
56
34
  return to;
57
35
  };
58
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps2(
59
- isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
60
38
  mod
61
39
  ));
40
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
62
41
  var __async = (__this, __arguments, generator) => {
63
42
  return new Promise((resolve, reject) => {
64
43
  var fulfilled = (value) => {
@@ -79,7 +58,14 @@ var __async = (__this, __arguments, generator) => {
79
58
  step((generator = generator.apply(__this, __arguments)).next());
80
59
  });
81
60
  };
82
- const debug = (0, import_utils.createDebugger)("module-tools");
61
+ var command_exports = {};
62
+ __export(command_exports, {
63
+ buildCommand: () => buildCommand,
64
+ devCommand: () => devCommand,
65
+ newCommand: () => newCommand,
66
+ upgradCommand: () => upgradCommand
67
+ });
68
+ module.exports = __toCommonJS(command_exports);
83
69
  const buildCommand = (program, api) => __async(void 0, null, function* () {
84
70
  const local = yield Promise.resolve().then(() => __toESM(require("./locale")));
85
71
  const { defaultTsConfigPath } = yield Promise.resolve().then(() => __toESM(require("./constants/dts")));
@@ -96,33 +82,21 @@ const buildCommand = (program, api) => __async(void 0, null, function* () {
96
82
  ).action((options) => __async(void 0, null, function* () {
97
83
  const { initModuleContext } = yield Promise.resolve().then(() => __toESM(require("./utils/context")));
98
84
  const context = yield initModuleContext(api);
99
- if (options.platform) {
100
- const { buildPlatform } = yield Promise.resolve().then(() => __toESM(require("./builder/platform")));
101
- yield buildPlatform(options, api, context);
102
- return;
103
- }
104
- const runner = api.useHookRunners();
105
- const { normalizeBuildConfig } = yield Promise.resolve().then(() => __toESM(require("./config/normalize")));
106
- const resolvedBuildConfig = yield normalizeBuildConfig(
107
- api,
108
- context,
109
- options
110
- );
111
- debug("resolvedBuildConfig", resolvedBuildConfig);
112
- yield runner.beforeBuild({ config: resolvedBuildConfig, options });
113
- const builder = yield Promise.resolve().then(() => __toESM(require("./builder")));
114
- yield builder.run(
115
- { cmdOptions: options, resolvedBuildConfig, context },
116
- api
117
- );
85
+ const { build } = yield Promise.resolve().then(() => __toESM(require("./build")));
86
+ yield build(api, options, context);
118
87
  }));
119
88
  });
120
89
  const devCommand = (program, api) => __async(void 0, null, function* () {
121
90
  const local = yield Promise.resolve().then(() => __toESM(require("./locale")));
91
+ const { defaultTsConfigPath } = yield Promise.resolve().then(() => __toESM(require("./constants/dts")));
122
92
  const runner = api.useHookRunners();
123
93
  const devToolMetas = yield runner.registerDev();
124
94
  yield runner.beforeDev(devToolMetas);
125
- const devProgram = program.command("dev").usage("[options]").description(local.i18n.t(local.localeKeys.command.dev.describe)).action((..._0) => __async(void 0, [..._0], function* (options = {}) {
95
+ const devProgram = program.command("dev").usage("[options]").description(local.i18n.t(local.localeKeys.command.dev.describe)).option(
96
+ "--tsconfig [tsconfig]",
97
+ local.i18n.t(local.localeKeys.command.dev.tsconfig),
98
+ defaultTsConfigPath
99
+ ).action((options) => __async(void 0, null, function* () {
126
100
  const { initModuleContext } = yield Promise.resolve().then(() => __toESM(require("./utils/context")));
127
101
  const context = yield initModuleContext(api);
128
102
  const { dev } = yield Promise.resolve().then(() => __toESM(require("./dev")));
@@ -133,9 +107,15 @@ const devCommand = (program, api) => __async(void 0, null, function* () {
133
107
  continue;
134
108
  }
135
109
  for (const subCmd of meta.subCommands) {
136
- devProgram.command(subCmd).action((..._0) => __async(void 0, [..._0], function* (options = {}) {
110
+ devProgram.command(subCmd).action((options) => __async(void 0, null, function* () {
111
+ var _a;
137
112
  const { initModuleContext } = yield Promise.resolve().then(() => __toESM(require("./utils/context")));
138
113
  const context = yield initModuleContext(api);
114
+ const { runBuildBeforeDevTools } = yield Promise.resolve().then(() => __toESM(require("./dev")));
115
+ yield runBuildBeforeDevTools(api, context, options, {
116
+ disableRunBuild: (_a = meta.disableRunBuild) != null ? _a : false,
117
+ appDirectory: context.appDirectory
118
+ });
139
119
  yield runner.beforeDevTask(meta);
140
120
  yield meta.action(options, { isTsProject: context.isTsProject });
141
121
  }));
@@ -165,5 +145,12 @@ const upgradCommand = (program) => __async(void 0, null, function* () {
165
145
  const { defineCommand } = yield Promise.resolve().then(() => __toESM(require("@modern-js/upgrade")));
166
146
  defineCommand(program.command("upgrade"));
167
147
  });
148
+ // Annotate the CommonJS export names for ESM import in node:
149
+ 0 && (module.exports = {
150
+ buildCommand,
151
+ devCommand,
152
+ newCommand,
153
+ upgradCommand
154
+ });
168
155
 
169
156
  //# sourceMappingURL=command.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,mBAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK/B,MAAM,YAAQ,6BAAe,cAAc;AAEpC,MAAM,eAAe,CAC1B,SACA,QACG;AACH,QAAM,QAAQ,MAAM,6CAAO;AAC3B,QAAM,EAAE,oBAAoB,IAAI,MAAM,6CAAO;AAE7C,UACG,QAAQ,OAAO,EACf,MAAM,WAAW,EACjB,YAAY,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,QAAQ,CAAC,EACjE,OAAO,eAAe,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,KAAK,CAAC,EACxE;AAAA,IACC;AAAA,IACA,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,QAAQ;AAAA,IACpD;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,QAAQ;AAAA,EACtD,EACC,OAAO,YAAY,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,GAAG,CAAC,EACnE,OAAO,cAAc,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,QAAQ,CAAC,EAC1E;AAAA,IACC;AAAA,IACA,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,MAAM;AAA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/utils';\nimport { createDebugger } from '@modern-js/utils';\nimport type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from './types';\nimport type { DevCommandOptions, BuildCommandOptions } from './types/command';\n\nconst debug = createDebugger('module-tools');\n\nexport const buildCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const { defaultTsConfigPath } = await import('./constants/dts');\n\n program\n .command('build')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.build.describe))\n .option('-w, --watch', local.i18n.t(local.localeKeys.command.build.watch))\n .option(\n '--tsconfig [tsconfig]',\n local.i18n.t(local.localeKeys.command.build.tsconfig),\n defaultTsConfigPath,\n )\n .option(\n '-p, --platform [platform...]',\n local.i18n.t(local.localeKeys.command.build.platform),\n )\n .option('--no-dts', local.i18n.t(local.localeKeys.command.build.dts))\n .option('--no-clear', local.i18n.t(local.localeKeys.command.build.no_clear))\n .option(\n '-c --config <config>',\n local.i18n.t(local.localeKeys.command.build.config),\n )\n .action(async (options: BuildCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n if (options.platform) {\n const { buildPlatform } = await import('./builder/platform');\n await buildPlatform(options, api, context);\n return;\n }\n\n const runner = api.useHookRunners();\n\n const { normalizeBuildConfig } = await import('./config/normalize');\n const resolvedBuildConfig = await normalizeBuildConfig(\n api,\n context,\n options,\n );\n\n debug('resolvedBuildConfig', resolvedBuildConfig);\n\n await runner.beforeBuild({ config: resolvedBuildConfig, options });\n const builder = await import('./builder');\n await builder.run(\n { cmdOptions: options, resolvedBuildConfig, context },\n api,\n );\n });\n};\n\nexport const devCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const runner = api.useHookRunners();\n const devToolMetas = await runner.registerDev();\n\n await runner.beforeDev(devToolMetas);\n\n const devProgram = program\n .command('dev')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.dev.describe))\n .action(async (options: DevCommandOptions = {}) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { dev } = await import('./dev');\n await dev(options, devToolMetas, api, context);\n });\n\n for (const meta of devToolMetas) {\n if (!meta.subCommands) {\n continue;\n }\n\n for (const subCmd of meta.subCommands) {\n devProgram\n .command(subCmd)\n .action(async (options: DevCommandOptions = {}) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n await runner.beforeDevTask(meta);\n await meta.action(options, { isTsProject: context.isTsProject });\n });\n }\n }\n};\n\nexport const newCommand = async (program: Command) => {\n const local = await import('./locale');\n\n program\n .command('new')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.new.describe))\n .option(\n '-d, --debug',\n local.i18n.t(local.localeKeys.command.new.debug),\n false,\n )\n .option(\n '-c, --config <config>',\n local.i18n.t(local.localeKeys.command.new.config),\n )\n .option(\n '--dist-tag <tag>',\n local.i18n.t(local.localeKeys.command.new.distTag),\n )\n .option('--registry', local.i18n.t(local.localeKeys.command.new.registry))\n .action(async options => {\n const { ModuleNewAction } = await import('@modern-js/new-action');\n const { getLocaleLanguage } = await import('./utils/language');\n const locale = getLocaleLanguage();\n\n await ModuleNewAction({ ...options, locale });\n });\n};\n\nexport const upgradCommand = async (program: Command) => {\n const { defineCommand } = await import('@modern-js/upgrade');\n defineCommand(program.command('upgrade'));\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,MAAM,eAAe,CAC1B,SACA,QACG;AACH,QAAM,QAAQ,MAAM,6CAAO;AAC3B,QAAM,EAAE,oBAAoB,IAAI,MAAM,6CAAO;AAE7C,UACG,QAAQ,OAAO,EACf,MAAM,WAAW,EACjB,YAAY,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,QAAQ,CAAC,EACjE,OAAO,eAAe,MAAM,KAA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AAE,gBAAgB,IAAI,MAAM,6CAAO;AACzC,UAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,UAAM,SAAS,kBAAkB;AAEjC,UAAM,gBAAgB,iCAAK,UAAL,EAAc,OAAO,EAAC;AAAA,EAC9C,EAAC;AACL;AAEO,MAAM,gBAAgB,CAAO,YAAqB;AACvD,QAAM,EAAE,cAAc,IAAI,MAAM,6CAAO;AACvC,gBAAc,QAAQ,QAAQ,SAAS,CAAC;AAC1C;;;;;;;;","names":[],"sources":["../src/command.ts"],"sourcesContent":["import type { Command } from '@modern-js/utils';\nimport type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from './types';\nimport type { DevCommandOptions, BuildCommandOptions } from './types/command';\n\nexport const buildCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const { defaultTsConfigPath } = await import('./constants/dts');\n\n program\n .command('build')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.build.describe))\n .option('-w, --watch', local.i18n.t(local.localeKeys.command.build.watch))\n .option(\n '--tsconfig [tsconfig]',\n local.i18n.t(local.localeKeys.command.build.tsconfig),\n defaultTsConfigPath,\n )\n .option(\n '-p, --platform [platform...]',\n local.i18n.t(local.localeKeys.command.build.platform),\n )\n .option('--no-dts', local.i18n.t(local.localeKeys.command.build.dts))\n .option('--no-clear', local.i18n.t(local.localeKeys.command.build.no_clear))\n .option(\n '-c --config <config>',\n local.i18n.t(local.localeKeys.command.build.config),\n )\n .action(async (options: BuildCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { build } = await import('./build');\n await build(api, options, context);\n });\n};\n\nexport const devCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const { defaultTsConfigPath } = await import('./constants/dts');\n const runner = api.useHookRunners();\n const devToolMetas = await runner.registerDev();\n\n await runner.beforeDev(devToolMetas);\n\n const devProgram = program\n .command('dev')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.dev.describe))\n .option(\n '--tsconfig [tsconfig]',\n local.i18n.t(local.localeKeys.command.dev.tsconfig),\n defaultTsConfigPath,\n )\n .action(async (options: DevCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { dev } = await import('./dev');\n await dev(options, devToolMetas, api, context);\n });\n\n for (const meta of devToolMetas) {\n if (!meta.subCommands) {\n continue;\n }\n\n for (const subCmd of meta.subCommands) {\n devProgram.command(subCmd).action(async (options: DevCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { runBuildBeforeDevTools } = await import('./dev');\n\n await runBuildBeforeDevTools(api, context, options, {\n disableRunBuild: meta.disableRunBuild ?? false,\n appDirectory: context.appDirectory,\n });\n\n await runner.beforeDevTask(meta);\n await meta.action(options, { isTsProject: context.isTsProject });\n });\n }\n }\n};\n\nexport const newCommand = async (program: Command) => {\n const local = await import('./locale');\n\n program\n .command('new')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.new.describe))\n .option(\n '-d, --debug',\n local.i18n.t(local.localeKeys.command.new.debug),\n false,\n )\n .option(\n '-c, --config <config>',\n local.i18n.t(local.localeKeys.command.new.config),\n )\n .option(\n '--dist-tag <tag>',\n local.i18n.t(local.localeKeys.command.new.distTag),\n )\n .option('--registry', local.i18n.t(local.localeKeys.command.new.registry))\n .action(async options => {\n const { ModuleNewAction } = await import('@modern-js/new-action');\n const { getLocaleLanguage } = await import('./utils/language');\n const locale = getLocaleLanguage();\n\n await ModuleNewAction({ ...options, locale });\n });\n};\n\nexport const upgradCommand = async (program: Command) => {\n const { defineCommand } = await import('@modern-js/upgrade');\n defineCommand(program.command('upgrade'));\n};\n"]}
@@ -15,11 +15,15 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
18
+ var defineConfig_exports = {};
19
+ __export(defineConfig_exports, {
20
20
  defineConfig: () => defineConfig
21
21
  });
22
- module.exports = __toCommonJS(stdin_exports);
22
+ module.exports = __toCommonJS(defineConfig_exports);
23
23
  const defineConfig = (config) => config;
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ defineConfig
27
+ });
24
28
 
25
29
  //# sourceMappingURL=defineConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;;;;;AAEO;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,eAAe,CAAC,WAC3B;","names":[],"sources":["../../src/config/defineConfig.ts"],"sourcesContent":["import type { ModuleConfigParams } from '../types';\n\nexport const defineConfig = (config: ModuleConfigParams): ModuleConfigParams =>\n config;\n"]}
1
+ {"version":3,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,eAAe,CAAC,WAC3B;","names":[],"sources":["../../src/config/defineConfig.ts"],"sourcesContent":["import type { ModuleConfigParams } from '../types';\n\nexport const defineConfig = (config: ModuleConfigParams): ModuleConfigParams =>\n config;\n"]}