@modern-js/app-tools 2.58.2 → 2.59.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. package/dist/cjs/builder/builder-rspack/adapterCopy.js +1 -1
  2. package/dist/cjs/builder/generator/getBuilderEnvironments.js +1 -1
  3. package/dist/cjs/builder/generator/index.js +2 -3
  4. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +8 -13
  5. package/dist/cjs/builder/shared/builderPlugins/index.js +1 -3
  6. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +1 -1
  7. package/dist/cjs/commands/build.js +2 -2
  8. package/dist/cjs/commands/dev.js +6 -5
  9. package/dist/cjs/commands/index.js +1 -1
  10. package/dist/cjs/commands/serve.js +4 -3
  11. package/dist/cjs/config/legacy/index.js +3 -3
  12. package/dist/cjs/esm/register-esm.mjs +2 -3
  13. package/dist/cjs/esm/utils.mjs +2 -2
  14. package/dist/cjs/index.js +17 -10
  15. package/dist/cjs/locale/index.js +1 -1
  16. package/dist/cjs/plugins/analyze/getFileSystemEntry.js +50 -44
  17. package/dist/cjs/plugins/analyze/getServerRoutes.js +2 -2
  18. package/dist/cjs/plugins/analyze/index.js +6 -6
  19. package/dist/cjs/plugins/analyze/utils.js +1 -1
  20. package/dist/cjs/plugins/deploy/dependencies/index.js +1 -1
  21. package/dist/cjs/plugins/deploy/dependencies/utils.js +2 -2
  22. package/dist/cjs/plugins/deploy/index.js +2 -2
  23. package/dist/cjs/plugins/deploy/platforms/netlify.js +1 -1
  24. package/dist/cjs/plugins/deploy/platforms/node.js +1 -1
  25. package/dist/cjs/plugins/deploy/platforms/vercel.js +1 -1
  26. package/dist/cjs/plugins/serverBuild.js +2 -2
  27. package/dist/cjs/utils/createServer.js +1 -1
  28. package/dist/esm/builder/builder-rspack/adapterCopy.js +166 -0
  29. package/dist/esm/builder/builder-rspack/index.js +34 -0
  30. package/dist/esm/builder/builder-webpack/adapterModern.js +29 -0
  31. package/dist/esm/builder/builder-webpack/createCopyPattern.js +43 -0
  32. package/dist/esm/builder/builder-webpack/index.js +52 -0
  33. package/dist/esm/builder/generator/createBuilderProviderConfig.js +37 -0
  34. package/dist/esm/builder/generator/getBuilderEnvironments.js +81 -0
  35. package/dist/esm/builder/generator/index.js +93 -0
  36. package/dist/esm/builder/index.js +45 -0
  37. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +85 -0
  38. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +126 -0
  39. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +261 -0
  40. package/dist/esm/builder/shared/builderPlugins/index.js +3 -0
  41. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +51 -0
  42. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +37 -0
  43. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +314 -0
  44. package/dist/esm/builder/shared/bundlerPlugins/index.js +3 -0
  45. package/dist/esm/builder/shared/createCopyInfo.js +14 -0
  46. package/dist/esm/builder/shared/index.js +3 -0
  47. package/dist/esm/builder/shared/loaders/serverModuleLoader.js +7 -0
  48. package/dist/esm/builder/shared/types.js +0 -0
  49. package/dist/esm/commands/build.js +140 -0
  50. package/dist/esm/commands/deploy.js +48 -0
  51. package/dist/esm/commands/dev.js +193 -0
  52. package/dist/esm/commands/index.js +411 -0
  53. package/dist/esm/commands/inspect.js +28 -0
  54. package/dist/esm/commands/serve.js +94 -0
  55. package/dist/esm/config/default.js +190 -0
  56. package/dist/esm/config/index.js +3 -0
  57. package/dist/esm/config/initialize/index.js +9 -0
  58. package/dist/esm/config/initialize/inits.js +89 -0
  59. package/dist/esm/config/legacy/createHtmlConfig.js +21 -0
  60. package/dist/esm/config/legacy/createOutputConfig.js +45 -0
  61. package/dist/esm/config/legacy/createSourceConfig.js +46 -0
  62. package/dist/esm/config/legacy/createToolsConfig.js +28 -0
  63. package/dist/esm/config/legacy/index.js +43 -0
  64. package/dist/esm/defineConfig.js +16 -0
  65. package/dist/esm/esm/esbuild-loader.mjs +20 -0
  66. package/dist/esm/esm/register-esm.mjs +66 -0
  67. package/dist/esm/esm/ts-node-loader.mjs +21 -0
  68. package/dist/esm/esm/utils.mjs +43 -0
  69. package/dist/esm/exports/server.js +4 -0
  70. package/dist/esm/hooks.js +34 -0
  71. package/dist/esm/index.js +246 -0
  72. package/dist/esm/locale/en.js +43 -0
  73. package/dist/esm/locale/index.js +12 -0
  74. package/dist/esm/locale/zh.js +43 -0
  75. package/dist/esm/plugins/analyze/constants.js +14 -0
  76. package/dist/esm/plugins/analyze/getBundleEntry.js +102 -0
  77. package/dist/esm/plugins/analyze/getFileSystemEntry.js +266 -0
  78. package/dist/esm/plugins/analyze/getHtmlTemplate.js +178 -0
  79. package/dist/esm/plugins/analyze/getServerRoutes.js +132 -0
  80. package/dist/esm/plugins/analyze/index.js +380 -0
  81. package/dist/esm/plugins/analyze/isDefaultExportFunction.js +49 -0
  82. package/dist/esm/plugins/analyze/templates.js +6 -0
  83. package/dist/esm/plugins/analyze/utils.js +101 -0
  84. package/dist/esm/plugins/deploy/dependencies/index.js +615 -0
  85. package/dist/esm/plugins/deploy/dependencies/utils.js +421 -0
  86. package/dist/esm/plugins/deploy/exports.js +4 -0
  87. package/dist/esm/plugins/deploy/index.js +135 -0
  88. package/dist/esm/plugins/deploy/platforms/netlify-entry.js +11 -0
  89. package/dist/esm/plugins/deploy/platforms/netlify-entry.mjs +1 -0
  90. package/dist/esm/plugins/deploy/platforms/netlify-handler.js +205 -0
  91. package/dist/esm/plugins/deploy/platforms/netlify.js +327 -0
  92. package/dist/esm/plugins/deploy/platforms/node-entry.js +108 -0
  93. package/dist/esm/plugins/deploy/platforms/node.js +161 -0
  94. package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
  95. package/dist/esm/plugins/deploy/platforms/vercel-entry.js +11 -0
  96. package/dist/esm/plugins/deploy/platforms/vercel-entry.mjs +3 -0
  97. package/dist/esm/plugins/deploy/platforms/vercel-handler.js +206 -0
  98. package/dist/esm/plugins/deploy/platforms/vercel.js +261 -0
  99. package/dist/esm/plugins/deploy/utils.js +47 -0
  100. package/dist/esm/plugins/initialize/index.js +119 -0
  101. package/dist/esm/plugins/serverBuild.js +87 -0
  102. package/dist/esm/types/config/deploy.js +0 -0
  103. package/dist/esm/types/config/dev.js +0 -0
  104. package/dist/esm/types/config/experiments.js +0 -0
  105. package/dist/esm/types/config/html.js +0 -0
  106. package/dist/esm/types/config/index.js +1 -0
  107. package/dist/esm/types/config/output.js +0 -0
  108. package/dist/esm/types/config/performance.js +0 -0
  109. package/dist/esm/types/config/security.js +0 -0
  110. package/dist/esm/types/config/source.js +0 -0
  111. package/dist/esm/types/config/testing.js +0 -0
  112. package/dist/esm/types/config/tools.js +0 -0
  113. package/dist/esm/types/hooks.js +0 -0
  114. package/dist/esm/types/index.js +3 -0
  115. package/dist/esm/types/legacyConfig/deploy.js +0 -0
  116. package/dist/esm/types/legacyConfig/dev.js +0 -0
  117. package/dist/esm/types/legacyConfig/index.js +0 -0
  118. package/dist/esm/types/legacyConfig/output.js +0 -0
  119. package/dist/esm/types/legacyConfig/source.js +0 -0
  120. package/dist/esm/types/legacyConfig/testing.js +0 -0
  121. package/dist/esm/types/legacyConfig/tools.js +0 -0
  122. package/dist/esm/types/utils.js +0 -0
  123. package/dist/esm/utils/config.js +122 -0
  124. package/dist/esm/utils/createServer.js +58 -0
  125. package/dist/esm/utils/env.js +16 -0
  126. package/dist/esm/utils/generateWatchFiles.js +71 -0
  127. package/dist/esm/utils/getSelectedEntries.js +67 -0
  128. package/dist/esm/utils/loadPlugins.js +74 -0
  129. package/dist/esm/utils/printInstructions.js +32 -0
  130. package/dist/esm/utils/register.js +188 -0
  131. package/dist/esm/utils/restart.js +67 -0
  132. package/dist/esm/utils/routes.js +42 -0
  133. package/dist/esm/utils/types.js +0 -0
  134. package/dist/esm-node/builder/builder-rspack/adapterCopy.js +67 -0
  135. package/dist/esm-node/builder/builder-rspack/index.js +12 -0
  136. package/dist/esm-node/builder/builder-webpack/adapterModern.js +26 -0
  137. package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +41 -0
  138. package/dist/esm-node/builder/builder-webpack/index.js +20 -0
  139. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +44 -0
  140. package/dist/esm-node/builder/generator/getBuilderEnvironments.js +60 -0
  141. package/dist/esm-node/builder/generator/index.js +36 -0
  142. package/dist/esm-node/builder/index.js +11 -0
  143. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +48 -0
  144. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +60 -0
  145. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +151 -0
  146. package/dist/esm-node/builder/shared/builderPlugins/index.js +3 -0
  147. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +30 -0
  148. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +31 -0
  149. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +228 -0
  150. package/dist/esm-node/builder/shared/bundlerPlugins/index.js +3 -0
  151. package/dist/esm-node/builder/shared/createCopyInfo.js +14 -0
  152. package/dist/esm-node/builder/shared/index.js +3 -0
  153. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +7 -0
  154. package/dist/esm-node/builder/shared/types.js +0 -0
  155. package/dist/esm-node/commands/build.js +64 -0
  156. package/dist/esm-node/commands/deploy.js +12 -0
  157. package/dist/esm-node/commands/dev.js +105 -0
  158. package/dist/esm-node/commands/index.js +92 -0
  159. package/dist/esm-node/commands/inspect.js +15 -0
  160. package/dist/esm-node/commands/serve.js +52 -0
  161. package/dist/esm-node/config/default.js +197 -0
  162. package/dist/esm-node/config/index.js +3 -0
  163. package/dist/esm-node/config/initialize/index.js +9 -0
  164. package/dist/esm-node/config/initialize/inits.js +79 -0
  165. package/dist/esm-node/config/legacy/createHtmlConfig.js +21 -0
  166. package/dist/esm-node/config/legacy/createOutputConfig.js +45 -0
  167. package/dist/esm-node/config/legacy/createSourceConfig.js +29 -0
  168. package/dist/esm-node/config/legacy/createToolsConfig.js +28 -0
  169. package/dist/esm-node/config/legacy/index.js +43 -0
  170. package/dist/esm-node/defineConfig.js +13 -0
  171. package/dist/esm-node/esm/esbuild-loader.mjs +20 -0
  172. package/dist/esm-node/esm/register-esm.mjs +66 -0
  173. package/dist/esm-node/esm/ts-node-loader.mjs +21 -0
  174. package/dist/esm-node/esm/utils.mjs +43 -0
  175. package/dist/esm-node/exports/server.js +4 -0
  176. package/dist/esm-node/hooks.js +34 -0
  177. package/dist/esm-node/index.js +131 -0
  178. package/dist/esm-node/locale/en.js +43 -0
  179. package/dist/esm-node/locale/index.js +12 -0
  180. package/dist/esm-node/locale/zh.js +43 -0
  181. package/dist/esm-node/plugins/analyze/constants.js +14 -0
  182. package/dist/esm-node/plugins/analyze/getBundleEntry.js +61 -0
  183. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +106 -0
  184. package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +74 -0
  185. package/dist/esm-node/plugins/analyze/getServerRoutes.js +132 -0
  186. package/dist/esm-node/plugins/analyze/index.js +166 -0
  187. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +47 -0
  188. package/dist/esm-node/plugins/analyze/templates.js +24 -0
  189. package/dist/esm-node/plugins/analyze/utils.js +68 -0
  190. package/dist/esm-node/plugins/deploy/dependencies/index.js +202 -0
  191. package/dist/esm-node/plugins/deploy/dependencies/utils.js +137 -0
  192. package/dist/esm-node/plugins/deploy/exports.js +4 -0
  193. package/dist/esm-node/plugins/deploy/index.js +44 -0
  194. package/dist/esm-node/plugins/deploy/platforms/netlify-entry.js +11 -0
  195. package/dist/esm-node/plugins/deploy/platforms/netlify-entry.mjs +1 -0
  196. package/dist/esm-node/plugins/deploy/platforms/netlify-handler.js +71 -0
  197. package/dist/esm-node/plugins/deploy/platforms/netlify.js +117 -0
  198. package/dist/esm-node/plugins/deploy/platforms/node-entry.js +44 -0
  199. package/dist/esm-node/plugins/deploy/platforms/node.js +72 -0
  200. package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
  201. package/dist/esm-node/plugins/deploy/platforms/vercel-entry.js +11 -0
  202. package/dist/esm-node/plugins/deploy/platforms/vercel-entry.mjs +3 -0
  203. package/dist/esm-node/plugins/deploy/platforms/vercel-handler.js +72 -0
  204. package/dist/esm-node/plugins/deploy/platforms/vercel.js +129 -0
  205. package/dist/esm-node/plugins/deploy/utils.js +44 -0
  206. package/dist/esm-node/plugins/initialize/index.js +84 -0
  207. package/dist/esm-node/plugins/serverBuild.js +58 -0
  208. package/dist/esm-node/types/config/deploy.js +0 -0
  209. package/dist/esm-node/types/config/dev.js +0 -0
  210. package/dist/esm-node/types/config/experiments.js +0 -0
  211. package/dist/esm-node/types/config/html.js +0 -0
  212. package/dist/esm-node/types/config/index.js +1 -0
  213. package/dist/esm-node/types/config/output.js +0 -0
  214. package/dist/esm-node/types/config/performance.js +0 -0
  215. package/dist/esm-node/types/config/security.js +0 -0
  216. package/dist/esm-node/types/config/source.js +0 -0
  217. package/dist/esm-node/types/config/testing.js +0 -0
  218. package/dist/esm-node/types/config/tools.js +0 -0
  219. package/dist/esm-node/types/hooks.js +0 -0
  220. package/dist/esm-node/types/index.js +3 -0
  221. package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
  222. package/dist/esm-node/types/legacyConfig/dev.js +0 -0
  223. package/dist/esm-node/types/legacyConfig/index.js +0 -0
  224. package/dist/esm-node/types/legacyConfig/output.js +0 -0
  225. package/dist/esm-node/types/legacyConfig/source.js +0 -0
  226. package/dist/esm-node/types/legacyConfig/testing.js +0 -0
  227. package/dist/esm-node/types/legacyConfig/tools.js +0 -0
  228. package/dist/esm-node/types/utils.js +0 -0
  229. package/dist/esm-node/utils/config.js +49 -0
  230. package/dist/esm-node/utils/createServer.js +26 -0
  231. package/dist/esm-node/utils/env.js +16 -0
  232. package/dist/esm-node/utils/generateWatchFiles.js +30 -0
  233. package/dist/esm-node/utils/getSelectedEntries.js +34 -0
  234. package/dist/esm-node/utils/loadPlugins.js +22 -0
  235. package/dist/esm-node/utils/printInstructions.js +11 -0
  236. package/dist/esm-node/utils/register.js +96 -0
  237. package/dist/esm-node/utils/restart.js +22 -0
  238. package/dist/esm-node/utils/routes.js +21 -0
  239. package/dist/esm-node/utils/types.js +0 -0
  240. package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +1 -1
  241. package/dist/types/builder/generator/index.d.ts +2 -2
  242. package/dist/types/builder/shared/builderPlugins/index.d.ts +0 -1
  243. package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +1 -1
  244. package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +1 -1
  245. package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -1
  246. package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +1 -1
  247. package/dist/types/builder/shared/types.d.ts +1 -1
  248. package/dist/types/commands/build.d.ts +1 -1
  249. package/dist/types/commands/dev.d.ts +1 -1
  250. package/dist/types/commands/inspect.d.ts +1 -1
  251. package/dist/types/config/default.d.ts +1 -1
  252. package/dist/types/index.d.ts +1 -1
  253. package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
  254. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
  255. package/dist/types/plugins/deploy/dependencies/index.d.ts +1 -1
  256. package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -1
  257. package/dist/types/plugins/initialize/index.d.ts +1 -1
  258. package/dist/types/plugins/serverBuild.d.ts +1 -1
  259. package/dist/types/types/config/index.d.ts +8 -8
  260. package/dist/types/types/config/output.d.ts +1 -1
  261. package/dist/types/types/config/tools.d.ts +3 -3
  262. package/dist/types/types/hooks.d.ts +2 -2
  263. package/dist/types/types/index.d.ts +2 -2
  264. package/dist/types/types/legacyConfig/index.d.ts +3 -3
  265. package/dist/types/types/legacyConfig/tools.d.ts +1 -1
  266. package/dist/types/utils/printInstructions.d.ts +1 -1
  267. package/package.json +20 -20
  268. package/dist/cjs/builder/shared/builderPlugins/adapterWorker.js +0 -51
  269. package/dist/types/builder/shared/builderPlugins/adapterWorker.d.ts +0 -2
