@modern-js/app-tools 2.0.0-canary.0 → 2.0.1

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 (183) hide show
  1. package/CHANGELOG.md +746 -0
  2. package/bin/modern.js +3 -0
  3. package/dist/js/modern/analyze/Builder.js +39 -0
  4. package/dist/js/modern/analyze/constants.js +16 -0
  5. package/dist/js/modern/analyze/generateCode.js +14 -15
  6. package/dist/js/modern/analyze/getBundleEntry.js +5 -1
  7. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +9 -6
  8. package/dist/js/modern/analyze/getFileSystemEntry.js +11 -3
  9. package/dist/js/modern/analyze/index.js +79 -8
  10. package/dist/js/modern/analyze/nestedRoutes.js +29 -22
  11. package/dist/js/modern/analyze/templates.js +28 -7
  12. package/dist/js/modern/analyze/utils.js +21 -4
  13. package/dist/js/modern/builder/builderPlugins/compatModern.js +12 -5
  14. package/dist/js/modern/builder/index.js +14 -16
  15. package/dist/js/modern/builder/share.js +4 -4
  16. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +3 -1
  17. package/dist/js/modern/commands/dev.js +6 -9
  18. package/dist/js/modern/commands/index.js +1 -1
  19. package/dist/js/modern/commands/{start.js → serve.js} +3 -1
  20. package/dist/js/modern/config/default.js +38 -61
  21. package/dist/js/modern/config/initial/createOutputConfig.js +1 -3
  22. package/dist/js/modern/config/initial/createSourceConfig.js +5 -1
  23. package/dist/js/modern/config/initial/inits.js +7 -0
  24. package/dist/js/modern/config/initial/transformNormalizedConfig.js +5 -1
  25. package/dist/js/modern/hooks.js +6 -1
  26. package/dist/js/modern/index.js +96 -59
  27. package/dist/js/modern/initialize/index.js +5 -4
  28. package/dist/js/modern/locale/en.js +1 -1
  29. package/dist/js/modern/locale/zh.js +1 -1
  30. package/dist/js/modern/schema/index.js +6 -8
  31. package/dist/js/modern/schema/legacy.js +2 -3
  32. package/dist/js/modern/utils/commands.js +6 -1
  33. package/dist/js/modern/utils/env.js +15 -0
  34. package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
  35. package/dist/js/node/analyze/Builder.js +64 -0
  36. package/dist/js/node/analyze/constants.js +44 -3
  37. package/dist/js/node/analyze/generateCode.js +33 -29
  38. package/dist/js/node/analyze/getBundleEntry.js +12 -4
  39. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +33 -28
  40. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +24 -22
  41. package/dist/js/node/analyze/getClientRoutes/index.js +8 -3
  42. package/dist/js/node/analyze/getClientRoutes/utils.js +10 -3
  43. package/dist/js/node/analyze/getFileSystemEntry.js +18 -6
  44. package/dist/js/node/analyze/getHtmlTemplate.js +18 -14
  45. package/dist/js/node/analyze/getServerRoutes.js +36 -34
  46. package/dist/js/node/analyze/index.js +105 -59
  47. package/dist/js/node/analyze/isDefaultExportFunction.js +7 -3
  48. package/dist/js/node/analyze/makeLegalIdentifier.js +7 -3
  49. package/dist/js/node/analyze/nestedRoutes.js +58 -49
  50. package/dist/js/node/analyze/templates.js +64 -37
  51. package/dist/js/node/analyze/utils.js +40 -18
  52. package/dist/js/node/builder/builderPlugins/compatModern.js +36 -27
  53. package/dist/js/node/builder/index.js +42 -55
  54. package/dist/js/node/builder/loaders/routerLoader.js +5 -3
  55. package/dist/js/node/builder/loaders/serverModuleLoader.js +5 -3
  56. package/dist/js/node/builder/share.js +11 -7
  57. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +7 -3
  58. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +7 -3
  59. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +12 -8
  60. package/dist/js/node/commands/build.js +30 -28
  61. package/dist/js/node/commands/deploy.js +9 -5
  62. package/dist/js/node/commands/dev.js +39 -40
  63. package/dist/js/node/commands/index.js +5 -5
  64. package/dist/js/node/commands/inspect.js +10 -6
  65. package/dist/js/node/commands/{start.js → serve.js} +16 -10
  66. package/dist/js/node/config/default.js +44 -64
  67. package/dist/js/node/config/index.js +10 -3
  68. package/dist/js/node/config/initial/createHtmlConfig.js +7 -3
  69. package/dist/js/node/config/initial/createOutputConfig.js +8 -6
  70. package/dist/js/node/config/initial/createSourceConfig.js +12 -4
  71. package/dist/js/node/config/initial/createToolsConfig.js +7 -3
  72. package/dist/js/node/config/initial/index.js +9 -3
  73. package/dist/js/node/config/initial/inits.js +33 -22
  74. package/dist/js/node/config/initial/transformNormalizedConfig.js +12 -4
  75. package/dist/js/node/defineConfig.js +25 -22
  76. package/dist/js/node/exports/server.js +7 -3
  77. package/dist/js/node/hooks.js +13 -4
  78. package/dist/js/node/index.js +135 -111
  79. package/dist/js/node/initialize/index.js +33 -32
  80. package/dist/js/node/locale/en.js +8 -4
  81. package/dist/js/node/locale/index.js +8 -3
  82. package/dist/js/node/locale/zh.js +8 -4
  83. package/dist/js/node/schema/Schema.js +7 -3
  84. package/dist/js/node/schema/index.js +14 -11
  85. package/dist/js/node/schema/legacy.js +7 -6
  86. package/dist/js/node/types/config/deploy.js +15 -0
  87. package/dist/js/node/types/config/dev.js +15 -0
  88. package/dist/js/node/types/config/experiments.js +15 -0
  89. package/dist/js/node/types/config/html.js +15 -0
  90. package/dist/js/node/types/config/index.js +3 -3
  91. package/dist/js/node/types/config/output.js +15 -0
  92. package/dist/js/node/types/config/performance.js +15 -0
  93. package/dist/js/node/types/config/security.js +15 -0
  94. package/dist/js/node/types/config/source.js +15 -0
  95. package/dist/js/node/types/config/tools.js +15 -0
  96. package/dist/js/node/types/hooks.js +15 -0
  97. package/dist/js/node/types/index.js +5 -5
  98. package/dist/js/node/types/legacyConfig/deploy.js +15 -0
  99. package/dist/js/node/types/legacyConfig/dev.js +15 -0
  100. package/dist/js/node/types/legacyConfig/index.js +15 -0
  101. package/dist/js/node/types/legacyConfig/output.js +15 -0
  102. package/dist/js/node/types/legacyConfig/source.js +15 -0
  103. package/dist/js/node/types/legacyConfig/tools.js +15 -0
  104. package/dist/js/node/utils/commands.js +14 -4
  105. package/dist/js/node/utils/config.js +35 -30
  106. package/dist/js/node/utils/createFileWatcher.js +15 -10
  107. package/dist/js/node/utils/createServer.js +35 -29
  108. package/dist/js/node/utils/env.js +38 -0
  109. package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
  110. package/dist/js/node/utils/getSpecifiedEntries.js +10 -6
  111. package/dist/js/node/utils/language.js +7 -3
  112. package/dist/js/node/utils/printInstructions.js +10 -6
  113. package/dist/js/node/utils/restart.js +11 -7
  114. package/dist/js/node/utils/routes.js +11 -7
  115. package/dist/js/node/utils/types.js +15 -0
  116. package/dist/js/treeshaking/analyze/Builder.js +199 -0
  117. package/dist/js/treeshaking/analyze/constants.js +13 -1
  118. package/dist/js/treeshaking/analyze/generateCode.js +14 -17
  119. package/dist/js/treeshaking/analyze/getBundleEntry.js +5 -1
  120. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +9 -6
  121. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +11 -3
  122. package/dist/js/treeshaking/analyze/index.js +110 -7
  123. package/dist/js/treeshaking/analyze/nestedRoutes.js +30 -23
  124. package/dist/js/treeshaking/analyze/templates.js +13 -8
  125. package/dist/js/treeshaking/analyze/utils.js +15 -4
  126. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +6 -1
  127. package/dist/js/treeshaking/builder/index.js +13 -20
  128. package/dist/js/treeshaking/builder/share.js +1 -4
  129. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +3 -1
  130. package/dist/js/treeshaking/commands/dev.js +19 -24
  131. package/dist/js/treeshaking/commands/index.js +1 -1
  132. package/dist/js/treeshaking/commands/{start.js → serve.js} +10 -3
  133. package/dist/js/treeshaking/config/default.js +53 -56
  134. package/dist/js/treeshaking/config/initial/createOutputConfig.js +1 -3
  135. package/dist/js/treeshaking/config/initial/createSourceConfig.js +5 -1
  136. package/dist/js/treeshaking/config/initial/inits.js +7 -0
  137. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +5 -1
  138. package/dist/js/treeshaking/hooks.js +6 -1
  139. package/dist/js/treeshaking/index.js +349 -132
  140. package/dist/js/treeshaking/initialize/index.js +6 -5
  141. package/dist/js/treeshaking/locale/en.js +1 -1
  142. package/dist/js/treeshaking/locale/zh.js +1 -1
  143. package/dist/js/treeshaking/schema/index.js +11 -12
  144. package/dist/js/treeshaking/schema/legacy.js +1 -4
  145. package/dist/js/treeshaking/utils/commands.js +5 -1
  146. package/dist/js/treeshaking/utils/env.js +13 -0
  147. package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
  148. package/dist/types/analyze/Builder.d.ts +8 -0
  149. package/dist/types/analyze/constants.d.ts +13 -1
  150. package/dist/types/analyze/templates.d.ts +3 -1
  151. package/dist/types/analyze/utils.d.ts +2 -1
  152. package/dist/types/builder/builderPlugins/compatModern.d.ts +3 -3
  153. package/dist/types/builder/index.d.ts +2 -2
  154. package/dist/types/commands/index.d.ts +1 -1
  155. package/dist/types/commands/{start.d.ts → serve.d.ts} +0 -0
  156. package/dist/types/index.d.ts +5 -1
  157. package/dist/types/locale/en.d.ts +1 -1
  158. package/dist/types/locale/index.d.ts +2 -2
  159. package/dist/types/locale/zh.d.ts +1 -1
  160. package/dist/types/schema/Schema.d.ts +1 -1
  161. package/dist/types/types/config/deploy.d.ts +1 -1
  162. package/dist/types/types/config/dev.d.ts +4 -4
  163. package/dist/types/types/config/experiments.d.ts +3 -3
  164. package/dist/types/types/config/html.d.ts +3 -3
  165. package/dist/types/types/config/index.d.ts +6 -3
  166. package/dist/types/types/config/output.d.ts +6 -6
  167. package/dist/types/types/config/performance.d.ts +3 -3
  168. package/dist/types/types/config/security.d.ts +3 -3
  169. package/dist/types/types/config/source.d.ts +6 -5
  170. package/dist/types/types/config/tools.d.ts +3 -3
  171. package/dist/types/types/hooks.d.ts +9 -1
  172. package/dist/types/types/index.d.ts +6 -6
  173. package/dist/types/types/legacyConfig/deploy.d.ts +1 -1
  174. package/dist/types/types/legacyConfig/dev.d.ts +2 -2
  175. package/dist/types/types/legacyConfig/index.d.ts +1 -1
  176. package/dist/types/types/legacyConfig/output.d.ts +2 -2
  177. package/dist/types/types/legacyConfig/source.d.ts +1 -2
  178. package/dist/types/types/legacyConfig/tools.d.ts +2 -2
  179. package/dist/types/utils/commands.d.ts +2 -1
  180. package/dist/types/utils/env.d.ts +2 -0
  181. package/dist/types/utils/getServerInternalPlugins.d.ts +2 -0
  182. package/dist/types/utils/types.d.ts +5 -5
  183. package/package.json +27 -24
