@modern-js/module-tools 2.15.0 → 2.16.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 (135) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/compiled/postcss-custom-properties/index.js +1 -1
  3. package/compiled/postcss-custom-properties/package.json +1 -1
  4. package/dist/build.js +23 -66
  5. package/dist/build.js.map +1 -1
  6. package/dist/builder/build.js +114 -170
  7. package/dist/builder/build.js.map +1 -1
  8. package/dist/builder/clear.js +23 -65
  9. package/dist/builder/clear.js.map +1 -1
  10. package/dist/builder/copy.js +83 -164
  11. package/dist/builder/copy.js.map +1 -1
  12. package/dist/builder/dts/index.js +15 -28
  13. package/dist/builder/dts/index.js.map +1 -1
  14. package/dist/builder/dts/rollup.js +46 -120
  15. package/dist/builder/dts/rollup.js.map +1 -1
  16. package/dist/builder/dts/tsc.js +82 -141
  17. package/dist/builder/dts/tsc.js.map +1 -1
  18. package/dist/builder/index.js +34 -85
  19. package/dist/builder/index.js.map +1 -1
  20. package/dist/builder/platform.js +40 -93
  21. package/dist/builder/platform.js.map +1 -1
  22. package/dist/cli.js +35 -84
  23. package/dist/cli.js.map +1 -1
  24. package/dist/command.js +56 -136
  25. package/dist/command.js.map +1 -1
  26. package/dist/config/defineConfig.js +13 -42
  27. package/dist/config/defineConfig.js.map +1 -1
  28. package/dist/config/legacySchema.js +96 -52
  29. package/dist/config/legacySchema.js.map +1 -1
  30. package/dist/config/normalize.js +73 -149
  31. package/dist/config/normalize.js.map +1 -1
  32. package/dist/config/schema.d.ts +36 -0
  33. package/dist/config/schema.js +118 -56
  34. package/dist/config/schema.js.map +1 -1
  35. package/dist/config/transformLegacyConfig.js +152 -203
  36. package/dist/config/transformLegacyConfig.js.map +1 -1
  37. package/dist/constants/build.js +15 -27
  38. package/dist/constants/build.js.map +1 -1
  39. package/dist/constants/buildPresets.js +71 -84
  40. package/dist/constants/buildPresets.js.map +1 -1
  41. package/dist/constants/colors.js +28 -30
  42. package/dist/constants/colors.js.map +1 -1
  43. package/dist/constants/dts.js +13 -28
  44. package/dist/constants/dts.js.map +1 -1
  45. package/dist/constants/file.js +27 -30
  46. package/dist/constants/file.js.map +1 -1
  47. package/dist/constants/legacyBuildPresets.js +33 -49
  48. package/dist/constants/legacyBuildPresets.js.map +1 -1
  49. package/dist/constants/log.js +15 -33
  50. package/dist/constants/log.js.map +1 -1
  51. package/dist/dev.js +45 -91
  52. package/dist/dev.js.map +1 -1
  53. package/dist/error.js +37 -54
  54. package/dist/error.js.map +1 -1
  55. package/dist/hooks/build.js +22 -35
  56. package/dist/hooks/build.js.map +1 -1
  57. package/dist/hooks/dev.js +15 -33
  58. package/dist/hooks/dev.js.map +1 -1
  59. package/dist/hooks/index.js +15 -42
  60. package/dist/hooks/index.js.map +1 -1
  61. package/dist/hooks/misc.js +10 -28
  62. package/dist/hooks/misc.js.map +1 -1
  63. package/dist/index.js +21 -35
  64. package/dist/index.js.map +1 -1
  65. package/dist/locale/en.d.ts +7 -2
  66. package/dist/locale/en.js +25 -32
  67. package/dist/locale/en.js.map +1 -1
  68. package/dist/locale/index.d.ts +14 -4
  69. package/dist/locale/index.js +18 -31
  70. package/dist/locale/index.js.map +1 -1
  71. package/dist/locale/zh.d.ts +7 -2
  72. package/dist/locale/zh.js +25 -32
  73. package/dist/locale/zh.js.map +1 -1
  74. package/dist/plugins.js +16 -39
  75. package/dist/plugins.js.map +1 -1
  76. package/dist/types/color.js +4 -15
  77. package/dist/types/color.js.map +1 -1
  78. package/dist/types/command.js +4 -15
  79. package/dist/types/command.js.map +1 -1
  80. package/dist/types/config/index.d.ts +6 -0
  81. package/dist/types/config/index.js +6 -17
  82. package/dist/types/config/index.js.map +1 -1
  83. package/dist/types/config/style.js +4 -15
  84. package/dist/types/config/style.js.map +1 -1
  85. package/dist/types/context.js +4 -15
  86. package/dist/types/context.js.map +1 -1
  87. package/dist/types/copy.js +4 -15
  88. package/dist/types/copy.js.map +1 -1
  89. package/dist/types/dts.js +4 -15
  90. package/dist/types/dts.js.map +1 -1
  91. package/dist/types/hooks.js +4 -15
  92. package/dist/types/hooks.js.map +1 -1
  93. package/dist/types/index.js +11 -22
  94. package/dist/types/index.js.map +1 -1
  95. package/dist/types/legacyConfig/index.js +4 -15
  96. package/dist/types/legacyConfig/index.js.map +1 -1
  97. package/dist/types/legacyConfig/output.js +4 -15
  98. package/dist/types/legacyConfig/output.js.map +1 -1
  99. package/dist/types/legacyConfig/source.js +4 -15
  100. package/dist/types/legacyConfig/source.js.map +1 -1
  101. package/dist/types/legacyConfig/tools.js +4 -15
  102. package/dist/types/legacyConfig/tools.js.map +1 -1
  103. package/dist/types/utils.js +4 -17
  104. package/dist/utils/builder.d.ts +20 -2
  105. package/dist/utils/builder.js +81 -68
  106. package/dist/utils/builder.js.map +1 -1
  107. package/dist/utils/common.js +10 -44
  108. package/dist/utils/common.js.map +1 -1
  109. package/dist/utils/config.js +108 -144
  110. package/dist/utils/config.js.map +1 -1
  111. package/dist/utils/context.js +16 -59
  112. package/dist/utils/context.js.map +1 -1
  113. package/dist/utils/dts.js +69 -146
  114. package/dist/utils/dts.js.map +1 -1
  115. package/dist/utils/input.js +44 -87
  116. package/dist/utils/input.js.map +1 -1
  117. package/dist/utils/language.js +15 -60
  118. package/dist/utils/language.js.map +1 -1
  119. package/dist/utils/libuildPlugins.js +27 -67
  120. package/dist/utils/libuildPlugins.js.map +1 -1
  121. package/dist/utils/log.js +14 -61
  122. package/dist/utils/log.js.map +1 -1
  123. package/dist/utils/onExit.js +14 -61
  124. package/dist/utils/onExit.js.map +1 -1
  125. package/dist/utils/path.js +13 -59
  126. package/dist/utils/path.js.map +1 -1
  127. package/dist/utils/print.js +57 -105
  128. package/dist/utils/print.js.map +1 -1
  129. package/dist/utils/style.js +54 -106
  130. package/dist/utils/style.js.map +1 -1
  131. package/dist/utils/tspathsTransform.js +44 -81
  132. package/dist/utils/tspathsTransform.js.map +1 -1
  133. package/package.json +25 -20
  134. package/scripts/debug-mode.js +23 -21
  135. package/dist/types/utils.js.map +0 -1