@@ -0,0 +1,380 @@
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 _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
5
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
6
+ import * as path from "path";
7
+ import { fs, createDebugger, getArgv, isApiOnly, isDevCommand, minimist } from "@modern-js/utils";
8
+ import { createBuilderGenerator } from "../../builder";
9
+ import { initialNormalizedConfig } from "../../config";
10
+ import { emitResolvedConfig } from "../../utils/config";
11
+ import { getSelectedEntries } from "../../utils/getSelectedEntries";
12
+ import { printInstructions } from "../../utils/printInstructions";
13
+ import { generateRoutes } from "../../utils/routes";
14
+ import { checkIsBuildCommands } from "./utils";
15
+ var debug = createDebugger("plugin-analyze");
16
+ function analyze_default(param) {
17
+ var bundler = param.bundler;
18
+ return {
19
+ name: "@modern-js/plugin-analyze",
20
+ post: [
21
+ "@modern-js/runtime"
22
+ ],
23
+ setup: function(api) {
24
+ var pagesDir = [];
25
+ var nestedRouteEntries = [];
26
+ return {
27
+ prepare: function prepare() {
28
+ return _async_to_generator(function() {
29
+ var _resolvedConfig_source, appContext, resolvedConfig, hookRunners, apiOnly, routes, _ref, getBundleEntry, getServerRoutes, getHtmlTemplate, entrypoints, _, _tmp, initialRoutes, routes1, htmlTemplates, checkedEntries, entry, normalizedConfig, createBuilderForModern, builder;
30
+ return _ts_generator(this, function(_state) {
31
+ switch (_state.label) {
32
+ case 0:
33
+ appContext = api.useAppContext();
34
+ resolvedConfig = api.useResolvedConfigContext();
35
+ hookRunners = api.useHookRunners();
36
+ try {
37
+ if (checkIsBuildCommands()) {
38
+ fs.emptydirSync(appContext.internalDirectory);
39
+ }
40
+ } catch (e) {
41
+ }
42
+ return [
43
+ 4,
44
+ isApiOnly(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir, appContext.apiDirectory)
45
+ ];
46
+ case 1:
47
+ apiOnly = _state.sent();
48
+ return [
49
+ 4,
50
+ hookRunners.addRuntimeExports()
51
+ ];
52
+ case 2:
53
+ _state.sent();
54
+ if (!apiOnly)
55
+ return [
56
+ 3,
57
+ 4
58
+ ];
59
+ return [
60
+ 4,
61
+ hookRunners.modifyServerRoutes({
62
+ routes: []
63
+ })
64
+ ];
65
+ case 3:
66
+ routes = _state.sent().routes;
67
+ debug("server routes: %o", routes);
68
+ appContext = _object_spread_props(_object_spread({}, api.useAppContext()), {
69
+ apiOnly,
70
+ serverRoutes: routes
71
+ });
72
+ api.setAppContext(appContext);
73
+ return [
74
+ 2
75
+ ];
76
+ case 4:
77
+ return [
78
+ 4,
79
+ Promise.all([
80
+ import("./getBundleEntry.js"),
81
+ import("./getServerRoutes.js"),
82
+ import("./getHtmlTemplate.js")
83
+ ])
84
+ ];
85
+ case 5:
86
+ _ref = _sliced_to_array.apply(void 0, [
87
+ _state.sent(),
88
+ 3
89
+ ]), getBundleEntry = _ref[0].getBundleEntry, getServerRoutes = _ref[1].getServerRoutes, getHtmlTemplate = _ref[2].getHtmlTemplate;
90
+ _ = hookRunners.modifyEntrypoints;
91
+ _tmp = {};
92
+ return [
93
+ 4,
94
+ getBundleEntry(hookRunners, appContext, resolvedConfig)
95
+ ];
96
+ case 6:
97
+ return [
98
+ 4,
99
+ _.apply(hookRunners, [
100
+ (_tmp.entrypoints = _state.sent(), _tmp)
101
+ ])
102
+ ];
103
+ case 7:
104
+ entrypoints = _state.sent().entrypoints;
105
+ debug("entrypoints: %o", entrypoints);
106
+ initialRoutes = getServerRoutes(entrypoints, {
107
+ appContext,
108
+ config: resolvedConfig
109
+ });
110
+ return [
111
+ 4,
112
+ hookRunners.modifyServerRoutes({
113
+ routes: initialRoutes
114
+ })
115
+ ];
116
+ case 8:
117
+ routes1 = _state.sent().routes;
118
+ debug("server routes: %o", routes1);
119
+ appContext = _object_spread_props(_object_spread({}, api.useAppContext()), {
120
+ entrypoints,
121
+ serverRoutes: routes1
122
+ });
123
+ api.setAppContext(appContext);
124
+ nestedRouteEntries = entrypoints.map(function(point) {
125
+ return point.nestedRoutesEntry;
126
+ }).filter(Boolean);
127
+ pagesDir = entrypoints.map(function(point) {
128
+ return point.entry;
129
+ }).filter(function(entry2) {
130
+ return entry2 && !path.extname(entry2);
131
+ }).concat(nestedRouteEntries);
132
+ return [
133
+ 4,
134
+ getHtmlTemplate(entrypoints, api, {
135
+ appContext,
136
+ config: resolvedConfig
137
+ })
138
+ ];
139
+ case 9:
140
+ htmlTemplates = _state.sent();
141
+ debug("html templates: %o", htmlTemplates);
142
+ return [
143
+ 4,
144
+ hookRunners.addDefineTypes()
145
+ ];
146
+ case 10:
147
+ _state.sent();
148
+ debug("add Define Types");
149
+ checkedEntries = entrypoints.map(function(point) {
150
+ return point.entryName;
151
+ });
152
+ if (!isDevCommand())
153
+ return [
154
+ 3,
155
+ 12
156
+ ];
157
+ entry = minimist(getArgv()).entry;
158
+ return [
159
+ 4,
160
+ getSelectedEntries(typeof entry === "string" ? entry.split(",") : entry, entrypoints)
161
+ ];
162
+ case 11:
163
+ checkedEntries = _state.sent();
164
+ _state.label = 12;
165
+ case 12:
166
+ appContext = _object_spread_props(_object_spread({}, api.useAppContext()), {
167
+ entrypoints,
168
+ checkedEntries,
169
+ apiOnly,
170
+ serverRoutes: routes1,
171
+ htmlTemplates
172
+ });
173
+ api.setAppContext(appContext);
174
+ if (!checkIsBuildCommands())
175
+ return [
176
+ 3,
177
+ 16
178
+ ];
179
+ return [
180
+ 4,
181
+ hookRunners.generateEntryCode({
182
+ entrypoints
183
+ })
184
+ ];
185
+ case 13:
186
+ _state.sent();
187
+ normalizedConfig = api.useResolvedConfigContext();
188
+ return [
189
+ 4,
190
+ createBuilderGenerator(bundler)
191
+ ];
192
+ case 14:
193
+ createBuilderForModern = _state.sent();
194
+ return [
195
+ 4,
196
+ createBuilderForModern({
197
+ normalizedConfig,
198
+ appContext
199
+ })
200
+ ];
201
+ case 15:
202
+ builder = _state.sent();
203
+ builder.onBeforeBuild(function() {
204
+ var _ref2 = _async_to_generator(function(param2) {
205
+ var bundlerConfigs, isFirstCompile, hookRunners2;
206
+ return _ts_generator(this, function(_state2) {
207
+ switch (_state2.label) {
208
+ case 0:
209
+ bundlerConfigs = param2.bundlerConfigs, isFirstCompile = param2.isFirstCompile;
210
+ if (!isFirstCompile) {
211
+ return [
212
+ 2
213
+ ];
214
+ }
215
+ hookRunners2 = api.useHookRunners();
216
+ return [
217
+ 4,
218
+ generateRoutes(appContext)
219
+ ];
220
+ case 1:
221
+ _state2.sent();
222
+ return [
223
+ 4,
224
+ hookRunners2.beforeBuild({
225
+ bundlerConfigs
226
+ })
227
+ ];
228
+ case 2:
229
+ _state2.sent();
230
+ return [
231
+ 2
232
+ ];
233
+ }
234
+ });
235
+ });
236
+ return function(_2) {
237
+ return _ref2.apply(this, arguments);
238
+ };
239
+ }());
240
+ builder.onAfterBuild(function() {
241
+ var _ref2 = _async_to_generator(function(param2) {
242
+ var stats, hookRunners2;
243
+ return _ts_generator(this, function(_state2) {
244
+ switch (_state2.label) {
245
+ case 0:
246
+ stats = param2.stats;
247
+ hookRunners2 = api.useHookRunners();
248
+ return [
249
+ 4,
250
+ hookRunners2.afterBuild({
251
+ stats
252
+ })
253
+ ];
254
+ case 1:
255
+ _state2.sent();
256
+ return [
257
+ 4,
258
+ emitResolvedConfig(appContext.appDirectory, normalizedConfig)
259
+ ];
260
+ case 2:
261
+ _state2.sent();
262
+ return [
263
+ 2
264
+ ];
265
+ }
266
+ });
267
+ });
268
+ return function(_2) {
269
+ return _ref2.apply(this, arguments);
270
+ };
271
+ }());
272
+ builder.onDevCompileDone(function() {
273
+ var _ref2 = _async_to_generator(function(param2) {
274
+ var isFirstCompile, hookRunners2;
275
+ return _ts_generator(this, function(_state2) {
276
+ isFirstCompile = param2.isFirstCompile;
277
+ hookRunners2 = api.useHookRunners();
278
+ hookRunners2.afterDev({
279
+ isFirstCompile
280
+ });
281
+ if (isFirstCompile) {
282
+ printInstructions(hookRunners2, appContext, normalizedConfig);
283
+ }
284
+ return [
285
+ 2
286
+ ];
287
+ });
288
+ });
289
+ return function(_2) {
290
+ return _ref2.apply(this, arguments);
291
+ };
292
+ }());
293
+ builder.onBeforeCreateCompiler(function() {
294
+ var _ref2 = _async_to_generator(function(param2) {
295
+ var bundlerConfigs, hookRunners2;
296
+ return _ts_generator(this, function(_state2) {
297
+ switch (_state2.label) {
298
+ case 0:
299
+ bundlerConfigs = param2.bundlerConfigs;
300
+ hookRunners2 = api.useHookRunners();
301
+ return [
302
+ 4,
303
+ hookRunners2.beforeCreateCompiler({
304
+ bundlerConfigs
305
+ })
306
+ ];
307
+ case 1:
308
+ _state2.sent();
309
+ return [
310
+ 2
311
+ ];
312
+ }
313
+ });
314
+ });
315
+ return function(_2) {
316
+ return _ref2.apply(this, arguments);
317
+ };
318
+ }());
319
+ builder.onAfterCreateCompiler(function() {
320
+ var _ref2 = _async_to_generator(function(param2) {
321
+ var compiler, hookRunners2;
322
+ return _ts_generator(this, function(_state2) {
323
+ switch (_state2.label) {
324
+ case 0:
325
+ compiler = param2.compiler;
326
+ hookRunners2 = api.useHookRunners();
327
+ return [
328
+ 4,
329
+ hookRunners2.afterCreateCompiler({
330
+ compiler
331
+ })
332
+ ];
333
+ case 1:
334
+ _state2.sent();
335
+ return [
336
+ 2
337
+ ];
338
+ }
339
+ });
340
+ });
341
+ return function(_2) {
342
+ return _ref2.apply(this, arguments);
343
+ };
344
+ }());
345
+ builder.addPlugins(resolvedConfig.builderPlugins);
346
+ appContext = _object_spread_props(_object_spread({}, api.useAppContext()), {
347
+ builder
348
+ });
349
+ api.setAppContext(appContext);
350
+ _state.label = 16;
351
+ case 16:
352
+ return [
353
+ 2
354
+ ];
355
+ }
356
+ });
357
+ })();
358
+ },
359
+ watchFiles: function watchFiles() {
360
+ return {
361
+ files: pagesDir,
362
+ isPrivate: true
363
+ };
364
+ },
365
+ resolvedConfig: function resolvedConfig(param2) {
366
+ var resolved = param2.resolved;
367
+ var appContext = api.useAppContext();
368
+ var config = initialNormalizedConfig(resolved, appContext, bundler);
369
+ return {
370
+ resolved: config
371
+ };
372
+ }
373
+ };
374
+ }
375
+ };
376
+ }
377
+ ;
378
+ export {
379
+ analyze_default as default
380
+ };
@@ -0,0 +1,49 @@
1
+ import fs from "fs";
2
+ import { parse } from "@babel/parser";
3
+ import traverse from "@babel/traverse";
4
+ import * as t from "@babel/types";
5
+ var isFunction = function(node) {
6
+ return t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
7
+ };
8
+ var isDefaultExportFunction = function(file) {
9
+ if (!file || !fs.existsSync(file)) {
10
+ return false;
11
+ }
12
+ var ast = parse(fs.readFileSync(file, "utf8"), {
13
+ sourceType: "unambiguous",
14
+ plugins: [
15
+ "jsx",
16
+ "typescript",
17
+ "classProperties",
18
+ "dynamicImport",
19
+ "exportDefaultFrom",
20
+ "exportNamespaceFrom",
21
+ "decorators-legacy",
22
+ "functionBind",
23
+ "classPrivateMethods",
24
+ [
25
+ "pipelineOperator",
26
+ {
27
+ proposal: "minimal"
28
+ }
29
+ ],
30
+ "optionalChaining",
31
+ "optionalCatchBinding",
32
+ "objectRestSpread",
33
+ "numericSeparator"
34
+ ]
35
+ });
36
+ var isExportFunction = false;
37
+ traverse(ast, {
38
+ ExportDefaultDeclaration: function(path) {
39
+ var declaration = path.node.declaration;
40
+ if (isFunction(declaration)) {
41
+ isExportFunction = true;
42
+ }
43
+ }
44
+ });
45
+ return isExportFunction;
46
+ };
47
+ export {
48
+ isDefaultExportFunction
49
+ };
@@ -0,0 +1,6 @@
1
+ var html = function(partials) {
2
+ return "\n<!DOCTYPE html>\n<html>\n<head>\n\n ".concat(partials.top.join("\n"), "\n\n ").concat(partials.head.join("\n"), '\n\n</head>\n\n<body>\n <div id="<%= mountId %>"><!--<?- html ?>--></div>\n ').concat(partials.body.join("\n"), "\n <!--<?- chunksMap.js ?>-->\n <!--<?- SSRDataScript ?>-->\n <!--<?- bottomTemplate ?>-->\n</body>\n\n</html>\n");
3
+ };
4
+ export {
5
+ html
6
+ };
@@ -0,0 +1,101 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
3
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
+ import fs from "fs";
5
+ import path from "path";
6
+ import { JS_EXTENSIONS, getCommand, normalizeToPosixPath } from "@modern-js/utils";
7
+ import { parse } from "es-module-lexer";
8
+ import { transform } from "esbuild";
9
+ var walkDirectory = function(dir) {
10
+ return fs.readdirSync(dir).reduce(function(previous, filename) {
11
+ var filePath = path.join(dir, filename);
12
+ if (fs.statSync(filePath).isDirectory()) {
13
+ return _to_consumable_array(previous).concat(_to_consumable_array(walkDirectory(filePath)));
14
+ } else {
15
+ return _to_consumable_array(previous).concat([
16
+ filePath
17
+ ]);
18
+ }
19
+ }, []);
20
+ };
21
+ var replaceWithAlias = function(base, filePath, alias) {
22
+ if (filePath.includes(base)) {
23
+ return normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
24
+ } else {
25
+ return filePath;
26
+ }
27
+ };
28
+ var parseModule = function() {
29
+ var _ref = _async_to_generator(function(param) {
30
+ var source, filename, content, result;
31
+ return _ts_generator(this, function(_state) {
32
+ switch (_state.label) {
33
+ case 0:
34
+ source = param.source, filename = param.filename;
35
+ content = source;
36
+ if (!JS_EXTENSIONS.some(function(ext) {
37
+ return filename.endsWith(ext);
38
+ }))
39
+ return [
40
+ 3,
41
+ 2
42
+ ];
43
+ return [
44
+ 4,
45
+ transform(content, {
46
+ loader: path.extname(filename).slice(1),
47
+ format: "esm"
48
+ })
49
+ ];
50
+ case 1:
51
+ result = _state.sent();
52
+ content = result.code;
53
+ _state.label = 2;
54
+ case 2:
55
+ return [
56
+ 4,
57
+ parse(content)
58
+ ];
59
+ case 3:
60
+ return [
61
+ 2,
62
+ _state.sent()
63
+ ];
64
+ }
65
+ });
66
+ });
67
+ return function parseModule2(_) {
68
+ return _ref.apply(this, arguments);
69
+ };
70
+ }();
71
+ var getServerCombinedModueFile = function(internalDirectory, entryName) {
72
+ return path.join(internalDirectory, entryName, "server-loader-combined.js");
73
+ };
74
+ var checkIsBuildCommands = function() {
75
+ var buildCommands = [
76
+ "dev",
77
+ "start",
78
+ "build",
79
+ "inspect",
80
+ "deploy",
81
+ "dev-worker"
82
+ ];
83
+ var command = getCommand();
84
+ return buildCommands.includes(command);
85
+ };
86
+ var isSubDirOrEqual = function(parent, child) {
87
+ if (parent === child) {
88
+ return true;
89
+ }
90
+ var relative = path.relative(parent, child);
91
+ var isSubdir = relative && !relative.startsWith("..") && !path.isAbsolute(relative);
92
+ return Boolean(isSubdir);
93
+ };
94
+ export {
95
+ checkIsBuildCommands,
96
+ getServerCombinedModueFile,
97
+ isSubDirOrEqual,
98
+ parseModule,
99
+ replaceWithAlias,
100
+ walkDirectory
101
+ };