@modern-js/module-tools 2.0.0-beta.0 → 2.0.0-beta.2

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 (98) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/dist/js/modern/cli/build.js +2 -1
  3. package/dist/js/modern/cli/dev.js +2 -2
  4. package/dist/js/modern/cli/new.js +0 -3
  5. package/dist/js/modern/commands/build.js +2 -6
  6. package/dist/js/modern/commands/dev.js +2 -5
  7. package/dist/js/modern/features/build/build-platform.js +11 -14
  8. package/dist/js/modern/features/build/bundle/runRollup.js +5 -18
  9. package/dist/js/modern/features/build/bundle/runSpeedy.js +6 -18
  10. package/dist/js/modern/features/build/bundleless/copy-assets.js +0 -8
  11. package/dist/js/modern/features/build/bundleless/generator-dts/index.js +7 -17
  12. package/dist/js/modern/features/build/bundleless/generator-dts/utils.js +6 -16
  13. package/dist/js/modern/features/build/bundleless/index.js +0 -2
  14. package/dist/js/modern/features/build/bundleless/runBabel.js +7 -34
  15. package/dist/js/modern/features/build/bundleless/style.js +1 -30
  16. package/dist/js/modern/features/build/constants.js +0 -3
  17. package/dist/js/modern/features/build/error.js +4 -27
  18. package/dist/js/modern/features/build/index.js +6 -15
  19. package/dist/js/modern/features/build/legacy-constants.js +8 -4
  20. package/dist/js/modern/features/build/logger/logText.js +0 -12
  21. package/dist/js/modern/features/build/logger/loggerManager.js +6 -19
  22. package/dist/js/modern/features/build/normalize.js +18 -43
  23. package/dist/js/modern/features/build/utils.js +5 -14
  24. package/dist/js/modern/features/dev/index.js +4 -9
  25. package/dist/js/modern/hooks/index.js +0 -3
  26. package/dist/js/modern/index.js +11 -11
  27. package/dist/js/modern/schema/build-config.js +2 -1
  28. package/dist/js/modern/schema/output.js +16 -10
  29. package/dist/js/modern/utils/babel.js +17 -15
  30. package/dist/js/modern/utils/copy.js +6 -15
  31. package/dist/js/modern/utils/init-env.js +0 -1
  32. package/dist/js/modern/utils/logger.js +1 -16
  33. package/dist/js/modern/utils/readline.js +2 -4
  34. package/dist/js/modern/utils/tsconfig.js +0 -1
  35. package/dist/js/modern/utils/tspaths-transform/constants.js +4 -2
  36. package/dist/js/modern/utils/tspaths-transform/index.js +2 -19
  37. package/dist/js/modern/utils/tspaths-transform/utils.js +0 -3
  38. package/dist/js/modern/utils/valide.js +10 -12
  39. package/dist/js/node/cli/build.js +2 -6
  40. package/dist/js/node/cli/dev.js +2 -7
  41. package/dist/js/node/cli/index.js +0 -6
  42. package/dist/js/node/cli/new.js +0 -8
  43. package/dist/js/node/commands/build.js +2 -21
  44. package/dist/js/node/commands/dev.js +2 -15
  45. package/dist/js/node/commands/index.js +0 -2
  46. package/dist/js/node/features/build/build-platform.js +11 -20
  47. package/dist/js/node/features/build/bundle/index.js +0 -6
  48. package/dist/js/node/features/build/bundle/runRollup.js +3 -32
  49. package/dist/js/node/features/build/bundle/runSpeedy.js +6 -32
  50. package/dist/js/node/features/build/bundleless/copy-assets.js +0 -20
  51. package/dist/js/node/features/build/bundleless/generator-dts/index.js +7 -27
  52. package/dist/js/node/features/build/bundleless/generator-dts/utils.js +6 -32
  53. package/dist/js/node/features/build/bundleless/index.js +0 -11
  54. package/dist/js/node/features/build/bundleless/runBabel.js +6 -60
  55. package/dist/js/node/features/build/bundleless/style.js +1 -50
  56. package/dist/js/node/features/build/constants.js +0 -11
  57. package/dist/js/node/features/build/error.js +4 -40
  58. package/dist/js/node/features/build/index.js +6 -38
  59. package/dist/js/node/features/build/legacy-constants.js +8 -4
  60. package/dist/js/node/features/build/logger/index.js +0 -4
  61. package/dist/js/node/features/build/logger/logText.js +0 -18
  62. package/dist/js/node/features/build/logger/loggerManager.js +5 -26
  63. package/dist/js/node/features/build/normalize.js +18 -61
  64. package/dist/js/node/features/build/utils.js +5 -30
  65. package/dist/js/node/features/dev/index.js +4 -17
  66. package/dist/js/node/hooks/build.js +0 -5
  67. package/dist/js/node/hooks/dev.js +0 -5
  68. package/dist/js/node/hooks/index.js +0 -10
  69. package/dist/js/node/index.js +12 -36
  70. package/dist/js/node/locale/index.js +0 -5
  71. package/dist/js/node/schema/build-config.js +2 -1
  72. package/dist/js/node/schema/index.js +0 -5
  73. package/dist/js/node/schema/output.js +16 -12
  74. package/dist/js/node/utils/babel.js +17 -23
  75. package/dist/js/node/utils/color.js +0 -3
  76. package/dist/js/node/utils/copy.js +6 -23
  77. package/dist/js/node/utils/init-env.js +0 -3
  78. package/dist/js/node/utils/json.js +0 -2
  79. package/dist/js/node/utils/language.js +0 -3
  80. package/dist/js/node/utils/logger.js +1 -26
  81. package/dist/js/node/utils/readline.js +0 -8
  82. package/dist/js/node/utils/tsconfig.js +0 -7
  83. package/dist/js/node/utils/tspaths-transform/constants.js +4 -2
  84. package/dist/js/node/utils/tspaths-transform/index.js +2 -34
  85. package/dist/js/node/utils/tspaths-transform/utils.js +0 -7
  86. package/dist/js/node/utils/valide.js +10 -17
  87. package/dist/types/commands/build.d.ts +0 -1
  88. package/dist/types/features/build/logger/loggerManager.d.ts +0 -1
  89. package/dist/types/features/build/normalize.d.ts +1 -1
  90. package/dist/types/features/build/utils.d.ts +0 -1
  91. package/dist/types/hooks/build.d.ts +6 -6
  92. package/dist/types/hooks/index.d.ts +3 -3
  93. package/dist/types/index.d.ts +0 -3
  94. package/dist/types/schema/types.d.ts +1 -3
  95. package/dist/types/types.d.ts +0 -1
  96. package/dist/types/utils/babel.d.ts +2 -2
  97. package/dist/types/utils/valide.d.ts +2 -2
  98. package/package.json +22 -22
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.normalizeModuleConfig = exports.normalizeBuildConfig = exports.getSourceMap = exports.getNormalizeModuleConfigByPackageModeAndFileds = exports.getFinalTsconfig = exports.getFinalDts = void 0;
7
-
8
7
  var _utils = require("@modern-js/utils");
