@modern-js/module-tools 2.35.1 → 2.37.0

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 (223) hide show
  1. package/dist/build.js +43 -16
  2. package/dist/builder/build.d.ts +0 -10
  3. package/dist/builder/build.js +96 -208
  4. package/dist/builder/clear.d.ts +1 -4
  5. package/dist/builder/clear.js +32 -28
  6. package/dist/builder/copy.js +75 -60
  7. package/dist/builder/dts/index.js +27 -19
  8. package/dist/builder/dts/rollup.d.ts +6 -14
  9. package/dist/builder/dts/rollup.js +60 -37
  10. package/dist/builder/dts/tsc.d.ts +3 -2
  11. package/dist/builder/dts/tsc.js +50 -37
  12. package/dist/builder/esbuild/adapter.d.ts +3 -0
  13. package/dist/builder/esbuild/adapter.js +286 -0
  14. package/dist/builder/esbuild/hook.d.ts +4 -0
  15. package/dist/builder/esbuild/hook.js +103 -0
  16. package/dist/builder/esbuild/index.d.ts +35 -0
  17. package/dist/builder/esbuild/index.js +268 -0
  18. package/dist/builder/esbuild/resolve.d.ts +18 -0
  19. package/dist/builder/esbuild/resolve.js +140 -0
  20. package/dist/builder/esbuild/sourcemap.d.ts +16 -0
  21. package/dist/builder/esbuild/sourcemap.js +86 -0
  22. package/dist/builder/esbuild/transform.d.ts +7 -0
  23. package/dist/builder/esbuild/transform.js +45 -0
  24. package/dist/builder/esbuild/watch.d.ts +2 -0
  25. package/dist/builder/esbuild/watch.js +115 -0
  26. package/dist/builder/esbuild/write-file.d.ts +2 -0
  27. package/dist/builder/esbuild/write-file.js +89 -0
  28. package/dist/builder/feature/asset.d.ts +19 -0
  29. package/dist/builder/feature/asset.js +149 -0
  30. package/dist/builder/feature/format-cjs.d.ts +5 -0
  31. package/dist/builder/feature/format-cjs.js +53 -0
  32. package/dist/builder/feature/index.d.ts +2 -0
  33. package/dist/builder/feature/index.js +74 -0
  34. package/dist/builder/feature/json.d.ts +5 -0
  35. package/dist/builder/feature/json.js +47 -0
  36. package/dist/builder/feature/redirect.d.ts +5 -0
  37. package/dist/builder/feature/redirect.js +223 -0
  38. package/dist/builder/feature/style/index.d.ts +5 -0
  39. package/dist/builder/feature/style/index.js +94 -0
  40. package/dist/builder/feature/style/lessAliasPlugin.d.ts +12 -0
  41. package/dist/builder/feature/style/lessAliasPlugin.js +70 -0
  42. package/dist/builder/feature/style/lessRender.d.ts +2 -0
  43. package/dist/builder/feature/style/lessRender.js +64 -0
  44. package/dist/builder/feature/style/postcssTransformer.d.ts +6 -0
  45. package/dist/builder/feature/style/postcssTransformer.js +95 -0
  46. package/dist/builder/feature/style/postcssUrlPlugin.d.ts +6 -0
  47. package/dist/builder/feature/style/postcssUrlPlugin.js +58 -0
  48. package/dist/builder/feature/style/sassRender.d.ts +2 -0
  49. package/dist/builder/feature/style/sassRender.js +85 -0
  50. package/dist/builder/feature/style/transformStyle.d.ts +13 -0
  51. package/dist/builder/feature/style/transformStyle.js +101 -0
  52. package/dist/builder/feature/style/utils.d.ts +18 -0
  53. package/dist/builder/feature/style/utils.js +130 -0
  54. package/dist/builder/feature/swc.d.ts +9 -0
  55. package/dist/builder/feature/swc.js +170 -0
  56. package/dist/builder/feature/terser.d.ts +5 -0
  57. package/dist/builder/feature/terser.js +83 -0
  58. package/dist/builder/index.js +59 -28
  59. package/dist/builder/platform.js +38 -23
  60. package/dist/cli.js +58 -29
  61. package/dist/command.js +62 -38
  62. package/dist/config/defineConfig.js +25 -17
  63. package/dist/config/legacySchema.js +35 -32
  64. package/dist/config/merge.js +69 -36
  65. package/dist/config/normalize.js +63 -46
  66. package/dist/config/schema.d.ts +48 -0
  67. package/dist/config/schema.js +53 -34
  68. package/dist/config/transformLegacyConfig.js +67 -61
  69. package/dist/config/valid.d.ts +2 -2
  70. package/dist/config/valid.js +44 -21
  71. package/dist/constants/build.d.ts +5 -1
  72. package/dist/constants/build.js +88 -46
  73. package/dist/constants/color.js +27 -20
  74. package/dist/constants/dts.js +27 -20
  75. package/dist/constants/file.d.ts +2 -2
  76. package/dist/constants/file.js +48 -25
  77. package/dist/constants/legacy-preset.js +45 -32
  78. package/dist/constants/loader.d.ts +2 -0
  79. package/dist/constants/loader.js +53 -0
  80. package/dist/constants/log.d.ts +0 -8
  81. package/dist/constants/log.js +27 -41
  82. package/dist/constants/preset.d.ts +4 -4
  83. package/dist/constants/preset.js +55 -62
  84. package/dist/debug.d.ts +4 -0
  85. package/dist/debug.js +37 -0
  86. package/dist/dev.js +42 -25
  87. package/dist/error.js +49 -42
  88. package/dist/hooks/build.d.ts +1 -2
  89. package/dist/hooks/build.js +36 -28
  90. package/dist/hooks/dev.js +32 -17
  91. package/dist/hooks/index.d.ts +1 -1
  92. package/dist/hooks/index.js +31 -16
  93. package/dist/hooks/misc.d.ts +5 -2
  94. package/dist/hooks/misc.js +31 -12
  95. package/dist/index.d.ts +2 -1
  96. package/dist/index.js +39 -32
  97. package/dist/locale/en.js +32 -17
  98. package/dist/locale/index.d.ts +2 -1
  99. package/dist/locale/index.js +31 -24
  100. package/dist/locale/zh.js +32 -17
  101. package/dist/plugins.js +28 -13
  102. package/dist/types/color.js +15 -5
  103. package/dist/types/command.d.ts +3 -3
  104. package/dist/types/command.js +15 -5
  105. package/dist/types/config/copy.js +15 -5
  106. package/dist/types/config/dev.js +15 -5
  107. package/dist/types/config/index.d.ts +87 -52
  108. package/dist/types/config/index.js +24 -6
  109. package/dist/types/config/style.d.ts +58 -6
  110. package/dist/types/config/style.js +15 -5
  111. package/dist/types/context.js +15 -5
  112. package/dist/types/dts.d.ts +14 -3
  113. package/dist/types/dts.js +15 -5
  114. package/dist/types/esbuild.d.ts +107 -0
  115. package/dist/types/esbuild.js +32 -0
  116. package/dist/types/hooks.js +15 -5
  117. package/dist/types/index.d.ts +1 -0
  118. package/dist/types/index.js +32 -11
  119. package/dist/types/legacyConfig/index.js +15 -5
  120. package/dist/types/legacyConfig/output.d.ts +4 -4
  121. package/dist/types/legacyConfig/output.js +15 -5
  122. package/dist/types/legacyConfig/source.js +15 -5
  123. package/dist/types/legacyConfig/tools.js +15 -5
  124. package/dist/utils/assert.d.ts +5 -0
  125. package/dist/utils/assert.js +50 -0
  126. package/dist/utils/builder.d.ts +10 -14
  127. package/dist/utils/builder.js +59 -59
  128. package/dist/utils/common.d.ts +1 -1
  129. package/dist/utils/common.js +25 -17
  130. package/dist/utils/dts.d.ts +26 -9
  131. package/dist/utils/dts.js +98 -64
  132. package/dist/utils/hash.d.ts +2 -0
  133. package/dist/utils/hash.js +31 -0
  134. package/dist/utils/index.d.ts +11 -0
  135. package/dist/utils/index.js +42 -0
  136. package/dist/utils/input.js +47 -24
  137. package/dist/utils/log.d.ts +1 -2
  138. package/dist/utils/log.js +36 -20
  139. package/dist/utils/map.d.ts +13 -0
  140. package/dist/utils/map.js +58 -0
  141. package/dist/utils/onExit.js +35 -11
  142. package/dist/utils/print.d.ts +2 -2
  143. package/dist/utils/print.js +52 -49
  144. package/dist/utils/style.d.ts +5 -23
  145. package/dist/utils/style.js +57 -37
  146. package/dist/utils/tspath.js +114 -0
  147. package/package.json +61 -50
  148. package/vitest.config.ts +20 -0
  149. package/dist/build.js.map +0 -1
  150. package/dist/builder/build.js.map +0 -1
  151. package/dist/builder/clear.js.map +0 -1
  152. package/dist/builder/copy.js.map +0 -1
  153. package/dist/builder/dts/index.js.map +0 -1
  154. package/dist/builder/dts/rollup.js.map +0 -1
  155. package/dist/builder/dts/tsc.js.map +0 -1
  156. package/dist/builder/index.js.map +0 -1
  157. package/dist/builder/platform.js.map +0 -1
  158. package/dist/cli.js.map +0 -1
  159. package/dist/command.js.map +0 -1
  160. package/dist/config/defineConfig.js.map +0 -1
  161. package/dist/config/legacySchema.js.map +0 -1
  162. package/dist/config/merge.js.map +0 -1
  163. package/dist/config/normalize.js.map +0 -1
  164. package/dist/config/schema.js.map +0 -1
  165. package/dist/config/transformLegacyConfig.js.map +0 -1
  166. package/dist/config/valid.js.map +0 -1
  167. package/dist/constants/build.js.map +0 -1
  168. package/dist/constants/color.js.map +0 -1
  169. package/dist/constants/dts.js.map +0 -1
  170. package/dist/constants/file.js.map +0 -1
  171. package/dist/constants/legacy-preset.js.map +0 -1
  172. package/dist/constants/log.js.map +0 -1
  173. package/dist/constants/preset.js.map +0 -1
  174. package/dist/dev.js.map +0 -1
  175. package/dist/error.js.map +0 -1
  176. package/dist/hooks/build.js.map +0 -1
  177. package/dist/hooks/dev.js.map +0 -1
  178. package/dist/hooks/index.js.map +0 -1
  179. package/dist/hooks/misc.js.map +0 -1
  180. package/dist/index.js.map +0 -1
  181. package/dist/locale/en.js.map +0 -1
  182. package/dist/locale/index.js.map +0 -1
  183. package/dist/locale/zh.js.map +0 -1
  184. package/dist/plugins.js.map +0 -1
  185. package/dist/types/color.js.map +0 -1
  186. package/dist/types/command.js.map +0 -1
  187. package/dist/types/config/copy.js.map +0 -1
  188. package/dist/types/config/dev.js.map +0 -1
  189. package/dist/types/config/index.js.map +0 -1
  190. package/dist/types/config/style.js.map +0 -1
  191. package/dist/types/context.js.map +0 -1
  192. package/dist/types/dts.js.map +0 -1
  193. package/dist/types/hooks.js.map +0 -1
  194. package/dist/types/index.js.map +0 -1
  195. package/dist/types/legacyConfig/index.js.map +0 -1
  196. package/dist/types/legacyConfig/output.js.map +0 -1
  197. package/dist/types/legacyConfig/source.js.map +0 -1
  198. package/dist/types/legacyConfig/tools.js.map +0 -1
  199. package/dist/types/utils.d.ts +0 -5
  200. package/dist/types/utils.js +0 -4
  201. package/dist/utils/builder.js.map +0 -1
  202. package/dist/utils/common.js.map +0 -1
  203. package/dist/utils/context.d.ts +0 -7
  204. package/dist/utils/context.js +0 -23
  205. package/dist/utils/context.js.map +0 -1
  206. package/dist/utils/dts.js.map +0 -1
  207. package/dist/utils/input.js.map +0 -1
  208. package/dist/utils/language.d.ts +0 -1
  209. package/dist/utils/language.js +0 -22
  210. package/dist/utils/language.js.map +0 -1
  211. package/dist/utils/libuild-plugin.d.ts +0 -3
  212. package/dist/utils/libuild-plugin.js +0 -31
  213. package/dist/utils/libuild-plugin.js.map +0 -1
  214. package/dist/utils/log.js.map +0 -1
  215. package/dist/utils/onExit.js.map +0 -1
  216. package/dist/utils/path.d.ts +0 -1
  217. package/dist/utils/path.js +0 -19
  218. package/dist/utils/path.js.map +0 -1
  219. package/dist/utils/print.js.map +0 -1
  220. package/dist/utils/style.js.map +0 -1
  221. package/dist/utils/tspathsTransform.js +0 -91
  222. package/dist/utils/tspathsTransform.js.map +0 -1
  223. /package/dist/utils/{tspathsTransform.d.ts → tspath.d.ts} +0 -0
