@modern-js/app-tools 2.53.1-alpha.3 → 2.54.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. package/bin/modern.js +0 -2
  2. package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +2 -1
  3. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +2 -2
  4. package/dist/cjs/commands/build.js +2 -0
  5. package/dist/cjs/commands/deploy.js +2 -2
  6. package/dist/cjs/commands/dev.js +19 -5
  7. package/dist/cjs/commands/index.js +113 -7
  8. package/dist/cjs/commands/serve.js +19 -5
  9. package/dist/cjs/hooks.js +5 -0
  10. package/dist/cjs/index.js +14 -83
  11. package/dist/cjs/plugins/analyze/constants.js +56 -0
  12. package/dist/cjs/{analyze → plugins/analyze}/generateCode.js +11 -84
  13. package/dist/cjs/{analyze → plugins/analyze}/getBundleEntry.js +11 -20
  14. package/dist/cjs/{analyze → plugins/analyze}/getFileSystemEntry.js +33 -47
  15. package/dist/cjs/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
  16. package/dist/cjs/{analyze → plugins/analyze}/index.js +9 -24
  17. package/dist/cjs/plugins/analyze/templates.js +101 -0
  18. package/dist/cjs/{analyze → plugins/analyze}/utils.js +12 -55
  19. package/dist/cjs/plugins/deploy/dependencies/index.js +16 -25
  20. package/dist/cjs/plugins/deploy/dependencies/utils.js +1 -2
  21. package/dist/cjs/plugins/deploy/platforms/netlify.js +5 -9
  22. package/dist/cjs/plugins/deploy/platforms/node.js +5 -13
  23. package/dist/cjs/plugins/deploy/platforms/vercel.js +5 -9
  24. package/dist/cjs/{initialize → plugins/initialize}/index.js +1 -1
  25. package/dist/cjs/plugins/serverBuild.js +10 -4
  26. package/dist/cjs/utils/createServer.js +1 -1
  27. package/dist/cjs/utils/{getServerInternalPlugins.js → loadPlugins.js} +18 -11
  28. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +4 -1
  29. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +2 -2
  30. package/dist/esm/commands/build.js +16 -9
  31. package/dist/esm/commands/deploy.js +2 -2
  32. package/dist/esm/commands/dev.js +13 -9
  33. package/dist/esm/commands/index.js +411 -3
  34. package/dist/esm/commands/serve.js +12 -8
  35. package/dist/esm/hooks.js +5 -0
  36. package/dist/esm/index.js +12 -394
  37. package/dist/esm/plugins/analyze/constants.js +24 -0
  38. package/dist/esm/{analyze → plugins/analyze}/generateCode.js +27 -169
  39. package/dist/esm/plugins/analyze/getBundleEntry.js +101 -0
  40. package/dist/esm/plugins/analyze/getFileSystemEntry.js +195 -0
  41. package/dist/esm/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
  42. package/dist/esm/{analyze → plugins/analyze}/index.js +42 -70
  43. package/dist/esm/plugins/analyze/templates.js +22 -0
  44. package/dist/esm/{analyze → plugins/analyze}/utils.js +13 -135
  45. package/dist/esm/plugins/deploy/dependencies/index.js +69 -94
  46. package/dist/esm/plugins/deploy/dependencies/utils.js +3 -4
  47. package/dist/esm/plugins/deploy/platforms/netlify.js +8 -10
  48. package/dist/esm/plugins/deploy/platforms/node.js +8 -14
  49. package/dist/esm/plugins/deploy/platforms/vercel.js +8 -10
  50. package/dist/esm/{initialize → plugins/initialize}/index.js +1 -1
  51. package/dist/esm/plugins/serverBuild.js +13 -6
  52. package/dist/esm/utils/createServer.js +2 -2
  53. package/dist/esm/utils/loadPlugins.js +64 -0
  54. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +2 -1
  55. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +2 -2
  56. package/dist/esm-node/commands/build.js +2 -0
  57. package/dist/esm-node/commands/deploy.js +2 -2
  58. package/dist/esm-node/commands/dev.js +11 -7
  59. package/dist/esm-node/commands/index.js +92 -3
  60. package/dist/esm-node/commands/serve.js +10 -6
  61. package/dist/esm-node/hooks.js +5 -0
  62. package/dist/esm-node/index.js +12 -79
  63. package/dist/esm-node/plugins/analyze/constants.js +24 -0
  64. package/dist/esm-node/{analyze → plugins/analyze}/generateCode.js +14 -87
  65. package/dist/esm-node/{analyze → plugins/analyze}/getBundleEntry.js +11 -20
  66. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +75 -0
  67. package/dist/esm-node/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
  68. package/dist/esm-node/{analyze → plugins/analyze}/index.js +10 -25
  69. package/dist/esm-node/plugins/analyze/templates.js +75 -0
  70. package/dist/esm-node/{analyze → plugins/analyze}/utils.js +13 -52
  71. package/dist/esm-node/plugins/deploy/dependencies/index.js +18 -27
  72. package/dist/esm-node/plugins/deploy/dependencies/utils.js +1 -2
  73. package/dist/esm-node/plugins/deploy/platforms/netlify.js +6 -10
  74. package/dist/esm-node/plugins/deploy/platforms/node.js +6 -14
  75. package/dist/esm-node/plugins/deploy/platforms/vercel.js +6 -10
  76. package/dist/esm-node/{initialize → plugins/initialize}/index.js +1 -1
  77. package/dist/esm-node/plugins/serverBuild.js +11 -5
  78. package/dist/esm-node/utils/createServer.js +2 -2
  79. package/dist/esm-node/utils/loadPlugins.js +21 -0
  80. package/dist/types/builder/builder-webpack/createCopyPattern.d.ts +2 -2
  81. package/dist/types/commands/index.d.ts +10 -3
  82. package/dist/types/config/initialize/inits.d.ts +1 -1
  83. package/dist/types/exports/server.d.ts +4 -0
  84. package/dist/types/index.d.ts +2 -5
  85. package/dist/types/plugins/analyze/constants.d.ts +9 -0
  86. package/dist/types/{analyze → plugins/analyze}/generateCode.d.ts +1 -1
  87. package/dist/types/plugins/analyze/getBundleEntry.d.ts +4 -0
  88. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +5 -0
  89. package/dist/types/{analyze → plugins/analyze}/getHtmlTemplate.d.ts +1 -1
  90. package/dist/types/{analyze → plugins/analyze}/getServerRoutes.d.ts +1 -1
  91. package/dist/types/{analyze → plugins/analyze}/index.d.ts +1 -1
  92. package/dist/types/plugins/analyze/templates.d.ts +19 -0
  93. package/dist/types/{analyze → plugins/analyze}/utils.d.ts +4 -6
  94. package/dist/types/plugins/deploy/dependencies/index.d.ts +1 -9
  95. package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -7
  96. package/dist/types/{initialize → plugins/initialize}/index.d.ts +1 -1
  97. package/dist/types/types/hooks.d.ts +11 -1
  98. package/dist/types/utils/loadPlugins.d.ts +5 -0
  99. package/package.json +22 -30
  100. package/dist/cjs/analyze/constants.js +0 -122
  101. package/dist/cjs/analyze/getClientRoutes/getRoutes.js +0 -197
  102. package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +0 -195
  103. package/dist/cjs/analyze/getClientRoutes/index.js +0 -31
  104. package/dist/cjs/analyze/getClientRoutes/utils.js +0 -59
  105. package/dist/cjs/analyze/makeLegalIdentifier.js +0 -37
  106. package/dist/cjs/analyze/nestedRoutes.js +0 -295
  107. package/dist/cjs/analyze/templates.js +0 -444
  108. package/dist/cjs/plugins/deploy/exports.js +0 -28
  109. package/dist/esm/analyze/constants.js +0 -76
  110. package/dist/esm/analyze/getBundleEntry.js +0 -75
  111. package/dist/esm/analyze/getClientRoutes/getRoutes.js +0 -185
  112. package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +0 -183
  113. package/dist/esm/analyze/getClientRoutes/index.js +0 -6
  114. package/dist/esm/analyze/getClientRoutes/utils.js +0 -28
  115. package/dist/esm/analyze/getFileSystemEntry.js +0 -113
  116. package/dist/esm/analyze/makeLegalIdentifier.js +0 -15
  117. package/dist/esm/analyze/nestedRoutes.js +0 -398
  118. package/dist/esm/analyze/templates.js +0 -435
  119. package/dist/esm/plugins/deploy/exports.js +0 -4
  120. package/dist/esm/utils/getServerInternalPlugins.js +0 -40
  121. package/dist/esm-node/analyze/constants.js +0 -76
  122. package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +0 -163
  123. package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +0 -161
  124. package/dist/esm-node/analyze/getClientRoutes/index.js +0 -6
  125. package/dist/esm-node/analyze/getClientRoutes/utils.js +0 -22
  126. package/dist/esm-node/analyze/getFileSystemEntry.js +0 -89
  127. package/dist/esm-node/analyze/makeLegalIdentifier.js +0 -13
  128. package/dist/esm-node/analyze/nestedRoutes.js +0 -259
  129. package/dist/esm-node/analyze/templates.js +0 -405
  130. package/dist/esm-node/plugins/deploy/exports.js +0 -4
  131. package/dist/esm-node/utils/getServerInternalPlugins.js +0 -15
  132. package/dist/js/modern/analyze/constants.js +0 -15
  133. package/dist/js/modern/analyze/generateCode.js +0 -179
  134. package/dist/js/modern/analyze/getBundleEntry.js +0 -75
  135. package/dist/js/modern/analyze/getClientRoutes.js +0 -219
  136. package/dist/js/modern/analyze/getFileSystemEntry.js +0 -74
  137. package/dist/js/modern/analyze/getHtmlTemplate.js +0 -82
  138. package/dist/js/modern/analyze/getServerRoutes.js +0 -192
  139. package/dist/js/modern/analyze/index.js +0 -148
  140. package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -32
  141. package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -16
  142. package/dist/js/modern/analyze/templates.js +0 -88
  143. package/dist/js/modern/analyze/utils.js +0 -92
  144. package/dist/js/modern/commands/build.js +0 -154
  145. package/dist/js/modern/commands/deploy.js +0 -5
  146. package/dist/js/modern/commands/dev.js +0 -95
  147. package/dist/js/modern/commands/index.js +0 -3
  148. package/dist/js/modern/commands/inspect.js +0 -69
  149. package/dist/js/modern/commands/start.js +0 -31
  150. package/dist/js/modern/exports/server.js +0 -1
  151. package/dist/js/modern/hooks.js +0 -21
  152. package/dist/js/modern/index.js +0 -109
  153. package/dist/js/modern/locale/en.js +0 -35
  154. package/dist/js/modern/locale/index.js +0 -9
  155. package/dist/js/modern/locale/zh.js +0 -35
  156. package/dist/js/modern/utils/config.js +0 -78
  157. package/dist/js/modern/utils/createCompiler.js +0 -61
  158. package/dist/js/modern/utils/createServer.js +0 -18
  159. package/dist/js/modern/utils/getSpecifiedEntries.js +0 -36
  160. package/dist/js/modern/utils/language.js +0 -5
  161. package/dist/js/modern/utils/printInstructions.js +0 -11
  162. package/dist/js/modern/utils/routes.js +0 -15
  163. package/dist/js/modern/utils/types.js +0 -0
  164. package/dist/js/node/analyze/constants.js +0 -36
  165. package/dist/js/node/analyze/generateCode.js +0 -208
  166. package/dist/js/node/analyze/getBundleEntry.js +0 -89
  167. package/dist/js/node/analyze/getClientRoutes.js +0 -241
  168. package/dist/js/node/analyze/getFileSystemEntry.js +0 -90
  169. package/dist/js/node/analyze/getHtmlTemplate.js +0 -106
  170. package/dist/js/node/analyze/getServerRoutes.js +0 -208
  171. package/dist/js/node/analyze/index.js +0 -178
  172. package/dist/js/node/analyze/isDefaultExportFunction.js +0 -50
  173. package/dist/js/node/analyze/makeLegalIdentifier.js +0 -24
  174. package/dist/js/node/analyze/templates.js +0 -106
  175. package/dist/js/node/analyze/utils.js +0 -113
  176. package/dist/js/node/commands/build.js +0 -174
  177. package/dist/js/node/commands/deploy.js +0 -14
  178. package/dist/js/node/commands/dev.js +0 -120
  179. package/dist/js/node/commands/index.js +0 -44
  180. package/dist/js/node/commands/inspect.js +0 -98
  181. package/dist/js/node/commands/start.js +0 -47
  182. package/dist/js/node/exports/server.js +0 -13
  183. package/dist/js/node/hooks.js +0 -39
  184. package/dist/js/node/index.js +0 -141
  185. package/dist/js/node/locale/en.js +0 -42
  186. package/dist/js/node/locale/index.js +0 -20
  187. package/dist/js/node/locale/zh.js +0 -42
  188. package/dist/js/node/utils/config.js +0 -103
  189. package/dist/js/node/utils/createCompiler.js +0 -81
  190. package/dist/js/node/utils/createServer.js +0 -35
  191. package/dist/js/node/utils/getSpecifiedEntries.js +0 -46
  192. package/dist/js/node/utils/language.js +0 -13
  193. package/dist/js/node/utils/printInstructions.js +0 -22
  194. package/dist/js/node/utils/routes.js +0 -25
  195. package/dist/js/node/utils/types.js +0 -0
  196. package/dist/types/analyze/constants.d.ts +0 -42
  197. package/dist/types/analyze/getBundleEntry.d.ts +0 -3
  198. package/dist/types/analyze/getClientRoutes/getRoutes.d.ts +0 -8
  199. package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +0 -9
  200. package/dist/types/analyze/getClientRoutes/index.d.ts +0 -2
  201. package/dist/types/analyze/getClientRoutes/utils.d.ts +0 -5
  202. package/dist/types/analyze/getFileSystemEntry.d.ts +0 -4
  203. package/dist/types/analyze/makeLegalIdentifier.d.ts +0 -1
  204. package/dist/types/analyze/nestedRoutes.d.ts +0 -7
  205. package/dist/types/analyze/templates.d.ts +0 -30
  206. package/dist/types/plugins/deploy/exports.d.ts +0 -1
  207. package/dist/types/utils/getServerInternalPlugins.d.ts +0 -2
  208. /package/dist/cjs/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
  209. /package/dist/cjs/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
  210. /package/dist/esm/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
  211. /package/dist/esm/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
  212. /package/dist/esm-node/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
  213. /package/dist/esm-node/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
  214. /package/dist/types/{analyze → plugins/analyze}/isDefaultExportFunction.d.ts +0 -0
