@modern-js/module-tools 2.31.2 → 2.32.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 (95) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +1 -1
  3. package/dist/builder/build.js +18 -23
  4. package/dist/builder/build.js.map +1 -1
  5. package/dist/builder/clear.js +6 -9
  6. package/dist/builder/clear.js.map +1 -1
  7. package/dist/builder/copy.d.ts +2 -1
  8. package/dist/builder/copy.js +19 -22
  9. package/dist/builder/copy.js.map +1 -1
  10. package/dist/builder/dts/rollup.d.ts +3 -1
  11. package/dist/builder/dts/rollup.js +14 -13
  12. package/dist/builder/dts/rollup.js.map +1 -1
  13. package/dist/builder/dts/tsc.js +16 -22
  14. package/dist/builder/dts/tsc.js.map +1 -1
  15. package/dist/builder/index.js +14 -14
  16. package/dist/builder/index.js.map +1 -1
  17. package/dist/builder/platform.js +14 -16
  18. package/dist/builder/platform.js.map +1 -1
  19. package/dist/cli.js +16 -16
  20. package/dist/cli.js.map +1 -1
  21. package/dist/command.js +9 -16
  22. package/dist/command.js.map +1 -1
  23. package/dist/config/merge.d.ts +9 -0
  24. package/dist/{utils/config.js → config/merge.js} +45 -53
  25. package/dist/config/merge.js.map +1 -0
  26. package/dist/config/normalize.d.ts +5 -13
  27. package/dist/config/normalize.js +54 -90
  28. package/dist/config/normalize.js.map +1 -1
  29. package/dist/config/schema.d.ts +12 -0
  30. package/dist/config/schema.js +3 -0
  31. package/dist/config/schema.js.map +1 -1
  32. package/dist/config/transformLegacyConfig.js +13 -16
  33. package/dist/config/transformLegacyConfig.js.map +1 -1
  34. package/dist/config/valid.d.ts +3 -0
  35. package/dist/config/valid.js +39 -0
  36. package/dist/config/valid.js.map +1 -0
  37. package/dist/constants/build.d.ts +1 -1
  38. package/dist/constants/build.js +61 -58
  39. package/dist/constants/build.js.map +1 -1
  40. package/dist/constants/{colors.js → color.js} +1 -1
  41. package/dist/constants/{colors.js.map → color.js.map} +1 -1
  42. package/dist/constants/dts.d.ts +0 -1
  43. package/dist/constants/dts.js +0 -4
  44. package/dist/constants/dts.js.map +1 -1
  45. package/dist/constants/{legacyBuildPresets.js → legacy-preset.js} +1 -1
  46. package/dist/constants/legacy-preset.js.map +1 -0
  47. package/dist/constants/preset.d.ts +26 -0
  48. package/dist/constants/{buildPresets.js → preset.js} +4 -18
  49. package/dist/constants/preset.js.map +1 -0
  50. package/dist/dev.js +6 -8
  51. package/dist/dev.js.map +1 -1
  52. package/dist/index.d.ts +1 -1
  53. package/dist/index.js +2 -2
  54. package/dist/index.js.map +1 -1
  55. package/dist/types/command.d.ts +2 -2
  56. package/dist/types/config/copy.js.map +1 -0
  57. package/dist/types/config/dev.d.ts +8 -0
  58. package/dist/types/config/dev.js +6 -0
  59. package/dist/types/config/dev.js.map +1 -0
  60. package/dist/types/config/index.d.ts +6 -5
  61. package/dist/types/config/index.js.map +1 -1
  62. package/dist/types/index.d.ts +3 -3
  63. package/dist/types/index.js.map +1 -1
  64. package/dist/utils/builder.d.ts +1 -4
  65. package/dist/utils/builder.js +3 -29
  66. package/dist/utils/builder.js.map +1 -1
  67. package/dist/utils/common.d.ts +2 -1
  68. package/dist/utils/common.js +18 -3
  69. package/dist/utils/common.js.map +1 -1
  70. package/dist/utils/dts.d.ts +1 -2
  71. package/dist/utils/dts.js +11 -32
  72. package/dist/utils/dts.js.map +1 -1
  73. package/dist/utils/input.d.ts +4 -10
  74. package/dist/utils/input.js +36 -60
  75. package/dist/utils/input.js.map +1 -1
  76. package/dist/utils/{libuildPlugins.d.ts → libuild-plugin.d.ts} +1 -4
  77. package/dist/utils/{libuildPlugins.js → libuild-plugin.js} +4 -25
  78. package/dist/utils/libuild-plugin.js.map +1 -0
  79. package/dist/utils/print.js +1 -3
  80. package/dist/utils/print.js.map +1 -1
  81. package/dist/utils/style.js +14 -19
  82. package/dist/utils/style.js.map +1 -1
  83. package/package.json +20 -17
  84. package/dist/constants/buildPresets.d.ts +0 -91
  85. package/dist/constants/buildPresets.js.map +0 -1
  86. package/dist/constants/legacyBuildPresets.js.map +0 -1
  87. package/dist/types/copy.js.map +0 -1
  88. package/dist/utils/config.d.ts +0 -9
  89. package/dist/utils/config.js.map +0 -1
  90. package/dist/utils/libuildPlugins.js.map +0 -1
  91. package/scripts/debug-mode.js +0 -48
  92. /package/dist/constants/{colors.d.ts → color.d.ts} +0 -0
  93. /package/dist/constants/{legacyBuildPresets.d.ts → legacy-preset.d.ts} +0 -0
  94. /package/dist/types/{copy.d.ts → config/copy.d.ts} +0 -0
  95. /package/dist/types/{copy.js → config/copy.js} +0 -0
@@ -10,48 +10,25 @@ function _export(target, all) {
10
10
  });
11
11
  }
12
12
  _export(exports, {
13
- validPartialBuildConfig: function() {
14
- return validPartialBuildConfig;
15
- },
16
- validBuildTypeAndFormat: function() {
17
- return validBuildTypeAndFormat;
18
- },
19
13
  mergeDefaultBaseConfig: function() {
20
14
  return mergeDefaultBaseConfig;
21
15
  },
22
- getDtsConfig: function() {
23
- return getDtsConfig;
24
- },
25
16
  isLegacyUserConfig: function() {
26
17
  return isLegacyUserConfig;
27
18
  }
28
19
  });
29
20
  const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