9
-
10
8
  var _lodash = require("@modern-js/utils/lodash");
11
-
12
9
  var _constants = require("../../utils/constants");
13
-
14
10
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
11
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
12
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
-
20
13
  const constants = _utils.Import.lazy('./constants', require);
21
-
22
14
  const legacyConstants = _utils.Import.lazy('./legacy-constants', require);
23
-
24
15
  const getNormalizeModuleConfigByPackageModeAndFileds = (api, buildFeatOption) => {
25
16
  const {
26
17
  output: {
@@ -31,7 +22,6 @@ const getNormalizeModuleConfigByPackageModeAndFileds = (api, buildFeatOption) =>
31
22
  }
32
23
  } = api.useResolvedConfigContext();
33
24
  let configs = [];
34
-
35
25
  if (buildFeatOption.styleOnly) {
36
26
  configs.push({
37
27
  buildType: 'bundleless',
@@ -55,7 +45,6 @@ const getNormalizeModuleConfigByPackageModeAndFileds = (api, buildFeatOption) =>
55
45
  });
56
46
  return configs;
57
47
  }
58
-
59
48
  const commonConfig = {
60
49
  buildType: 'bundleless',
61
50
  bundlelessOptions: {
@@ -71,7 +60,6 @@ const getNormalizeModuleConfigByPackageModeAndFileds = (api, buildFeatOption) =>
71
60
  outputPath: './'
72
61
  };
73
62
  commonConfig.tsconfig = getFinalTsconfig(commonConfig, buildFeatOption);
74
-
75
63
  if (!packageFields || typeof packageFields === 'object' && Object.keys(packageFields).length === 0) {
76
64
  const buildConfigs = legacyConstants.PACKAGE_MODES[packageMode || legacyConstants.DEFAULT_PACKAGE_MODE];
77
65
  configs = buildConfigs.map(config => _utils.lodash.mergeWith({}, commonConfig, config));
@@ -90,33 +78,27 @@ const getNormalizeModuleConfigByPackageModeAndFileds = (api, buildFeatOption) =>
90
78
  outputPath
91
79
  });
92
80
  }
