@modern-js/app-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 (279) hide show
  1. package/CHANGELOG.md +375 -0
  2. package/dist/js/modern/analyze/generateCode.js +30 -38
  3. package/dist/js/modern/analyze/getBundleEntry.js +5 -13
  4. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +5 -30
  5. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +5 -30
  6. package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -3
  7. package/dist/js/modern/analyze/getFileSystemEntry.js +5 -18
  8. package/dist/js/modern/analyze/getHtmlTemplate.js +3 -10
  9. package/dist/js/modern/analyze/getServerRoutes.js +25 -38
  10. package/dist/js/modern/analyze/index.js +90 -48
  11. package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -4
  12. package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -2
  13. package/dist/js/modern/analyze/nestedRoutes.js +8 -33
  14. package/dist/js/modern/analyze/templates.js +22 -37
  15. package/dist/js/modern/analyze/utils.js +0 -7
  16. package/dist/js/modern/builder/builderPlugins/compatModern.js +41 -58
  17. package/dist/js/modern/builder/index.js +56 -37
  18. package/dist/js/modern/builder/share.js +1 -5
  19. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -8
  20. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +2 -13
  21. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +97 -0
  22. package/dist/js/modern/commands/build.js +12 -46
  23. package/dist/js/modern/commands/dev.js +20 -23
  24. package/dist/js/modern/commands/inspect.js +4 -19
  25. package/dist/js/modern/commands/start.js +1 -2
  26. package/dist/js/modern/config/default.js +207 -0
  27. package/dist/js/modern/config/index.js +2 -0
  28. package/dist/js/modern/config/initial/createHtmlConfig.js +32 -0
  29. package/dist/js/modern/{builder → config/initial}/createOutputConfig.js +19 -18
  30. package/dist/js/modern/config/initial/createSourceConfig.js +32 -0
  31. package/dist/js/modern/config/initial/createToolsConfig.js +41 -0
  32. package/dist/js/modern/config/initial/index.js +11 -0
  33. package/dist/js/modern/config/initial/inits.js +117 -0
  34. package/dist/js/modern/config/initial/transformNormalizedConfig.js +40 -0
  35. package/dist/js/modern/defineConfig.js +12 -0
  36. package/dist/js/modern/hooks.js +23 -19
  37. package/dist/js/modern/index.js +12 -19
  38. package/dist/js/modern/initialize/index.js +72 -0
  39. package/dist/js/modern/schema/Schema.js +39 -0
  40. package/dist/js/modern/schema/index.js +139 -0
  41. package/dist/js/modern/schema/legacy.js +284 -0
  42. package/dist/js/modern/types/config/deploy.js +0 -0
  43. package/dist/js/modern/types/config/dev.js +0 -0
  44. package/dist/js/modern/types/config/experiments.js +0 -0
  45. package/dist/js/modern/types/config/html.js +0 -0
  46. package/dist/js/modern/types/config/index.js +2 -0
  47. package/dist/js/modern/types/config/output.js +0 -0
  48. package/dist/js/modern/types/config/performance.js +0 -0
  49. package/dist/js/modern/types/config/security.js +0 -0
  50. package/dist/js/modern/types/config/source.js +0 -0
  51. package/dist/js/modern/types/config/tools.js +0 -0
  52. package/dist/js/modern/types/hooks.js +0 -0
  53. package/dist/js/modern/types/index.js +4 -0
  54. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  55. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  56. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  57. package/dist/js/modern/types/legacyConfig/output.js +1 -0
  58. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  59. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  60. package/dist/js/modern/utils/config.js +2 -13
  61. package/dist/js/modern/utils/createFileWatcher.js +82 -0
  62. package/dist/js/modern/utils/createServer.js +0 -5
  63. package/dist/js/modern/utils/getSpecifiedEntries.js +0 -6
  64. package/dist/js/modern/utils/printInstructions.js +2 -1
  65. package/dist/js/modern/utils/restart.js +17 -0
  66. package/dist/js/modern/utils/routes.js +0 -2
  67. package/dist/js/node/analyze/generateCode.js +30 -61
  68. package/dist/js/node/analyze/getBundleEntry.js +5 -19
  69. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +5 -45
  70. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +5 -45
  71. package/dist/js/node/analyze/getClientRoutes/index.js +0 -2
  72. package/dist/js/node/analyze/getClientRoutes/utils.js +0 -14
  73. package/dist/js/node/analyze/getFileSystemEntry.js +5 -26
  74. package/dist/js/node/analyze/getHtmlTemplate.js +3 -24
  75. package/dist/js/node/analyze/getServerRoutes.js +24 -46
  76. package/dist/js/node/analyze/index.js +91 -70
  77. package/dist/js/node/analyze/isDefaultExportFunction.js +0 -12
  78. package/dist/js/node/analyze/makeLegalIdentifier.js +0 -4
  79. package/dist/js/node/analyze/nestedRoutes.js +8 -41
  80. package/dist/js/node/analyze/templates.js +22 -47
  81. package/dist/js/node/analyze/utils.js +0 -20
  82. package/dist/js/node/builder/builderPlugins/compatModern.js +41 -69
  83. package/dist/js/node/builder/index.js +57 -51
  84. package/dist/js/node/builder/share.js +1 -13
  85. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -10
  86. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +2 -15
  87. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +105 -0
  88. package/dist/js/node/commands/build.js +10 -57
  89. package/dist/js/node/commands/deploy.js +0 -2
  90. package/dist/js/node/commands/dev.js +19 -34
  91. package/dist/js/node/commands/index.js +0 -6
  92. package/dist/js/node/commands/inspect.js +4 -26
  93. package/dist/js/node/commands/start.js +1 -11
  94. package/dist/js/node/config/default.js +214 -0
  95. package/dist/js/node/config/index.js +31 -0
  96. package/dist/js/node/config/initial/createHtmlConfig.js +38 -0
  97. package/dist/js/node/{builder → config/initial}/createOutputConfig.js +19 -20
  98. package/dist/js/node/config/initial/createSourceConfig.js +38 -0
  99. package/dist/js/node/config/initial/createToolsConfig.js +47 -0
  100. package/dist/js/node/config/initial/index.js +24 -0
  101. package/dist/js/node/config/initial/inits.js +127 -0
  102. package/dist/js/node/config/initial/transformNormalizedConfig.js +46 -0
  103. package/dist/js/node/defineConfig.js +20 -0
  104. package/dist/js/node/exports/server.js +0 -1
  105. package/dist/js/node/hooks.js +23 -30
  106. package/dist/js/node/index.js +35 -48
  107. package/dist/js/node/initialize/index.js +79 -0
  108. package/dist/js/node/locale/index.js +0 -4
  109. package/dist/js/node/schema/Schema.js +46 -0
  110. package/dist/js/node/schema/index.js +152 -0
  111. package/dist/js/node/schema/legacy.js +291 -0
  112. package/dist/js/node/types/config/deploy.js +0 -0
  113. package/dist/js/node/types/config/dev.js +0 -0
  114. package/dist/js/node/types/config/experiments.js +0 -0
  115. package/dist/js/node/types/config/html.js +0 -0
  116. package/dist/js/node/types/config/index.js +16 -0
  117. package/dist/js/node/types/config/output.js +0 -0
  118. package/dist/js/node/types/config/performance.js +0 -0
  119. package/dist/js/node/types/config/security.js +0 -0
  120. package/dist/js/node/types/config/source.js +0 -0
  121. package/dist/js/node/types/config/tools.js +0 -0
  122. package/dist/js/node/types/hooks.js +0 -0
  123. package/dist/js/node/types/index.js +38 -0
  124. package/dist/js/node/types/legacyConfig/deploy.js +0 -0
  125. package/dist/js/node/types/legacyConfig/dev.js +0 -0
  126. package/dist/js/node/types/legacyConfig/index.js +0 -0
  127. package/dist/js/node/types/legacyConfig/output.js +5 -0
  128. package/dist/js/node/types/legacyConfig/source.js +0 -0
  129. package/dist/js/node/types/legacyConfig/tools.js +0 -0
  130. package/dist/js/node/utils/commands.js +0 -2
  131. package/dist/js/node/utils/config.js +2 -26
  132. package/dist/js/node/utils/createFileWatcher.js +90 -0
  133. package/dist/js/node/utils/createServer.js +0 -15
  134. package/dist/js/node/utils/getSpecifiedEntries.js +0 -9
  135. package/dist/js/node/utils/language.js +0 -2
  136. package/dist/js/node/utils/printInstructions.js +2 -5
  137. package/dist/js/node/utils/restart.js +23 -0
  138. package/dist/js/node/utils/routes.js +0 -5
  139. package/dist/js/treeshaking/analyze/generateCode.js +58 -101
  140. package/dist/js/treeshaking/analyze/getBundleEntry.js +12 -20
  141. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +16 -42
  142. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +16 -42
  143. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -3
  144. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +5 -18
  145. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +3 -27
  146. package/dist/js/treeshaking/analyze/getServerRoutes.js +29 -41
  147. package/dist/js/treeshaking/analyze/index.js +195 -91
  148. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -4
  149. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -2
  150. package/dist/js/treeshaking/analyze/nestedRoutes.js +9 -51
  151. package/dist/js/treeshaking/analyze/templates.js +31 -50
  152. package/dist/js/treeshaking/analyze/utils.js +7 -14
  153. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +50 -68
  154. package/dist/js/treeshaking/builder/index.js +69 -65
  155. package/dist/js/treeshaking/builder/share.js +1 -5
  156. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +1 -13
  157. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +2 -14
  158. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +121 -0
  159. package/dist/js/treeshaking/commands/build.js +41 -116
  160. package/dist/js/treeshaking/commands/deploy.js +0 -3
  161. package/dist/js/treeshaking/commands/dev.js +38 -46
  162. package/dist/js/treeshaking/commands/inspect.js +9 -27
  163. package/dist/js/treeshaking/commands/start.js +1 -9
  164. package/dist/js/treeshaking/config/default.js +200 -0
  165. package/dist/js/treeshaking/config/index.js +2 -0
  166. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +31 -0
  167. package/dist/js/treeshaking/config/initial/createOutputConfig.js +67 -0
  168. package/dist/js/treeshaking/config/initial/createSourceConfig.js +41 -0
  169. package/dist/js/treeshaking/config/initial/createToolsConfig.js +38 -0
  170. package/dist/js/treeshaking/config/initial/index.js +11 -0
  171. package/dist/js/treeshaking/config/initial/inits.js +114 -0
  172. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +38 -0
  173. package/dist/js/treeshaking/defineConfig.js +14 -0
  174. package/dist/js/treeshaking/hooks.js +23 -19
  175. package/dist/js/treeshaking/index.js +8 -43
  176. package/dist/js/treeshaking/initialize/index.js +121 -0
  177. package/dist/js/treeshaking/schema/Schema.js +75 -0
  178. package/dist/js/treeshaking/schema/index.js +138 -0
  179. package/dist/js/treeshaking/schema/legacy.js +273 -0
  180. package/dist/js/treeshaking/types/config/deploy.js +0 -0
  181. package/dist/js/treeshaking/types/config/dev.js +0 -0
  182. package/dist/js/treeshaking/types/config/experiments.js +0 -0
  183. package/dist/js/treeshaking/types/config/html.js +0 -0
  184. package/dist/js/treeshaking/types/config/index.js +2 -0
  185. package/dist/js/treeshaking/types/config/output.js +0 -0
  186. package/dist/js/treeshaking/types/config/performance.js +0 -0
  187. package/dist/js/treeshaking/types/config/security.js +0 -0
  188. package/dist/js/treeshaking/types/config/source.js +0 -0
  189. package/dist/js/treeshaking/types/config/tools.js +0 -0
  190. package/dist/js/treeshaking/types/hooks.js +0 -0
  191. package/dist/js/treeshaking/types/index.js +4 -0
  192. package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -0
  193. package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -0
  194. package/dist/js/treeshaking/types/legacyConfig/index.js +0 -0
  195. package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
  196. package/dist/js/treeshaking/types/legacyConfig/source.js +0 -0
  197. package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -0
  198. package/dist/js/treeshaking/utils/config.js +2 -18
  199. package/dist/js/treeshaking/utils/createFileWatcher.js +123 -0
  200. package/dist/js/treeshaking/utils/createServer.js +0 -10
  201. package/dist/js/treeshaking/utils/getSpecifiedEntries.js +0 -10
  202. package/dist/js/treeshaking/utils/printInstructions.js +0 -5
  203. package/dist/js/treeshaking/utils/restart.js +45 -0
  204. package/dist/js/treeshaking/utils/routes.js +0 -4
  205. package/dist/types/analyze/generateCode.d.ts +3 -2
  206. package/dist/types/analyze/getBundleEntry.d.ts +2 -2
  207. package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
  208. package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
  209. package/dist/types/analyze/getServerRoutes.d.ts +3 -2
  210. package/dist/types/analyze/index.d.ts +3 -42
  211. package/dist/types/analyze/nestedRoutes.d.ts +1 -1
  212. package/dist/types/analyze/templates.d.ts +4 -2
  213. package/dist/types/analyze/utils.d.ts +1 -1
  214. package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -3
  215. package/dist/types/builder/index.d.ts +7 -8
  216. package/dist/types/builder/share.d.ts +2 -2
  217. package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +10 -0
  218. package/dist/types/commands/build.d.ts +2 -2
  219. package/dist/types/commands/deploy.d.ts +2 -2
  220. package/dist/types/commands/dev.d.ts +2 -2
  221. package/dist/types/commands/inspect.d.ts +6 -1
  222. package/dist/types/commands/start.d.ts +2 -2
  223. package/dist/types/config/default.d.ts +3 -0
  224. package/dist/types/config/index.d.ts +2 -0
  225. package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
  226. package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
  227. package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
  228. package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
  229. package/dist/types/config/initial/index.d.ts +4 -0
  230. package/dist/types/config/initial/inits.d.ts +4 -0
  231. package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
  232. package/dist/types/defineConfig.d.ts +7 -0
  233. package/dist/types/hooks.d.ts +2 -42
  234. package/dist/types/index.d.ts +5 -7
  235. package/dist/types/initialize/index.d.ts +3 -0
  236. package/dist/types/schema/Schema.d.ts +14 -0
  237. package/dist/types/schema/index.d.ts +4 -0
  238. package/dist/types/schema/legacy.d.ts +3 -0
  239. package/dist/types/types/config/deploy.d.ts +9 -0
  240. package/dist/types/types/config/dev.d.ts +13 -0
  241. package/dist/types/types/config/experiments.d.ts +4 -0
  242. package/dist/types/types/config/html.d.ts +4 -0
  243. package/dist/types/types/config/index.d.ts +62 -0
  244. package/dist/types/types/config/output.d.ts +23 -0
  245. package/dist/types/types/config/performance.d.ts +4 -0
  246. package/dist/types/types/config/security.d.ts +4 -0
  247. package/dist/types/types/config/source.d.ts +22 -0
  248. package/dist/types/types/config/tools.d.ts +15 -0
  249. package/dist/types/types/hooks.d.ts +80 -0
  250. package/dist/types/types/index.d.ts +23 -0
  251. package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
  252. package/dist/types/types/legacyConfig/dev.d.ts +12 -0
  253. package/dist/types/types/legacyConfig/index.d.ts +33 -0
  254. package/dist/types/types/legacyConfig/output.d.ts +51 -0
  255. package/dist/types/types/legacyConfig/source.d.ts +25 -0
  256. package/dist/types/types/legacyConfig/tools.d.ts +16 -0
  257. package/dist/types/utils/config.d.ts +2 -3
  258. package/dist/types/utils/createFileWatcher.d.ts +3 -0
  259. package/dist/types/utils/printInstructions.d.ts +3 -3
  260. package/dist/types/utils/restart.d.ts +3 -0
  261. package/package.json +26 -25
  262. package/dist/js/modern/builder/createHtmlConfig.js +0 -58
  263. package/dist/js/modern/builder/createSourceConfig.js +0 -85
  264. package/dist/js/modern/builder/createToolsConfig.js +0 -94
  265. package/dist/js/modern/utils/createCompiler.js +0 -58
  266. package/dist/js/node/builder/createHtmlConfig.js +0 -76
  267. package/dist/js/node/builder/createSourceConfig.js +0 -99
  268. package/dist/js/node/builder/createToolsConfig.js +0 -103
  269. package/dist/js/node/utils/createCompiler.js +0 -75
  270. package/dist/js/treeshaking/builder/createHtmlConfig.js +0 -59
  271. package/dist/js/treeshaking/builder/createOutputConfig.js +0 -67
  272. package/dist/js/treeshaking/builder/createSourceConfig.js +0 -100
  273. package/dist/js/treeshaking/builder/createToolsConfig.js +0 -90
  274. package/dist/js/treeshaking/utils/createCompiler.js +0 -117
  275. package/dist/types/builder/createHtmlConfig.d.ts +0 -6
  276. package/dist/types/builder/createOutputConfig.d.ts +0 -3
  277. package/dist/types/builder/createSourceConfig.d.ts +0 -5
  278. package/dist/types/builder/createToolsConfig.d.ts +0 -13
  279. package/dist/types/utils/createCompiler.d.ts +0 -12