@@ -1,50 +1,48 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- transformToolsToBuildConfig: function() {
14
- return transformToolsToBuildConfig;
15
- },
16
- transformSourceToBuildConfig: function() {
17
- return transformSourceToBuildConfig;
18
- },
19
- transformOutputToBuildConfig: function() {
20
- return transformOutputToBuildConfig;
21
- },
22
- commonTransformAndLog: function() {
23
- return commonTransformAndLog;
24
- },
25
- createConfigByBuildConfig: function() {
26
- return createConfigByBuildConfig;
27
- },
28
- createConfigByBuildPreset: function() {
29
- return createConfigByBuildPreset;
30
- },
31
- createConfigByPackageFields: function() {
32
- return createConfigByPackageFields;
33
- },
34
- createConfigByPackageMode: function() {
35
- return createConfigByPackageMode;
36
- },
37
- createConfigByDefault: function() {
38
- return createConfigByDefault;
39
- },
40
- createUserConfigFromLegacy: function() {
41
- return createUserConfigFromLegacy;
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
42
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var transformLegacyConfig_exports = {};
30
+ __export(transformLegacyConfig_exports, {
31
+ commonTransformAndLog: () => commonTransformAndLog,
32
+ createConfigByBuildConfig: () => createConfigByBuildConfig,
33
+ createConfigByBuildPreset: () => createConfigByBuildPreset,
34
+ createConfigByDefault: () => createConfigByDefault,
35
+ createConfigByPackageFields: () => createConfigByPackageFields,
36
+ createConfigByPackageMode: () => createConfigByPackageMode,
37
+ createUserConfigFromLegacy: () => createUserConfigFromLegacy,
38
+ transformOutputToBuildConfig: () => transformOutputToBuildConfig,
39
+ transformSourceToBuildConfig: () => transformSourceToBuildConfig,
40
+ transformToolsToBuildConfig: () => transformToolsToBuildConfig
43
41
  });
44
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
45
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
46
- const _utils = require("@modern-js/utils");
47
- const _legacypreset = require("../constants/legacy-preset");
42
+ module.exports = __toCommonJS(transformLegacyConfig_exports);
43
+ var import_path = __toESM(require("path"));
44
+ var import_utils = require("@modern-js/utils");
45
+ var import_legacy_preset = require("../constants/legacy-preset");
48
46
  const transformToolsToBuildConfig = (buildConfig, legacyUserConfig) => {
49
47
  if (!legacyUserConfig.tools) {
50
48
  return;
@@ -109,10 +107,10 @@ const commonTransformAndLog = async (legacyUserConfig) => {
109
107
  if (legacyUserConfig.tools) {
110
108
  const legacyTools = legacyUserConfig.tools;
111
109
  if (legacyTools.babel) {
112
- _utils.logger.warn("`tools.babel` is not support in legacy mode. Please check migrate documentation.");
110
+ import_utils.logger.warn("`tools.babel` is not support in legacy mode. Please check migrate documentation.");
113
111
  }
114
112
  if (legacyTools.lodash) {
115
- _utils.logger.warn("`tools.lodash` is not support in legacy mode. Please check migrate documentation.");
113
+ import_utils.logger.warn("`tools.lodash` is not support in legacy mode. Please check migrate documentation.");
116
114
  }
117
115
  if (legacyTools.jest) {
118
116
  finalConfig.testing = {
@@ -121,10 +119,10 @@ const commonTransformAndLog = async (legacyUserConfig) => {
121
119
  }
122
120
  }
123
121
  if ((_legacyUserConfig_output = legacyUserConfig.output) === null || _legacyUserConfig_output === void 0 ? void 0 : _legacyUserConfig_output.importStyle) {
124
- _utils.logger.warn("`output.importStyle` is not support in legacy mode. Please check migrate documentation. By default, the style will be compiled");
122
+ import_utils.logger.warn("`output.importStyle` is not support in legacy mode. Please check migrate documentation. By default, the style will be compiled");
125
123
  }
126
124
  if ((_legacyUserConfig_output1 = legacyUserConfig.output) === null || _legacyUserConfig_output1 === void 0 ? void 0 : _legacyUserConfig_output1.jsPath) {
127
- _utils.logger.warn("`output.jsPath` is not support in legacy mode.");
125
+ import_utils.logger.warn("`output.jsPath` is not support in legacy mode.");
128
126
  }
129
127
  return finalConfig;
130
128
  };
@@ -138,7 +136,7 @@ const createConfigByBuildConfig = async (legacyUserConfig) => {
138
136
  var _legacyUserConfig_output_path;
139
137
  const legacyPath = (_legacyUserConfig_output_path = (_legacyUserConfig_output2 = legacyUserConfig.output) === null || _legacyUserConfig_output2 === void 0 ? void 0 : _legacyUserConfig_output2.path) !== null && _legacyUserConfig_output_path !== void 0 ? _legacyUserConfig_output_path : "dist";
140
138
  var _config_outputPath;
141
- newConfig.outDir = _path.default.join(legacyPath, (_config_outputPath = config.outputPath) !== null && _config_outputPath !== void 0 ? _config_outputPath : "./");
139
+ newConfig.outDir = import_path.default.join(legacyPath, (_config_outputPath = config.outputPath) !== null && _config_outputPath !== void 0 ? _config_outputPath : "./");
142
140
  newConfig.asset = {
143
141
  path: (_legacyUserConfig_output1 = legacyUserConfig.output) === null || _legacyUserConfig_output1 === void 0 ? void 0 : _legacyUserConfig_output1.assetsPath
144
142
  };
@@ -159,10 +157,7 @@ const createConfigByBuildConfig = async (legacyUserConfig) => {
159
157
  };
160
158
  }
161
159
  if (config.tsconfig) {
162
- newConfig.dts = {
163
- ...typeof newConfig.dts === "object" ? newConfig.dts : {},
164
- tsconfigPath: config.tsconfig
165
- };
160
+ newConfig.tsconfig = config.tsconfig;
166
161
  }
167
162
  if (!config.enableDts) {
168
163
  newConfig.dts = false;
@@ -189,7 +184,7 @@ const createConfigByBuildConfig = async (legacyUserConfig) => {
189
184
  var _bundlelessOptions_sourceDir;
190
185
  newConfig.sourceDir = (_bundlelessOptions_sourceDir = bundlelessOptions.sourceDir) !== null && _bundlelessOptions_sourceDir !== void 0 ? _bundlelessOptions_sourceDir : "./src";
191
186
  if (bundlelessOptions.style) {
192
- _utils.logger.warn("bundlelessOptions.style is not support in legacy mode. Please check migrate documentation. By default, the style will be compiled.");
187
+ import_utils.logger.warn("bundlelessOptions.style is not support in legacy mode. Please check migrate documentation. By default, the style will be compiled.");
193
188
  }
194
189
  if ((_bundlelessOptions_static = bundlelessOptions.static) === null || _bundlelessOptions_static === void 0 ? void 0 : _bundlelessOptions_static.path) {
195
190
  var _bundlelessOptions_static1;
@@ -199,10 +194,10 @@ const createConfigByBuildConfig = async (legacyUserConfig) => {
199
194
  }
200
195
  }
201
196
  if ((_legacyUserConfig_output4 = legacyUserConfig.output) === null || _legacyUserConfig_output4 === void 0 ? void 0 : _legacyUserConfig_output4.importStyle) {
202
- _utils.logger.warn("`output.importStyle` is not support in legacy mode. Please check migrate documentation. By default, the style will be compiled");
197
+ import_utils.logger.warn("`output.importStyle` is not support in legacy mode. Please check migrate documentation. By default, the style will be compiled");
203
198
  }
204
199
  if ((_legacyUserConfig_output5 = legacyUserConfig.output) === null || _legacyUserConfig_output5 === void 0 ? void 0 : _legacyUserConfig_output5.jsPath) {
205
- _utils.logger.warn("`output.jsPath` is not support in legacy mode.");
200
+ import_utils.logger.warn("`output.jsPath` is not support in legacy mode.");
206
201
  }
207
202
  if (legacyUserConfig.tools) {
208
203
  transformToolsToBuildConfig(newConfig, legacyUserConfig);
@@ -228,10 +223,10 @@ const createConfigByBuildConfig = async (legacyUserConfig) => {
228
223
  if (legacyUserConfig.tools) {
229
224
  const legacyTools = legacyUserConfig.tools;
230
225
  if (legacyTools.babel) {
231
- _utils.logger.warn("`tools.babel` is not support in legacy mode. Please check migrate documentation.");
226
+ import_utils.logger.warn("`tools.babel` is not support in legacy mode. Please check migrate documentation.");
232
227
  }
233
228
  if (legacyTools.lodash) {
234
- _utils.logger.warn("`tools.lodash` is not support in legacy mode. Please check migrate documentation.");
229
+ import_utils.logger.warn("`tools.lodash` is not support in legacy mode. Please check migrate documentation.");
235
230
  }
236
231
  if (legacyTools.jest) {
237
232
  finalConfig.testing = {
@@ -334,7 +329,7 @@ const createConfigByPackageMode = async (legacyUserConfig) => {
334
329
  var _legacyUserConfig_output;
335
330
  const finalConfig = await commonTransformAndLog(legacyUserConfig);
336
331
  const packageMode = legacyUserConfig.output.packageMode;
337
- const buildConfigs = _legacypreset.legacyPresets[packageMode];
332
+ const buildConfigs = import_legacy_preset.legacyPresets[packageMode];
338
333
  for (const buildConfig of buildConfigs) {
339
334
  transformSourceToBuildConfig(buildConfig, legacyUserConfig);
340
335
  transformToolsToBuildConfig(buildConfig, legacyUserConfig);
@@ -355,7 +350,7 @@ const createConfigByPackageMode = async (legacyUserConfig) => {
355
350
  const createConfigByDefault = async (legacyUserConfig) => {
356
351
  var _legacyUserConfig_output;
357
352
  const finalConfig = await commonTransformAndLog(legacyUserConfig);
358
- const buildConfigs = _legacypreset.legacyPresets["universal-js"];
353
+ const buildConfigs = import_legacy_preset.legacyPresets["universal-js"];
359
354
  for (const buildConfig of buildConfigs) {
360
355
  transformSourceToBuildConfig(buildConfig, legacyUserConfig);
361
356
  transformToolsToBuildConfig(buildConfig, legacyUserConfig);
@@ -390,5 +385,16 @@ const createUserConfigFromLegacy = async (config) => {
390
385
  }
391
386
  return createConfigByDefault(config);
392
387
  };
393
-
394
- //# sourceMappingURL=transformLegacyConfig.js.map
388
+ // Annotate the CommonJS export names for ESM import in node:
389
+ 0 && (module.exports = {
390
+ commonTransformAndLog,
391
+ createConfigByBuildConfig,
392
+ createConfigByBuildPreset,
393
+ createConfigByDefault,
394
+ createConfigByPackageFields,
395
+ createConfigByPackageMode,
396
+ createUserConfigFromLegacy,
397
+ transformOutputToBuildConfig,
398
+ transformSourceToBuildConfig,
399
+ transformToolsToBuildConfig
400
+ });
@@ -1,3 +1,3 @@
1
1
  import type { PartialBuildConfig, PartialBaseBuildConfig } from '../types';
2
- export declare const validPartialBuildConfig: (config: PartialBuildConfig) => void;
3
- export declare const validBuildTypeAndFormat: (config: PartialBaseBuildConfig) => void;
2
+ export declare const validPartialBuildConfig: (config: PartialBuildConfig, appDirectory: string) => void;
3
+ export declare const validBuildConfig: (config: PartialBaseBuildConfig, appDirectory: string) => void;
@@ -1,32 +1,49 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- validPartialBuildConfig: function() {
14
- return validPartialBuildConfig;
15
- },
16
- validBuildTypeAndFormat: function() {
17
- return validBuildTypeAndFormat;
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var valid_exports = {};
30
+ __export(valid_exports, {
31
+ validBuildConfig: () => validBuildConfig,
32
+ validPartialBuildConfig: () => validPartialBuildConfig
19
33
  });
20
- const validPartialBuildConfig = (config) => {
34
+ module.exports = __toCommonJS(valid_exports);
35
+ var import_path = __toESM(require("path"));
36
+ var import_utils = require("@modern-js/utils");
37
+ const validPartialBuildConfig = (config, appDirectory) => {
21
38
  if (Array.isArray(config)) {
22
39
  for (const c of config) {
23
- validBuildTypeAndFormat(c);
40
+ validBuildConfig(c, appDirectory);
24
41
  }
25
42
  } else {
26
- validBuildTypeAndFormat(config);
43
+ validBuildConfig(config, appDirectory);
27
44
  }
28
45
  };
29
- const validBuildTypeAndFormat = (config) => {
46
+ const validBuildConfig = (config, appDirectory) => {
30
47
  var _config_format;
31
48
  if (config.buildType === "bundleless" && [
32
49
  "iife",
@@ -34,6 +51,12 @@ const validBuildTypeAndFormat = (config) => {
34
51
  ].includes((_config_format = config.format) !== null && _config_format !== void 0 ? _config_format : "")) {
35
52
  throw new Error(`when buildType is bundleless, the format must be equal to one of the allowed values: (cjs, esm)`);
36
53
  }
54
+ if (config.tsconfig && !import_utils.fs.existsSync(import_path.default.resolve(appDirectory, config.tsconfig))) {
55
+ throw new Error(`${config.tsconfig} does not exist in your project`);
56
+ }
37
57
  };
38
-
39
- //# sourceMappingURL=valid.js.map
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ validBuildConfig,
61
+ validPartialBuildConfig
62
+ });
@@ -1,2 +1,6 @@
1
1
  import type { BaseBuildConfig } from '../types';
2
- export declare const getDefaultBuildConfig: () => Readonly<BaseBuildConfig>;
2
+ export declare const getDefaultBuildConfig: () => Readonly<BaseBuildConfig>;
3
+ /**
4
+ * supports require js plugin in less file
5
+ */
6
+ export declare const cssExtensions: string[];
@@ -1,71 +1,113 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "getDefaultBuildConfig", {
6
- enumerable: true,
7
- get: function() {
8
- return getDefaultBuildConfig;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var build_exports = {};
20
+ __export(build_exports, {
21
+ cssExtensions: () => cssExtensions,
22
+ getDefaultBuildConfig: () => getDefaultBuildConfig
10
23
  });
24
+ module.exports = __toCommonJS(build_exports);
11
25
  const getDefaultBuildConfig = () => {
12
26
  return Object.freeze({
27
+ alias: {},
28
+ asset: {
29
+ limit: 14336,
30
+ path: "assets",
31
+ publicPath: "",
32
+ svgr: false
33
+ },
34
+ autoExternal: true,
35
+ banner: {},
13
36
  buildType: "bundle",
14
- format: "cjs",
15
- target: "es6",
16
- sourceMap: false,
17
37
  copy: {},
18
- outDir: "./dist",
38
+ define: {},
39
+ disableSwcTransform: false,
19
40
  dts: Object.freeze({
20
41
  only: false,
21
42
  distPath: "./",
22
- tsconfigPath: "./tsconfig.json",
43
+ tsconfigPath: void 0,
23
44
  abortOnError: true,
24
45
  respectExternal: true
25
46
  }),
26
- jsx: "automatic",
47
+ esbuildOptions: (c) => c,
48
+ externalHelpers: false,
49
+ externals: [],
50
+ format: "cjs",
51
+ footer: {},
52
+ hooks: [],
27
53
  input: [
28
54
  "src/index.ts"
29
55
  ],
30
- platform: "node",
31
- splitting: false,
32
- externals: [],
33
- minify: false,
34
- autoExternal: true,
35
- umdGlobals: {},
36
- sourceDir: "./src",
37
- alias: {},
56
+ jsx: "automatic",
38
57
  metafile: false,
39
- umdModuleName: (name) => name,
40
- define: {},
41
- asset: {
42
- path: "assets",
43
- limit: 14336,
44
- publicPath: "",
45
- svgr: false
58
+ minify: false,
59
+ outDir: "./dist",
60
+ platform: "node",
61
+ redirect: {
62
+ alias: true,
63
+ asset: true,
64
+ style: true
65
+ },
66
+ resolve: {
67
+ mainFields: [
68
+ "module",
69
+ "main"
70
+ ],
71
+ jsExtensions: [
72
+ ".jsx",
73
+ ".tsx",
74
+ ".js",
75
+ ".ts",
76
+ ".json"
77
+ ]
46
78
  },
79
+ sideEffects: void 0,
80
+ sourceDir: "./src",
81
+ sourceMap: false,
82
+ sourceType: "module",
83
+ splitting: false,
47
84
  style: {
85
+ autoModules: true,
86
+ inject: false,
48
87
  less: {},
49
- sass: {},
88
+ modules: {},
50
89
  postcss: {},
51
- tailwindcss: {},
52
- inject: false,
53
- autoModules: true,
54
- modules: {}
55
- },
56
- sideEffects: void 0,
57
- redirect: {
58
- alias: true,
59
- style: true,
60
- asset: true
90
+ sass: {},
91
+ tailwindcss: {}
61
92
  },
62
- esbuildOptions: (c) => c,
63
- externalHelpers: false,
93
+ target: "es6",
94
+ transformCache: true,
64
95
  transformImport: [],
65
- transformLodash: true,
66
- sourceType: "module",
67
- disableSwcTransform: false
96
+ transformLodash: false,
97
+ tsconfig: "tsconfig.json",
98
+ umdGlobals: {},
99
+ umdModuleName: (name) => name
68
100
  });
69
101
  };
70
-
71
- //# sourceMappingURL=build.js.map
102
+ const cssExtensions = [
103
+ ".less",
104
+ ".css",
105
+ ".sass",
106
+ ".scss",
107
+ ".js"
108
+ ];
109
+ // Annotate the CommonJS export names for ESM import in node:
110
+ 0 && (module.exports = {
111
+ cssExtensions,
112
+ getDefaultBuildConfig
113
+ });
@@ -1,25 +1,28 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
6
7
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- green: function() {
14
- return green;
15
- },
16
- blue: function() {
17
- return blue;
18
- },
19
- gray: function() {
20
- return gray;
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var color_exports = {};
20
+ __export(color_exports, {
21
+ blue: () => blue,
22
+ gray: () => gray,
23
+ green: () => green
22
24
  });
25
+ module.exports = __toCommonJS(color_exports);
23
26
  const green = [
24
27
  96,
25
28
  186,
@@ -35,5 +38,9 @@ const gray = [
35
38
  2,
36
39
  45
37
40
  ];
38
-
39
- //# sourceMappingURL=color.js.map
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ blue,
44
+ gray,
45
+ green
46
+ });
@@ -1,25 +1,28 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
6
7
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- defaultTransformedFunctions: function() {
14
- return defaultTransformedFunctions;
15
- },
16
- watchDoneText: function() {
17
- return watchDoneText;
18
- },
19
- dtsTempDirectory: function() {
20
- return dtsTempDirectory;
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var dts_exports = {};
20
+ __export(dts_exports, {
21
+ defaultTransformedFunctions: () => defaultTransformedFunctions,
22
+ dtsTempDirectory: () => dtsTempDirectory,
23
+ watchDoneText: () => watchDoneText
22
24
  });
25
+ module.exports = __toCommonJS(dts_exports);
23
26
  const defaultTransformedFunctions = [
24
27
  "require",
25
28
  "require.resolve",
@@ -39,5 +42,9 @@ const defaultTransformedFunctions = [
39
42
  ];
40
43
  const watchDoneText = "Watching for file changes";
41
44
  const dtsTempDirectory = "node_modules/.dts-temp";
42
-
43
- //# sourceMappingURL=dts.js.map
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ defaultTransformedFunctions,
48
+ dtsTempDirectory,
49
+ watchDoneText
50
+ });
@@ -1,3 +1,3 @@
1
- export declare const assetExts: string[];
2
1
  export declare const styleExts: string[];
3
- export declare const dtsAliasExts: string[];
2
+ export declare const dtsAliasExts: string[];
3
+ export declare const assetExt: string[];