93
-
94
81
  return _utils.lodash.mergeWith({}, commonConfig, {
95
82
  format: 'esm',
96
83
  target: 'es6',
97
84
  outputPath
98
85
  });
99
86
  };
100
-
101
87
  if (!packageFields['jsnext:modern'] && !packageFields.main && !packageFields.module) {
102
88
  throw new Error(`Unrecognized ${JSON.stringify(packageFields)} configuration, please use keys: 'modern, main, jupiter:modern' and use values: 'CJS+ES6, ESM+ES5, ESM+ES6'`);
103
- } // The fields configured in packageFields correspond to the main, module, and jsnext:modern fields on package.json,
89
+ }
90
+ // The fields configured in packageFields correspond to the main, module, and jsnext:modern fields on package.json,
104
91
  // and can also be used on package.json exports field.
105
-
106
-
107
92
  if (packageFields['jsnext:modern']) {
108
93
  configs.push(getConfigsByJsSyntaxType(packageFields['jsnext:modern'], 'js/modern'));
109
94
  }
110
-
111
95
  if (packageFields.main) {
112
96
  configs.push(getConfigsByJsSyntaxType(packageFields.main, 'js/node'));
113
97
  }
114
-
115
98
  if (packageFields.module) {
116
99
  configs.push(getConfigsByJsSyntaxType(packageFields.module, 'js/treeshaking'));
117
100
  }
118
101
  }
119
-
120
102
  if (configs.length > 0) {
121
103
  const firstConfig = configs[0];
122
104
  firstConfig.bundlelessOptions = _utils.lodash.mergeWith({}, firstConfig.bundlelessOptions, {
@@ -124,9 +106,9 @@ const getNormalizeModuleConfigByPackageModeAndFileds = (api, buildFeatOption) =>
124
106
  compileMode: importStyle === 'source-code' ? 'only-source-code' : 'all'
125
107
  }
126
108
  });
127
- } // [compatibe mode]: dts gen
128
-
109
+ }
129
110
 
111
+ // [compatibe mode]: dts gen
130
112
  if (buildFeatOption.legacyTsc && !disableTsChecker) {
131
113
  configs.push({
132
114
  buildType: 'bundleless',
@@ -135,7 +117,6 @@ const getNormalizeModuleConfigByPackageModeAndFileds = (api, buildFeatOption) =>
135
117
  dtsOnly: true
136
118
  });
137
119
  }
138
-
139
120
  configs.push({
140
121
  buildType: 'bundleless',
141
122
  outputPath: './styles',
@@ -148,43 +129,33 @@ const getNormalizeModuleConfigByPackageModeAndFileds = (api, buildFeatOption) =>
148
129
  });
149
130
  return configs;
150
131
  };
151
-
152
132
  exports.getNormalizeModuleConfigByPackageModeAndFileds = getNormalizeModuleConfigByPackageModeAndFileds;
153
-
154
133
  const getFinalTsconfig = (config, buildFeatOption) => {
155
134
  var _config$tsconfig;
156
-
157
135
  // cli tsconfig option > buildPreset tsconfig option
136
+
158
137
  // Since tsconfig configuration has default values,
159
138
  // compare the two to see if the user is configured with cli tsconfig
160
139
  if (buildFeatOption.tsconfigName !== _constants.cliTsConfigDefaultValue) {
161
140
  // TODO: transform tsconfig to absPath
162
141
  return buildFeatOption.tsconfigName;
163
142
  }
164
-
165
143
  return (_config$tsconfig = config.tsconfig) !== null && _config$tsconfig !== void 0 ? _config$tsconfig : './tsconfig.json';
166
144
  };
167
-
168
145
  exports.getFinalTsconfig = getFinalTsconfig;
169
-
170
146
  const getFinalDts = (config, buildFeatOption) => {
171
147
  var _config$enableDts;
172
-
173
148
  // is js project, should return false
174
149
  if (!buildFeatOption.isTsProject) {
175
150
  return false;
176
- } // when `build --dts`, then all build tasks`s enableDts is true
177
-
178
-
151
+ }
152
+ // when `build --dts`, then all build tasks`s enableDts is true
179
153
  if (buildFeatOption.enableDtsGen) {
180
154
  return true;
181
155
  }