@@ -1,202 +1,126 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __export = (target, all) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
22
6
  for (var name in all)
23
- __defProp(target, name, { get: all[name], enumerable: true });
24
- };
25
- var __copyProps = (to, from, except, desc) => {
26
- if (from && typeof from === "object" || typeof from === "function") {
27
- for (let key of __getOwnPropNames(from))
28
- if (!__hasOwnProp.call(to, key) && key !== except)
29
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
- }
31
- return to;
32
- };
33
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
- // If the importer is in node compatibility mode or this is not an ESM
35
- // file that has been converted to a CommonJS file using a Babel-
36
- // compatible transform (i.e. "__esModule" has not been set), then set
37
- // "default" to the CommonJS "module.exports" for node compatibility.
38
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
- mod
40
- ));
41
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
42
- var __async = (__this, __arguments, generator) => {
43
- return new Promise((resolve, reject) => {
44
- var fulfilled = (value) => {
45
- try {
46
- step(generator.next(value));
47
- } catch (e) {
48
- reject(e);
49
- }
50
- };
51
- var rejected = (value) => {
52
- try {
53
- step(generator.throw(value));
54
- } catch (e) {
55
- reject(e);
56
- }
57
- };
58
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
59
- step((generator = generator.apply(__this, __arguments)).next());
60
- });
61
- };
62
- var normalize_exports = {};
63
- __export(normalize_exports, {
64
- checkConfig: () => checkConfig,
65
- normalizeBuildConfig: () => normalizeBuildConfig,
66
- requiredBuildConfig: () => requiredBuildConfig,
67
- transformBuildConfigToBaseConfigs: () => transformBuildConfigToBaseConfigs,
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
68
13
  transformBuildPresetToBaseConfigs: () => transformBuildPresetToBaseConfigs,
69
- transformToAbsPath: () => transformToAbsPath
14
+ transformBuildConfigToBaseConfigs: () => transformBuildConfigToBaseConfigs,
15
+ requiredBuildConfig: () => requiredBuildConfig,
16
+ transformToAbsPath: () => transformToAbsPath,
17
+ checkConfig: () => checkConfig,
18
+ normalizeBuildConfig: () => normalizeBuildConfig
70
19
  });