@@ -2,22 +2,24 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
4
  import path from 'path';
5
- import { defineConfig, cli } from '@modern-js/core';
6
- import LintPlugin from '@modern-js/plugin-jarvis';
5
+ import LintPlugin from '@modern-js/plugin-lint';
7
6
  import { cleanRequireCache, emptyDir, Import } from '@modern-js/utils';
8
7
  import AnalyzePlugin from "./analyze";
8
+ import InitializePlugin from "./initialize";
9
9
  import { hooks } from "./hooks";
10
10
  import { i18n, localeKeys } from "./locale";
11
11
  import { getLocaleLanguage } from "./utils/language";
12
12
  import { getCommand } from "./utils/commands";
13
- export { defineConfig, hooks };
13
+ import { restart } from "./utils/restart";
14
+ export * from "./defineConfig";
15
+ export * from "./types";
14
16
  var upgradeModel = Import.lazy('@modern-js/upgrade', require);
15
17
  export default (function () {
16
18
  return {
17
19
  name: '@modern-js/app-tools',
18
- post: ['@modern-js/plugin-analyze', '@modern-js/plugin-ssr', '@modern-js/plugin-state', '@modern-js/plugin-router', '@modern-js/plugin-router-legacy', '@modern-js/plugin-polyfill'],
20
+ post: ['@modern-js/plugin-initialize', '@modern-js/plugin-analyze', '@modern-js/plugin-ssr', '@modern-js/plugin-document', '@modern-js/plugin-state', '@modern-js/plugin-router', '@modern-js/plugin-router-legacy', '@modern-js/plugin-polyfill'],
19
21
  registerHook: hooks,
20
- usePlugins: [AnalyzePlugin(), LintPlugin()],
22
+ usePlugins: [InitializePlugin(), AnalyzePlugin(), LintPlugin()],
21
23
  setup: function setup(api) {
22
24
  var locale = getLocaleLanguage();
23
25
  i18n.changeLanguage({
@@ -29,20 +31,17 @@ export default (function () {
29
31
  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( /*#__PURE__*/function () {
30
32
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
31
33
  var _yield$import, dev;
32
-
33
34
  return _regeneratorRuntime().wrap(function _callee$(_context) {
34
35
  while (1) {
35
36
  switch (_context.prev = _context.next) {
36
37
  case 0:
37
38
  _context.next = 2;
38
39
  return import("./commands/dev");
39
-
40
40
  case 2:
41
41
  _yield$import = _context.sent;
42
42
  dev = _yield$import.dev;
43
43
  _context.next = 6;
44
44
  return dev(api, options);
45
-
46
45
  case 6:
47
46
  case "end":
48
47
  return _context.stop();
@@ -50,7 +49,6 @@ export default (function () {
50
49
  }
51
50
  }, _callee);
52
51
  }));
53
-
54
52
  return function (_x) {
55
53
  return _ref2.apply(this, arguments);
56
54
  };
@@ -58,25 +56,21 @@ export default (function () {
58
56
  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( /*#__PURE__*/function () {
59
57
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
60
58
  var _yield$import2, build;
61
-
62
59
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
63
60
  while (1) {
64
61
  switch (_context2.prev = _context2.next) {
65
62
  case 0:
66
63
  _context2.next = 2;
67
64
  return import("./commands/build");
68
-
69
65
  case 2:
70
66
  _yield$import2 = _context2.sent;
71
67
  build = _yield$import2.build;
72
68
  _context2.next = 6;
73
69
  return build(api, options);
74
-
75
70
  case 6:
76
71
  // force exit after build.
77
72
  // eslint-disable-next-line no-process-exit
78
73
  process.exit(0);
79
-
80
74
  case 7:
81
75
  case "end":
82
76
  return _context2.stop();
@@ -84,27 +78,23 @@ export default (function () {
84
78
  }
85
79
  }, _callee2);
86
80
  }));
87
-
88
81
  return function (_x2) {
89
82
  return _ref3.apply(this, arguments);
90
83
  };
91
84
  }());
92
85
  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( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
93
86
  var _yield$import3, start;
94
-
95
87
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
96
88
  while (1) {
97
89
  switch (_context3.prev = _context3.next) {
98
90
  case 0:
99
91
  _context3.next = 2;
100
92
  return import("./commands/start");
101
-
102
93
  case 2:
103
94
  _yield$import3 = _context3.sent;
104
95
  start = _yield$import3.start;
105
96
  _context3.next = 6;
106
97
  return start(api);
107
-
108
98
  case 6:
109
99
  case "end":
110
100
  return _context3.stop();
@@ -115,34 +105,28 @@ export default (function () {
115
105
  program.command('deploy').usage('[options]').option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).description(i18n.t(localeKeys.command.deploy.describe)).action( /*#__PURE__*/function () {
116
106
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options) {
117
107
  var _yield$import4, build, _yield$import5, deploy;
118
-
119
108
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
120
109
  while (1) {
121
110
  switch (_context4.prev = _context4.next) {
122
111
  case 0:
123
112
  _context4.next = 2;
124
113
  return import("./commands/build");
125
-
126
114
  case 2:
127
115
  _yield$import4 = _context4.sent;
128
116
  build = _yield$import4.build;
129
117
  _context4.next = 6;
130
118
  return build(api);
131
-
132
119
  case 6:
133
120
  _context4.next = 8;
134
121
  return import("./commands/deploy");
135
-
136
122
  case 8:
137
123
  _yield$import5 = _context4.sent;
138
124
  deploy = _yield$import5.deploy;
139
125
  _context4.next = 12;
140
126
  return deploy(api, options);
141
-
142
127
  case 12:
143
128
  // eslint-disable-next-line no-process-exit
144
129
  process.exit(0);
145
-
146
130
  case 13:
147
131
  case "end":
148
132
  return _context4.stop();
@@ -150,7 +134,6 @@ export default (function () {
150
134
  }
151
135
  }, _callee4);
152
136
  }));
153
-
154
137
  return function (_x3) {
155
138
  return _ref5.apply(this, arguments);
156
139
  };
@@ -158,14 +141,12 @@ export default (function () {
158
141
  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( /*#__PURE__*/function () {
159
142
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options) {
160
143
  var _yield$import6, MWANewAction;
161
-
162
144
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
163
145
  while (1) {
164
146
  switch (_context5.prev = _context5.next) {
165
147
  case 0:
166
148
  _context5.next = 2;
167
149
  return import('@modern-js/new-action');
168
-
169
150
  case 2:
170
151
  _yield$import6 = _context5.sent;
171
152
  MWANewAction = _yield$import6.MWANewAction;
@@ -173,7 +154,6 @@ export default (function () {
173
154
  return MWANewAction(_objectSpread(_objectSpread({}, options), {}, {
174
155
  locale: locale
175
156
  }));
176
-
177
157
  case 6:
178
158
  case "end":
179
159
  return _context5.stop();
@@ -181,7 +161,6 @@ export default (function () {
181
161
  }
182
162
  }, _callee5);
183
163
  }));
184
-
185
164
  return function (_x4) {
186
165
  return _ref6.apply(this, arguments);
187
166
  };
@@ -189,19 +168,16 @@ export default (function () {
189
168
  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( /*#__PURE__*/function () {
190
169
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options) {
191
170
  var _yield$import7, inspect;
192
-
193
171
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
194
172
  while (1) {
195
173
  switch (_context6.prev = _context6.next) {
196
174
  case 0:
197
175
  _context6.next = 2;
198
176
  return import("./commands/inspect");
199
-
200
177
  case 2:
201
178
  _yield$import7 = _context6.sent;
202
179
  inspect = _yield$import7.inspect;
203
180
  inspect(api, options);
204
-
205
181
  case 5:
206
182
  case "end":
207
183
  return _context6.stop();
@@ -209,7 +185,6 @@ export default (function () {
209
185
  }
210
186
  }, _callee6);
211
187
  }));
212
-
213
188
  return function (_x5) {
214
189
  return _ref7.apply(this, arguments);
215
190
  };
@@ -224,16 +199,13 @@ export default (function () {
224
199
  switch (_context7.prev = _context7.next) {
225
200
  case 0:
226
201
  command = getCommand();
227
-
228
202
  if (!(command === 'dev' || command === 'build')) {
229
203
  _context7.next = 5;
230
204
  break;
231
205
  }
232
-
233
206
  appContext = api.useAppContext();
234
207
  _context7.next = 5;
235
208
  return emptyDir(appContext.distDirectory);
236
-
237
209
  case 5:
238
210
  case "end":
239
211
  return _context7.stop();
@@ -246,7 +218,6 @@ export default (function () {
246
218
  fileChange: function fileChange(e) {
247
219
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
248
220
  var filename, eventType, appContext, appDirectory, srcDirectory, absolutePath, _yield$import8, closeServer;
249
-
250
221
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
251
222
  while (1) {
252
223
  switch (_context8.prev = _context8.next) {
@@ -255,25 +226,20 @@ export default (function () {
255
226
  appContext = api.useAppContext();
256
227
  appDirectory = appContext.appDirectory, srcDirectory = appContext.srcDirectory;
257
228
  absolutePath = path.resolve(appDirectory, filename);
258
-
259
229
  if (!(!absolutePath.includes(srcDirectory) && (eventType === 'change' || eventType === 'unlink'))) {
260
230
  _context8.next = 13;
261
231
  break;
262
232
  }
263
-
264
233
  _context8.next = 7;
265
234
  return import("./utils/createServer");
266
-
267
235
  case 7:
268
236
  _yield$import8 = _context8.sent;
269
237
  closeServer = _yield$import8.closeServer;
270
238
  _context8.next = 11;
271
239
  return closeServer();
272
-
273
240
  case 11:
274
241
  _context8.next = 13;
275
- return cli.restart();
276
-
242
+ return restart(api.useHookRunners());
277
243
  case 13:
278
244
  case "end":
279
245
  return _context8.stop();
@@ -289,7 +255,6 @@ export default (function () {
289
255
  switch (_context9.prev = _context9.next) {
290
256
  case 0:
291
257
  cleanRequireCache([require.resolve("./analyze")]);
292
-
293
258
  case 1:
294
259
  case "end":
295
260
  return _context9.stop();
@@ -0,0 +1,121 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
+ import { ensureAbsolutePath, getPort, isDev } from '@modern-js/utils';
5
+ import { legacySchema, schema } from "../schema";
6
+ import { getCommand } from "../utils/commands";
7
+ import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
8
+ import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig } from "../config";
9
+ export default (function () {
10
+ return {
11
+ name: '@modern-js/plugin-initialize',
12
+ setup: function setup(api) {
13
+ var config = function config() {
14
+ var appContext = api.useAppContext();
15
+ var userConfig = api.useConfigContext();
16
+ return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext);
17
+ };
18
+ var validateSchema = function validateSchema() {
19
+ var userConfig = api.useConfigContext();
20
+ var schemas = checkIsLegacyConfig(userConfig) ? legacySchema : schema;
21
+ return schemas.generate();
22
+ };
23
+ return {
24
+ config: config,
25
+ validateSchema: validateSchema,
26
+ resolvedConfig: function resolvedConfig(_ref) {
27
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
28
+ var _resolved$output$dist, _normalizedConfig$ser;
29
+ var resolved, appContext, userConfig, port, normalizedConfig;
30
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
31
+ while (1) {
32
+ switch (_context.prev = _context.next) {
33
+ case 0:
34
+ resolved = _ref.resolved;
35
+ appContext = api.useAppContext();
36
+ userConfig = api.useConfigContext();
37
+ _context.next = 5;
38
+ return getDevServerPort(appContext, resolved);
39
+ case 5:
40
+ port = _context.sent;
41
+ appContext = _objectSpread(_objectSpread({}, appContext), {}, {
42
+ port: port,
43
+ distDirectory: ensureAbsolutePath(appContext.distDirectory, ((_resolved$output$dist = resolved.output.distPath) === null || _resolved$output$dist === void 0 ? void 0 : _resolved$output$dist.root) || 'dist')
44
+ });
45
+ api.setAppContext(appContext);
46
+ normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
47
+ return _context.abrupt("return", {
48
+ resolved: {
49
+ // FIXME: the userConfig mayby legacy userConfig
50
+ _raw: userConfig,
51
+ source: normalizedConfig.source || {},
52
+ server: _objectSpread(_objectSpread({}, normalizedConfig.server || {}), {}, {
53
+ port: port || ((_normalizedConfig$ser = normalizedConfig.server) === null || _normalizedConfig$ser === void 0 ? void 0 : _normalizedConfig$ser.port)
54
+ }),
55
+ bff: normalizedConfig.bff || {},
56
+ dev: normalizedConfig.dev || {},
57
+ html: normalizedConfig.html || {},
58
+ output: normalizedConfig.output || {},
59
+ security: normalizedConfig.security || {},
60
+ tools: normalizedConfig.tools || {},
61
+ testing: normalizedConfig.testing || {},
62
+ plugins: normalizedConfig.plugins || [],
63
+ runtime: normalizedConfig.runtime || {},
64
+ runtimeByEntries: normalizedConfig.runtimeByEntries || {},
65
+ deploy: normalizedConfig.deploy || {},
66
+ performance: normalizedConfig.performance || {},
67
+ experiments: normalizedConfig.experiments || {}
68
+ }
69
+ });
70
+ case 10:
71
+ case "end":
72
+ return _context.stop();
73
+ }
74
+ }
75
+ }, _callee);
76
+ }))();
77
+ }
78
+ };
79
+ }
80
+ };
81
+ });
82
+ function getDevServerPort(_x, _x2) {
83
+ return _getDevServerPort.apply(this, arguments);
84
+ }
85
+ function _getDevServerPort() {
86
+ _getDevServerPort = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(appContext, resolved) {
87
+ var command, _appContext$port;
88
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
89
+ while (1) {
90
+ switch (_context2.prev = _context2.next) {
91
+ case 0:
92
+ command = getCommand();
93
+ if (!(isDev() && command === 'dev')) {
94
+ _context2.next = 10;
95
+ break;
96
+ }
97
+ if (!(((_appContext$port = appContext.port) !== null && _appContext$port !== void 0 ? _appContext$port : 0) > 0)) {
98
+ _context2.next = 6;
99
+ break;
100
+ }
101
+ _context2.t0 = appContext.port;
102
+ _context2.next = 9;
103
+ break;
104
+ case 6:
105
+ _context2.next = 8;
106
+ return getPort(resolved.server.port || 8080);
107
+ case 8:
108
+ _context2.t0 = _context2.sent;
109
+ case 9:
110
+ return _context2.abrupt("return", _context2.t0);
111
+ case 10:
112
+ return _context2.abrupt("return", resolved.server.port);
113
+ case 11:
114
+ case "end":
115
+ return _context2.stop();
116
+ }
117
+ }
118
+ }, _callee2);
119
+ }));
120
+ return _getDevServerPort.apply(this, arguments);
121
+ }
@@ -0,0 +1,75 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
5
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
6
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
7
+ import _wrapNativeSuper from "@babel/runtime/helpers/esm/wrapNativeSuper";
8
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
+ import { merge } from '@modern-js/utils/lodash';
10
+ export var Schema = /*#__PURE__*/function (_Map) {
11
+ _inherits(Schema, _Map);
12
+ var _super = _createSuper(Schema);
13
+ function Schema() {
14
+ var _this;
15
+ var baseSchema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
+ _classCallCheck(this, Schema);
17
+ _this = _super.call(this);
18
+ _defineProperty(_assertThisInitialized(_this), "schema", void 0);
19
+ _this.schema = baseSchema;
20
+ return _this;
21
+ }
22
+ _createClass(Schema, [{
23
+ key: "setSchema",
24
+ value: function setSchema(key, object) {
25
+ var _this2 = this;
26
+ Object.entries(object).forEach(function (_ref) {
27
+ var _ref2 = _slicedToArray(_ref, 2),
28
+ k = _ref2[0],
29
+ v = _ref2[1];
30
+ var target = "".concat(key, ".").concat(k);
31
+ _this2.set(target, v);
32
+ });
33
+ return this;
34
+ }
35
+ }, {
36
+ key: "set",
37
+ value: function set(key, value) {
38
+ if (this.has(key)) {
39
+ merge(this.schema[key], value);
40
+ } else {
41
+ this.schema[key] = value;
42
+ }
43
+ return this;
44
+ }
45
+ }, {
46
+ key: "has",
47
+ value: function has(key) {
48
+ return key in this.schema;
49
+ }
50
+ }, {
51
+ key: "get",
52
+ value: function get(key) {
53
+ return this.schema[key];
54
+ }
55
+ }, {
56
+ key: "delete",
57
+ value: function _delete(key) {
58
+ return delete this.schema[key];
59
+ }
60
+ }, {
61
+ key: "generate",
62
+ value: function generate() {
63
+ return Object.entries(this.schema).map(function (_ref3) {
64
+ var _ref4 = _slicedToArray(_ref3, 2),
65
+ target = _ref4[0],
66
+ schema = _ref4[1];
67
+ return {
68
+ target: target,
69
+ schema: schema
70
+ };
71
+ });
72
+ }
73
+ }]);
74
+ return Schema;
75
+ }( /*#__PURE__*/_wrapNativeSuper(Map));
@@ -0,0 +1,138 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { ENTRY_NAME_PATTERN } from '@modern-js/utils/constants';
3
+ import { Schema } from "./Schema";
4
+ var source = {
5
+ entries: {
6
+ type: 'object',
7
+ patternProperties: _defineProperty({}, ENTRY_NAME_PATTERN, {
8
+ "if": {
9
+ type: 'object'
10
+ },
11
+ then: {
12
+ required: ['entry'],
13
+ properties: {
14
+ entry: {
15
+ type: ['string', 'array']
16
+ },
17
+ disableMount: {
18
+ type: 'boolean'
19
+ },
20
+ enableFileSystemRoutes: {
21
+ type: 'boolean'
22
+ }
23
+ },
24
+ additionalProperties: false
25
+ },
26
+ "else": {
27
+ type: ['string', 'array']
28
+ }
29
+ })
30
+ },
31
+ enableAsyncEntry: {
32
+ type: 'boolean'
33
+ },
34
+ disableDefaultEntries: {
35
+ type: 'boolean'
36
+ },
37
+ entriesDir: {
38
+ type: 'string'
39
+ },
40
+ configDir: {
41
+ type: 'string'
42
+ },
43
+ designSystem: {
44
+ type: 'object'
45
+ }
46
+ };
47
+ var bff = {
48
+ prefix: {
49
+ type: 'string'
50
+ },
51
+ proxy: {
52
+ type: 'object',
53
+ additionalProperties: {
54
+ type: 'string'
55
+ }
56
+ }
57
+ };
58
+ var output = {
59
+ ssg: {
60
+ "typeof": ['boolean', 'object', 'function']
61
+ },
62
+ enableModernMode: {
63
+ type: 'boolean'
64
+ },
65
+ disableNodePolyfill: {
66
+ type: 'boolean'
67
+ }
68
+ };
69
+ var dev = {
70
+ proxy: {
71
+ type: ['boolean', 'object']
72
+ }
73
+ };
74
+ var server = {
75
+ routes: {
76
+ type: 'object'
77
+ },
78
+ publicRoutes: {
79
+ type: 'object'
80
+ },
81
+ ssr: {
82
+ type: ['boolean', 'object']
83
+ },
84
+ ssrByEntries: {
85
+ type: 'object'
86
+ },
87
+ baseUrl: {
88
+ anyOf: [{
89
+ type: 'string'
90
+ }, {
91
+ type: 'array',
92
+ items: {
93
+ type: 'string'
94
+ }
95
+ }]
96
+ },
97
+ port: {
98
+ type: 'number'
99
+ },
100
+ logger: {
101
+ type: ['boolean', 'object']
102
+ },
103
+ metrics: {
104
+ type: ['boolean', 'object']
105
+ },
106
+ enableMicroFrontendDebug: {
107
+ type: 'boolean'
108
+ },
109
+ watchOptions: {
110
+ type: 'object'
111
+ },
112
+ compiler: {
113
+ type: 'string'
114
+ },
115
+ disableFrameworkExt: {
116
+ type: 'boolean'
117
+ }
118
+ };
119
+ var tools = {
120
+ tailwindcss: {
121
+ type: 'object'
122
+ },
123
+ jest: {
124
+ "typeof": ['object', 'function']
125
+ },
126
+ esbuild: {
127
+ "typeof": ['object']
128
+ }
129
+ };
130
+ var deploy = {
131
+ microFrontend: {
132
+ type: ['boolean', 'object']
133
+ }
134
+ };
135
+ var schema = new Schema();
136
+ schema.setSchema('bff', bff).setSchema('dev', dev).setSchema('server', server).setSchema('source', source).setSchema('output', output).setSchema('tools', tools).setSchema('deploy', deploy);
137
+ export { default as legacySchema } from "./legacy";
138
+ export { schema };