@@ -1,3 +1,411 @@
1
- export * from "./dev";
2
- export * from "./build";
3
- export * from "./serve";
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
+ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
+ import { newAction, upgradeAction } from "@modern-js/utils";
6
+ import { castArray } from "@rsbuild/shared";
7
+ import { i18n, localeKeys } from "../locale";
8
+ var devCommand = function() {
9
+ var _ref = _async_to_generator(function(program, api) {
10
+ var runner, devToolMetas, devProgram, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, meta, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, subCmd;
11
+ return _ts_generator(this, function(_state) {
12
+ switch (_state.label) {
13
+ case 0:
14
+ runner = api.useHookRunners();
15
+ return [
16
+ 4,
17
+ runner.registerDev()
18
+ ];
19
+ case 1:
20
+ devToolMetas = _state.sent();
21
+ 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)).option("--web-only", i18n.t(localeKeys.command.dev.webOnly)).action(function() {
22
+ var _ref2 = _async_to_generator(function(options) {
23
+ var dev;
24
+ return _ts_generator(this, function(_state2) {
25
+ switch (_state2.label) {
26
+ case 0:
27
+ return [
28
+ 4,
29
+ import("./dev")
30
+ ];
31
+ case 1:
32
+ dev = _state2.sent().dev;
33
+ return [
34
+ 4,
35
+ dev(api, options)
36
+ ];
37
+ case 2:
38
+ _state2.sent();
39
+ return [
40
+ 2
41
+ ];
42
+ }
43
+ });
44
+ });
45
+ return function(options) {
46
+ return _ref2.apply(this, arguments);
47
+ };
48
+ }());
49
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
50
+ try {
51
+ for (_iterator = devToolMetas[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
52
+ meta = _step.value;
53
+ if (!meta.subCommands) {
54
+ continue;
55
+ }
56
+ _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
57
+ try {
58
+ for (_iterator1 = meta.subCommands[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
59
+ subCmd = _step1.value;
60
+ devProgram.command(subCmd).action(/* @__PURE__ */ _async_to_generator(function() {
61
+ var options, appDirectory, isTypescript;
62
+ var _arguments = arguments;
63
+ return _ts_generator(this, function(_state2) {
64
+ switch (_state2.label) {
65
+ case 0:
66
+ options = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {};
67
+ appDirectory = api.useAppContext().appDirectory;
68
+ return [
69
+ 4,
70
+ import("@modern-js/utils")
71
+ ];
72
+ case 1:
73
+ isTypescript = _state2.sent().isTypescript;
74
+ return [
75
+ 4,
76
+ runner.beforeDevTask(meta)
77
+ ];
78
+ case 2:
79
+ _state2.sent();
80
+ return [
81
+ 4,
82
+ meta.action(options, {
83
+ isTsProject: isTypescript(appDirectory)
84
+ })
85
+ ];
86
+ case 3:
87
+ _state2.sent();
88
+ return [
89
+ 2
90
+ ];
91
+ }
92
+ });
93
+ }));
94
+ }
95
+ } catch (err) {
96
+ _didIteratorError1 = true;
97
+ _iteratorError1 = err;
98
+ } finally {
99
+ try {
100
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
101
+ _iterator1.return();
102
+ }
103
+ } finally {
104
+ if (_didIteratorError1) {
105
+ throw _iteratorError1;
106
+ }
107
+ }
108
+ }
109
+ }
110
+ } catch (err) {
111
+ _didIteratorError = true;
112
+ _iteratorError = err;
113
+ } finally {
114
+ try {
115
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
116
+ _iterator.return();
117
+ }
118
+ } finally {
119
+ if (_didIteratorError) {
120
+ throw _iteratorError;
121
+ }
122
+ }
123
+ }
124
+ return [
125
+ 2
126
+ ];
127
+ }
128
+ });
129
+ });
130
+ return function devCommand2(program, api) {
131
+ return _ref.apply(this, arguments);
132
+ };
133
+ }();
134
+ var buildCommand = function() {
135
+ var _ref = _async_to_generator(function(program, api) {
136
+ var runner, platformBuilders, buildProgram, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step;
137
+ return _ts_generator(this, function(_state) {
138
+ switch (_state.label) {
139
+ case 0:
140
+ runner = api.useHookRunners();
141
+ return [
142
+ 4,
143
+ runner.registerBuildPlatform()
144
+ ];
145
+ case 1:
146
+ platformBuilders = _state.sent();
147
+ 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() {
148
+ var _ref2 = _async_to_generator(function(options) {
149
+ var build;
150
+ return _ts_generator(this, function(_state2) {
151
+ switch (_state2.label) {
152
+ case 0:
153
+ return [
154
+ 4,
155
+ import("./build")
156
+ ];
157
+ case 1:
158
+ build = _state2.sent().build;
159
+ return [
160
+ 4,
161
+ build(api, options)
162
+ ];
163
+ case 2:
164
+ _state2.sent();
165
+ return [
166
+ 2
167
+ ];
168
+ }
169
+ });
170
+ });
171
+ return function(options) {
172
+ return _ref2.apply(this, arguments);
173
+ };
174
+ }());
175
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
176
+ try {
177
+ _loop = function() {
178
+ var platformBuilder = _step.value;
179
+ var platforms = castArray(platformBuilder.platform);
180
+ var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
181
+ try {
182
+ var _loop2 = function() {
183
+ var platform = _step1.value;
184
+ buildProgram.command(platform).action(/* @__PURE__ */ _async_to_generator(function() {
185
+ var appDirectory, isTypescript;
186
+ return _ts_generator(this, function(_state2) {
187
+ switch (_state2.label) {
188
+ case 0:
189
+ appDirectory = api.useAppContext().appDirectory;
190
+ return [
191
+ 4,
192
+ import("@modern-js/utils")
193
+ ];
194
+ case 1:
195
+ isTypescript = _state2.sent().isTypescript;
196
+ return [
197
+ 4,
198
+ runner.beforeBuildPlatform(platformBuilders)
199
+ ];
200
+ case 2:
201
+ _state2.sent();
202
+ return [
203
+ 4,
204
+ platformBuilder.build(platform, {
205
+ isTsProject: isTypescript(appDirectory)
206
+ })
207
+ ];
208
+ case 3:
209
+ _state2.sent();
210
+ return [
211
+ 2
212
+ ];
213
+ }
214
+ });
215
+ }));
216
+ };
217
+ for (var _iterator2 = platforms[Symbol.iterator](), _step1; !(_iteratorNormalCompletion2 = (_step1 = _iterator2.next()).done); _iteratorNormalCompletion2 = true)
218
+ _loop2();
219
+ } catch (err) {
220
+ _didIteratorError2 = true;
221
+ _iteratorError2 = err;
222
+ } finally {
223
+ try {
224
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
225
+ _iterator2.return();
226
+ }
227
+ } finally {
228
+ if (_didIteratorError2) {
229
+ throw _iteratorError2;
230
+ }
231
+ }
232
+ }
233
+ };
234
+ for (_iterator = platformBuilders[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)
235
+ _loop();
236
+ } catch (err) {
237
+ _didIteratorError = true;
238
+ _iteratorError = err;
239
+ } finally {
240
+ try {
241
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
242
+ _iterator.return();
243
+ }
244
+ } finally {
245
+ if (_didIteratorError) {
246
+ throw _iteratorError;
247
+ }
248
+ }
249
+ }
250
+ return [
251
+ 2
252
+ ];
253
+ }
254
+ });
255
+ });
256
+ return function buildCommand2(program, api) {
257
+ return _ref.apply(this, arguments);
258
+ };
259
+ }();
260
+ var serverCommand = function(program, api) {
261
+ 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__ */ _async_to_generator(function() {
262
+ var start;
263
+ return _ts_generator(this, function(_state) {
264
+ switch (_state.label) {
265
+ case 0:
266
+ return [
267
+ 4,
268
+ import("./serve")
269
+ ];
270
+ case 1:
271
+ start = _state.sent().start;
272
+ return [
273
+ 4,
274
+ start(api)
275
+ ];
276
+ case 2:
277
+ _state.sent();
278
+ return [
279
+ 2
280
+ ];
281
+ }
282
+ });
283
+ }));
284
+ };
285
+ var deployCommand = function(program, api) {
286
+ program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-s --skip-build", i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(function() {
287
+ var _ref = _async_to_generator(function(options) {
288
+ var build, deploy;
289
+ return _ts_generator(this, function(_state) {
290
+ switch (_state.label) {
291
+ case 0:
292
+ if (!!options.skipBuild)
293
+ return [
294
+ 3,
295
+ 3
296
+ ];
297
+ return [
298
+ 4,
299
+ import("./build")
300
+ ];
301
+ case 1:
302
+ build = _state.sent().build;
303
+ return [
304
+ 4,
305
+ build(api)
306
+ ];
307
+ case 2:
308
+ _state.sent();
309
+ _state.label = 3;
310
+ case 3:
311
+ return [
312
+ 4,
313
+ import("./deploy")
314
+ ];
315
+ case 4:
316
+ deploy = _state.sent().deploy;
317
+ return [
318
+ 4,
319
+ deploy(api, options)
320
+ ];
321
+ case 5:
322
+ _state.sent();
323
+ process.exit(0);
324
+ return [
325
+ 2
326
+ ];
327
+ }
328
+ });
329
+ });
330
+ return function(options) {
331
+ return _ref.apply(this, arguments);
332
+ };
333
+ }());
334
+ };
335
+ var newCommand = function(program, locale) {
336
+ program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("--config-file <configFile>", i18n.t(localeKeys.command.shared.config)).option("--lang <lang>", i18n.t(localeKeys.command.new.lang)).option("-c, --config <config>", i18n.t(localeKeys.command.new.config)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).option("--no-need-install", i18n.t(localeKeys.command.shared.noNeedInstall)).action(function() {
337
+ var _ref = _async_to_generator(function(options) {
338
+ return _ts_generator(this, function(_state) {
339
+ switch (_state.label) {
340
+ case 0:
341
+ return [
342
+ 4,
343
+ newAction(_object_spread_props(_object_spread({}, options), {
344
+ locale: options.lang || locale
345
+ }), "mwa")
346
+ ];
347
+ case 1:
348
+ _state.sent();
349
+ return [
350
+ 2
351
+ ];
352
+ }
353
+ });
354
+ });
355
+ return function(options) {
356
+ return _ref.apply(this, arguments);
357
+ };
358
+ }());
359
+ };
360
+ var inspectCommand = function(program, api) {
361
+ program.command("inspect").description("inspect the internal configs").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() {
362
+ var _ref = _async_to_generator(function(options) {
363
+ var inspect;
364
+ return _ts_generator(this, function(_state) {
365
+ switch (_state.label) {
366
+ case 0:
367
+ return [
368
+ 4,
369
+ import("./inspect")
370
+ ];
371
+ case 1:
372
+ inspect = _state.sent().inspect;
373
+ inspect(api, options);
374
+ return [
375
+ 2
376
+ ];
377
+ }
378
+ });
379
+ });
380
+ return function(options) {
381
+ return _ref.apply(this, arguments);
382
+ };
383
+ }());
384
+ };
385
+ var upgradeCommand = function(program) {
386
+ program.command("upgrade").allowUnknownOption().option("-h --help", "Show help").action(/* @__PURE__ */ _async_to_generator(function() {
387
+ return _ts_generator(this, function(_state) {
388
+ switch (_state.label) {
389
+ case 0:
390
+ return [
391
+ 4,
392
+ upgradeAction()
393
+ ];
394
+ case 1:
395
+ _state.sent();
396
+ return [
397
+ 2
398
+ ];
399
+ }
400
+ });
401
+ }));
402
+ };
403
+ export {
404
+ buildCommand,
405
+ deployCommand,
406
+ devCommand,
407
+ inspectCommand,
408
+ newCommand,
409
+ serverCommand,
410
+ upgradeCommand
411
+ };
@@ -2,20 +2,21 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
3
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
4
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
- import { logger, isApiOnly, getTargetDir } from "@modern-js/utils";
5
+ import path from "path";
6
+ import { logger, isApiOnly, getTargetDir, getMeta, SERVER_DIR } from "@modern-js/utils";
6
7
  import { createProdServer } from "@modern-js/prod-server";