71
- module.exports = __toCommonJS(normalize_exports);
72
- var import_path = __toESM(require("path"));
73
- const transformBuildPresetToBaseConfigs = (options, preset) => __async(void 0, null, function* () {
74
- const { BuildInPreset, presetList } = yield Promise.resolve().then(() => __toESM(require("../constants/buildPresets")));
75
- const { addInputToPreset } = yield Promise.resolve().then(() => __toESM(require("../utils/input")));
20
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
21
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
22
+ const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
23
+ const transformBuildPresetToBaseConfigs = async (options, preset) => {
24
+ const { BuildInPreset, presetList } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/buildPresets")));
25
+ const { addInputToPreset } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/input")));
76
26
  if (typeof preset === "function") {
77
27
  const extendPreset = (presetName, extendConfig) => {
78
28
  const originalBuildConfig = BuildInPreset[presetName];
79
29
  if (Array.isArray(originalBuildConfig)) {
80
30
  return originalBuildConfig.map((config) => {
81
- return __spreadValues(__spreadValues({}, config), extendConfig);
31
+ return {
32
+ ...config,
33
+ ...extendConfig
34
+ };
82
35
  });
83
36
  } else if (originalBuildConfig) {
84
- return __spreadValues(__spreadValues({}, originalBuildConfig), extendConfig);
37
+ return {
38
+ ...originalBuildConfig,
39
+ ...extendConfig
40
+ };
85
41
  }
86
42
  return extendConfig;
87
43
  };
88
- const partialBuildConfig = yield preset({
44
+ const partialBuildConfig = await preset({
89
45
  preset: BuildInPreset,
90
46
  extendPreset
91
47
  });
92
48
  if (!partialBuildConfig) {
93
- throw new Error(
94
- "The `buildPreset` function does not allow no return value"
95
- );
49
+ throw new Error("The `buildPreset` function does not allow no return value");
96
50
  }
97
51
  return transformBuildConfigToBaseConfigs(partialBuildConfig, options);
98
52
  }
99
53
  const inPresetList = (p) => p in presetList;
100
54
  if (preset && inPresetList(preset)) {
101
- return transformBuildConfigToBaseConfigs(
102
- yield addInputToPreset(presetList[preset], options.context),
103
- options
104
- );
55
+ return transformBuildConfigToBaseConfigs(await addInputToPreset(presetList[preset], options.context), options);
105
56
  }
106
57
  return transformBuildConfigToBaseConfigs({}, options);
107
- });
108
- const transformBuildConfigToBaseConfigs = (config, options) => __async(void 0, null, function* () {
109
- const { validPartialBuildConfig } = yield Promise.resolve().then(() => __toESM(require("../utils/config")));
58
+ };
59
+ const transformBuildConfigToBaseConfigs = async (config, options) => {
60
+ const { validPartialBuildConfig } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/config")));
110
61
  validPartialBuildConfig(config);
111
62
  const { buildCmdOptions } = options;
112
- const { ensureArray } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
113
- const { assignTsConfigPath } = yield Promise.resolve().then(() => __toESM(require("../utils/dts")));
63
+ const { ensureArray } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
64
+ const { assignTsConfigPath } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/dts")));
114
65
  const partialConfigs = ensureArray(config);
115
- const configs = yield Promise.all(
116
- partialConfigs.map((config2) => __async(void 0, null, function* () {
117
- let newConfig = yield requiredBuildConfig(config2, options.context);
118
- newConfig = yield assignTsConfigPath(newConfig, buildCmdOptions);
119
- newConfig = yield transformToAbsPath(newConfig, options);
120
- return newConfig;
121
- }))
122
- );
66
+ const configs = await Promise.all(partialConfigs.map(async (config2) => {
67
+ let newConfig = await requiredBuildConfig(config2, options.context);
68
+ newConfig = await assignTsConfigPath(newConfig, buildCmdOptions);
69
+ newConfig = await transformToAbsPath(newConfig, options);
70
+ return newConfig;
71
+ }));
123
72
  return configs;
124
- });
125
- const requiredBuildConfig = (partialBuildConfig, context) => __async(void 0, null, function* () {
126
- const { mergeDefaultBaseConfig } = yield Promise.resolve().then(() => __toESM(require("../utils/config")));
127
- const mergedConfig = yield mergeDefaultBaseConfig(
128
- partialBuildConfig,
129
- context
130
- );
73
+ };
74
+ const requiredBuildConfig = async (partialBuildConfig, context) => {
75
+ const { mergeDefaultBaseConfig } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/config")));
76
+ const mergedConfig = await mergeDefaultBaseConfig(partialBuildConfig, context);
131
77
  return mergedConfig;
132
- });
133
- const transformToAbsPath = (baseConfig, options) => __async(void 0, null, function* () {
134
- const { slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
78
+ };
79
+ const transformToAbsPath = async (baseConfig, options) => {
80
+ const { slash } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
135
81
  const newConfig = baseConfig;
136
- const { normalizeInput } = yield Promise.resolve().then(() => __toESM(require("../utils/input")));
82
+ const { normalizeInput } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/input")));
137
83
  const { context } = options;
138
- newConfig.outDir = import_path.default.isAbsolute(newConfig.outDir) ? newConfig.outDir : import_path.default.join(context.appDirectory, newConfig.outDir);
139
- newConfig.sourceDir = slash(
140
- import_path.default.resolve(context.appDirectory, baseConfig.sourceDir)
141
- );
142
- newConfig.input = yield normalizeInput(newConfig, {
84
+ newConfig.outDir = _path.default.isAbsolute(newConfig.outDir) ? newConfig.outDir : _path.default.join(context.appDirectory, newConfig.outDir);
85
+ newConfig.sourceDir = slash(_path.default.resolve(context.appDirectory, baseConfig.sourceDir));
86
+ newConfig.input = await normalizeInput(newConfig, {
143
87
  appDirectory: context.appDirectory
144
88
  });
145
89
  if (newConfig.dts) {
146
- newConfig.dts.distPath = import_path.default.join(
147
- newConfig.outDir,
148
- newConfig.dts.distPath
149
- );
150
- newConfig.dts.tsconfigPath = import_path.default.join(
151
- context.appDirectory,
152
- newConfig.dts.tsconfigPath
153
- );
90
+ newConfig.dts.distPath = _path.default.join(newConfig.outDir, newConfig.dts.distPath);
91
+ newConfig.dts.tsconfigPath = _path.default.join(context.appDirectory, newConfig.dts.tsconfigPath);
154
92
  }
155
93
  return newConfig;
156
- });
157
- const checkConfig = (config) => __async(void 0, null, function* () {
94
+ };
95
+ const checkConfig = async (config) => {
158
96
  const { buildConfig, buildPreset } = config;
159
97
  if (buildConfig && buildPreset) {
160
- const { logger } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
161
- logger.warn(
162
- `因为同时出现 'buildConfig' 和 'buildPreset' 配置,因此仅 'buildConfig' 配置生效`
163
- );
98
+ const { logger } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
99
+ logger.warn(`因为同时出现 'buildConfig' 和 'buildPreset' 配置,因此仅 'buildConfig' 配置生效`);
164
100
  }
165
- });
166
- const normalizeBuildConfig = (api, context, buildCmdOptions) => __async(void 0, null, function* () {
167
- const { isLegacyUserConfig } = yield Promise.resolve().then(() => __toESM(require("../utils/config")));
101
+ };
102
+ const normalizeBuildConfig = async (api, context, buildCmdOptions) => {
103
+ const { isLegacyUserConfig } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/config")));
168
104
  let config = api.useConfigContext();
169
105
  if (isLegacyUserConfig(config)) {
170
- const { createUserConfigFromLegacy } = yield Promise.resolve().then(() => __toESM(require("./transformLegacyConfig")));
171
- config = yield createUserConfigFromLegacy(config);
106
+ const { createUserConfigFromLegacy } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./transformLegacyConfig")));
107
+ config = await createUserConfigFromLegacy(config);
172
108
  }
173
109
  const { buildConfig, buildPreset } = config;
174
- yield checkConfig(config);
110
+ await checkConfig(config);
175
111
  let baseConfigs;
176
112
  if (buildConfig) {
177
- baseConfigs = yield transformBuildConfigToBaseConfigs(buildConfig, {
113
+ baseConfigs = await transformBuildConfigToBaseConfigs(buildConfig, {
178
114
  buildCmdOptions,
179
115
  context
180
116
  });
181
117
  } else {
182
- baseConfigs = yield transformBuildPresetToBaseConfigs(
183
- {
184
- context,
185
- buildCmdOptions
186
- },
187
- buildPreset
188
- );
118
+ baseConfigs = await transformBuildPresetToBaseConfigs({
119
+ context,
120
+ buildCmdOptions
121
+ }, buildPreset);
189
122
  }
190
123
  return baseConfigs;
191
- });
192
- // Annotate the CommonJS export names for ESM import in node:
193
- 0 && (module.exports = {
194
- checkConfig,
195
- normalizeBuildConfig,
196
- requiredBuildConfig,
197
- transformBuildConfigToBaseConfigs,
198
- transformBuildPresetToBaseConfigs,
199
- transformToAbsPath
200
- });
124
+ };
201
125
 
202
126
  //#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AAEO,MAAM,cAAc,CAAO,WAA6B;AAC7D,QAAM,EAAE,aAAa,YAAY,IAAI;AACrC,MAAI,eAAe,aAAa;AAC9B,UAAM,EAAE,OAAO,IAAI,MAAM,6CAAO,kBAAkB;AAClD,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;AAEO,MAAM,uBAAuB,CAClC,KACA,SACA,oBAC+B;AAC/B,QAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,iBAAiB;AAC7D,MAAI,SAAS,IAAI,iBAAiB;AAElC,MAAI,mBAAmB,MAA8B,GAAG;AACtD,UAAM,EAAE,2BAA2B,IAAI,MAAM,6CAC3C,yBACF;AACA,aAAS,MAAM,2BAA2B,MAAgC;AAAA,EAC5E;AAEA,QAAM,EAAE,aAAa,YAAY,IAAI;AAErC,QAAM,YAAY,MAAM;AAExB,MAAI;AAGJ,MAAI,aAAa;AACf,kBAAc,MAAM,kCAAkC,aAAa;AAAA,MACjE;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,kBAAc,MAAM;AAAA,MAClB;AAAA,QACE;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;;;;;;;;;;","names":["config"],"sources":["../../src/config/normalize.ts"],"sourcesContent":["import path from 'path';\nimport type { PluginAPI } from '@modern-js/core';\nimport type {\n ModuleUserConfig,\n ModuleLegacyUserConfig,\n BaseBuildConfig,\n BuildPreset,\n PartialBuildConfig,\n PartialBaseBuildConfig,\n ModuleContext,\n BuildCommandOptions,\n ModuleTools,\n} from '../types';\n\nexport const transformBuildPresetToBaseConfigs = async (\n options: {\n context: ModuleContext;\n buildCmdOptions: BuildCommandOptions;\n },\n preset?: BuildPreset,\n): Promise<BaseBuildConfig[]> => {\n const { BuildInPreset, presetList } = await import(\n '../constants/buildPresets'\n );\n const { addInputToPreset } = await import('../utils/input');\n\n if (typeof preset === 'function') {\n const extendPreset = (\n presetName: keyof typeof BuildInPreset,\n extendConfig: PartialBaseBuildConfig,\n ) => {\n const originalBuildConfig = BuildInPreset[presetName];\n if (Array.isArray(originalBuildConfig)) {\n return originalBuildConfig.map(config => {\n return {\n ...config,\n ...extendConfig,\n };\n });\n } else if (originalBuildConfig) {\n return {\n ...originalBuildConfig,\n ...extendConfig,\n };\n }\n\n return extendConfig;\n };\n const partialBuildConfig = await preset({\n preset: BuildInPreset,\n extendPreset,\n });\n\n if (!partialBuildConfig) {\n throw new Error(\n 'The `buildPreset` function does not allow no return value',\n );\n }\n\n return transformBuildConfigToBaseConfigs(partialBuildConfig, options);\n }\n\n const inPresetList = (p: string): p is keyof typeof presetList =>\n p in presetList;\n\n if (preset && inPresetList(preset)) {\n return transformBuildConfigToBaseConfigs(\n await addInputToPreset(presetList[preset], options.context),\n options,\n );\n }\n\n // buildConfig and buildPreset is undefined\n return transformBuildConfigToBaseConfigs({}, options);\n};\n\nexport const transformBuildConfigToBaseConfigs = async (\n config: PartialBuildConfig,\n options: {\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n): Promise<BaseBuildConfig[]> => {\n const { validPartialBuildConfig } = await import('../utils/config');\n validPartialBuildConfig(config);\n const { buildCmdOptions } = options;\n const { ensureArray } = await import('@modern-js/utils');\n const { assignTsConfigPath } = await import('../utils/dts');\n const partialConfigs = ensureArray(config);\n const configs = await Promise.all(\n partialConfigs.map(async config => {\n let newConfig = await requiredBuildConfig(config, options.context);\n newConfig = await assignTsConfigPath(newConfig, buildCmdOptions);\n newConfig = await transformToAbsPath(newConfig, options);\n return newConfig;\n }),\n );\n return configs;\n};\n\nexport const requiredBuildConfig = async (\n partialBuildConfig: PartialBaseBuildConfig,\n context: ModuleContext,\n): Promise<BaseBuildConfig> => {\n const { mergeDefaultBaseConfig } = await import('../utils/config');\n const mergedConfig = await mergeDefaultBaseConfig(\n partialBuildConfig,\n context,\n );\n return mergedConfig;\n};\n\nexport const transformToAbsPath = async (\n baseConfig: BaseBuildConfig,\n options: { context: ModuleContext; buildCmdOptions: BuildCommandOptions },\n) => {\n const { slash } = await import('@modern-js/utils');\n const newConfig = baseConfig;\n const { normalizeInput } = await import('../utils/input');\n const { context } = options;\n\n newConfig.outDir = path.isAbsolute(newConfig.outDir)\n ? newConfig.outDir\n : path.join(context.appDirectory, newConfig.outDir);\n\n newConfig.sourceDir = slash(\n path.resolve(context.appDirectory, baseConfig.sourceDir),\n );\n newConfig.input = await normalizeInput(newConfig, {\n appDirectory: context.appDirectory,\n });\n\n // dts path\n if (newConfig.dts) {\n newConfig.dts.distPath = path.join(\n newConfig.outDir,\n newConfig.dts.distPath,\n );\n newConfig.dts.tsconfigPath = path.join(\n context.appDirectory,\n newConfig.dts.tsconfigPath,\n );\n }\n\n // Maybe need transform 'config.copy'\n\n return newConfig;\n};\n\nexport const checkConfig = async (config: ModuleUserConfig) => {\n const { buildConfig, buildPreset } = config;\n if (buildConfig && buildPreset) {\n const { logger } = await import('@modern-js/utils');\n logger.warn(\n `因为同时出现 'buildConfig' 和 'buildPreset' 配置,因此仅 'buildConfig' 配置生效`,\n );\n }\n};\n\nexport const normalizeBuildConfig = async (\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n buildCmdOptions: BuildCommandOptions,\n): Promise<BaseBuildConfig[]> => {\n const { isLegacyUserConfig } = await import('../utils/config');\n let config = api.useConfigContext() as unknown as ModuleUserConfig;\n\n if (isLegacyUserConfig(config as { legacy?: boolean })) {\n const { createUserConfigFromLegacy } = await import(\n './transformLegacyConfig'\n );\n config = await createUserConfigFromLegacy(config as ModuleLegacyUserConfig);\n }\n\n const { buildConfig, buildPreset } = config;\n\n await checkConfig(config);\n\n let baseConfigs: BaseBuildConfig[];\n\n // buildConfig High priority\n if (buildConfig) {\n baseConfigs = await transformBuildConfigToBaseConfigs(buildConfig, {\n buildCmdOptions,\n context,\n });\n } else {\n baseConfigs = await transformBuildPresetToBaseConfigs(\n {\n context,\n buildCmdOptions,\n },\n buildPreset,\n );\n }\n\n return baseConfigs;\n};\n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,OAAM,IAAK,MAAM,iFAAO;AAChCA,WAAOC,KACL,gEAAgE;EAEpE;AACF;AAEO,MAAM/C,uBAAuB,OAClCgD,KACA9B,SACAE,oBAC+B;AAC/B,QAAM,EAAE6B,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,MAAIpC,SAASmC,IAAIE,iBAAgB;AAEjC,MAAID,mBAAmBpC,SAAiC;AACtD,UAAM,EAAEsC,2BAA0B,IAAK,MAAM,iFAC3C;AAEFtC,aAAS,MAAMsC,2BAA2BtC;EAC5C;AAEA,QAAM,EAAE+B,aAAaC,YAAW,IAAKhC;AAErC,QAAMd,YAAYc;AAElB,MAAIuC;AAGJ,MAAIR,aAAa;AACfQ,kBAAc,MAAMxD,kCAAkCgD,aAAa;MACjExB;MACAF;IACF;EACF,OAAO;AACLkC,kBAAc,MAAMzD,kCAClB;MACEuB;MACAE;IACF,GACAyB;EAEJ;AAEA,SAAOO;AACT;","names":["transformBuildPresetToBaseConfigs","transformBuildConfigToBaseConfigs","requiredBuildConfig","transformToAbsPath","checkConfig","normalizeBuildConfig","options","preset","BuildInPreset","presetList","addInputToPreset","extendPreset","presetName","extendConfig","originalBuildConfig","Array","isArray","map","config","partialBuildConfig","Error","inPresetList","p","context","validPartialBuildConfig","buildCmdOptions","ensureArray","assignTsConfigPath","partialConfigs","configs","Promise","all","newConfig","mergeDefaultBaseConfig","mergedConfig","baseConfig","slash","normalizeInput","outDir","path","isAbsolute","join","appDirectory","sourceDir","resolve","input","dts","distPath","tsconfigPath","buildConfig","buildPreset","logger","warn","api","isLegacyUserConfig","useConfigContext","createUserConfigFromLegacy","baseConfigs"],"sources":["../../src/config/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/config/normalize.ts"],"sourcesContent":["import path from 'path';\nimport type { PluginAPI } from '@modern-js/core';\nimport type {\n ModuleUserConfig,\n ModuleLegacyUserConfig,\n BaseBuildConfig,\n BuildPreset,\n PartialBuildConfig,\n PartialBaseBuildConfig,\n ModuleContext,\n BuildCommandOptions,\n ModuleTools,\n} from '../types';\n\nexport const transformBuildPresetToBaseConfigs = async (\n options: {\n context: ModuleContext;\n buildCmdOptions: BuildCommandOptions;\n },\n preset?: BuildPreset,\n): Promise<BaseBuildConfig[]> => {\n const { BuildInPreset, presetList } = await import(\n '../constants/buildPresets'\n );\n const { addInputToPreset } = await import('../utils/input');\n\n if (typeof preset === 'function') {\n const extendPreset = (\n presetName: keyof typeof BuildInPreset,\n extendConfig: PartialBaseBuildConfig,\n ) => {\n const originalBuildConfig = BuildInPreset[presetName];\n if (Array.isArray(originalBuildConfig)) {\n return originalBuildConfig.map(config => {\n return {\n ...config,\n ...extendConfig,\n };\n });\n } else if (originalBuildConfig) {\n return {\n ...originalBuildConfig,\n ...extendConfig,\n };\n }\n\n return extendConfig;\n };\n const partialBuildConfig = await preset({\n preset: BuildInPreset,\n extendPreset,\n });\n\n if (!partialBuildConfig) {\n throw new Error(\n 'The `buildPreset` function does not allow no return value',\n );\n }\n\n return transformBuildConfigToBaseConfigs(partialBuildConfig, options);\n }\n\n const inPresetList = (p: string): p is keyof typeof presetList =>\n p in presetList;\n\n if (preset && inPresetList(preset)) {\n return transformBuildConfigToBaseConfigs(\n await addInputToPreset(presetList[preset], options.context),\n options,\n );\n }\n\n // buildConfig and buildPreset is undefined\n return transformBuildConfigToBaseConfigs({}, options);\n};\n\nexport const transformBuildConfigToBaseConfigs = async (\n config: PartialBuildConfig,\n options: {\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n): Promise<BaseBuildConfig[]> => {\n const { validPartialBuildConfig } = await import('../utils/config');\n validPartialBuildConfig(config);\n const { buildCmdOptions } = options;\n const { ensureArray } = await import('@modern-js/utils');\n const { assignTsConfigPath } = await import('../utils/dts');\n const partialConfigs = ensureArray(config);\n const configs = await Promise.all(\n partialConfigs.map(async config => {\n let newConfig = await requiredBuildConfig(config, options.context);\n newConfig = await assignTsConfigPath(newConfig, buildCmdOptions);\n newConfig = await transformToAbsPath(newConfig, options);\n return newConfig;\n }),\n );\n return configs;\n};\n\nexport const requiredBuildConfig = async (\n partialBuildConfig: PartialBaseBuildConfig,\n context: ModuleContext,\n): Promise<BaseBuildConfig> => {\n const { mergeDefaultBaseConfig } = await import('../utils/config');\n const mergedConfig = await mergeDefaultBaseConfig(\n partialBuildConfig,\n context,\n );\n return mergedConfig;\n};\n\nexport const transformToAbsPath = async (\n baseConfig: BaseBuildConfig,\n options: { context: ModuleContext; buildCmdOptions: BuildCommandOptions },\n) => {\n const { slash } = await import('@modern-js/utils');\n const newConfig = baseConfig;\n const { normalizeInput } = await import('../utils/input');\n const { context } = options;\n\n newConfig.outDir = path.isAbsolute(newConfig.outDir)\n ? newConfig.outDir\n : path.join(context.appDirectory, newConfig.outDir);\n\n newConfig.sourceDir = slash(\n path.resolve(context.appDirectory, baseConfig.sourceDir),\n );\n newConfig.input = await normalizeInput(newConfig, {\n appDirectory: context.appDirectory,\n });\n\n // dts path\n if (newConfig.dts) {\n newConfig.dts.distPath = path.join(\n newConfig.outDir,\n newConfig.dts.distPath,\n );\n newConfig.dts.tsconfigPath = path.join(\n context.appDirectory,\n newConfig.dts.tsconfigPath,\n );\n }\n\n // Maybe need transform 'config.copy'\n\n return newConfig;\n};\n\nexport const checkConfig = async (config: ModuleUserConfig) => {\n const { buildConfig, buildPreset } = config;\n if (buildConfig && buildPreset) {\n const { logger } = await import('@modern-js/utils');\n logger.warn(\n `因为同时出现 'buildConfig' 和 'buildPreset' 配置,因此仅 'buildConfig' 配置生效`,\n );\n }\n};\n\nexport const normalizeBuildConfig = async (\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n buildCmdOptions: BuildCommandOptions,\n): Promise<BaseBuildConfig[]> => {\n const { isLegacyUserConfig } = await import('../utils/config');\n let config = api.useConfigContext() as unknown as ModuleUserConfig;\n\n if (isLegacyUserConfig(config as { legacy?: boolean })) {\n const { createUserConfigFromLegacy } = await import(\n './transformLegacyConfig'\n );\n config = await createUserConfigFromLegacy(config as ModuleLegacyUserConfig);\n }\n\n const { buildConfig, buildPreset } = config;\n\n await checkConfig(config);\n\n let baseConfigs: BaseBuildConfig[];\n\n // buildConfig High priority\n if (buildConfig) {\n baseConfigs = await transformBuildConfigToBaseConfigs(buildConfig, {\n buildCmdOptions,\n context,\n });\n } else {\n baseConfigs = await transformBuildPresetToBaseConfigs(\n {\n context,\n buildCmdOptions,\n },\n buildPreset,\n );\n }\n\n return baseConfigs;\n};\n"]}
@@ -179,6 +179,15 @@ export declare const buildConfig: {
179
179
  items?: undefined;
180
180
  })[];
181
181
  };
182
+ externalHelpers: {
183
+ type: string;
184
+ };
185
+ transformImport: {
186
+ type: string;
187
+ };
188
+ sourceType: {
189
+ enum: string[];
190
+ };
182
191
  };
183
192
  }[];
184
193
  };
@@ -354,6 +363,15 @@ export declare const buildConfig: {
354
363
  items?: undefined;
355
364
  })[];
356
365
  };