@@ -177,6 +177,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
177
177
  import path from "path";
178
178
  import LintPlugin from "@modern-js/plugin-lint";
179
179
  import { cleanRequireCache, emptyDir, Import } from "@modern-js/utils";
180
+ import { castArray } from "@modern-js/utils/lodash";
180
181
  import AnalyzePlugin from "./analyze";
181
182
  import InitializePlugin from "./initialize";
182
183
  import { hooks } from "./hooks";
@@ -187,34 +188,20 @@ import { restart } from "./utils/restart";
187
188
  export * from "./defineConfig";
188
189
  export * from "./types";
189
190
  var upgradeModel = Import.lazy("@modern-js/upgrade", require);
190
- var src_default = function() {
191
- return {
192
- name: "@modern-js/app-tools",
193
- post: [
194
- "@modern-js/plugin-initialize",
195
- "@modern-js/plugin-analyze",
196
- "@modern-js/plugin-ssr",
197
- "@modern-js/plugin-document",
198
- "@modern-js/plugin-state",
199
- "@modern-js/plugin-router",
200
- "@modern-js/plugin-router-legacy",
201
- "@modern-js/plugin-polyfill"
202
- ],
203
- registerHook: hooks,
204
- usePlugins: [
205
- InitializePlugin(),
206
- AnalyzePlugin(),
207
- LintPlugin()
208
- ],
209
- setup: function(api) {
210
- var locale = getLocaleLanguage();
211
- i18n.changeLanguage({
212
- locale: locale
213
- });
214
- return {
215
- commands: function commands(param) {
216
- var program = param.program;
217
- program.command("dev").usage("[options]").description(i18n.t(localeKeys.command.dev.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-e --entry [entry...]", i18n.t(localeKeys.command.dev.entry)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).action(function() {
191
+ var devCommand = function() {
192
+ var _ref = _asyncToGenerator(function(program, api) {
193
+ var runner, devToolMetas, devProgram, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, meta, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, subCmd;
194
+ return __generator(this, function(_state) {
195
+ switch(_state.label){
196
+ case 0:
197
+ runner = api.useHookRunners();
198
+ return [
199
+ 4,
200
+ runner.registerDev()
201
+ ];
202
+ case 1:
203
+ devToolMetas = _state.sent();
204
+ devProgram = program.command("dev").alias("start").usage("[options]").description(i18n.t(localeKeys.command.dev.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-e --entry [entry...]", i18n.t(localeKeys.command.dev.entry)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).action(function() {
218
205
  var _ref = _asyncToGenerator(function(options) {
219
206
  var dev;
220
207
  return __generator(this, function(_state) {
@@ -242,7 +229,105 @@ var src_default = function() {
242
229
  return _ref.apply(this, arguments);
243
230
  };
244
231
  }());
245
- program.command("build").usage("[options]").description(i18n.t(localeKeys.command.build.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).action(function() {
232
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
233
+ try {
234
+ for(_iterator = devToolMetas[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
235
+ meta = _step.value;
236
+ if (!meta.subCommands) {
237
+ continue;
238
+ }
239
+ _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
240
+ try {
241
+ for(_iterator1 = meta.subCommands[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
242
+ subCmd = _step1.value;
243
+ devProgram.command(subCmd).action(/*#__PURE__*/ _asyncToGenerator(function() {
244
+ var options, appDirectory, isTypescript;
245
+ var _arguments = arguments;
246
+ return __generator(this, function(_state) {
247
+ switch(_state.label){
248
+ case 0:
249
+ options = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {};
250
+ appDirectory = api.useAppContext().appDirectory;
251
+ return [
252
+ 4,
253
+ import("@modern-js/utils")
254
+ ];
255
+ case 1:
256
+ isTypescript = _state.sent().isTypescript;
257
+ return [
258
+ 4,
259
+ runner.beforeDevTask(meta)
260
+ ];
261
+ case 2:
262
+ _state.sent();
263
+ return [
264
+ 4,
265
+ meta.action(options, {
266
+ isTsProject: isTypescript(appDirectory)
267
+ })
268
+ ];
269
+ case 3:
270
+ _state.sent();
271
+ return [
272
+ 2
273
+ ];
274
+ }
275
+ });
276
+ }));
277
+ }
278
+ } catch (err) {
279
+ _didIteratorError1 = true;
280
+ _iteratorError1 = err;
281
+ } finally{
282
+ try {
283
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
284
+ _iterator1.return();
285
+ }
286
+ } finally{
287
+ if (_didIteratorError1) {
288
+ throw _iteratorError1;
289
+ }
290
+ }
291
+ }
292
+ }
293
+ } catch (err) {
294
+ _didIteratorError = true;
295
+ _iteratorError = err;
296
+ } finally{
297
+ try {
298
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
299
+ _iterator.return();
300
+ }
301
+ } finally{
302
+ if (_didIteratorError) {
303
+ throw _iteratorError;
304
+ }
305
+ }
306
+ }
307
+ return [
308
+ 2
309
+ ];
310
+ }
311
+ });
312
+ });
313
+ return function devCommand(program, api) {
314
+ return _ref.apply(this, arguments);
315
+ };
316
+ }();
317
+ var buildCommand = function() {
318
+ var _ref = _asyncToGenerator(function(program, api) {
319
+ var runner, platformBuilders, buildProgram, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step;
320
+ return __generator(this, function(_state) {
321
+ switch(_state.label){
322
+ case 0:
323
+ runner = api.useHookRunners();
324
+ return [
325
+ 4,
326
+ runner.registerBuildPlatform()
327
+ ];
328
+ case 1:
329
+ platformBuilders = _state.sent();
330
+ buildProgram = program.command("build").usage("[options]").description(i18n.t(localeKeys.command.build.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).action(function() {
246
331
  var _ref = _asyncToGenerator(function(options) {
247
332
  var build;
248
333
  return __generator(this, function(_state) {
@@ -271,124 +356,256 @@ var src_default = function() {
271
356
  return _ref.apply(this, arguments);
272
357
  };
273
358
  }());
274
- program.command("start").usage("[options]").description(i18n.t(localeKeys.command.start.describe)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(/*#__PURE__*/ _asyncToGenerator(function() {
275
- var start;
359
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
360
+ try {
361
+ _loop = function() {
362
+ var platformBuilder = _step.value;
363
+ var platforms = castArray(platformBuilder.platform);
364
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
365
+ try {
366
+ var _loop = function() {
367
+ var platform = _step1.value;
368
+ buildProgram.command(platform).action(/*#__PURE__*/ _asyncToGenerator(function() {
369
+ var appDirectory, isTypescript;
370
+ return __generator(this, function(_state) {
371
+ switch(_state.label){
372
+ case 0:
373
+ appDirectory = api.useAppContext().appDirectory;
374
+ return [
375
+ 4,
376
+ import("@modern-js/utils")
377
+ ];
378
+ case 1:
379
+ isTypescript = _state.sent().isTypescript;
380
+ return [
381
+ 4,
382
+ runner.beforeBuildPlatform(platformBuilders)
383
+ ];
384
+ case 2:
385
+ _state.sent();
386
+ return [
387
+ 4,
388
+ platformBuilder.build(platform, {
389
+ isTsProject: isTypescript(appDirectory)
390
+ })
391
+ ];
392
+ case 3:
393
+ _state.sent();
394
+ return [
395
+ 2
396
+ ];
397
+ }
398
+ });
399
+ }));
400
+ };
401
+ for(var _iterator = platforms[Symbol.iterator](), _step1; !(_iteratorNormalCompletion = (_step1 = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
402
+ } catch (err) {
403
+ _didIteratorError = true;
404
+ _iteratorError = err;
405
+ } finally{
406
+ try {
407
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
408
+ _iterator.return();
409
+ }
410
+ } finally{
411
+ if (_didIteratorError) {
412
+ throw _iteratorError;
413
+ }
414
+ }
415
+ }
416
+ };
417
+ for(_iterator = platformBuilders[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
418
+ } catch (err) {
419
+ _didIteratorError = true;
420
+ _iteratorError = err;
421
+ } finally{
422
+ try {
423
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
424
+ _iterator.return();
425
+ }
426
+ } finally{
427
+ if (_didIteratorError) {
428
+ throw _iteratorError;
429
+ }
430
+ }
431
+ }
432
+ return [
433
+ 2
434
+ ];
435
+ }
436
+ });
437
+ });
438
+ return function buildCommand(program, api) {
439
+ return _ref.apply(this, arguments);
440
+ };
441
+ }();
442
+ var src_default = function() {
443
+ return {
444
+ name: "@modern-js/app-tools",
445
+ post: [
446
+ "@modern-js/plugin-initialize",
447
+ "@modern-js/plugin-analyze",
448
+ "@modern-js/plugin-ssr",
449
+ "@modern-js/plugin-document",
450
+ "@modern-js/plugin-state",
451
+ "@modern-js/plugin-router",
452
+ "@modern-js/plugin-router-v5",
453
+ "@modern-js/plugin-polyfill"
454
+ ],
455
+ registerHook: hooks,
456
+ usePlugins: [
457
+ InitializePlugin(),
458
+ AnalyzePlugin(),
459
+ LintPlugin()
460
+ ],
461
+ setup: function(api) {
462
+ var locale = getLocaleLanguage();
463
+ i18n.changeLanguage({
464
+ locale: locale
465
+ });
466
+ return {
467
+ commands: function commands(param) {
468
+ var program = param.program;
469
+ return _asyncToGenerator(function() {
276
470
  return __generator(this, function(_state) {
277
471
  switch(_state.label){
278
472
  case 0:
279
473
  return [
280
474
  4,
281
- import("./commands/start")
475
+ devCommand(program, api)
282
476
  ];
283
477
  case 1:
284
- start = _state.sent().start;
478
+ _state.sent();
285
479
  return [
286
480
  4,
287
- start(api)
481
+ buildCommand(program, api)
288
482
  ];
289
483
  case 2:
290
484
  _state.sent();
485
+ program.command("serve").usage("[options]").description(i18n.t(localeKeys.command.serve.describe)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(/*#__PURE__*/ _asyncToGenerator(function() {
486
+ var start;
487
+ return __generator(this, function(_state) {
488
+ switch(_state.label){
489
+ case 0:
490
+ return [
491
+ 4,
492
+ import("./commands/serve")
493
+ ];
494
+ case 1:
495
+ start = _state.sent().start;
496
+ return [
497
+ 4,
498
+ start(api)
499
+ ];
500
+ case 2:
501
+ _state.sent();
502
+ return [
503
+ 2
504
+ ];
505
+ }
506
+ });
507
+ }));
508
+ program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).description(i18n.t(localeKeys.command.deploy.describe)).action(function() {
509
+ var _ref = _asyncToGenerator(function(options) {
510
+ var build, deploy;
511
+ return __generator(this, function(_state) {
512
+ switch(_state.label){
513
+ case 0:
514
+ return [
515
+ 4,
516
+ import("./commands/build")
517
+ ];
518
+ case 1:
519
+ build = _state.sent().build;
520
+ return [
521
+ 4,
522
+ build(api)
523
+ ];
524
+ case 2:
525
+ _state.sent();
526
+ return [
527
+ 4,
528
+ import("./commands/deploy")
529
+ ];
530
+ case 3:
531
+ deploy = _state.sent().deploy;
532
+ return [
533
+ 4,
534
+ deploy(api, options)
535
+ ];
536
+ case 4:
537
+ _state.sent();
538
+ process.exit(0);
539
+ return [
540
+ 2
541
+ ];
542
+ }
543
+ });
544
+ });
545
+ return function(options) {
546
+ return _ref.apply(this, arguments);
547
+ };
548
+ }());
549
+ program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option("-c, --config <config>", i18n.t(localeKeys.command.new.config)).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).action(function() {
550
+ var _ref = _asyncToGenerator(function(options) {
551
+ var MWANewAction;
552
+ return __generator(this, function(_state) {
553
+ switch(_state.label){
554
+ case 0:
555
+ return [
556
+ 4,
557
+ import("@modern-js/new-action")
558
+ ];
559
+ case 1:
560
+ MWANewAction = _state.sent().MWANewAction;
561
+ return [
562
+ 4,
563
+ MWANewAction(_objectSpreadProps(_objectSpread({}, options), {
564
+ locale: locale
565
+ }))
566
+ ];
567
+ case 2:
568
+ _state.sent();
569
+ return [
570
+ 2
571
+ ];
572
+ }
573
+ });
574
+ });
575
+ return function(options) {
576
+ return _ref.apply(this, arguments);
577
+ };
578
+ }());
579
+ program.command("inspect").description("inspect internal webpack config").option("--env <env>", i18n.t(localeKeys.command.inspect.env), "development").option("--output <output>", i18n.t(localeKeys.command.inspect.output), "/").option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(function() {
580
+ var _ref = _asyncToGenerator(function(options) {
581
+ var inspect;
582
+ return __generator(this, function(_state) {
583
+ switch(_state.label){
584
+ case 0:
585
+ return [
586
+ 4,
587
+ import("./commands/inspect")
588
+ ];
589
+ case 1:
590
+ inspect = _state.sent().inspect;
591
+ inspect(api, options);
592
+ return [
593
+ 2
594
+ ];
595
+ }
596
+ });
597
+ });
598
+ return function(options) {
599
+ return _ref.apply(this, arguments);
600
+ };
601
+ }());
602
+ upgradeModel.defineCommand(program.command("upgrade"));
291
603
  return [
292
604
  2
293
605
  ];
294
606
  }
295
607
  });
296
- }));
297
- program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).description(i18n.t(localeKeys.command.deploy.describe)).action(function() {
298
- var _ref = _asyncToGenerator(function(options) {
299
- var build, deploy;
300
- return __generator(this, function(_state) {
301
- switch(_state.label){
302
- case 0:
303
- return [
304
- 4,
305
- import("./commands/build")
306
- ];
307
- case 1:
308
- build = _state.sent().build;
309
- return [
310
- 4,
311
- build(api)
312
- ];
313
- case 2:
314
- _state.sent();
315
- return [
316
- 4,
317
- import("./commands/deploy")
318
- ];
319
- case 3:
320
- deploy = _state.sent().deploy;
321
- return [
322
- 4,
323
- deploy(api, options)
324
- ];
325
- case 4:
326
- _state.sent();
327
- process.exit(0);
328
- return [
329
- 2
330
- ];
331
- }
332
- });
333
- });
334
- return function(options) {
335
- return _ref.apply(this, arguments);
336
- };
337
- }());
338
- program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option("-c, --config <config>", i18n.t(localeKeys.command.new.config)).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).action(function() {
339
- var _ref = _asyncToGenerator(function(options) {
340
- var MWANewAction;
341
- return __generator(this, function(_state) {
342
- switch(_state.label){
343
- case 0:
344
- return [
345
- 4,
346
- import("@modern-js/new-action")
347
- ];
348
- case 1:
349
- MWANewAction = _state.sent().MWANewAction;
350
- return [
351
- 4,
352
- MWANewAction(_objectSpreadProps(_objectSpread({}, options), {
353
- locale: locale
354
- }))
355
- ];
356
- case 2:
357
- _state.sent();
358
- return [
359
- 2
360
- ];
361
- }
362
- });
363
- });
364
- return function(options) {
365
- return _ref.apply(this, arguments);
366
- };
367
- }());
368
- program.command("inspect").description("inspect internal webpack config").option("--env <env>", i18n.t(localeKeys.command.inspect.env), "development").option("--output <output>", i18n.t(localeKeys.command.inspect.output), "/").option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(function() {
369
- var _ref = _asyncToGenerator(function(options) {
370
- var inspect;
371
- return __generator(this, function(_state) {
372
- switch(_state.label){
373
- case 0:
374
- return [
375
- 4,
376
- import("./commands/inspect")
377
- ];
378
- case 1:
379
- inspect = _state.sent().inspect;
380
- inspect(api, options);
381
- return [
382
- 2
383
- ];
384
- }
385
- });
386
- });
387
- return function(options) {
388
- return _ref.apply(this, arguments);
389
- };
390
- }());
391
- upgradeModel.defineCommand(program.command("upgrade"));
608
+ })();
392
609
  },
393
610
  prepare: function prepare() {
394
611
  return _asyncToGenerator(function() {
@@ -397,7 +614,7 @@ var src_default = function() {
397
614
  switch(_state.label){
398
615
  case 0:
399
616
  command = getCommand();
400
- if (!(command === "dev" || command === "build")) return [
617
+ if (!(command === "dev" || command === "start" || command === "build")) return [
401
618
  3,
402
619
  2
403
620
  ];
@@ -474,4 +691,4 @@ var src_default = function() {
474
691
  }
475
692
  };
476
693
  };
477
- export { src_default as default };
694
+ export { buildCommand, src_default as default, devCommand };
@@ -176,7 +176,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
176
176
  };
177
177
  import { ensureAbsolutePath, getPort, isDev } from "@modern-js/utils";
178
178
  import { legacySchema, schema } from "../schema";
179
- import { getCommand } from "../utils/commands";
179
+ import { isDevCommand } from "../utils/commands";
180
180
  import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
181
181
  import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig } from "../config";
182
182
  var initialize_default = function() {
@@ -234,11 +234,13 @@ var initialize_default = function() {
234
234
  tools: normalizedConfig.tools || {},
235
235
  testing: normalizedConfig.testing || {},
236
236
  plugins: normalizedConfig.plugins || [],
237
+ builderPlugins: normalizedConfig.builderPlugins || [],
237
238
  runtime: normalizedConfig.runtime || {},
238
239
  runtimeByEntries: normalizedConfig.runtimeByEntries || {},
239
240
  deploy: normalizedConfig.deploy || {},
240
241
  performance: normalizedConfig.performance || {},
241
- experiments: normalizedConfig.experiments || {}
242
+ experiments: normalizedConfig.experiments || {},
243
+ autoLoadPlugins: normalizedConfig.autoLoadPlugins || false
242
244
  }
243
245
  }
244
246
  ];
@@ -255,12 +257,11 @@ function getDevServerPort(appContext, resolved) {
255
257
  }
256
258
  function _getDevServerPort() {
257
259
  _getDevServerPort = _asyncToGenerator(function(appContext, resolved) {
258
- var command, _port, _tmp;
260
+ var _port, _tmp;
259
261
  return __generator(this, function(_state) {
260
262
  switch(_state.label){
261
263
  case 0:
262
- command = getCommand();
263
- if (!(isDev() && command === "dev")) return [
264
+ if (!(isDev() && isDevCommand())) return [
264
265
  3,
265
266
  4
266
267
  ];
@@ -12,7 +12,7 @@ var EN_LOCALE = {
12
12
  build: {
13
13
  describe: "build application"
14
14
  },
15
- start: {
15
+ serve: {
16
16
  describe: "start server"
17
17
  },
18
18
  deploy: {
@@ -12,7 +12,7 @@ var ZH_LOCALE = {
12
12
  build: {
13
13
  describe: "构建应用命令"
14
14
  },
15
- start: {
15
+ serve: {
16
16
  describe: "应用启动命令"
17
17
  },
18
18
  deploy: {
@@ -34,8 +34,8 @@ var source = {
34
34
  disableMount: {
35
35
  type: "boolean"
36
36
  },
37
- enableFileSystemRoutes: {
38
- type: "boolean"
37
+ customBootstrap: {
38
+ type: "string"
39
39
  }
40
40
  },
41
41
  additionalProperties: false
@@ -57,6 +57,9 @@ var source = {
57
57
  entriesDir: {
58
58
  type: "string"
59
59
  },
60
+ disableEntryDirs: {
61
+ type: "array"
62
+ },
60
63
  configDir: {
61
64
  type: "string"
62
65
  },
@@ -87,14 +90,7 @@ var output = {
87
90
  type: "boolean"
88
91
  }
89
92
  };
90
- var dev = {
91
- proxy: {
92
- type: [
93
- "boolean",
94
- "object"
95
- ]
96
- }
97
- };
93
+ var dev = {};
98
94
  var server = {
99
95
  routes: {
100
96
  type: "object"
@@ -148,7 +144,7 @@ var server = {
148
144
  compiler: {
149
145
  type: "string"
150
146
  },
151
- disableFrameworkExt: {
147
+ enableFrameworkExt: {
152
148
  type: "boolean"
153
149
  }
154
150
  };
@@ -176,7 +172,10 @@ var deploy = {
176
172
  ]
177
173
  }
178
174
  };
175
+ var builderPlugins = {
176
+ type: "array"
177
+ };
179
178
  var schema = new Schema();
180
- schema.setSchema("bff", bff).setSchema("dev", dev).setSchema("server", server).setSchema("source", source).setSchema("output", output).setSchema("tools", tools).setSchema("deploy", deploy);
179
+ schema.setSchema("bff", bff).setSchema("dev", dev).setSchema("server", server).setSchema("source", source).setSchema("output", output).setSchema("tools", tools).setSchema("deploy", deploy).set("builderPlugin", builderPlugins);
181
180
  import { default as default2 } from "./legacy";
182
181
  export { default2 as legacySchema, schema };