7
8
  import { printInstructions } from "../utils/printInstructions";
8
- import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
9
+ import { loadServerPlugins } from "../utils/loadPlugins";
9
10
  var start = function() {
10
11
  var _ref = _async_to_generator(function(api) {
11
- var _userConfig_source, _userConfig_output_distPath, appContext, userConfig, hookRunners, distDirectory, appDirectory, port, serverConfigFile, metaName, serverRoutes, apiOnly, runMode, serverInternalPlugins, app;
12
+ var _userConfig_source, _userConfig_output_distPath, appContext, userConfig, hookRunners, distDirectory, appDirectory, port, metaName, serverRoutes, serverConfigFile, apiOnly, runMode, meta, serverConfigPath, pluginInstances, app;
12
13
  return _ts_generator(this, function(_state) {
13
14
  switch (_state.label) {
14
15
  case 0:
15
16
  appContext = api.useAppContext();
16
17
  userConfig = api.useResolvedConfigContext();
17
18
  hookRunners = api.useHookRunners();
18
- distDirectory = appContext.distDirectory, appDirectory = appContext.appDirectory, port = appContext.port, serverConfigFile = appContext.serverConfigFile, metaName = appContext.metaName, serverRoutes = appContext.serverRoutes;
19
+ distDirectory = appContext.distDirectory, appDirectory = appContext.appDirectory, port = appContext.port, metaName = appContext.metaName, serverRoutes = appContext.serverRoutes, serverConfigFile = appContext.serverConfigFile;
19
20
  logger.info("Starting production server...");
20
21
  return [
21
22
  4,
@@ -26,12 +27,14 @@ var start = function() {
26
27
  if (apiOnly) {
27
28
  runMode = "apiOnly";
28
29
  }
30
+ meta = getMeta(metaName);
31
+ serverConfigPath = path.resolve(distDirectory, SERVER_DIR, "".concat(meta, ".server"));
29
32
  return [
30
33
  4,
31
- getServerInternalPlugins(api)
34
+ loadServerPlugins(api, appDirectory)
32
35
  ];
33
36
  case 2:
34
- serverInternalPlugins = _state.sent();
37
+ pluginInstances = _state.sent();
35
38
  return [
36
39
  4,
37
40
  createProdServer({
@@ -44,14 +47,15 @@ var start = function() {
44
47
  }, userConfig.output || {})
45
48
  }),
46
49
  routes: serverRoutes,
50
+ plugins: pluginInstances,
51
+ serverConfigFile,
52
+ serverConfigPath,
47
53
  appContext: {
48
54
  appDirectory,
49
55
  sharedDirectory: getTargetDir(appContext.sharedDirectory, appContext.appDirectory, appContext.distDirectory),
50
56
  apiDirectory: getTargetDir(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
51
57
  lambdaDirectory: getTargetDir(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
52
58
  },
53
- serverConfigFile,
54
- internalPlugins: serverInternalPlugins,
55
59
  runMode
56
60
  })
57
61
  ];
package/dist/esm/hooks.js CHANGED
@@ -7,10 +7,15 @@ var hooks = {
7
7
  modifyAsyncEntry: createAsyncWaterfall(),
8
8
  modifyFileSystemRoutes: createAsyncWaterfall(),
9
9
  modifyServerRoutes: createAsyncWaterfall(),
10
+ /** add entry point info to entrypoints array */
11
+ modifyEntrypoints: createAsyncWaterfall(),
12
+ /** add entry type */
13
+ checkEntryPoint: createAsyncWaterfall(),
10
14
  htmlPartials: createAsyncWaterfall(),
11
15
  beforeGenerateRoutes: createAsyncWaterfall(),
12
16
  addDefineTypes: createAsyncWaterfall(),
13
17
  collectServerPlugins: createAsyncWaterfall(),
18
+ _internalServerPlugins: createAsyncWaterfall(),
14
19
  beforeDev: createAsyncWorkflow(),
15
20
  afterDev: createAsyncWorkflow(),
16
21
  beforeCreateCompiler: createAsyncWorkflow(),