366
+ externalHelpers: {
367
+ type: string;
368
+ };
369
+ transformImport: {
370
+ type: string;
371
+ };
372
+ sourceType: {
373
+ enum: string[];
374
+ };
357
375
  };
358
376
  };
359
377
  };
@@ -557,6 +575,15 @@ export declare const schema: ({
557
575
  items?: undefined;
558
576
  })[];
559
577
  };
578
+ externalHelpers: {
579
+ type: string;
580
+ };
581
+ transformImport: {
582
+ type: string;
583
+ };
584
+ sourceType: {
585
+ enum: string[];
586
+ };
560
587
  };
561
588
  }[];
562
589
  };
@@ -732,6 +759,15 @@ export declare const schema: ({
732
759
  items?: undefined;
733
760
  })[];
734
761
  };
762
+ externalHelpers: {
763
+ type: string;
764
+ };
765
+ transformImport: {
766
+ type: string;
767
+ };
768
+ sourceType: {
769
+ enum: string[];
770
+ };
735
771
  };
736
772
  };
737
773
  };
@@ -1,32 +1,24 @@
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) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
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 schema_exports = {};
19
- __export(schema_exports, {
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ targets: () => targets,
14
+ presets: () => presets,
20
15
  buildConfig: () => buildConfig,
21
16
  buildPreset: () => buildPreset,
22
17
  legacy: () => legacy,
23
- legacySchema: () => import_legacySchema.legacySchema,
24
- presets: () => presets,
25
18
  schema: () => schema,
26
- targets: () => targets
19
+ legacySchema: () => _legacySchema.legacySchema
27
20
  });
