@modern-js/app-tools 2.0.0-beta.2 → 2.0.0-beta.4

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 (236) hide show
  1. package/CHANGELOG.md +556 -0
  2. package/bin/modern.js +11 -1
  3. package/dist/js/modern/analyze/Builder.js +39 -0
  4. package/dist/js/modern/analyze/constants.js +38 -16
  5. package/dist/js/modern/analyze/generateCode.js +272 -211
  6. package/dist/js/modern/analyze/getBundleEntry.js +34 -32
  7. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +93 -49
  8. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +89 -47
  9. package/dist/js/modern/analyze/getClientRoutes/index.js +6 -2
  10. package/dist/js/modern/analyze/getClientRoutes/utils.js +23 -10
  11. package/dist/js/modern/analyze/getFileSystemEntry.js +43 -22
  12. package/dist/js/modern/analyze/getHtmlTemplate.js +89 -49
  13. package/dist/js/modern/analyze/getServerRoutes.js +122 -126
  14. package/dist/js/modern/analyze/index.js +201 -160
  15. package/dist/js/modern/analyze/isDefaultExportFunction.js +30 -16
  16. package/dist/js/modern/analyze/makeLegalIdentifier.js +10 -11
  17. package/dist/js/modern/analyze/nestedRoutes.js +110 -53
  18. package/dist/js/modern/analyze/templates.js +191 -77
  19. package/dist/js/modern/analyze/utils.js +98 -51
  20. package/dist/js/modern/builder/builderPlugins/compatModern.js +125 -107
  21. package/dist/js/modern/builder/index.js +124 -89
  22. package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
  23. package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
  24. package/dist/js/modern/builder/share.js +23 -21
  25. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +23 -22
  26. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +31 -27
  27. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +100 -84
  28. package/dist/js/modern/commands/build.js +67 -42
  29. package/dist/js/modern/commands/deploy.js +27 -4
  30. package/dist/js/modern/commands/dev.js +93 -47
  31. package/dist/js/modern/commands/index.js +1 -1
  32. package/dist/js/modern/commands/inspect.js +30 -5
  33. package/dist/js/modern/commands/start.js +37 -16
  34. package/dist/js/modern/config/default.js +103 -114
  35. package/dist/js/modern/config/index.js +8 -2
  36. package/dist/js/modern/config/initial/createHtmlConfig.js +5 -2
  37. package/dist/js/modern/config/initial/createOutputConfig.js +11 -9
  38. package/dist/js/modern/config/initial/createSourceConfig.js +5 -2
  39. package/dist/js/modern/config/initial/createToolsConfig.js +7 -6
  40. package/dist/js/modern/config/initial/index.js +9 -4
  41. package/dist/js/modern/config/initial/inits.js +109 -73
  42. package/dist/js/modern/config/initial/transformNormalizedConfig.js +6 -3
  43. package/dist/js/modern/defineConfig.js +26 -11
  44. package/dist/js/modern/exports/server.js +4 -1
  45. package/dist/js/modern/hooks.js +15 -4
  46. package/dist/js/modern/index.js +178 -90
  47. package/dist/js/modern/initialize/index.js +98 -51
  48. package/dist/js/modern/locale/en.js +20 -21
  49. package/dist/js/modern/locale/index.js +6 -6
  50. package/dist/js/modern/locale/zh.js +21 -22
  51. package/dist/js/modern/schema/Schema.js +6 -5
  52. package/dist/js/modern/schema/index.js +51 -100
  53. package/dist/js/modern/schema/legacy.js +96 -231
  54. package/dist/js/modern/types/config/index.js +0 -1
  55. package/dist/js/modern/types/index.js +0 -1
  56. package/dist/js/modern/types/legacyConfig/output.js +0 -1
  57. package/dist/js/modern/utils/commands.js +5 -2
  58. package/dist/js/modern/utils/config.js +102 -41
  59. package/dist/js/modern/utils/createFileWatcher.js +84 -51
  60. package/dist/js/modern/utils/createServer.js +63 -17
  61. package/dist/js/modern/utils/getSpecifiedEntries.js +46 -19
  62. package/dist/js/modern/utils/language.js +6 -3
  63. package/dist/js/modern/utils/printInstructions.js +27 -8
  64. package/dist/js/modern/utils/restart.js +43 -16
  65. package/dist/js/modern/utils/routes.js +29 -12
  66. package/dist/js/node/analyze/Builder.js +58 -0
  67. package/dist/js/node/analyze/constants.js +54 -35
  68. package/dist/js/node/analyze/generateCode.js +291 -228
  69. package/dist/js/node/analyze/getBundleEntry.js +58 -44
  70. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +132 -76
  71. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +128 -74
  72. package/dist/js/node/analyze/getClientRoutes/index.js +23 -17
  73. package/dist/js/node/analyze/getClientRoutes/utils.js +44 -21
  74. package/dist/js/node/analyze/getFileSystemEntry.js +70 -39
  75. package/dist/js/node/analyze/getHtmlTemplate.js +116 -61
  76. package/dist/js/node/analyze/getServerRoutes.js +143 -137
  77. package/dist/js/node/analyze/index.js +247 -174
  78. package/dist/js/node/analyze/isDefaultExportFunction.js +55 -26
  79. package/dist/js/node/analyze/makeLegalIdentifier.js +27 -15
  80. package/dist/js/node/analyze/nestedRoutes.js +140 -67
  81. package/dist/js/node/analyze/templates.js +212 -84
  82. package/dist/js/node/analyze/utils.js +123 -62
  83. package/dist/js/node/builder/builderPlugins/compatModern.js +153 -120
  84. package/dist/js/node/builder/index.js +152 -98
  85. package/dist/js/node/builder/loaders/routerLoader.js +36 -0
  86. package/dist/js/node/builder/loaders/serverModuleLoader.js +26 -0
  87. package/dist/js/node/builder/share.js +46 -26
  88. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +39 -26
  89. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +47 -31
  90. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +118 -90
  91. package/dist/js/node/commands/build.js +89 -52
  92. package/dist/js/node/commands/deploy.js +45 -10
  93. package/dist/js/node/commands/dev.js +115 -61
  94. package/dist/js/node/commands/index.js +19 -38
  95. package/dist/js/node/commands/inspect.js +48 -11
  96. package/dist/js/node/commands/start.js +65 -27
  97. package/dist/js/node/config/default.js +119 -118
  98. package/dist/js/node/config/index.js +25 -29
  99. package/dist/js/node/config/initial/createHtmlConfig.js +22 -6
  100. package/dist/js/node/config/initial/createOutputConfig.js +28 -13
  101. package/dist/js/node/config/initial/createSourceConfig.js +22 -6
  102. package/dist/js/node/config/initial/createToolsConfig.js +24 -10
  103. package/dist/js/node/config/initial/index.js +28 -17
  104. package/dist/js/node/config/initial/inits.js +126 -81
  105. package/dist/js/node/config/initial/transformNormalizedConfig.js +31 -15
  106. package/dist/js/node/defineConfig.js +43 -17
  107. package/dist/js/node/exports/server.js +21 -10
  108. package/dist/js/node/hooks.js +48 -29
  109. package/dist/js/node/index.js +225 -128
  110. package/dist/js/node/initialize/index.js +116 -61
  111. package/dist/js/node/locale/en.js +36 -25
  112. package/dist/js/node/locale/index.js +27 -15
  113. package/dist/js/node/locale/zh.js +37 -26
  114. package/dist/js/node/schema/Schema.js +23 -10
  115. package/dist/js/node/schema/index.js +77 -114
  116. package/dist/js/node/schema/legacy.js +117 -240
  117. package/dist/js/node/types/config/index.js +17 -16
  118. package/dist/js/node/types/index.js +19 -38
  119. package/dist/js/node/types/legacyConfig/output.js +0 -5
  120. package/dist/js/node/utils/commands.js +21 -6
  121. package/dist/js/node/utils/config.js +120 -51
  122. package/dist/js/node/utils/createFileWatcher.js +104 -60
  123. package/dist/js/node/utils/createServer.js +86 -25
  124. package/dist/js/node/utils/getSpecifiedEntries.js +64 -25
  125. package/dist/js/node/utils/language.js +24 -8
  126. package/dist/js/node/utils/printInstructions.js +47 -16
  127. package/dist/js/node/utils/restart.js +61 -21
  128. package/dist/js/node/utils/routes.js +53 -18
  129. package/dist/js/treeshaking/analyze/Builder.js +199 -0
  130. package/dist/js/treeshaking/analyze/constants.js +28 -16
  131. package/dist/js/treeshaking/analyze/generateCode.js +605 -355
  132. package/dist/js/treeshaking/analyze/getBundleEntry.js +55 -63
  133. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +214 -168
  134. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +215 -169
  135. package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -2
  136. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +19 -20
  137. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +89 -86
  138. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +298 -125
  139. package/dist/js/treeshaking/analyze/getServerRoutes.js +210 -146
  140. package/dist/js/treeshaking/analyze/index.js +571 -304
  141. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +45 -26
  142. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -16
  143. package/dist/js/treeshaking/analyze/nestedRoutes.js +414 -160
  144. package/dist/js/treeshaking/analyze/templates.js +432 -161
  145. package/dist/js/treeshaking/analyze/utils.js +361 -80
  146. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +282 -195
  147. package/dist/js/treeshaking/builder/index.js +371 -167
  148. package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
  149. package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
  150. package/dist/js/treeshaking/builder/share.js +38 -44
  151. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +108 -44
  152. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +70 -39
  153. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +334 -112
  154. package/dist/js/treeshaking/commands/build.js +286 -88
  155. package/dist/js/treeshaking/commands/deploy.js +153 -25
  156. package/dist/js/treeshaking/commands/dev.js +318 -132
  157. package/dist/js/treeshaking/commands/index.js +1 -1
  158. package/dist/js/treeshaking/commands/inspect.js +147 -32
  159. package/dist/js/treeshaking/commands/start.js +190 -68
  160. package/dist/js/treeshaking/config/default.js +210 -199
  161. package/dist/js/treeshaking/config/index.js +3 -2
  162. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -31
  163. package/dist/js/treeshaking/config/initial/createOutputConfig.js +43 -67
  164. package/dist/js/treeshaking/config/initial/createSourceConfig.js +37 -40
  165. package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -38
  166. package/dist/js/treeshaking/config/initial/index.js +10 -9
  167. package/dist/js/treeshaking/config/initial/inits.js +205 -106
  168. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +27 -34
  169. package/dist/js/treeshaking/defineConfig.js +60 -13
  170. package/dist/js/treeshaking/exports/server.js +2 -1
  171. package/dist/js/treeshaking/hooks.js +30 -25
  172. package/dist/js/treeshaking/index.js +681 -256
  173. package/dist/js/treeshaking/initialize/index.js +290 -112
  174. package/dist/js/treeshaking/locale/en.js +34 -33
  175. package/dist/js/treeshaking/locale/index.js +5 -5
  176. package/dist/js/treeshaking/locale/zh.js +34 -33
  177. package/dist/js/treeshaking/schema/Schema.js +267 -69
  178. package/dist/js/treeshaking/schema/index.js +165 -121
  179. package/dist/js/treeshaking/schema/legacy.js +323 -256
  180. package/dist/js/treeshaking/types/config/deploy.js +1 -0
  181. package/dist/js/treeshaking/types/config/dev.js +1 -0
  182. package/dist/js/treeshaking/types/config/experiments.js +1 -0
  183. package/dist/js/treeshaking/types/config/html.js +1 -0
  184. package/dist/js/treeshaking/types/config/index.js +0 -1
  185. package/dist/js/treeshaking/types/config/output.js +1 -0
  186. package/dist/js/treeshaking/types/config/performance.js +1 -0
  187. package/dist/js/treeshaking/types/config/security.js +1 -0
  188. package/dist/js/treeshaking/types/config/source.js +1 -0
  189. package/dist/js/treeshaking/types/config/tools.js +1 -0
  190. package/dist/js/treeshaking/types/hooks.js +1 -0
  191. package/dist/js/treeshaking/types/index.js +0 -1
  192. package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
  193. package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
  194. package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
  195. package/dist/js/treeshaking/types/legacyConfig/output.js +1 -1
  196. package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
  197. package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
  198. package/dist/js/treeshaking/utils/commands.js +6 -5
  199. package/dist/js/treeshaking/utils/config.js +295 -117
  200. package/dist/js/treeshaking/utils/createFileWatcher.js +278 -118
  201. package/dist/js/treeshaking/utils/createServer.js +252 -67
  202. package/dist/js/treeshaking/utils/getSpecifiedEntries.js +182 -55
  203. package/dist/js/treeshaking/utils/language.js +6 -5
  204. package/dist/js/treeshaking/utils/printInstructions.js +151 -29
  205. package/dist/js/treeshaking/utils/restart.js +184 -42
  206. package/dist/js/treeshaking/utils/routes.js +151 -27
  207. package/dist/js/treeshaking/utils/types.js +1 -0
  208. package/dist/types/analyze/Builder.d.ts +8 -0
  209. package/dist/types/analyze/constants.d.ts +2 -0
  210. package/dist/types/analyze/index.d.ts +2 -0
  211. package/dist/types/analyze/templates.d.ts +10 -7
  212. package/dist/types/analyze/utils.d.ts +9 -1
  213. package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -1
  214. package/dist/types/builder/index.d.ts +3 -3
  215. package/dist/types/builder/loaders/routerLoader.d.ts +3 -0
  216. package/dist/types/builder/loaders/serverModuleLoader.d.ts +3 -0
  217. package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +1 -7
  218. package/dist/types/defineConfig.d.ts +1 -0
  219. package/dist/types/index.d.ts +6 -1
  220. package/dist/types/initialize/index.d.ts +2 -0
  221. package/dist/types/types/config/dev.d.ts +2 -2
  222. package/dist/types/types/config/index.d.ts +1 -0
  223. package/dist/types/types/config/output.d.ts +0 -1
  224. package/dist/types/types/config/source.d.ts +1 -0
  225. package/dist/types/types/config/tools.d.ts +10 -1
  226. package/dist/types/types/hooks.d.ts +7 -1
  227. package/dist/types/types/legacyConfig/dev.d.ts +1 -0
  228. package/dist/types/types/legacyConfig/output.d.ts +1 -1
  229. package/dist/types/types/legacyConfig/source.d.ts +1 -0
  230. package/dist/types/types/legacyConfig/tools.d.ts +1 -0
  231. package/dist/types/utils/config.d.ts +1 -0
  232. package/dist/types/utils/createFileWatcher.d.ts +2 -1
  233. package/dist/types/utils/createServer.d.ts +1 -0
  234. package/dist/types/utils/restart.d.ts +1 -1
  235. package/lib/types.d.ts +1 -1
  236. package/package.json +26 -22