30
- const validPartialBuildConfig = (config) => {
31
- if (Array.isArray(config)) {
32
- for (const c of config) {
33
- validBuildTypeAndFormat(c);
34
- }
35
- } else {
36
- validBuildTypeAndFormat(config);
37
- }
38
- };
39
- const validBuildTypeAndFormat = (config) => {
40
- var _config_format;
41
- if (config.buildType === "bundleless" && [
42
- "iife",
43
- "umd"
44
- ].includes((_config_format = config.format) !== null && _config_format !== void 0 ? _config_format : "")) {
45
- throw new Error(`when buildType is bundleless, the format must be equal to one of the allowed values: (cjs, esm)`);
46
- }
47
- };
48
- const mergeDefaultBaseConfig = async (pConfig, context) => {
21
+ const _utils = require("@modern-js/utils");
22
+ const _builder = require("../utils/builder");
23
+ const _input = require("../utils/input");
24
+ const _build = require("../constants/build");
25
+ const mergeDefaultBaseConfig = async (pConfig, options) => {
49
26
  var _pConfig_style, _pConfig_style1, _pConfig_style2, _pConfig_style3;
50
- const { defaultBuildConfig: defaultConfig } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/build")));
51
- const { cloneDeep } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils/lodash")));
27
+ const defaultConfig = (0, _build.getDefaultBuildConfig)();
28
+ const { context, buildCmdOptions } = options;
52
29
  const { applyOptionsChain, ensureAbsolutePath, slash } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
53
- const { getDefaultIndexEntry } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./input")));
54
- const { getStyleConfig } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./style")));
30
+ const { getDefaultIndexEntry } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/input")));
31
+ const { getStyleConfig } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/style")));
55
32
  const defaultAlias = {
56
33
  "@": context.srcDirectory
57
34
  };
@@ -74,9 +51,11 @@ const mergeDefaultBaseConfig = async (pConfig, context) => {
74
51
  const sourceDir = (_pConfig_sourceDir = pConfig.sourceDir) !== null && _pConfig_sourceDir !== void 0 ? _pConfig_sourceDir : defaultConfig.sourceDir;
75
52
  var _pConfig_metafile;
76
53
  const metafile = (_pConfig_metafile = pConfig.metafile) !== null && _pConfig_metafile !== void 0 ? _pConfig_metafile : defaultConfig.metafile;
77
- const input = buildType === "bundle" ? await getDefaultIndexEntry(context) : [
54
+ const defaultIndexEntry = buildType === "bundle" ? await getDefaultIndexEntry(context) : [
78
55
  sourceDir
79
56
  ];
57
+ var _pConfig_input;
58
+ const input = await (0, _input.normalizeInput)((_pConfig_input = pConfig.input) !== null && _pConfig_input !== void 0 ? _pConfig_input : defaultIndexEntry, context.appDirectory);
80
59
  var _pConfig_define;
81
60
  const userDefine = (_pConfig_define = pConfig.define) !== null && _pConfig_define !== void 0 ? _pConfig_define : {};
82
61
  const define = {
@@ -86,9 +65,34 @@ const mergeDefaultBaseConfig = async (pConfig, context) => {
86
65
  return memo;
87
66
  }, {})
88
67
  };
68
+ const { dts: cmdDts, tsconfig: cmdTsconfigPath } = buildCmdOptions;
69
+ const noDts = cmdDts === false || pConfig.dts === false;
70
+ const dts = noDts ? false : {
71
+ ...defaultConfig.dts,
72
+ ...pConfig.dts
73
+ };
74
+ if (dts) {
75
+ if (cmdTsconfigPath) {
76
+ dts.tsconfigPath = cmdTsconfigPath;
77
+ }
78
+ }
79
+ var _pConfig_externals;
80
+ let externals = (_pConfig_externals = pConfig.externals) !== null && _pConfig_externals !== void 0 ? _pConfig_externals : defaultConfig.externals;
81
+ var _pConfig_autoExternal;
82
+ const autoExternal = (_pConfig_autoExternal = pConfig.autoExternal) !== null && _pConfig_autoExternal !== void 0 ? _pConfig_autoExternal : defaultConfig.autoExternal;
83
+ if (autoExternal) {
84
+ const deps = await (0, _builder.getAllDeps)(context.appDirectory, (0, _utils.isObject)(autoExternal) ? autoExternal : {
85
+ dependencies: true,
86
+ peerDependencies: true
87
+ });
88
+ externals = [
89
+ ...deps.map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`)),
90
+ ...externals || []
91
+ ];
92
+ }
89
93
  var _pConfig_esbuildOptions;
90
94
  const esbuildOptions = (_pConfig_esbuildOptions = pConfig.esbuildOptions) !== null && _pConfig_esbuildOptions !== void 0 ? _pConfig_esbuildOptions : defaultConfig.esbuildOptions;
91
- var _pConfig_format, _pConfig_target, _pConfig_sourceMap, _pConfig_copy, _pConfig_outDir, _pConfig_jsx, _pConfig_input, _pConfig_platform, _pConfig_splitting, _pConfig_minify, _pConfig_autoExternal, _pConfig_umdModuleName, _pConfig_sideEffects, _pConfig_externals, _pConfig_style_inject, _pConfig_style_modules, _pConfig_style_autoModules, _pConfig_style_tailwindcss, _pConfig_externalHelpers, _pConfig_transformImport, _pConfig_sourceType, _pConfig_disableSwcTransform;
95
+ var _pConfig_format, _pConfig_target, _pConfig_sourceMap, _pConfig_copy, _pConfig_outDir, _pConfig_jsx, _pConfig_platform, _pConfig_splitting, _pConfig_minify, _pConfig_umdModuleName, _pConfig_sideEffects, _pConfig_style_inject, _pConfig_style_modules, _pConfig_style_autoModules, _pConfig_style_tailwindcss, _pConfig_externalHelpers, _pConfig_transformImport, _pConfig_transformLodash, _pConfig_sourceType, _pConfig_disableSwcTransform;
92
96
  return {
93
97
  asset: {
94
98
  ...defaultConfig.asset,
@@ -98,22 +102,22 @@ const mergeDefaultBaseConfig = async (pConfig, context) => {
98
102
  format: (_pConfig_format = pConfig.format) !== null && _pConfig_format !== void 0 ? _pConfig_format : defaultConfig.format,
99
103
  target: (_pConfig_target = pConfig.target) !== null && _pConfig_target !== void 0 ? _pConfig_target : defaultConfig.target,
100
104
  sourceMap: (_pConfig_sourceMap = pConfig.sourceMap) !== null && _pConfig_sourceMap !== void 0 ? _pConfig_sourceMap : defaultConfig.sourceMap,
101
- copy: (_pConfig_copy = pConfig.copy) !== null && _pConfig_copy !== void 0 ? _pConfig_copy : cloneDeep(defaultConfig.copy),
105
+ copy: (_pConfig_copy = pConfig.copy) !== null && _pConfig_copy !== void 0 ? _pConfig_copy : defaultConfig.copy,
102
106
  outDir: (_pConfig_outDir = pConfig.outDir) !== null && _pConfig_outDir !== void 0 ? _pConfig_outDir : defaultConfig.outDir,
103
- dts: await getDtsConfig(pConfig.dts, defaultConfig.dts),
107
+ dts,
104
108
  jsx: (_pConfig_jsx = pConfig.jsx) !== null && _pConfig_jsx !== void 0 ? _pConfig_jsx : defaultConfig.jsx,
105
- input: (_pConfig_input = pConfig.input) !== null && _pConfig_input !== void 0 ? _pConfig_input : cloneDeep(input),
109
+ input,
106
110
  platform: (_pConfig_platform = pConfig.platform) !== null && _pConfig_platform !== void 0 ? _pConfig_platform : defaultConfig.platform,
107
111
  splitting: (_pConfig_splitting = pConfig.splitting) !== null && _pConfig_splitting !== void 0 ? _pConfig_splitting : defaultConfig.splitting,
108
112
  minify: (_pConfig_minify = pConfig.minify) !== null && _pConfig_minify !== void 0 ? _pConfig_minify : defaultConfig.minify,
109
- autoExternal: (_pConfig_autoExternal = pConfig.autoExternal) !== null && _pConfig_autoExternal !== void 0 ? _pConfig_autoExternal : defaultConfig.autoExternal,
113
+ autoExternal,
110
114
  umdGlobals: {
111
115
  ...defaultConfig.umdGlobals,
112
116
  ...pConfig.umdGlobals
113
117
  },
114
118
  umdModuleName: (_pConfig_umdModuleName = pConfig.umdModuleName) !== null && _pConfig_umdModuleName !== void 0 ? _pConfig_umdModuleName : defaultConfig.umdModuleName,
115
119
  sideEffects: (_pConfig_sideEffects = pConfig.sideEffects) !== null && _pConfig_sideEffects !== void 0 ? _pConfig_sideEffects : defaultConfig.sideEffects,
116
- externals: (_pConfig_externals = pConfig.externals) !== null && _pConfig_externals !== void 0 ? _pConfig_externals : defaultConfig.externals,
120
+ externals,
117
121
  sourceDir,
118
122
  alias,
119
123
  define,
@@ -132,23 +136,11 @@ const mergeDefaultBaseConfig = async (pConfig, context) => {
132
136
  esbuildOptions,
133
137
  externalHelpers: (_pConfig_externalHelpers = pConfig.externalHelpers) !== null && _pConfig_externalHelpers !== void 0 ? _pConfig_externalHelpers : defaultConfig.externalHelpers,
134
138
  transformImport: (_pConfig_transformImport = pConfig.transformImport) !== null && _pConfig_transformImport !== void 0 ? _pConfig_transformImport : defaultConfig.transformImport,
139
+ transformLodash: (_pConfig_transformLodash = pConfig.transformLodash) !== null && _pConfig_transformLodash !== void 0 ? _pConfig_transformLodash : defaultConfig.transformLodash,
135
140
  sourceType: (_pConfig_sourceType = pConfig.sourceType) !== null && _pConfig_sourceType !== void 0 ? _pConfig_sourceType : defaultConfig.sourceType,
136
141
  disableSwcTransform: (_pConfig_disableSwcTransform = pConfig.disableSwcTransform) !== null && _pConfig_disableSwcTransform !== void 0 ? _pConfig_disableSwcTransform : defaultConfig.disableSwcTransform
137
142
  };
138
143
  };
139
- const getDtsConfig = async (userDTS, defaultDTS) => {
140
- const { cloneDeep, isUndefined, isObject } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils/lodash")));
141
- if (isUndefined(userDTS)) {
142
- return cloneDeep(defaultDTS);
143
- }
144
- if (isObject(userDTS)) {
145
- return {
146
- ...defaultDTS,
147
- ...userDTS
148
- };
149
- }
150
- return userDTS;
151
- };
152
144
  const isLegacyUserConfig = (config) => Boolean(config.legacy);
153
145
 
154
- //# sourceMappingURL=config.js.map
146
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAaaA,wBAAsB;WAAtBA;;EAiJAC,oBAAkB;WAAlBA;;;;uBA9JY;yBASE;uBACI;uBACO;AAE/B,MAAMD,yBAAyB,OACpCE,SACAC;MA0HYD,gBACCA,iBAEPA,iBAEAA;AA7HN,QAAME,iBAAgBC,iCAAqB;AAC3C,QAAM,EAAEC,SAASC,gBAAe,IAAKJ;AACrC,QAAM,EAAEK,mBAAmBC,oBAAoBC,MAAK,IAAK,MAAM,iFAC7D;AAEF,QAAM,EAAEC,qBAAoB,IAAK,MAAM,iFAAO;AAC9C,QAAM,EAAEC,eAAc,IAAK,MAAM,iFAAO;AACxC,QAAMC,eAAe;IACnB,KAAKP,QAAQQ;EACf;AACA,QAAMC,cAAcP,kBAAkBK,cAAcX,QAAQc,KAAK;AAOjE,QAAMA,QAAQC,OAAOC,KAAKH,aAAaI,OACrC,CAACC,MAAMC;AACL,UAAMC,iBAAiB,CAACC;AACtB,UAAI,OAAOA,WAAU,YAAYA,OAAMC,WAAW,MAAM;AACtD,eAAOd,MAAMD,mBAAmBH,QAAQmB,cAAcF;MACxD;AACA,aAAOA;IACT;AACA,UAAMA,QAAQD,eAAeP,YAAYM,KAAK;AAE9CD,SAAKC,QAAQE;AACb,WAAOH;EACT,GACA,C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,kDAAQkE,WAAK,QAAblE,oDAAemE,YAAM,QAArBnE,2DAAyBE,cAAcgE,MAAMC;MACrDC,UAASpE,oDAAQkE,WAAK,QAAblE,sDAAeoE,aAAO,QAAtBpE,6DAA0BE,cAAcgE,MAAME;MACvDC,cACErE,wDAAQkE,WAAK,QAAblE,sDAAeqE,iBAAW,QAA1BrE,qEAA8BE,cAAcgE,MAAMG;MACpDC,cACEtE,wDAAQkE,WAAK,QAAblE,sDAAesE,iBAAW,QAA1BtE,qEAA8BE,cAAcgE,MAAMI;IACtD;IACAC,UAAU;MACR,GAAGrE,cAAcqE;MACjB,GAAGvE,QAAQuE;IACb;IACAnB;IACAoB,kBAAiBxE,mCAAQwE,qBAAe,QAAvBxE,iEAA2BE,cAAcsE;IAC1DC,kBAAiBzE,mCAAQyE,qBAAe,QAAvBzE,iEAA2BE,cAAcuE;IAC1DC,kBAAiB1E,mCAAQ0E,qBAAe,QAAvB1E,iEAA2BE,cAAcwE;IAC1DC,aAAY3E,8BAAQ2E,gBAAU,QAAlB3E,uDAAsBE,cAAcyE;IAChDC,sBACE5E,uCAAQ4E,yBAAmB,QAA3B5E,yEAA+BE,cAAc0E;EACjD;AACF;AAEO,MAAM7E,qBAAqB,CAAC8E,WAEKC,QAAQD,OAAOE,MAAM;","names":["mergeDefaultBaseConfig","isLegacyUserConfig","pConfig","options","defaultConfig","getDefaultBuildConfig","context","buildCmdOptions","applyOptionsChain","ensureAbsolutePath","slash","getDefaultIndexEntry","getStyleConfig","defaultAlias","srcDirectory","mergedAlias","alias","Object","keys","reduce","prev","name","formattedValue","value","startsWith","appDirectory","styleConfig","buildType","sourceDir","metafile","defaultIndexEntry","input","normalizeInput","userDefine","define","memo","JSON","stringify","dts","cmdDts","tsconfig","cmdTsconfigPath","noDts","tsconfigPath","externals","autoExternal","deps","getAllDeps","isObject","dependencies","peerDependencies","map","dep","RegExp","esbuildOptions","asset","format","target","sourceMap","copy","outDir","jsx","platform","splitting","minify","umdGlobals","umdModuleName","sideEffects","style","inject","modules","autoModules","tailwindcss","redirect","externalHelpers","transformImport","transformLodash","sourceType","disableSwcTransform","config","Boolean","legacy"],"sources":["../../src/config/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/config/merge.ts"],"sourcesContent":["import { isObject } from '@modern-js/utils';\nimport { ModuleContext } from '../types';\nimport type {\n BaseBuildConfig,\n PartialBaseBuildConfig,\n DTSOptions,\n ModuleLegacyUserConfig,\n BuildCommandOptions,\n} from '../types';\nimport { getAllDeps } from '../utils/builder';\nimport { normalizeInput } from '../utils/input';\nimport { getDefaultBuildConfig } from '../constants/build';\n\nexport const mergeDefaultBaseConfig = async (\n pConfig: PartialBaseBuildConfig,\n options: { context: ModuleContext; buildCmdOptions: BuildCommandOptions },\n): Promise<BaseBuildConfig> => {\n const defaultConfig = getDefaultBuildConfig();\n const { context, buildCmdOptions } = options;\n const { applyOptionsChain, ensureAbsolutePath, slash } = await import(\n '@modern-js/utils'\n );\n const { getDefaultIndexEntry } = await import('../utils/input');\n const { getStyleConfig } = await import('../utils/style');\n const defaultAlias = {\n '@': context.srcDirectory,\n };\n const mergedAlias = applyOptionsChain(defaultAlias, pConfig.alias);\n\n /**\n * Format alias value:\n * - Relative paths need to be turned into absolute paths.\n * - Absolute paths or a package name are not processed.\n */\n const alias = Object.keys(mergedAlias).reduce<Record<string, string>>(\n (prev, name) => {\n const formattedValue = (value: string) => {\n if (typeof value === 'string' && value.startsWith('.')) {\n return slash(ensureAbsolutePath(context.appDirectory, value));\n }\n return value;\n };\n const value = formattedValue(mergedAlias[name]);\n\n prev[name] = value;\n return prev;\n },\n {},\n );\n\n const styleConfig = await getStyleConfig(pConfig);\n const buildType = pConfig.buildType ?? defaultConfig.buildType;\n const sourceDir = pConfig.sourceDir ?? defaultConfig.sourceDir;\n const metafile = pConfig.metafile ?? defaultConfig.metafile;\n const defaultIndexEntry =\n buildType === 'bundle' ? await getDefaultIndexEntry(context) : [sourceDir];\n const input = await normalizeInput(\n pConfig.input ?? defaultIndexEntry,\n context.appDirectory,\n );\n const userDefine = pConfig.define ?? {};\n const define = {\n ...defaultConfig.define,\n ...Object.keys(userDefine).reduce<Record<string, string>>((memo, name) => {\n memo[name] = JSON.stringify(userDefine[name]!);\n return memo;\n }, {}),\n };\n const { dts: cmdDts, tsconfig: cmdTsconfigPath } = buildCmdOptions;\n\n // Impact eslint complexity\n const noDts = cmdDts === false || pConfig.dts === false;\n\n const dts = noDts\n ? false\n : ({\n ...defaultConfig.dts,\n ...pConfig.dts,\n } as DTSOptions);\n\n if (dts) {\n if (cmdTsconfigPath) {\n dts.tsconfigPath = cmdTsconfigPath;\n }\n }\n let externals = pConfig.externals ?? defaultConfig.externals;\n\n const autoExternal = pConfig.autoExternal ?? defaultConfig.autoExternal;\n\n if (autoExternal) {\n const deps = await getAllDeps(\n context.appDirectory,\n isObject(autoExternal)\n ? autoExternal\n : {\n dependencies: true,\n peerDependencies: true,\n },\n );\n externals = [\n ...deps.map(dep => new RegExp(`^${dep}($|\\\\/|\\\\\\\\)`)),\n ...(externals || []),\n ];\n }\n\n const esbuildOptions = pConfig.esbuildOptions ?? defaultConfig.esbuildOptions;\n return {\n asset: {\n ...defaultConfig.asset,\n ...pConfig.asset,\n },\n buildType,\n format: pConfig.format ?? defaultConfig.format,\n target: pConfig.target ?? defaultConfig.target,\n sourceMap: pConfig.sourceMap ?? defaultConfig.sourceMap,\n copy: pConfig.copy ?? defaultConfig.copy,\n outDir: pConfig.outDir ?? defaultConfig.outDir,\n dts,\n jsx: pConfig.jsx ?? defaultConfig.jsx,\n input,\n platform: pConfig.platform ?? defaultConfig.platform,\n splitting: pConfig.splitting ?? defaultConfig.splitting,\n minify: pConfig.minify ?? defaultConfig.minify,\n autoExternal,\n umdGlobals: {\n ...defaultConfig.umdGlobals,\n ...pConfig.umdGlobals,\n },\n umdModuleName: pConfig.umdModuleName ?? defaultConfig.umdModuleName,\n sideEffects: pConfig.sideEffects ?? defaultConfig.sideEffects,\n externals,\n sourceDir,\n alias,\n define,\n metafile,\n style: {\n ...styleConfig,\n inject: pConfig.style?.inject ?? defaultConfig.style.inject,\n modules: pConfig.style?.modules ?? defaultConfig.style.modules,\n autoModules:\n pConfig.style?.autoModules ?? defaultConfig.style.autoModules,\n tailwindcss:\n pConfig.style?.tailwindcss ?? defaultConfig.style.tailwindcss,\n },\n redirect: {\n ...defaultConfig.redirect,\n ...pConfig.redirect,\n },\n esbuildOptions,\n externalHelpers: pConfig.externalHelpers ?? defaultConfig.externalHelpers,\n transformImport: pConfig.transformImport ?? defaultConfig.transformImport,\n transformLodash: pConfig.transformLodash ?? defaultConfig.transformLodash,\n sourceType: pConfig.sourceType ?? defaultConfig.sourceType,\n disableSwcTransform:\n pConfig.disableSwcTransform ?? defaultConfig.disableSwcTransform,\n };\n};\n\nexport const isLegacyUserConfig = (config: {\n legacy?: boolean;\n}): config is ModuleLegacyUserConfig => Boolean(config.legacy);\n"]}
@@ -1,17 +1,9 @@
1
1
  import type { PluginAPI } from '@modern-js/core';
2
- import type { ModuleUserConfig, BaseBuildConfig, BuildPreset, PartialBuildConfig, PartialBaseBuildConfig, ModuleContext, BuildCommandOptions, ModuleTools } from '../types';
3
- export declare const transformBuildPresetToBaseConfigs: (options: {
4
- context: ModuleContext;
5
- buildCmdOptions: BuildCommandOptions;
6
- }, preset?: BuildPreset) => Promise<BaseBuildConfig[]>;
7
- export declare const transformBuildConfigToBaseConfigs: (config: PartialBuildConfig, options: {
8
- buildCmdOptions: BuildCommandOptions;
9
- context: ModuleContext;
10
- }) => Promise<BaseBuildConfig[]>;
11
- export declare const requiredBuildConfig: (partialBuildConfig: PartialBaseBuildConfig, context: ModuleContext) => Promise<BaseBuildConfig>;
2
+ import type { BaseBuildConfig, BuildPreset, PartialBuildConfig, PartialBaseBuildConfig, ModuleContext, BuildCommandOptions, ModuleTools } from '../types';
3
+ export declare const presetToConfig: (preset?: BuildPreset) => Promise<PartialBaseBuildConfig[] | undefined>;
4
+ export declare const mergeConfig: (low?: PartialBaseBuildConfig[], high?: PartialBuildConfig) => PartialBaseBuildConfig[];
5
+ export declare const normalizeBuildConfig: (api: PluginAPI<ModuleTools>, context: ModuleContext, buildCmdOptions: BuildCommandOptions) => Promise<BaseBuildConfig[]>;
12
6
  export declare const transformToAbsPath: (baseConfig: BaseBuildConfig, options: {
13
7
  context: ModuleContext;
14
8
  buildCmdOptions: BuildCommandOptions;
15
- }) => Promise<BaseBuildConfig>;
16
- export declare const checkConfig: (config: ModuleUserConfig) => Promise<void>;
17
- export declare const normalizeBuildConfig: (api: PluginAPI<ModuleTools>, context: ModuleContext, buildCmdOptions: BuildCommandOptions) => Promise<BaseBuildConfig[]>;
9
+ }) => Promise<BaseBuildConfig>;
@@ -10,130 +10,94 @@ function _export(target, all) {
10
10
  });
11
11
  }
12
12
  _export(exports, {
13
- transformBuildPresetToBaseConfigs: function() {
14
- return transformBuildPresetToBaseConfigs;
13
+ presetToConfig: function() {
14
+ return presetToConfig;
15
15
  },
16
- transformBuildConfigToBaseConfigs: function() {
17
- return transformBuildConfigToBaseConfigs;
16
+ mergeConfig: function() {
17
+ return mergeConfig;
18
18
  },
19
- requiredBuildConfig: function() {
20
- return requiredBuildConfig;
19
+ normalizeBuildConfig: function() {
20
+ return normalizeBuildConfig;
21
21
  },
22
22
  transformToAbsPath: function() {
23
23
  return transformToAbsPath;
24
- },
25
- checkConfig: function() {
26
- return checkConfig;
27
- },
28
- normalizeBuildConfig: function() {
29
- return normalizeBuildConfig;
30
24
  }
31
25
  });
32
26
  const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
33
27
  const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
34
28
  const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
35
- const transformBuildPresetToBaseConfigs = async (options, preset) => {
36
- const { BuildInPreset, presetList } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/buildPresets")));
37
- const { addInputToPreset } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/input")));
29
+ const _lodash = /* @__PURE__ */ _interop_require_default._(require("@modern-js/utils/lodash"));
30
+ const _utils = require("@modern-js/utils");
31
+ const _preset = require("../constants/preset");
32
+ const _merge = require("./merge");
33
+ const _valid = require("./valid");
34
+ const presetToConfig = async (preset) => {
38
35
  if (typeof preset === "function") {
39
36
  const extendPreset = (presetName, extendConfig) => {
40
- const originalBuildConfig = BuildInPreset[presetName];
41
- if (Array.isArray(originalBuildConfig)) {
42
- return originalBuildConfig.map((config) => {
43
- return {
44
- ...config,
45
- ...extendConfig
46
- };
47
- });
48
- } else if (originalBuildConfig) {
49
- return {
50
- ...originalBuildConfig,
51
- ...extendConfig
52
- };
37
+ const originalBuildConfig = _preset.internalPreset[presetName];
38
+ if (!originalBuildConfig) {
39
+ throw new Error(`**${presetName}** is not internal buildPreset`);
53
40
  }
54
- return extendConfig;
41
+ return originalBuildConfig.map((config) => {
42
+ return _lodash.default.merge(config, extendConfig);
43
+ });
55
44
  };
56
45
  const partialBuildConfig = await preset({
57
- preset: BuildInPreset,
46
+ preset: _preset.internalPreset,
58
47
  extendPreset
59
48
  });
60
49
  if (!partialBuildConfig) {
61
50
  throw new Error("The `buildPreset` function does not allow no return value");
62
51
  }
63
- return transformBuildConfigToBaseConfigs(partialBuildConfig, options);
64
- }
65
- const inPresetList = (p) => p in presetList;
66
- if (preset && inPresetList(preset)) {
67
- return transformBuildConfigToBaseConfigs(await addInputToPreset(presetList[preset], options.context), options);
68
- }
69
- return transformBuildConfigToBaseConfigs({}, options);
70
- };
71
- const transformBuildConfigToBaseConfigs = async (config, options) => {
72
- const { validPartialBuildConfig } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/config")));
73
- validPartialBuildConfig(config);
74
- const { buildCmdOptions } = options;
75
- const { ensureArray } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
76
- const { assignTsConfigPath } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/dts")));
77
- const partialConfigs = ensureArray(config);
78
- const configs = await Promise.all(partialConfigs.map(async (config2) => {
79
- let newConfig = await requiredBuildConfig(config2, options.context);
80
- newConfig = await assignTsConfigPath(newConfig, buildCmdOptions);
81
- newConfig = await transformToAbsPath(newConfig, options);
82
- return newConfig;
83
- }));
84
- return configs;
85
- };
86
- const requiredBuildConfig = async (partialBuildConfig, context) => {
87
- const { mergeDefaultBaseConfig } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/config")));
88
- const mergedConfig = await mergeDefaultBaseConfig(partialBuildConfig, context);
89
- return mergedConfig;
90
- };
91
- const transformToAbsPath = async (baseConfig, options) => {
92
- const { slash } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
93
- const newConfig = baseConfig;
94
- const { normalizeInput } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/input")));
95
- const { context } = options;
96
- newConfig.outDir = _path.default.isAbsolute(newConfig.outDir) ? newConfig.outDir : _path.default.join(context.appDirectory, newConfig.outDir);
97
- newConfig.sourceDir = slash(_path.default.resolve(context.appDirectory, baseConfig.sourceDir));
98
- newConfig.input = await normalizeInput(newConfig, {
99
- appDirectory: context.appDirectory
100
- });
101
- if (newConfig.dts) {
102
- newConfig.dts.distPath = _path.default.join(newConfig.outDir, newConfig.dts.distPath);
103
- newConfig.dts.tsconfigPath = _path.default.join(context.appDirectory, newConfig.dts.tsconfigPath);
52
+ return partialBuildConfig;
104
53
  }
105
- return newConfig;
54
+ const inPresetList = (p) => p in _preset.presetList;
55
+ return preset && inPresetList(preset) ? _preset.presetList[preset] : void 0;
106
56
  };
107
- const checkConfig = async (config) => {
108
- const { buildConfig, buildPreset } = config;
109
- if (buildConfig && buildPreset) {
110
- const { logger } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
111
- const local = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../locale")));
112
- logger.warn(local.i18n.t(local.localeKeys.log.buildConfigTip));
57
+ const mergeConfig = (low, high = {}) => {
58
+ if (!low) {
59
+ return (0, _utils.ensureArray)(high);
113
60
  }
61
+ return Array.isArray(high) ? [
62
+ ...low,
63
+ ...high
64
+ ] : low.map((config) => {
65
+ return _lodash.default.merge(config, high);
66
+ });
114
67
  };
115
68
  const normalizeBuildConfig = async (api, context, buildCmdOptions) => {
116
- const { isLegacyUserConfig } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/config")));
117
69
  let config = api.useConfigContext();
118
- if (isLegacyUserConfig(config)) {
70
+ if ((0, _merge.isLegacyUserConfig)(config)) {
119
71
  const { createUserConfigFromLegacy } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./transformLegacyConfig")));
120
72
  config = await createUserConfigFromLegacy(config);
121
73
  }
122
74
  const { buildConfig, buildPreset } = config;
123
- await checkConfig(config);
124
- let baseConfigs;
125
- if (buildConfig) {
126
- baseConfigs = await transformBuildConfigToBaseConfigs(buildConfig, {
127
- buildCmdOptions,
128
- context
75
+ const configFromPreset = await presetToConfig(buildPreset);
76
+ const mergedConfig = mergeConfig(configFromPreset, buildConfig !== null && buildConfig !== void 0 ? buildConfig : {});
77
+ (0, _valid.validPartialBuildConfig)(mergedConfig);
78
+ const normalizedConfig = await Promise.all(mergedConfig.map(async (config2) => {
79
+ let newConfig = await (0, _merge.mergeDefaultBaseConfig)(config2, {
80
+ context,
81
+ buildCmdOptions
129
82
  });
130
- } else {
131
- baseConfigs = await transformBuildPresetToBaseConfigs({
83
+ newConfig = await transformToAbsPath(newConfig, {
132
84
  context,
133
85
  buildCmdOptions
134
- }, buildPreset);
86
+ });
87
+ return newConfig;
88
+ }));
89
+ return normalizedConfig;
90
+ };
91
+ const transformToAbsPath = async (baseConfig, options) => {
92
+ const newConfig = baseConfig;
93
+ const { context } = options;
94
+ newConfig.outDir = _path.default.resolve(context.appDirectory, newConfig.outDir);
95
+ newConfig.sourceDir = (0, _utils.slash)(_path.default.resolve(context.appDirectory, baseConfig.sourceDir));
96
+ if (newConfig.dts) {
97
+ newConfig.dts.distPath = _path.default.resolve(newConfig.outDir, newConfig.dts.distPath);
98
+ newConfig.dts.tsconfigPath = _path.default.resolve(context.appDirectory, newConfig.dts.tsconfigPath);
135
99
  }
136
- return baseConfigs;
100
+ return newConfig;
137
101
  };
138
102
 
139
103
  //# sourceMappingURL=normalize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAcaA,mCAAiC;WAAjCA;;EA8DAC,mCAAiC;WAAjCA;;EAwBAC,qBAAmB;WAAnBA;;EAYAC,oBAAkB;WAAlBA;;EAqCAC,aAAW;WAAXA;;EASAC,sBAAoB;WAApBA;;;;;iEA9JI;AAcV,MAAML,oCAAoC,OAC/CM,SAIAC;AAEA,QAAM,EAAEC,eAAeC,WAAU,IAAK,MAAM,iFAC1C;AAEF,QAAM,EAAEC,iBAAgB,IAAK,MAAM,iFAAO;AAE1C,MAAI,OAAOH,WAAW,YAAY;AAChC,UAAMI,eAAe,CACnBC,YACAC;AAEA,YAAMC,sBAAsBN,cAAcI;AAC1C,UAAIG,MAAMC,QAAQF,sBAAsB;AACtC,eAAOA,oBAAoBG,IAAIC;AAC7B,iBAAO;YACL,GAAGA;YACH,GAAGL;UACL;QACF;MACF,WAAWC,qBAAqB;AAC9B,eAAO;UACL,GAAGA;UACH,GAAGD;QACL;MACF;AAEA,aAAOA;IACT;AACA,UAAMM,qBAAqB,MAAMZ,OAAO;MACtCA,QAAQC;MACRG;IACF;AAEA,QAAI,CAACQ,oBAAoB;AACvB,YAAM,IAAIC,MACR;IAEJ;AAEA,WAAOnB,kCAAkCkB,oBAAoBb;EAC/D;AAEA,QAAMe,eAAe,CAACC,MACpBA,KAAKb;AAEP,MAAIF,UAAUc,aAAad,SAAS;AAClC,WAAON,kCACL,MAAMS,iBAAiBD,W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WAAWR,cAAKE,KAC5BT,UAAUM,QACVN,UAAUc,IAAIC,QAAQ;AAExBf,cAAUc,IAAIE,eAAeT,cAAKE,KAChClB,QAAQmB,cACRV,UAAUc,IAAIE,YAAY;EAE9B;AAIA,SAAOhB;AACT;AAEO,MAAM5B,cAAc,OAAOc;AAChC,QAAM,EAAE+B,aAAaC,YAAW,IAAKhC;AACrC,MAAI+B,eAAeC,aAAa;AAC9B,UAAM,EAAEC,OAAM,IAAK,MAAM,iFAAO;AAChC,UAAMC,QAAQ,MAAM,iFAAO;AAC3BD,WAAOE,KAAKD,MAAME,KAAKC,EAAEH,MAAMI,WAAWC,IAAIC,cAAc;EAC9D;AACF;AAEO,MAAMrD,uBAAuB,OAClCsD,KACApC,SACAE;AAEA,QAAM,EAAEmC,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,MAAI1C,SAASyC,IAAIE,iBAAgB;AAEjC,MAAID,mBAAmB1C,SAAiC;AACtD,UAAM,EAAE4C,2BAA0B,IAAK,MAAM,iFAC3C;AAEF5C,aAAS,MAAM4C,2BAA2B5C;EAC5C;AAEA,QAAM,EAAE+B,aAAaC,YAAW,IAAKhC;AAErC,QAAMd,YAAYc;AAElB,MAAI6C;AAGJ,MAAId,aAAa;AACfc,kBAAc,MAAM9D,kCAAkCgD,aAAa;MACjExB;MACAF;IACF;EACF,OAAO;AACLwC,kBAAc,MAAM/D,kCAClB;MACEuB;MACAE;IACF,GACAyB;EAEJ;AAEA,SAAOa;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","local","warn","i18n","t","localeKeys","log","buildConfigTip","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 const local = await import('../locale');\n logger.warn(local.i18n.t(local.localeKeys.log.buildConfigTip));\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"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAmBaA,gBAAc;WAAdA;;EAmCAC,aAAW;WAAXA;;EAcAC,sBAAoB;WAApBA;;EAuCAC,oBAAkB;WAAlBA;;;;;iEA3GI;mEAEH;uBACqB;wBAYQ;uBACgB;uBACnB;AAEjC,MAAMH,iBAAiB,OAAOI;AACnC,MAAI,OAAOA,WAAW,YAAY;AAChC,UAAMC,eAAe,CACnBC,YACAC;AAEA,YAAMC,sBAAsBC,uBAAeH;AAC3C,UAAI,CAACE,qBAAqB;AACxB,cAAM,IAAIE,MAAM,KAAKJ,0CAA0C;MACjE;AACA,aAAOE,oBAAoBG,IAAIC;AAC7B,eAAOC,gBAAEC,MAAMF,QAAQL;MACzB;IACF;AAEA,UAAMQ,qBAAqB,MAAMX,OAAO;MACtCA,QAAQK;MACRJ;IACF;AAEA,QAAI,CAACU,oBAAoB;AACvB,YAAM,IAAIL,MACR;IAEJ;AAEA,WAAOK;EACT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Q;AAExBX,cAAUU,IAAIE,eAAeP,cAAKC,QAChCnB,QAAQoB,cACRP,UAAUU,IAAIE,YAAY;EAE9B;AAEA,SAAOZ;AACT;","names":["presetToConfig","mergeConfig","normalizeBuildConfig","transformToAbsPath","preset","extendPreset","presetName","extendConfig","originalBuildConfig","internalPreset","Error","map","config","_","merge","partialBuildConfig","inPresetList","p","presetList","undefined","low","high","ensureArray","Array","isArray","api","context","buildCmdOptions","useConfigContext","isLegacyUserConfig","createUserConfigFromLegacy","buildConfig","buildPreset","configFromPreset","mergedConfig","validPartialBuildConfig","normalizedConfig","Promise","all","newConfig","mergeDefaultBaseConfig","baseConfig","options","outDir","path","resolve","appDirectory","sourceDir","slash","dts","distPath","tsconfigPath"],"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 _ from '@modern-js/utils/lodash';\nimport { ensureArray, slash } from '@modern-js/utils';\nimport type {\n ModuleUserConfig,\n ModuleLegacyUserConfig,\n BaseBuildConfig,\n BuildPreset,\n PartialBuildConfig,\n PartialBaseBuildConfig,\n ModuleContext,\n BuildCommandOptions,\n ModuleTools,\n} from '../types';\nimport { internalPreset, presetList } from '../constants/preset';\nimport { isLegacyUserConfig, mergeDefaultBaseConfig } from './merge';\nimport { validPartialBuildConfig } from './valid';\n\nexport const presetToConfig = async (preset?: BuildPreset) => {\n if (typeof preset === 'function') {\n const extendPreset = (\n presetName: keyof typeof internalPreset,\n extendConfig: PartialBaseBuildConfig,\n ) => {\n const originalBuildConfig = internalPreset[presetName];\n if (!originalBuildConfig) {\n throw new Error(`**${presetName}** is not internal buildPreset`);\n }\n return originalBuildConfig.map(config => {\n return _.merge(config, extendConfig);\n });\n };\n\n const partialBuildConfig = await preset({\n preset: internalPreset,\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 partialBuildConfig;\n }\n\n const inPresetList = (p: string): p is keyof typeof presetList =>\n p in presetList;\n\n return preset && inPresetList(preset) ? presetList[preset] : undefined;\n};\n\nexport const mergeConfig = (\n low?: PartialBaseBuildConfig[],\n high = {} as PartialBuildConfig,\n): PartialBaseBuildConfig[] => {\n if (!low) {\n return ensureArray(high);\n }\n return Array.isArray(high)\n ? [...low, ...high]\n : low.map(config => {\n return _.merge(config, high);\n });\n};\n\nexport const normalizeBuildConfig = async (\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n buildCmdOptions: BuildCommandOptions,\n): Promise<BaseBuildConfig[]> => {\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 const configFromPreset = await presetToConfig(buildPreset);\n\n const mergedConfig = mergeConfig(configFromPreset, buildConfig ?? {});\n\n validPartialBuildConfig(mergedConfig);\n\n const normalizedConfig = await Promise.all(\n mergedConfig.map(async config => {\n let newConfig = await mergeDefaultBaseConfig(config, {\n context,\n buildCmdOptions,\n });\n newConfig = await transformToAbsPath(newConfig, {\n context,\n buildCmdOptions,\n });\n return newConfig;\n }),\n );\n\n return normalizedConfig;\n};\n\nexport const transformToAbsPath = async (\n baseConfig: BaseBuildConfig,\n options: { context: ModuleContext; buildCmdOptions: BuildCommandOptions },\n) => {\n const newConfig = baseConfig;\n const { context } = options;\n\n newConfig.outDir = path.resolve(context.appDirectory, newConfig.outDir);\n\n newConfig.sourceDir = slash(\n path.resolve(context.appDirectory, baseConfig.sourceDir),\n );\n\n // dts path\n if (newConfig.dts) {\n newConfig.dts.distPath = path.resolve(\n newConfig.outDir,\n newConfig.dts.distPath,\n );\n newConfig.dts.tsconfigPath = path.resolve(\n context.appDirectory,\n newConfig.dts.tsconfigPath,\n );\n }\n\n return newConfig;\n};\n"]}
@@ -188,6 +188,9 @@ export declare const buildConfig: {
188
188
  transformImport: {
189
189
  type: string;
190
190
  };
191
+ transformLodash: {
192
+ type: string;
193
+ };
191
194
  sourceType: {
192
195
  enum: string[];
193
196
  };
@@ -375,6 +378,9 @@ export declare const buildConfig: {
375
378
  transformImport: {
376
379
  type: string;
377
380
  };
381
+ transformLodash: {
382
+ type: string;
383
+ };
378
384
  sourceType: {
379
385
  enum: string[];
380
386
  };
@@ -590,6 +596,9 @@ export declare const schema: ({
590
596
  transformImport: {
591
597
  type: string;
592
598
  };
599
+ transformLodash: {
600
+ type: string;
601
+ };
593
602
  sourceType: {
594
603
  enum: string[];
595
604
  };
@@ -777,6 +786,9 @@ export declare const schema: ({
777
786
  transformImport: {
778
787
  type: string;
779
788
  };
789
+ transformLodash: {
790
+ type: string;
791
+ };
780
792
  sourceType: {
781
793
  enum: string[];
782
794
  };
@@ -276,6 +276,9 @@ const buildConfigProperties = {
276
276
  transformImport: {
277
277
  type: "array"
278
278
  },
279
+ transformLodash: {
280
+ type: "boolean"
281
+ },
279
282
  sourceType: {
280
283
  enum: [
281
284
  "commonjs",
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAAaA,SAAO;WAAPA;;EAeAC,SAAO;WAAPA;;EA6KAC,aAAW;WAAXA;;EAoBAC,aAAW;WAAXA;;EAWAC,QAAM;WAANA;;EAOAC,QAAM;WAANA;;EACJC,cAAY;WAAZA;;;8BAAoB;AAnOtB,MAAMN,UAAU;EACrB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;AAGK,MAAMC,UAAU;EACrB;EACA;EACA;EACA;KACG;IACD;IACA;IACA;IACA;IACAM,OAAiB,CAACC,KAAKC;AACvB,WAAO;SAAID;SAAQR,QAAQU,IAAIC,OAAK,GAAGF,OAAOE,GAAG;;EACnD,GAAG,EAAE;EACL;EACA;;AAEF,MAAMC,wBAAwB;EAC5BC,OAAO;IACLC,QAAQ;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AC;QAAW;QAAU;;IAAO;EAC7C;EACAuB,QAAQ;IAAEhC,MAAM;EAAS;EACzBiC,UAAU;IACRxB,MAAM;MAAC;MAAQ;;EACjB;EACAyB,WAAW;IACTpC,QAAQ;EACV;EACAqC,WAAW;IACT1B,MAAM;MAAC;MAAM;MAAO;MAAU;;EAChC;EACA2B,WAAW;IACTpC,MAAM;EACR;EACAqC,OAAO;;IAELrC,MAAM;EACR;EACAsC,UAAU;IACRtC,MAAM;EACR;EACAuC,QAAQ;IACN9B,MAAMzB;EACR;EACAwD,YAAY;IACVxC,MAAM;EACR;EACAyC,gBAAgB;IACdd,YAAY;EACd;EACAe,eAAe;IACbhB,OAAO;MACL;QACEC,YAAY;MACd;MACA;QACE7B,QAAQ;MACV;;EAEJ;EACA6C,aAAa;IACXjB,OAAO;MACL;QACE1B,MAAM;QACNY,OAAO;UACLe,YAAY;QACd;MACF;MACA;QACE3B,MAAM;MACR;MACA;QACE2B,YAAY;MACd;;EAEJ;EACAiB,iBAAiB;IACf5C,MAAM;EACR;EACA6C,iBAAiB;IACf7C,MAAM;EACR;EACA8C,YAAY;IACVrC,MAAM;MAAC;MAAY;;EACrB;AACF;AACO,MAAMvB,cAAc;EACzBqD,QAAQ;EACRlD,QAAQ;IACNa,IAAI;MACFF,MAAM;IACR;IACAG,MAAM;MACJS,OAAO;QACL;UACEZ,MAAM;UACNI,YAAYR;QACd;;IAEJ;IACAW,MAAM;MACJP,MAAM;MACNI,YAAYR;IACd;EACF;AACF;AACO,MAAMT,cAAc;EACzBoD,QAAQ;EACRlD,QAAQ;IACNa,IAAI;MAAEF,MAAM;IAAS;IACrBG,MAAM;MACJM,MAAMxB;IACR;IACAsB,MAAM;MAAET,QAAQ;IAAW;EAC7B;AACF;AAEO,MAAMV,SAAS;EACpBmD,QAAQ;EACRlD,QAAQ;IACNW,MAAM;EACR;AACF;AAEO,MAAMX,SAAS;EAACH;EAAaC;EAAaC;;","names":["targets","presets","buildConfig","buildPreset","legacy","schema","legacySchema","reduce","ret","crt","map","t","buildConfigProperties","alias","typeof","asset","type","autoExternal","if","then","properties","dependencies","peerDependencies","else","buildType","enum","copy","patterns","items","from","to","context","globOptions","options","concurrency","define","dts","distPath","tsconfigPath","abortOnError","respectExternal","externals","anyOf","instanceof","format","input","jsx","minify","outDir","platform","sourceDir","sourceMap","splitting","style","redirect","target","umdGlobals","esbuildOpitons","umdModuleName","sideEffects","externalHelpers","transformImport","sourceType"],"sources":["../../src/config/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/config/schema.ts"],"sourcesContent":["export const targets = [\n 'es5',\n 'es6',\n 'es2015',\n 'es2016',\n 'es2017',\n 'es2018',\n 'es2019',\n 'es2020',\n 'es2021',\n 'es2022',\n // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.\n 'esnext',\n];\n\nexport const presets = [\n 'npm-library',\n 'npm-library-with-umd',\n 'npm-component',\n 'npm-component-with-umd',\n ...[\n 'npm-library',\n 'npm-library-with-umd',\n 'npm-component',\n 'npm-component-with-umd',\n ].reduce<string[]>((ret, crt) => {\n return [...ret, ...targets.map(t => `${crt}-${t}`)];\n }, []),\n 'modern-js-node',\n 'modern-js-universal',\n];\nconst buildConfigProperties = {\n alias: {\n typeof: ['object', 'function'],\n },\n asset: {\n type: 'object',\n },\n autoExternal: {\n if: {\n type: 'object',\n },\n then: {\n properties: {\n dependencies: { type: 'boolean' },\n peerDependencies: { type: 'boolean' },\n },\n },\n else: { type: 'boolean' },\n },\n buildType: {\n enum: ['bundle', 'bundleless'],\n },\n copy: {\n type: 'object',\n properties: {\n patterns: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n from: { type: 'string' },\n to: { type: 'string' },\n context: { type: 'string' },\n globOptions: { type: 'object' },\n },\n },\n },\n options: {\n type: 'object',\n properties: {\n concurrency: {\n type: 'number',\n },\n },\n },\n },\n },\n define: {\n typeof: 'object',\n },\n dts: {\n if: { type: 'object' },\n then: {\n properties: {\n distPath: { type: 'string' },\n tsconfigPath: { type: 'string' },\n abortOnError: { type: 'boolean' },\n respectExternal: {\n type: 'boolean',\n },\n },\n },\n else: { type: 'boolean' },\n },\n externals: {\n type: 'array',\n items: {\n anyOf: [\n {\n instanceof: 'RegExp',\n },\n {\n typeof: 'string',\n },\n ],\n },\n },\n format: {\n enum: ['cjs', 'esm', 'iife', 'umd'],\n },\n input: {\n type: ['array', 'object'],\n },\n jsx: {\n enum: ['automatic', 'transform'],\n },\n minify: {\n if: {\n type: 'object',\n },\n else: { enum: ['esbuild', 'terser', false] },\n },\n outDir: { type: 'string' },\n platform: {\n enum: ['node', 'browser'],\n },\n sourceDir: {\n typeof: 'string',\n },\n sourceMap: {\n enum: [true, false, 'inline', 'external'],\n },\n splitting: {\n type: 'boolean',\n },\n style: {\n // TODO: add properties\n type: 'object',\n },\n redirect: {\n type: 'object',\n },\n target: {\n enum: targets,\n },\n umdGlobals: {\n type: 'object',\n },\n esbuildOpitons: {\n instanceof: 'Function',\n },\n umdModuleName: {\n anyOf: [\n {\n instanceof: 'Function',\n },\n {\n typeof: 'string',\n },\n ],\n },\n sideEffects: {\n anyOf: [\n {\n type: 'array',\n items: {\n instanceof: 'RegExp',\n },\n },\n {\n type: 'boolean',\n },\n {\n instanceof: 'Function',\n },\n ],\n },\n externalHelpers: {\n type: 'boolean',\n },\n transformImport: {\n type: 'array',\n },\n sourceType: {\n enum: ['commonjs', 'module'],\n },\n};\nexport const buildConfig = {\n target: 'buildConfig',\n schema: {\n if: {\n type: 'array',\n },\n then: {\n items: [\n {\n type: 'object',\n properties: buildConfigProperties,\n },\n ],\n },\n else: {\n type: 'object',\n properties: buildConfigProperties,\n },\n },\n};\nexport const buildPreset = {\n target: 'buildPreset',\n schema: {\n if: { type: 'string' },\n then: {\n enum: presets,\n },\n else: { typeof: 'function' },\n },\n};\n\nexport const legacy = {\n target: 'legacy',\n schema: {\n type: 'boolean',\n },\n};\n\nexport const schema = [buildConfig, buildPreset, legacy];\nexport { legacySchema } from './legacySchema';\n"]}
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AAY;IACVtC,MAAM;MAAC;MAAY;;EACrB;AACF;AACO,MAAMvB,cAAc;EACzBqD,QAAQ;EACRlD,QAAQ;IACNa,IAAI;MACFF,MAAM;IACR;IACAG,MAAM;MACJS,OAAO;QACL;UACEZ,MAAM;UACNI,YAAYR;QACd;;IAEJ;IACAW,MAAM;MACJP,MAAM;MACNI,YAAYR;IACd;EACF;AACF;AACO,MAAMT,cAAc;EACzBoD,QAAQ;EACRlD,QAAQ;IACNa,IAAI;MAAEF,MAAM;IAAS;IACrBG,MAAM;MACJM,MAAMxB;IACR;IACAsB,MAAM;MAAET,QAAQ;IAAW;EAC7B;AACF;AAEO,MAAMV,SAAS;EACpBmD,QAAQ;EACRlD,QAAQ;IACNW,MAAM;EACR;AACF;AAEO,MAAMX,SAAS;EAACH;EAAaC;EAAaC;;","names":["targets","presets","buildConfig","buildPreset","legacy","schema","legacySchema","reduce","ret","crt","map","t","buildConfigProperties","alias","typeof","asset","type","autoExternal","if","then","properties","dependencies","peerDependencies","else","buildType","enum","copy","patterns","items","from","to","context","globOptions","options","concurrency","define","dts","distPath","tsconfigPath","abortOnError","respectExternal","externals","anyOf","instanceof","format","input","jsx","minify","outDir","platform","sourceDir","sourceMap","splitting","style","redirect","target","umdGlobals","esbuildOpitons","umdModuleName","sideEffects","externalHelpers","transformImport","transformLodash","sourceType"],"sources":["../../src/config/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/config/schema.ts"],"sourcesContent":["export const targets = [\n 'es5',\n 'es6',\n 'es2015',\n 'es2016',\n 'es2017',\n 'es2018',\n 'es2019',\n 'es2020',\n 'es2021',\n 'es2022',\n // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.\n 'esnext',\n];\n\nexport const presets = [\n 'npm-library',\n 'npm-library-with-umd',\n 'npm-component',\n 'npm-component-with-umd',\n ...[\n 'npm-library',\n 'npm-library-with-umd',\n 'npm-component',\n 'npm-component-with-umd',\n ].reduce<string[]>((ret, crt) => {\n return [...ret, ...targets.map(t => `${crt}-${t}`)];\n }, []),\n 'modern-js-node',\n 'modern-js-universal',\n];\nconst buildConfigProperties = {\n alias: {\n typeof: ['object', 'function'],\n },\n asset: {\n type: 'object',\n },\n autoExternal: {\n if: {\n type: 'object',\n },\n then: {\n properties: {\n dependencies: { type: 'boolean' },\n peerDependencies: { type: 'boolean' },\n },\n },\n else: { type: 'boolean' },\n },\n buildType: {\n enum: ['bundle', 'bundleless'],\n },\n copy: {\n type: 'object',\n properties: {\n patterns: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n from: { type: 'string' },\n to: { type: 'string' },\n context: { type: 'string' },\n globOptions: { type: 'object' },\n },\n },\n },\n options: {\n type: 'object',\n properties: {\n concurrency: {\n type: 'number',\n },\n },\n },\n },\n },\n define: {\n typeof: 'object',\n },\n dts: {\n if: { type: 'object' },\n then: {\n properties: {\n distPath: { type: 'string' },\n tsconfigPath: { type: 'string' },\n abortOnError: { type: 'boolean' },\n respectExternal: {\n type: 'boolean',\n },\n },\n },\n else: { type: 'boolean' },\n },\n externals: {\n type: 'array',\n items: {\n anyOf: [\n {\n instanceof: 'RegExp',\n },\n {\n typeof: 'string',\n },\n ],\n },\n },\n format: {\n enum: ['cjs', 'esm', 'iife', 'umd'],\n },\n input: {\n type: ['array', 'object'],\n },\n jsx: {\n enum: ['automatic', 'transform'],\n },\n minify: {\n if: {\n type: 'object',\n },\n else: { enum: ['esbuild', 'terser', false] },\n },\n outDir: { type: 'string' },\n platform: {\n enum: ['node', 'browser'],\n },\n sourceDir: {\n typeof: 'string',\n },\n sourceMap: {\n enum: [true, false, 'inline', 'external'],\n },\n splitting: {\n type: 'boolean',\n },\n style: {\n // TODO: add properties\n type: 'object',\n },\n redirect: {\n type: 'object',\n },\n target: {\n enum: targets,\n },\n umdGlobals: {\n type: 'object',\n },\n esbuildOpitons: {\n instanceof: 'Function',\n },\n umdModuleName: {\n anyOf: [\n {\n instanceof: 'Function',\n },\n {\n typeof: 'string',\n },\n ],\n },\n sideEffects: {\n anyOf: [\n {\n type: 'array',\n items: {\n instanceof: 'RegExp',\n },\n },\n {\n type: 'boolean',\n },\n {\n instanceof: 'Function',\n },\n ],\n },\n externalHelpers: {\n type: 'boolean',\n },\n transformImport: {\n type: 'array',\n },\n transformLodash: {\n type: 'boolean',\n },\n sourceType: {\n enum: ['commonjs', 'module'],\n },\n};\nexport const buildConfig = {\n target: 'buildConfig',\n schema: {\n if: {\n type: 'array',\n },\n then: {\n items: [\n {\n type: 'object',\n properties: buildConfigProperties,\n },\n ],\n },\n else: {\n type: 'object',\n properties: buildConfigProperties,\n },\n },\n};\nexport const buildPreset = {\n target: 'buildPreset',\n schema: {\n if: { type: 'string' },\n then: {\n enum: presets,\n },\n else: { typeof: 'function' },\n },\n};\n\nexport const legacy = {\n target: 'legacy',\n schema: {\n type: 'boolean',\n },\n};\n\nexport const schema = [buildConfig, buildPreset, legacy];\nexport { legacySchema } from './legacySchema';\n"]}