28
- module.exports = __toCommonJS(schema_exports);
29
- var import_legacySchema = require("./legacySchema");
21
+ const _legacySchema = require("./legacySchema");
30
22
  const targets = [
31
23
  "es5",
32
24
  "es6",
@@ -52,14 +44,20 @@ const presets = [
52
44
  "npm-component",
53
45
  "npm-component-with-umd"
54
46
  ].reduce((ret, crt) => {
55
- return [...ret, ...targets.map((t) => `${crt}-${t}`)];
47
+ return [
48
+ ...ret,
49
+ ...targets.map((t) => `${crt}-${t}`)
50
+ ];
56
51
  }, []),
57
52
  "modern-js-node",
58
53
  "modern-js-universal"
59
54
  ];
60
55
  const buildConfigProperties = {
61
56
  alias: {
62
- typeof: ["object", "function"]
57
+ typeof: [
58
+ "object",
59
+ "function"
60
+ ]
63
61
  },
64
62
  asset: {
65
63
  type: "object"
@@ -70,14 +68,23 @@ const buildConfigProperties = {
70
68
  },
71
69
  then: {
72
70
  properties: {
73
- dependencies: { type: "boolean" },
74
- peerDependencies: { type: "boolean" }
71
+ dependencies: {
72
+ type: "boolean"
73
+ },
74
+ peerDependencies: {
75
+ type: "boolean"
76
+ }
75
77
  }
76
78
  },
77
- else: { type: "boolean" }
79
+ else: {
80
+ type: "boolean"
81
+ }
78
82
  },
79
83
  buildType: {
80
- enum: ["bundle", "bundleless"]
84
+ enum: [
85
+ "bundle",
86
+ "bundleless"
87
+ ]
81
88
  },
82
89
  copy: {
83
90
  type: "object",
@@ -87,10 +94,18 @@ const buildConfigProperties = {
87
94
  items: {
88
95
  type: "object",
89
96
  properties: {
90
- from: { type: "string" },
91
- to: { type: "string" },
92
- context: { type: "string" },
93
- globOptions: { type: "object" }
97
+ from: {
98
+ type: "string"
99
+ },
100
+ to: {
101
+ type: "string"
102
+ },
103
+ context: {
104
+ type: "string"
105
+ },
106
+ globOptions: {
107
+ type: "object"
108
+ }
94
109
  }
95
110
  }
96
111
  },
@@ -108,15 +123,25 @@ const buildConfigProperties = {
108
123
  typeof: "object"
109
124
  },
110
125
  dts: {
111
- if: { type: "object" },
126
+ if: {
127
+ type: "object"
128
+ },
112
129
  then: {
113
130
  properties: {
114
- distPath: { type: "string" },
115
- tsconfigPath: { type: "string" },
116
- abortOnError: { type: "boolean" }
131
+ distPath: {
132
+ type: "string"
133
+ },
134
+ tsconfigPath: {
135
+ type: "string"
136
+ },
137
+ abortOnError: {
138
+ type: "boolean"
139
+ }
117
140
  }
118
141
  },
119
- else: { type: "boolean" }
142
+ else: {
143
+ type: "boolean"
144
+ }
120
145
  },
121
146
  externals: {
122
147
  type: "array",
@@ -132,29 +157,56 @@ const buildConfigProperties = {
132
157
  }
133
158
  },
134
159
  format: {
135
- enum: ["cjs", "esm", "iife", "umd"]
160
+ enum: [
161
+ "cjs",
162
+ "esm",
163
+ "iife",
164
+ "umd"
165
+ ]
136
166
  },
137
167
  input: {
138
- type: ["array", "object"]
168
+ type: [
169
+ "array",
170
+ "object"
171
+ ]
139
172
  },
140
173
  jsx: {
141
- enum: ["automatic", "transform"]
174
+ enum: [
175
+ "automatic",
176
+ "transform"
177
+ ]
142
178
  },
143
179
  minify: {
144
180
  if: {
145
181
  type: "object"
146
182
  },
147
- else: { enum: ["esbuild", "terser", false] }
183
+ else: {
184
+ enum: [
185
+ "esbuild",
186
+ "terser",
187
+ false
188
+ ]
189
+ }
190
+ },
191
+ outDir: {
192
+ type: "string"
148
193
  },
149
- outDir: { type: "string" },
150
194
  platform: {
151
- enum: ["node", "browser"]
195
+ enum: [
196
+ "node",
197
+ "browser"
198
+ ]
152
199
  },
153
200
  sourceDir: {
154
201
  typeof: "string"
155
202
  },
156
203
  sourceMap: {
157
- enum: [true, false, "inline", "external"]
204
+ enum: [
205
+ true,
206
+ false,
207
+ "inline",
208
+ "external"
209
+ ]
158
210
  },
159
211
  splitting: {
160
212
  type: "boolean"
@@ -200,6 +252,18 @@ const buildConfigProperties = {
200
252
  instanceof: "Function"
201
253
  }
202
254
  ]
255
+ },
256
+ externalHelpers: {
257
+ type: "boolean"
258
+ },
259
+ transformImport: {
260
+ type: "array"
261
+ },
262
+ sourceType: {
263
+ enum: [
264
+ "commonjs",
265
+ "module"
266
+ ]
203
267
  }
204
268
  };
205
269
  const buildConfig = {
@@ -225,11 +289,15 @@ const buildConfig = {
225
289
  const buildPreset = {
226
290
  target: "buildPreset",
227
291
  schema: {
228
- if: { type: "string" },
292
+ if: {
293
+ type: "string"
294
+ },
229
295
  then: {
230
296
  enum: presets
231
297
  },
232
- else: { typeof: "function" }
298
+ else: {
299
+ typeof: "function"
300
+ }
233
301
  }
234
302
  };
235
303
  const legacy = {
@@ -238,16 +306,10 @@ const legacy = {
238
306
  type: "boolean"
239
307
  }
240
308
  };
241
- const schema = [buildConfig, buildPreset, legacy];
242
- // Annotate the CommonJS export names for ESM import in node:
243
- 0 && (module.exports = {
309
+ const schema = [
244
310
  buildConfig,
245
311
  buildPreset,
246
- legacy,
247
- legacySchema,
248
- presets,
249
- schema,
250
- targets
251
- });
312
+ legacy
313
+ ];
252
314
 
253
315
  //# sourceMappingURL=schema.js.map