@@ -1,70 +1,192 @@
1
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
- import { logger, chalk, isApiOnly } from '@modern-js/utils';
4
- import server from '@modern-js/prod-server';
5
- import { printInstructions } from "../utils/printInstructions";
6
- import { injectDataLoaderPlugin } from "../utils/createServer";
7
- export var start = /*#__PURE__*/function () {
8
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(api) {
9
- var _userConfig$source;
10
- var appContext, userConfig, hookRunners, appDirectory, port, serverConfigFile, apiOnly, app;
11
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
12
- while (1) {
13
- switch (_context2.prev = _context2.next) {
14
- case 0:
15
- appContext = api.useAppContext();
16
- userConfig = api.useResolvedConfigContext();
17
- hookRunners = api.useHookRunners();
18
- appDirectory = appContext.appDirectory, port = appContext.port, serverConfigFile = appContext.serverConfigFile;
19
- logger.log(chalk.cyan("Starting the modern server..."));
20
- _context2.next = 7;
21
- return isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.entriesDir);
22
- case 7:
23
- apiOnly = _context2.sent;
24
- _context2.next = 10;
25
- return server({
26
- pwd: appDirectory,
27
- // FIXME: remove the `any` type
28
- config: userConfig,
29
- serverConfigFile: serverConfigFile,
30
- internalPlugins: injectDataLoaderPlugin(appContext.serverInternalPlugins),
31
- apiOnly: apiOnly
32
- });
33
- case 10:
34
- app = _context2.sent;
35
- app.listen(port, /*#__PURE__*/function () {
36
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(err) {
37
- return _regeneratorRuntime().wrap(function _callee$(_context) {
38
- while (1) {
39
- switch (_context.prev = _context.next) {
40
- case 0:
41
- if (!err) {
42
- _context.next = 2;
43
- break;
44
- }
45
- throw err;
46
- case 2:
47
- _context.next = 4;
48
- return printInstructions(hookRunners, appContext, userConfig);
49
- case 4:
50
- case "end":
51
- return _context.stop();
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _asyncToGenerator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ var __generator = this && this.__generator || function(thisArg, body) {
31
+ var f, y, t, g, _ = {
32
+ label: 0,
33
+ sent: function() {
34
+ if (t[0] & 1) throw t[1];
35
+ return t[1];
36
+ },
37
+ trys: [],
38
+ ops: []
39
+ };
40
+ return(g = {
41
+ next: verb(0),
42
+ "throw": verb(1),
43
+ "return": verb(2)
44
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
45
+ return this;
46
+ }), g);
47
+ function verb(n) {
48
+ return function(v) {
49
+ return step([
50
+ n,
51
+ v
52
+ ]);
53
+ };
54
+ }
55
+ function step(op) {
56
+ if (f) throw new TypeError("Generator is already executing.");
57
+ while(_)try {
58
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
59
+ if (y = 0, t) op = [
60
+ op[0] & 2,
61
+ t.value
62
+ ];
63
+ switch(op[0]){
64
+ case 0:
65
+ case 1:
66
+ t = op;
67
+ break;
68
+ case 4:
69
+ _.label++;
70
+ return {
71
+ value: op[1],
72
+ done: false
73
+ };
74
+ case 5:
75
+ _.label++;
76
+ y = op[1];
77
+ op = [
78
+ 0
79
+ ];
80
+ continue;
81
+ case 7:
82
+ op = _.ops.pop();
83
+ _.trys.pop();
84
+ continue;
85
+ default:
86
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
87
+ _ = 0;
88
+ continue;
89
+ }
90
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
91
+ _.label = op[1];
92
+ break;
93
+ }
94
+ if (op[0] === 6 && _.label < t[1]) {
95
+ _.label = t[1];
96
+ t = op;
97
+ break;
52
98
  }
53
- }
54
- }, _callee);
55
- }));
56
- return function (_x2) {
57
- return _ref2.apply(this, arguments);
58
- };
59
- }());
60
- case 12:
61
- case "end":
62
- return _context2.stop();
99
+ if (t && _.label < t[2]) {
100
+ _.label = t[2];
101
+ _.ops.push(op);
102
+ break;
103
+ }
104
+ if (t[2]) _.ops.pop();
105
+ _.trys.pop();
106
+ continue;
107
+ }
108
+ op = body.call(thisArg, _);
109
+ } catch (e) {
110
+ op = [
111
+ 6,
112
+ e
113
+ ];
114
+ y = 0;
115
+ } finally{
116
+ f = t = 0;
63
117
  }
64
- }
65
- }, _callee2);
66
- }));
67
- return function start(_x) {
68
- return _ref.apply(this, arguments);
69
- };
70
- }();
118
+ if (op[0] & 5) throw op[1];
119
+ return {
120
+ value: op[0] ? op[1] : void 0,
121
+ done: true
122
+ };
123
+ }
124
+ };
125
+ import { logger, chalk, isApiOnly } from "@modern-js/utils";
126
+ import server from "@modern-js/prod-server";
127
+ import { printInstructions } from "../utils/printInstructions";
128
+ import { injectDataLoaderPlugin } from "../utils/createServer";
129
+ var start = function() {
130
+ var _ref = _asyncToGenerator(function(api) {
131
+ var ref, appContext, userConfig, hookRunners, appDirectory, port, serverConfigFile, apiOnly, app;
132
+ return __generator(this, function(_state) {
133
+ switch(_state.label){
134
+ case 0:
135
+ appContext = api.useAppContext();
136
+ userConfig = api.useResolvedConfigContext();
137
+ hookRunners = api.useHookRunners();
138
+ appDirectory = appContext.appDirectory, port = appContext.port, serverConfigFile = appContext.serverConfigFile;
139
+ logger.log(chalk.cyan("Starting the modern server..."));
140
+ return [
141
+ 4,
142
+ isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (ref = userConfig.source) === null || ref === void 0 ? void 0 : ref.entriesDir)
143
+ ];
144
+ case 1:
145
+ apiOnly = _state.sent();
146
+ return [
147
+ 4,
148
+ server({
149
+ pwd: appDirectory,
150
+ config: userConfig,
151
+ serverConfigFile: serverConfigFile,
152
+ internalPlugins: injectDataLoaderPlugin(appContext.serverInternalPlugins),
153
+ apiOnly: apiOnly
154
+ })
155
+ ];
156
+ case 2:
157
+ app = _state.sent();
158
+ app.listen(port, function() {
159
+ var _ref = _asyncToGenerator(function(err) {
160
+ return __generator(this, function(_state) {
161
+ switch(_state.label){
162
+ case 0:
163
+ if (err) {
164
+ throw err;
165
+ }
166
+ return [
167
+ 4,
168
+ printInstructions(hookRunners, appContext, userConfig)
169
+ ];
170
+ case 1:
171
+ _state.sent();
172
+ return [
173
+ 2
174
+ ];
175
+ }
176
+ });
177
+ });
178
+ return function(err) {
179
+ return _ref.apply(this, arguments);
180
+ };
181
+ }());
182
+ return [
183
+ 2
184
+ ];
185
+ }
186
+ });
187
+ });
188
+ return function start(api) {
189
+ return _ref.apply(this, arguments);
190
+ };
191
+ }();
192
+ export { start };
@@ -1,200 +1,211 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- export function createDefaultConfig(appContext) {
3
- var _ref;
4
- var defaultAlias = appContext ? (_ref = {}, _defineProperty(_ref, appContext.internalDirAlias, appContext.internalDirectory), _defineProperty(_ref, appContext.internalSrcAlias, appContext.srcDirectory), _defineProperty(_ref, '@', appContext.srcDirectory), _defineProperty(_ref, '@shared', appContext.sharedDirectory), _ref) : {};
5
- var source = {
6
- entries: undefined,
7
- enableAsyncEntry: false,
8
- disableDefaultEntries: false,
9
- entriesDir: './src',
10
- configDir: './config',
11
- globalVars: undefined,
12
- moduleScopes: undefined,
13
- include: [],
14
- alias: defaultAlias
15
- };
16
- var output = {
17
- assetPrefix: '/',
18
- distPath: {
19
- html: 'html',
20
- js: 'static/js',
21
- css: 'static/css',
22
- media: 'static/media',
23
- root: 'dist'
24
- },
25
- copy: undefined,
26
- disableCssModuleExtension: false,
27
- enableCssModuleTSDeclaration: false,
28
- disableMinimize: false,
29
- enableInlineStyles: false,
30
- enableInlineScripts: false,
31
- disableSourceMap: false,
32
- disableInlineRuntimeChunk: false,
33
- disableFilenameHash: false,
34
- enableLatestDecorators: false,
35
- polyfill: 'entry',
36
- dataUriLimit: 10000,
37
- cssModuleLocalIdentName: undefined
38
- };
39
- var html = {
40
- title: '',
41
- titleByEntries: undefined,
42
- meta: {
43
- charset: {
44
- charset: 'utf-8'
45
- },
46
- viewport: 'width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
47
- 'http-equiv': {
48
- 'http-equiv': 'x-ua-compatible',
49
- content: 'ie=edge'
50
- },
51
- renderer: 'webkit',
52
- layoutmode: 'standard',
53
- imagemode: 'force',
54
- 'wap-font-scale': 'no',
55
- 'format-detection': 'telephone=no'
56
- },
57
- metaByEntries: undefined,
58
- inject: 'head',
59
- injectByEntries: undefined,
60
- mountId: 'root',
61
- favicon: '',
62
- faviconByEntries: undefined,
63
- disableHtmlFolder: false,
64
- templateParameters: {},
65
- templateParametersByEntries: undefined
66
- };
67
- var server = {
68
- routes: undefined,
69
- publicRoutes: undefined,
70
- ssr: undefined,
71
- ssrByEntries: undefined,
72
- baseUrl: '/',
73
- port: 8080
74
- };
75
- var dev = {
76
- assetPrefix: false,
77
- https: false
78
- };
79
- var tools = {
80
- webpack: undefined,
81
- babel: undefined,
82
- postcss: undefined,
83
- autoprefixer: undefined,
84
- devServer: undefined,
85
- tsLoader: undefined,
86
- terser: undefined,
87
- minifyCss: undefined
88
- };
89
- return {
90
- source: source,
91
- output: output,
92
- server: server,
93
- dev: dev,
94
- html: html,
95
- tools: tools,
96
- plugins: [],
97
- runtime: {},
98
- runtimeByEntries: {}
99
- };
1
+ function _defineProperty(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
100
13
  }
101
- export function createLegacyDefaultConfig(appContext) {
102
- var _ref2;
103
- var defaultAlias = appContext ? (_ref2 = {}, _defineProperty(_ref2, appContext.internalDirAlias, appContext.internalDirectory), _defineProperty(_ref2, appContext.internalSrcAlias, appContext.srcDirectory), _defineProperty(_ref2, '@', appContext.srcDirectory), _defineProperty(_ref2, '@shared', appContext.sharedDirectory), _ref2) : {};
104
- var sourceDefaults = {
105
- entries: undefined,
106
- enableAsyncEntry: false,
107
- disableDefaultEntries: false,
108
- entriesDir: './src',
109
- configDir: './config',
110
- apiDir: './api',
111
- envVars: [],
112
- globalVars: undefined,
113
- alias: defaultAlias,
114
- moduleScopes: undefined,
115
- include: []
116
- };
117
- var outputDefaults = {
118
- assetPrefix: '/',
119
- htmlPath: 'html',
120
- jsPath: 'static/js',
121
- cssPath: 'static/css',
122
- mediaPath: 'static/media',
123
- path: 'dist',
124
- title: '',
125
- titleByEntries: undefined,
126
- meta: {
127
- charset: {
128
- charset: 'utf-8'
129
- },
130
- viewport: 'width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
131
- 'http-equiv': {
132
- 'http-equiv': 'x-ua-compatible',
133
- content: 'ie=edge'
134
- },
135
- renderer: 'webkit',
136
- layoutmode: 'standard',
137
- imagemode: 'force',
138
- 'wap-font-scale': 'no',
139
- 'format-detection': 'telephone=no'
140
- },
141
- metaByEntries: undefined,
142
- inject: 'head',
143
- injectByEntries: undefined,
144
- mountId: 'root',
145
- favicon: '',
146
- faviconByEntries: undefined,
147
- copy: undefined,
148
- disableHtmlFolder: false,
149
- disableCssModuleExtension: false,
150
- disableCssExtract: false,
151
- enableCssModuleTSDeclaration: false,
152
- disableMinimize: false,
153
- enableInlineStyles: false,
154
- enableInlineScripts: false,
155
- disableSourceMap: false,
156
- disableInlineRuntimeChunk: false,
157
- disableAssetsCache: false,
158
- enableLatestDecorators: false,
159
- polyfill: 'entry',
160
- dataUriLimit: 10000,
161
- templateParameters: {},
162
- templateParametersByEntries: undefined,
163
- cssModuleLocalIdentName: undefined,
164
- enableModernMode: false,
165
- disableNodePolyfill: false,
166
- enableTsLoader: false
167
- };
168
- var serverDefaults = {
169
- routes: undefined,
170
- publicRoutes: undefined,
171
- ssr: undefined,
172
- ssrByEntries: undefined,
173
- baseUrl: '/',
174
- port: 8080
175
- };
176
- var devDefaults = {
177
- assetPrefix: false,
178
- https: false
179
- };
180
- var toolsDefaults = {
181
- webpack: undefined,
182
- babel: undefined,
183
- postcss: undefined,
184
- autoprefixer: undefined,
185
- lodash: undefined,
186
- devServer: undefined,
187
- tsLoader: undefined,
188
- terser: undefined,
189
- minifyCss: undefined
190
- };
191
- return {
192
- source: sourceDefaults,
193
- output: outputDefaults,
194
- server: serverDefaults,
195
- dev: devDefaults,
196
- tools: toolsDefaults,
197
- runtime: {},
198
- runtimeByEntries: {}
199
- };
200
- }
14
+ function createDefaultConfig(appContext) {
15
+ var _obj;
16
+ var defaultAlias = appContext ? (_obj = {}, _defineProperty(_obj, appContext.internalDirAlias, appContext.internalDirectory), _defineProperty(_obj, appContext.internalSrcAlias, appContext.srcDirectory), _defineProperty(_obj, "@", appContext.srcDirectory), _defineProperty(_obj, "@shared", appContext.sharedDirectory), _obj) : {};
17
+ var source = {
18
+ entries: void 0,
19
+ enableAsyncEntry: false,
20
+ disableDefaultEntries: false,
21
+ entriesDir: "./src",
22
+ configDir: "./config",
23
+ globalVars: void 0,
24
+ moduleScopes: void 0,
25
+ include: [],
26
+ alias: defaultAlias
27
+ };
28
+ var output = {
29
+ assetPrefix: "/",
30
+ distPath: {
31
+ html: "html",
32
+ js: "static/js",
33
+ css: "static/css",
34
+ media: "static/media",
35
+ root: "dist"
36
+ },
37
+ copy: void 0,
38
+ disableCssModuleExtension: false,
39
+ enableCssModuleTSDeclaration: false,
40
+ disableMinimize: false,
41
+ enableInlineStyles: false,
42
+ enableInlineScripts: false,
43
+ disableSourceMap: false,
44
+ disableInlineRuntimeChunk: false,
45
+ disableFilenameHash: false,
46
+ enableLatestDecorators: false,
47
+ polyfill: "entry",
48
+ cssModuleLocalIdentName: void 0
49
+ };
50
+ var html = {
51
+ title: "",
52
+ titleByEntries: void 0,
53
+ meta: {
54
+ charset: {
55
+ charset: "utf-8"
56
+ },
57
+ viewport: "width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no",
58
+ "http-equiv": {
59
+ "http-equiv": "x-ua-compatible",
60
+ content: "ie=edge"
61
+ },
62
+ renderer: "webkit",
63
+ layoutmode: "standard",
64
+ imagemode: "force",
65
+ "wap-font-scale": "no",
66
+ "format-detection": "telephone=no"
67
+ },
68
+ metaByEntries: void 0,
69
+ inject: "head",
70
+ injectByEntries: void 0,
71
+ mountId: "root",
72
+ favicon: "",
73
+ faviconByEntries: void 0,
74
+ disableHtmlFolder: false,
75
+ templateParameters: {},
76
+ templateParametersByEntries: void 0
77
+ };
78
+ var server = {
79
+ routes: void 0,
80
+ publicRoutes: void 0,
81
+ ssr: void 0,
82
+ ssrByEntries: void 0,
83
+ baseUrl: "/",
84
+ port: 8080
85
+ };
86
+ var dev = {
87
+ assetPrefix: false,
88
+ https: false
89
+ };
90
+ var tools = {
91
+ webpack: void 0,
92
+ babel: void 0,
93
+ postcss: void 0,
94
+ autoprefixer: void 0,
95
+ devServer: void 0,
96
+ tsLoader: void 0,
97
+ terser: void 0,
98
+ minifyCss: void 0
99
+ };
100
+ return {
101
+ source: source,
102
+ output: output,
103
+ server: server,
104
+ dev: dev,
105
+ html: html,
106
+ tools: tools,
107
+ plugins: [],
108
+ runtime: {},
109
+ runtimeByEntries: {}
110
+ };
111
+ }
112
+ function createLegacyDefaultConfig(appContext) {
113
+ var _obj;
114
+ var defaultAlias = appContext ? (_obj = {}, _defineProperty(_obj, appContext.internalDirAlias, appContext.internalDirectory), _defineProperty(_obj, appContext.internalSrcAlias, appContext.srcDirectory), _defineProperty(_obj, "@", appContext.srcDirectory), _defineProperty(_obj, "@shared", appContext.sharedDirectory), _obj) : {};
115
+ var sourceDefaults = {
116
+ entries: void 0,
117
+ enableAsyncEntry: false,
118
+ disableDefaultEntries: false,
119
+ entriesDir: "./src",
120
+ configDir: "./config",
121
+ apiDir: "./api",
122
+ envVars: [],
123
+ globalVars: void 0,
124
+ alias: defaultAlias,
125
+ moduleScopes: void 0,
126
+ include: []
127
+ };
128
+ var outputDefaults = {
129
+ assetPrefix: "/",
130
+ htmlPath: "html",
131
+ jsPath: "static/js",
132
+ cssPath: "static/css",
133
+ mediaPath: "static/media",
134
+ path: "dist",
135
+ title: "",
136
+ titleByEntries: void 0,
137
+ meta: {
138
+ charset: {
139
+ charset: "utf-8"
140
+ },
141
+ viewport: "width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no",
142
+ "http-equiv": {
143
+ "http-equiv": "x-ua-compatible",
144
+ content: "ie=edge"
145
+ },
146
+ renderer: "webkit",
147
+ layoutmode: "standard",
148
+ imagemode: "force",
149
+ "wap-font-scale": "no",
150
+ "format-detection": "telephone=no"
151
+ },
152
+ metaByEntries: void 0,
153
+ inject: "head",
154
+ injectByEntries: void 0,
155
+ mountId: "root",
156
+ favicon: "",
157
+ faviconByEntries: void 0,
158
+ copy: void 0,
159
+ disableHtmlFolder: false,
160
+ disableCssModuleExtension: false,
161
+ disableCssExtract: false,
162
+ enableCssModuleTSDeclaration: false,
163
+ disableMinimize: false,
164
+ enableInlineStyles: false,
165
+ enableInlineScripts: false,
166
+ disableSourceMap: false,
167
+ disableInlineRuntimeChunk: false,
168
+ disableAssetsCache: false,
169
+ enableLatestDecorators: false,
170
+ polyfill: "entry",
171
+ dataUriLimit: 1e4,
172
+ templateParameters: {},
173
+ templateParametersByEntries: void 0,
174
+ cssModuleLocalIdentName: void 0,
175
+ disableNodePolyfill: false,
176
+ enableTsLoader: false
177
+ };
178
+ var serverDefaults = {
179
+ routes: void 0,
180
+ publicRoutes: void 0,
181
+ ssr: void 0,
182
+ ssrByEntries: void 0,
183
+ baseUrl: "/",
184
+ port: 8080
185
+ };
186
+ var devDefaults = {
187
+ assetPrefix: false,
188
+ https: false
189
+ };
190
+ var toolsDefaults = {
191
+ webpack: void 0,
192
+ babel: void 0,
193
+ postcss: void 0,
194
+ autoprefixer: void 0,
195
+ lodash: void 0,
196
+ devServer: void 0,
197
+ tsLoader: void 0,
198
+ terser: void 0,
199
+ minifyCss: void 0
200
+ };
201
+ return {
202
+ source: sourceDefaults,
203
+ output: outputDefaults,
204
+ server: serverDefaults,
205
+ dev: devDefaults,
206
+ tools: toolsDefaults,
207
+ runtime: {},
208
+ runtimeByEntries: {}
209
+ };
210
+ }
211
+ export { createDefaultConfig, createLegacyDefaultConfig };