182
-
183
156
  return (_config$enableDts = config.enableDts) !== null && _config$enableDts !== void 0 ? _config$enableDts : false;
184
157
  };
185
-
186
158
  exports.getFinalDts = getFinalDts;
187
-
188
159
  const getSourceMap = (config, buildType, api) => {
189
160
  // TODO: remove
190
161
  const {
@@ -192,20 +163,15 @@ const getSourceMap = (config, buildType, api) => {
192
163
  disableSourceMap
193
164
  }
194
165
  } = api.useResolvedConfigContext();
195
-
196
166
  if (disableSourceMap) {
197
167
  return false;
198
168
  }
199
-
200
169
  if (config.sourceMap !== undefined) {
201
170
  return config.sourceMap;
202
171
  }
203
-
204
172
  return buildType === 'bundle';
205
173
  };
206
-
207
174
  exports.getSourceMap = getSourceMap;
208
-
209
175
  const normalizeBuildConfig = (context, buildConfig, deps = []) => {
210
176
  const {
211
177
  buildFeatOption,
@@ -214,7 +180,6 @@ const normalizeBuildConfig = (context, buildConfig, deps = []) => {
214
180
  const configArray = Array.isArray(buildConfig) ? buildConfig : [buildConfig];
215
181
  const normalizedModule = configArray.map(config => {
216
182
  var _config$format, _config$target, _bundleOptions$skipDe, _bundleOptions$minify, _bundleOptions$splitt, _config$outputPath, _config$dtsOnly;
217
-
218
183
  const format = (_config$format = config.format) !== null && _config$format !== void 0 ? _config$format : 'cjs';
219
184
  const target = (_config$target = config.target) !== null && _config$target !== void 0 ? _config$target : 'esnext';
220
185
  const {
@@ -222,7 +187,6 @@ const normalizeBuildConfig = (context, buildConfig, deps = []) => {
222
187
  } = config;
223
188
  const skipDeps = (_bundleOptions$skipDe = bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.skipDeps) !== null && _bundleOptions$skipDe !== void 0 ? _bundleOptions$skipDe : true;
224
189
  const externals = skipDeps === false ? (bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.externals) || [] : [...deps.map(dep => new RegExp(`^${dep}($|\\/|\\\\)`)), ...((bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.externals) || [])];
225
-
226
190
  const normalizedBundleOption = _objectSpread(_objectSpread({}, bundleOptions), {}, {
227
191
  entry: (bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.entry) || {
228
192
  index: `src/index.${buildFeatOption.isTsProject ? 'ts' : 'js'}`
@@ -233,7 +197,6 @@ const normalizeBuildConfig = (context, buildConfig, deps = []) => {
233
197
  splitting: (_bundleOptions$splitt = bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.splitting) !== null && _bundleOptions$splitt !== void 0 ? _bundleOptions$splitt : false,
234
198
  skipDeps
235
199
  });
236
-
237
200
  const normalizedBundlelessOptions = (0, _lodash.mergeWith)({}, {
238
201
  sourceDir: './src',
239
202
  style: {
@@ -260,13 +223,11 @@ const normalizeBuildConfig = (context, buildConfig, deps = []) => {
260
223
  dtsOnly,
261
224
  sourceMap
262
225
  };
263
-
264
226
  if (!buildFeatOption.isTsProject && (dtsOnly || enableDts)) {
265
227
  console.warn('[WARN] dtsOnly、enableDts 配置仅在 Ts 项目下生效');
266
228
  } else if (buildFeatOption.isTsProject && dtsOnly && !enableDts) {
267
229
  console.warn('[WARN] dtsOnly 配置仅在 enableDts 为 true 的时候生效. 请检查当前的 dtsOnly、enableDts 是否配置正确');
268
230
  }
269
-
270
231
  if (config.buildType === 'bundle') {
271
232
  return _objectSpread(_objectSpread({}, commmonConfig), {}, {
272
233
  buildType: 'bundle',
@@ -281,9 +242,7 @@ const normalizeBuildConfig = (context, buildConfig, deps = []) => {
281
242
  });
282
243
  return normalizedModule;
283
244
  };
284
-
285
245
  exports.normalizeBuildConfig = normalizeBuildConfig;
286
-
287
246
  const normalizeModuleConfig = context => {
288
247
  const {
289
248
  buildFeatOption,
@@ -295,37 +254,35 @@ const normalizeModuleConfig = context => {
295
254
  buildConfig,
296
255
  buildPreset
297
256
  }
298
- } = api.useResolvedConfigContext(); // buildConfig is the most important.
257
+ } = api.useResolvedConfigContext();
299
258
 
259
+ // buildConfig is the most important.
300
260
  if (buildConfig) {
301
261
  return normalizeBuildConfig(context, buildConfig, deps);
302
- } // buildPreset is the second important. It can be used when buildConfig is not defined.
303
- // buildPreset -> buildConfig
304
-
262
+ }
305
263
 
264
+ // buildPreset is the second important. It can be used when buildConfig is not defined.
265
+ // buildPreset -> buildConfig
306
266
  if (buildPreset) {
307
267
  const {
308
268
  unPresetConfigs,
309
269
  unPresetWithTargetConfigs
310
270
  } = constants;
311
-
312
271
  if (unPresetConfigs[buildPreset]) {
313
272
  return normalizeBuildConfig(context, unPresetConfigs[buildPreset], deps);
314
273
  } else if (unPresetWithTargetConfigs[buildPreset]) {
315
274
  return normalizeBuildConfig(context, unPresetWithTargetConfigs[buildPreset], deps);
316
- } // If the buildPreset is not found, then it is used 'npm-library'
317
- // TODO: Warning: The buildPreset 'npm-library' is not supported.
318
-
275
+ }
319
276
 
277
+ // If the buildPreset is not found, then it is used 'npm-library'
278
+ // TODO: Warning: The buildPreset 'npm-library' is not supported.
320
279
  return normalizeBuildConfig(context, unPresetConfigs['npm-library'], deps);
321
- } // If the user does not configure buildConfig and buildPreset,
322
- // the configuration is generated based on packageMode and packageField
323
-
280
+ }
324
281
 
282
+ // If the user does not configure buildConfig and buildPreset,
283
+ // the configuration is generated based on packageMode and packageField
325
284
  const legacyBuildConfig = getNormalizeModuleConfigByPackageModeAndFileds(api, buildFeatOption);
326
285
  return normalizeBuildConfig(context, legacyBuildConfig, deps);
327
286
  };
328
287
  /* eslint-enable max-lines */
329
-
330
-
331
288
  exports.normalizeModuleConfig = normalizeModuleConfig;
@@ -4,34 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.watchSectionTitle = exports.logTemplate = exports.getPostcssOption = exports.getAllDeps = exports.SectionTitleStatus = exports.LogStack = void 0;
7
-
8
7
  var os = _interopRequireWildcard(require("os"));
9
-
10
8
  var _path = _interopRequireDefault(require("path"));
11
-
12
9
  var _utils = require("@modern-js/utils");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
13
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
-
22
14
  const constants = _utils.Import.lazy('./constants', require);
15
+
23
16
  /**
24
17
  * 处理日志信息
25
18
  */
26
-
27
-
28
19
  class LogStack {
29
20
  constructor() {
30
21
  _defineProperty(this, "_codeLogStack", void 0);
31
-
32
22
  this._codeLogStack = [];
33
23
  }
34
-
35
24
  update(latestLog, {
36
25
  splitEOL = false
37
26
  } = {}) {
@@ -41,22 +30,16 @@ class LogStack {
41
30
  });
42
31
  return;
43
32
  }
44
-
45
33
  this._codeLogStack.unshift(latestLog.trim());
46
34
  }
47
-
48
35
  clear() {
49
36
  this._codeLogStack = [];
50
37
  }
51
-
52
38
  get value() {
53
39
  return [...new Set(this._codeLogStack)];
54
40
  }
55
-
56
41
  }
57
-
58
42
  exports.LogStack = LogStack;
59
-
60
43
  const logTemplate = (title, messageStack, maxLength, {
61
44
  noBottomBorder: _noBottomBorder = false,
62
45
  bottomBorderText: _bottomBorderText = '',
@@ -72,35 +55,29 @@ const logTemplate = (title, messageStack, maxLength, {
72
55
  .slice(0, maxLength) // 控制长度
73
56
  .filter(s => s !== leftBorderFlag) // 过滤空字符串
74
57
  .reverse(); // 调换顺序,最新的消息在最后面
75
-
76
58
  const template = `${title}:
77
59
  ${_contentColor(messageFragments.join(os.EOL))}${_noBottomBorder ? '' : `\n${_bottomBorderText}`}`;
78
60
  return template;
79
61
  };
80
-
81
62
  exports.logTemplate = logTemplate;
82
63
  let SectionTitleStatus;
83
64
  exports.SectionTitleStatus = SectionTitleStatus;
84
-
85
65
  (function (SectionTitleStatus) {
86
66
  SectionTitleStatus[SectionTitleStatus["Success"] = 0] = "Success";
87
67
  SectionTitleStatus[SectionTitleStatus["Fail"] = 1] = "Fail";
88
68
  SectionTitleStatus[SectionTitleStatus["Log"] = 2] = "Log";
89
69
  })(SectionTitleStatus || (exports.SectionTitleStatus = SectionTitleStatus = {}));
90
-
91
70
  const watchSectionTitle = (str, status) => {
92
71
  if (status === SectionTitleStatus.Success) {
93
72
  return `${_utils.chalk.bgWhite.gray.underline(str)} ${_utils.chalk.green.underline('Successful')}`;
94
73
  } else if (status === SectionTitleStatus.Fail) {
95
74
  return `${_utils.chalk.bgWhite.gray.underline(str)} ${_utils.chalk.red.underline('Build Failed')}`;
96
75
  }
97
-
98
76
  return `${_utils.chalk.bgWhite.gray.underline(str)} ${_utils.chalk.blue.underline('Log')}`;
99
- }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
100
-
77
+ };
101
78
 
79
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
102
80
  exports.watchSectionTitle = watchSectionTitle;
103
-
104
81
  const getPostcssOption = (...args) => {
105
82
  // const postcssOption: any = cssConfig.getPostcssConfig(
106
83
  // appDirectory,
@@ -115,18 +92,16 @@ const getPostcssOption = (...args) => {
115
92
  options: {}
116
93
  };
117
94
  };
118
-
119
95
  exports.getPostcssOption = getPostcssOption;
120
-
121
96
  const getAllDeps = appDirectory => {
122
97
  try {
123
- const json = JSON.parse(_utils.fs.readFileSync(_path.default.resolve(appDirectory, './package.json'), 'utf8')); // return json[packageJsonConfig ?? PACKAGE_JSON_CONFIG_NAME] as T | undefined;
98
+ const json = JSON.parse(_utils.fs.readFileSync(_path.default.resolve(appDirectory, './package.json'), 'utf8'));
124
99
 
100
+ // return json[packageJsonConfig ?? PACKAGE_JSON_CONFIG_NAME] as T | undefined;
125
101
  return [...Object.keys(json.dependencies || {}), ...Object.keys(json.devDependencies || {}), ...Object.keys(json.peerDependencies || {})];
126
102
  } catch (e) {
127
103
  console.warn('[WARN] package.json is broken');
128
104
  return [];
129
105
  }
130
106
  };
131
-
132
107
  exports.getAllDeps = getAllDeps;
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.showMenu = exports.runSubCmd = exports.devStorybook = void 0;
7
-
8
7
  var _utils = require("@modern-js/utils");
9
-
10
8
  const color = _utils.Import.lazy('../../utils/color', require);
11
-
12
9
  const showMenu = async (api, config) => {
13
10
  const runners = api.useHookRunners();
14
11
  const metas = await runners.moduleToolsMenu(undefined);
15
-
16
12
  if (metas.length <= 0) {
17
- console.info(_utils.chalk.yellow('No runnable development features found.\nYou can use the `new` command to enable the development features')); // eslint-disable-next-line no-process-exit
18
-
13
+ console.info(_utils.chalk.yellow('No runnable development features found.\nYou can use the `new` command to enable the development features'));
14
+ // eslint-disable-next-line no-process-exit
19
15
  process.exit(0);
20
16
  }
21
-
22
17
  const menuMessage = color.devMenuTitle('Select the debug mode:');
23
18
  const {
24
19
  type
@@ -29,35 +24,28 @@ const showMenu = async (api, config) => {
29
24
  choices: metas
30
25
  }]);
31
26
  const devMeta = metas.find(meta => meta.value === type);
32
-
33
27
  if (devMeta) {
34
28
  await devMeta.runTask(config);
35
29
  }
36
30
  };
37
-
38
31
  exports.showMenu = showMenu;
39
-
40
32
  const devStorybook = async (api, config) => {
41
33
  const runners = api.useHookRunners();
42
34
  const metas = await runners.moduleToolsMenu(undefined);
43
35
  const findStorybook = metas.find(meta => meta.value === 'storybook');
44
-
45
36
  if (findStorybook) {
46
37
  await findStorybook.runTask(config);
47
38
  } else {
48
- console.info(_utils.chalk.yellow('No development features found.\nYou can use the `new` command to enable the development features')); // eslint-disable-next-line no-process-exit
49
-
39
+ console.info(_utils.chalk.yellow('No development features found.\nYou can use the `new` command to enable the development features'));
40
+ // eslint-disable-next-line no-process-exit
50
41
  process.exit(0);
51
42
  }
52
43
  };
53
-
54
44
  exports.devStorybook = devStorybook;
55
-
56
45
  const runSubCmd = async (api, subCmd, config) => {
57
46
  const runners = api.useHookRunners();
58
47
  const metas = await runners.moduleToolsMenu(undefined);
59
48
  const devMeta = metas.find(meta => meta.value === subCmd || Array.isArray(meta.aliasValues) && meta.aliasValues.includes(subCmd));
60
-
61
49
  if (devMeta) {
62
50
  await devMeta.runTask(config);
63
51
  } else {
@@ -65,5 +53,4 @@ const runSubCmd = async (api, subCmd, config) => {
65
53
  process.exit(0);
66
54
  }
67
55
  };
68
-
69
56
  exports.runSubCmd = runSubCmd;
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.platformBuild = exports.moduleTailwindConfig = exports.moduleSassConfig = exports.moduleLessConfig = exports.lifecycle = exports.buildHooks = void 0;
7
-
8
7
  var _plugin = require("@modern-js/plugin");
9
-
10
8
  var _core = require("@modern-js/core");
11
-
12
9
  const platformBuild = (0, _plugin.createParallelWorkflow)();
13
10
  exports.platformBuild = platformBuild;
14
11
  const moduleLessConfig = (0, _plugin.createAsyncPipeline)();
@@ -24,7 +21,6 @@ const buildHooks = {
24
21
  moduleTailwindConfig
25
22
  };
26
23
  exports.buildHooks = buildHooks;
27
-
28
24
  const lifecycle = () => {
29
25
  (0, _core.registerHook)({
30
26
  moduleLessConfig,
@@ -33,5 +29,4 @@ const lifecycle = () => {
33
29
  platformBuild
34
30
  });
35
31
  };
36
-
37
32
  exports.lifecycle = lifecycle;
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.moduleToolsMenu = exports.lifecycle = exports.devHooks = exports.afterDev = void 0;
7
-
8
7
  var _plugin = require("@modern-js/plugin");
9
-
10
8
  var _core = require("@modern-js/core");
11
-
12
9
  const moduleToolsMenu = (0, _plugin.createParallelWorkflow)();
13
10
  exports.moduleToolsMenu = moduleToolsMenu;
14
11
  const afterDev = (0, _plugin.createAsyncWorkflow)();
@@ -18,12 +15,10 @@ const devHooks = {
18
15
  afterDev
19
16
  };
20
17
  exports.devHooks = devHooks;
21
-
22
18
  const lifecycle = () => {
23
19
  (0, _core.registerHook)({
24
20
  moduleToolsMenu,
25
21
  afterDev
26
22
  });
27
23
  };
28
-
29
24
  exports.lifecycle = lifecycle;
@@ -17,30 +17,20 @@ Object.defineProperty(exports, "devLifeCycle", {
17
17
  }
18
18
  });
19
19
  exports.lifecycle = exports.hooks = void 0;
20
-
21
20
  var _plugin = require("@modern-js/plugin");
22
-
23
21
  var _build = require("./build");
24
-
25
22
  var _dev = require("./dev");
26
-
27
23
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
28
-
29
24
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
30
-
31
25
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
32
-
33
26
  const lifecycle = () => {
34
27
  (0, _dev.lifecycle)();
35
28
  (0, _build.lifecycle)();
36
29
  };
37
-
38
30
  exports.lifecycle = lifecycle;
39
31
  const addRuntimeExports = (0, _plugin.createAsyncWaterfall)();
40
32
  exports.addRuntimeExports = addRuntimeExports;
41
-
42
33
  const hooks = _objectSpread(_objectSpread(_objectSpread({}, _build.buildHooks), _dev.devHooks), {}, {
43
34
  addRuntimeExports
44
35
  });
45
-
46
36
  exports.hooks = hooks;
@@ -3,27 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _exportNames = {
7
- defineConfig: true
8
- };
6
+ var _exportNames = {};
9
7
  exports.default = void 0;
10
- Object.defineProperty(exports, "defineConfig", {
11
- enumerable: true,
12
- get: function () {
13
- return _core.defineConfig;
14
- }
15
- });
16
-
17
8
  var _utils = require("@modern-js/utils");
18
-
19
9
  var _pluginChangeset = _interopRequireDefault(require("@modern-js/plugin-changeset"));
20
-
21
- var _pluginJarvis = _interopRequireDefault(require("@modern-js/plugin-jarvis"));
22
-
10
+ var _pluginLint = _interopRequireDefault(require("@modern-js/plugin-lint"));
23
11
  var _hooks = require("./hooks");
24
-
25
12
  var _types = require("./types");
26
-
27
13
  Object.keys(_types).forEach(function (key) {
28
14
  if (key === "default" || key === "__esModule") return;
29
15
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -35,28 +21,21 @@ Object.keys(_types).forEach(function (key) {
35
21
  }
36
22
  });
37
23
  });
38
-
39
- var _core = require("@modern-js/core");
40
-
41
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42
-
43
25
  const upgradeModel = _utils.Import.lazy('@modern-js/upgrade', require);
44
-
45
26
  const cli = _utils.Import.lazy('./cli', require);
46
-
47
27
  const local = _utils.Import.lazy('./locale', require);
48
-
49
28
  const schema = _utils.Import.lazy('./schema', require);
50
-
51
29
  const lang = _utils.Import.lazy('./utils/language', require);
52
30
 
53
- const isBuildMode = process.argv.slice(2)[0] === 'build';
31
+ // export { defineConfig } from '@modern-js/core';
54
32
 
33
+ const isBuildMode = process.argv.slice(2)[0] === 'build';
55
34
  var _default = () => ({
56
35
  name: '@modern-js/module-tools',
57
36
  post: ['@modern-js/plugin-changeset'],
58
37
  registerHook: _hooks.hooks,
59
- usePlugins: isBuildMode ? [] : [(0, _pluginChangeset.default)(), (0, _pluginJarvis.default)()],
38
+ usePlugins: isBuildMode ? [] : [(0, _pluginChangeset.default)(), (0, _pluginLint.default)()],
60
39
  setup: api => {
61
40
  const locale = lang.getLocaleLanguage();
62
41
  local.i18n.changeLanguage({
@@ -67,41 +46,38 @@ var _default = () => ({
67
46
  async prepare() {
68
47
  const appContext = api.useAppContext();
69
48
  const hookRunners = api.useHookRunners();
70
-
71
49
  try {
72
50
  _utils.fs.emptydirSync(appContext.internalDirectory);
73
- } catch (_unused) {// FIXME:
51
+ } catch (_unused) {
52
+ // FIXME:
74
53
  }
75
-
76
54
  await hookRunners.addRuntimeExports();
77
55
  },
78
-
79
56
  validateSchema() {
80
57
  return schema.addSchema();
81
58
  },
82
-
83
59
  config() {
84
60
  return {
61
+ source: {},
85
62
  output: {
86
63
  enableSourceMap: false,
87
64
  jsPath: 'js'
88
- }
65
+ },
66
+ tools: {}
89
67
  };
90
68
  },
91
-
92
69
  commands({
93
70
  program
94
71
  }) {
95
72
  cli.devCli(program, api);
96
73
  cli.buildCli(program, api);
97
74
  cli.newCli(program, locale);
98
- upgradeModel.defineCommand(program.command('upgrade')); // 便于其他插件辨别
75
+ upgradeModel.defineCommand(program.command('upgrade'));
99
76
 
77
+ // 便于其他插件辨别
100
78
  program.$$libraryName = 'module-tools';
101
79
  }
102
-
103
80
  };
104
81
  }
105
82
  });
106
-
107
83
  exports.default = _default;
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.localeKeys = exports.i18n = void 0;
7
-
8
7
  var _utils = require("@modern-js/utils");
9
-
10
8
  var _zh = require("./zh");
11
-
12
9
  var _en = require("./en");
13
-
14
10
  const i18nPlugin = _utils.Import.lazy('@modern-js/plugin-i18n', require);
15
-
16
11
  const i18n = new i18nPlugin.I18n();
17
12
  exports.i18n = i18n;
18
13
  const localeKeys = i18n.init('zh', {
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.targets = exports.presets = exports.buildSchema = void 0;
7
- const targets = ['es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.
7
+ const targets = ['es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020',
8
+ // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.
8
9
  'esnext'];
9
10
  exports.targets = targets;
10
11
  const presets = ['npm-library', 'npm-library-with-umd', 'npm-component', 'npm-component-with-umd', ...['npm-library', 'npm-library-with-umd', 'npm-component', 'npm-component-with-umd'].reduce((ret, crt) => {