@modern-js/app-tools 2.58.1 → 2.58.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (283) hide show
  1. package/dist/cjs/builder/builder-webpack/createCopyPattern.js +0 -1
  2. package/dist/cjs/builder/builder-webpack/index.js +1 -1
  3. package/dist/cjs/builder/generator/index.js +2 -2
  4. package/dist/cjs/builder/index.js +2 -2
  5. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +1 -4
  6. package/dist/cjs/commands/build.js +19 -0
  7. package/dist/cjs/commands/dev.js +9 -0
  8. package/dist/cjs/commands/index.js +8 -8
  9. package/dist/cjs/config/initialize/inits.js +4 -4
  10. package/dist/cjs/esm/esbuild-loader.mjs +20 -0
  11. package/dist/cjs/esm/register-esm.mjs +67 -0
  12. package/dist/cjs/esm/ts-node-loader.mjs +21 -0
  13. package/dist/cjs/esm/utils.mjs +43 -0
  14. package/dist/cjs/index.js +1 -1
  15. package/dist/cjs/plugins/analyze/index.js +3 -3
  16. package/dist/cjs/plugins/deploy/dependencies/index.js +1 -0
  17. package/dist/cjs/plugins/deploy/dependencies/utils.js +11 -0
  18. package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +3 -0
  19. package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +1 -0
  20. package/dist/cjs/plugins/deploy/platforms/{netlifyEntry.js → netlify-handler.js} +6 -4
  21. package/dist/cjs/plugins/deploy/platforms/netlify.js +14 -5
  22. package/dist/cjs/plugins/deploy/platforms/node.js +13 -4
  23. package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +3 -0
  24. package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +3 -0
  25. package/dist/cjs/plugins/deploy/platforms/{vercelEntry.js → vercel-handler.js} +4 -1
  26. package/dist/cjs/plugins/deploy/platforms/vercel.js +14 -5
  27. package/dist/cjs/utils/config.js +1 -1
  28. package/dist/cjs/utils/loadPlugins.js +1 -1
  29. package/dist/cjs/utils/register.js +50 -23
  30. package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -2
  31. package/dist/types/builder/builder-rspack/index.d.ts +1 -1
  32. package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -2
  33. package/dist/types/builder/builder-webpack/index.d.ts +1 -1
  34. package/dist/types/builder/generator/index.d.ts +2 -2
  35. package/dist/types/builder/index.d.ts +1 -1
  36. package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
  37. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
  38. package/dist/types/builder/shared/createCopyInfo.d.ts +1 -1
  39. package/dist/types/commands/build.d.ts +1 -1
  40. package/dist/types/commands/dev.d.ts +3 -3
  41. package/dist/types/commands/index.d.ts +3 -3
  42. package/dist/types/config/default.d.ts +1 -1
  43. package/dist/types/config/initialize/inits.d.ts +1 -1
  44. package/dist/types/config/legacy/createHtmlConfig.d.ts +1 -1
  45. package/dist/types/config/legacy/createOutputConfig.d.ts +1 -1
  46. package/dist/types/config/legacy/createSourceConfig.d.ts +1 -1
  47. package/dist/types/config/legacy/createToolsConfig.d.ts +1 -1
  48. package/dist/types/esm/esbuild-loader.d.mts +6 -0
  49. package/dist/types/esm/register-esm.d.mts +5 -0
  50. package/dist/types/esm/ts-node-loader.d.mts +6 -0
  51. package/dist/types/esm/utils.d.mts +6 -0
  52. package/dist/types/exports/server.d.ts +1 -1
  53. package/dist/types/hooks.d.ts +1 -1
  54. package/dist/types/index.d.ts +2 -2
  55. package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
  56. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
  57. package/dist/types/plugins/analyze/index.d.ts +1 -1
  58. package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -1
  59. package/dist/types/plugins/deploy/index.d.ts +2 -2
  60. package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +1 -0
  61. package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +1 -0
  62. package/dist/types/plugins/deploy/platforms/netlify-handler.d.cts +1 -0
  63. package/dist/types/plugins/deploy/platforms/netlify.d.ts +1 -1
  64. package/dist/types/plugins/deploy/platforms/node.d.ts +1 -1
  65. package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
  66. package/dist/types/plugins/deploy/platforms/vercel-entry.d.mts +2 -0
  67. package/dist/types/plugins/deploy/platforms/vercel-entry.d.ts +2 -0
  68. package/dist/types/plugins/deploy/platforms/vercel-handler.d.cts +1 -0
  69. package/dist/types/plugins/deploy/platforms/vercel.d.ts +1 -1
  70. package/dist/types/plugins/deploy/utils.d.ts +1 -1
  71. package/dist/types/plugins/serverBuild.d.ts +1 -1
  72. package/dist/types/types/hooks.d.ts +1 -1
  73. package/dist/types/types/index.d.ts +1 -1
  74. package/dist/types/utils/createServer.d.ts +1 -1
  75. package/dist/types/utils/generateWatchFiles.d.ts +1 -1
  76. package/dist/types/utils/getSelectedEntries.d.ts +1 -1
  77. package/dist/types/utils/loadPlugins.d.ts +3 -3
  78. package/dist/types/utils/register.d.ts +2 -2
  79. package/dist/types/utils/restart.d.ts +2 -2
  80. package/lib/types.d.ts +15 -0
  81. package/package.json +20 -20
  82. package/dist/esm/builder/builder-rspack/adapterCopy.js +0 -166
  83. package/dist/esm/builder/builder-rspack/index.js +0 -34
  84. package/dist/esm/builder/builder-webpack/adapterModern.js +0 -29
  85. package/dist/esm/builder/builder-webpack/createCopyPattern.js +0 -44
  86. package/dist/esm/builder/builder-webpack/index.js +0 -52
  87. package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -37
  88. package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -81
  89. package/dist/esm/builder/generator/index.js +0 -94
  90. package/dist/esm/builder/index.js +0 -45
  91. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -85
  92. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
  93. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -270
  94. package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +0 -43
  95. package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
  96. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
  97. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
  98. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -317
  99. package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
  100. package/dist/esm/builder/shared/createCopyInfo.js +0 -14
  101. package/dist/esm/builder/shared/index.js +0 -3
  102. package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
  103. package/dist/esm/builder/shared/types.js +0 -0
  104. package/dist/esm/commands/build.js +0 -117
  105. package/dist/esm/commands/deploy.js +0 -48
  106. package/dist/esm/commands/dev.js +0 -169
  107. package/dist/esm/commands/index.js +0 -411
  108. package/dist/esm/commands/inspect.js +0 -28
  109. package/dist/esm/commands/serve.js +0 -93
  110. package/dist/esm/config/default.js +0 -190
  111. package/dist/esm/config/index.js +0 -3
  112. package/dist/esm/config/initialize/index.js +0 -9
  113. package/dist/esm/config/initialize/inits.js +0 -85
  114. package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
  115. package/dist/esm/config/legacy/createOutputConfig.js +0 -45
  116. package/dist/esm/config/legacy/createSourceConfig.js +0 -46
  117. package/dist/esm/config/legacy/createToolsConfig.js +0 -28
  118. package/dist/esm/config/legacy/index.js +0 -43
  119. package/dist/esm/defineConfig.js +0 -16
  120. package/dist/esm/exports/server.js +0 -4
  121. package/dist/esm/hooks.js +0 -34
  122. package/dist/esm/index.js +0 -239
  123. package/dist/esm/locale/en.js +0 -43
  124. package/dist/esm/locale/index.js +0 -12
  125. package/dist/esm/locale/zh.js +0 -43
  126. package/dist/esm/plugins/analyze/constants.js +0 -14
  127. package/dist/esm/plugins/analyze/getBundleEntry.js +0 -102
  128. package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -238
  129. package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -178
  130. package/dist/esm/plugins/analyze/getServerRoutes.js +0 -132
  131. package/dist/esm/plugins/analyze/index.js +0 -380
  132. package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
  133. package/dist/esm/plugins/analyze/templates.js +0 -6
  134. package/dist/esm/plugins/analyze/utils.js +0 -101
  135. package/dist/esm/plugins/deploy/dependencies/index.js +0 -614
  136. package/dist/esm/plugins/deploy/dependencies/utils.js +0 -394
  137. package/dist/esm/plugins/deploy/exports.js +0 -4
  138. package/dist/esm/plugins/deploy/index.js +0 -135
  139. package/dist/esm/plugins/deploy/platforms/netlify.js +0 -299
  140. package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +0 -203
  141. package/dist/esm/plugins/deploy/platforms/node.js +0 -133
  142. package/dist/esm/plugins/deploy/platforms/nodeEntry.js +0 -108
  143. package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
  144. package/dist/esm/plugins/deploy/platforms/vercel.js +0 -233
  145. package/dist/esm/plugins/deploy/platforms/vercelEntry.js +0 -203
  146. package/dist/esm/plugins/deploy/utils.js +0 -47
  147. package/dist/esm/plugins/initialize/index.js +0 -119
  148. package/dist/esm/plugins/serverBuild.js +0 -87
  149. package/dist/esm/types/config/deploy.js +0 -0
  150. package/dist/esm/types/config/dev.js +0 -0
  151. package/dist/esm/types/config/experiments.js +0 -0
  152. package/dist/esm/types/config/html.js +0 -0
  153. package/dist/esm/types/config/index.js +0 -1
  154. package/dist/esm/types/config/output.js +0 -0
  155. package/dist/esm/types/config/performance.js +0 -0
  156. package/dist/esm/types/config/security.js +0 -0
  157. package/dist/esm/types/config/source.js +0 -0
  158. package/dist/esm/types/config/testing.js +0 -0
  159. package/dist/esm/types/config/tools.js +0 -0
  160. package/dist/esm/types/hooks.js +0 -0
  161. package/dist/esm/types/index.js +0 -3
  162. package/dist/esm/types/legacyConfig/deploy.js +0 -0
  163. package/dist/esm/types/legacyConfig/dev.js +0 -0
  164. package/dist/esm/types/legacyConfig/index.js +0 -0
  165. package/dist/esm/types/legacyConfig/output.js +0 -0
  166. package/dist/esm/types/legacyConfig/source.js +0 -0
  167. package/dist/esm/types/legacyConfig/testing.js +0 -0
  168. package/dist/esm/types/legacyConfig/tools.js +0 -0
  169. package/dist/esm/types/utils.js +0 -0
  170. package/dist/esm/utils/config.js +0 -122
  171. package/dist/esm/utils/createServer.js +0 -58
  172. package/dist/esm/utils/env.js +0 -16
  173. package/dist/esm/utils/generateWatchFiles.js +0 -71
  174. package/dist/esm/utils/getSelectedEntries.js +0 -67
  175. package/dist/esm/utils/loadPlugins.js +0 -69
  176. package/dist/esm/utils/printInstructions.js +0 -32
  177. package/dist/esm/utils/register.js +0 -129
  178. package/dist/esm/utils/restart.js +0 -67
  179. package/dist/esm/utils/routes.js +0 -42
  180. package/dist/esm/utils/types.js +0 -0
  181. package/dist/esm-node/builder/builder-rspack/adapterCopy.js +0 -67
  182. package/dist/esm-node/builder/builder-rspack/index.js +0 -12
  183. package/dist/esm-node/builder/builder-webpack/adapterModern.js +0 -26
  184. package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +0 -42
  185. package/dist/esm-node/builder/builder-webpack/index.js +0 -20
  186. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -44
  187. package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -60
  188. package/dist/esm-node/builder/generator/index.js +0 -37
  189. package/dist/esm-node/builder/index.js +0 -11
  190. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -48
  191. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
  192. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -156
  193. package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +0 -27
  194. package/dist/esm-node/builder/shared/builderPlugins/index.js +0 -4
  195. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
  196. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
  197. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -231
  198. package/dist/esm-node/builder/shared/bundlerPlugins/index.js +0 -3
  199. package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
  200. package/dist/esm-node/builder/shared/index.js +0 -3
  201. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
  202. package/dist/esm-node/builder/shared/types.js +0 -0
  203. package/dist/esm-node/commands/build.js +0 -55
  204. package/dist/esm-node/commands/deploy.js +0 -12
  205. package/dist/esm-node/commands/dev.js +0 -95
  206. package/dist/esm-node/commands/index.js +0 -92
  207. package/dist/esm-node/commands/inspect.js +0 -15
  208. package/dist/esm-node/commands/serve.js +0 -51
  209. package/dist/esm-node/config/default.js +0 -197
  210. package/dist/esm-node/config/index.js +0 -3
  211. package/dist/esm-node/config/initialize/index.js +0 -9
  212. package/dist/esm-node/config/initialize/inits.js +0 -79
  213. package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
  214. package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
  215. package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
  216. package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
  217. package/dist/esm-node/config/legacy/index.js +0 -43
  218. package/dist/esm-node/defineConfig.js +0 -13
  219. package/dist/esm-node/exports/server.js +0 -4
  220. package/dist/esm-node/hooks.js +0 -34
  221. package/dist/esm-node/index.js +0 -124
  222. package/dist/esm-node/locale/en.js +0 -43
  223. package/dist/esm-node/locale/index.js +0 -12
  224. package/dist/esm-node/locale/zh.js +0 -43
  225. package/dist/esm-node/plugins/analyze/constants.js +0 -14
  226. package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -61
  227. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -100
  228. package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -74
  229. package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -132
  230. package/dist/esm-node/plugins/analyze/index.js +0 -166
  231. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
  232. package/dist/esm-node/plugins/analyze/templates.js +0 -24
  233. package/dist/esm-node/plugins/analyze/utils.js +0 -68
  234. package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -201
  235. package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -126
  236. package/dist/esm-node/plugins/deploy/exports.js +0 -4
  237. package/dist/esm-node/plugins/deploy/index.js +0 -44
  238. package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -108
  239. package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +0 -69
  240. package/dist/esm-node/plugins/deploy/platforms/node.js +0 -63
  241. package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +0 -44
  242. package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
  243. package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -120
  244. package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +0 -69
  245. package/dist/esm-node/plugins/deploy/utils.js +0 -44
  246. package/dist/esm-node/plugins/initialize/index.js +0 -84
  247. package/dist/esm-node/plugins/serverBuild.js +0 -58
  248. package/dist/esm-node/types/config/deploy.js +0 -0
  249. package/dist/esm-node/types/config/dev.js +0 -0
  250. package/dist/esm-node/types/config/experiments.js +0 -0
  251. package/dist/esm-node/types/config/html.js +0 -0
  252. package/dist/esm-node/types/config/index.js +0 -1
  253. package/dist/esm-node/types/config/output.js +0 -0
  254. package/dist/esm-node/types/config/performance.js +0 -0
  255. package/dist/esm-node/types/config/security.js +0 -0
  256. package/dist/esm-node/types/config/source.js +0 -0
  257. package/dist/esm-node/types/config/testing.js +0 -0
  258. package/dist/esm-node/types/config/tools.js +0 -0
  259. package/dist/esm-node/types/hooks.js +0 -0
  260. package/dist/esm-node/types/index.js +0 -3
  261. package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
  262. package/dist/esm-node/types/legacyConfig/dev.js +0 -0
  263. package/dist/esm-node/types/legacyConfig/index.js +0 -0
  264. package/dist/esm-node/types/legacyConfig/output.js +0 -0
  265. package/dist/esm-node/types/legacyConfig/source.js +0 -0
  266. package/dist/esm-node/types/legacyConfig/testing.js +0 -0
  267. package/dist/esm-node/types/legacyConfig/tools.js +0 -0
  268. package/dist/esm-node/types/utils.js +0 -0
  269. package/dist/esm-node/utils/config.js +0 -49
  270. package/dist/esm-node/utils/createServer.js +0 -26
  271. package/dist/esm-node/utils/env.js +0 -16
  272. package/dist/esm-node/utils/generateWatchFiles.js +0 -30
  273. package/dist/esm-node/utils/getSelectedEntries.js +0 -34
  274. package/dist/esm-node/utils/loadPlugins.js +0 -22
  275. package/dist/esm-node/utils/printInstructions.js +0 -11
  276. package/dist/esm-node/utils/register.js +0 -69
  277. package/dist/esm-node/utils/restart.js +0 -22
  278. package/dist/esm-node/utils/routes.js +0 -21
  279. package/dist/esm-node/utils/types.js +0 -0
  280. package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +0 -2
  281. package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +0 -2
  282. /package/dist/cjs/plugins/deploy/platforms/{nodeEntry.js → node-entry.js} +0 -0
  283. /package/dist/types/plugins/deploy/platforms/{nodeEntry.d.ts → node-entry.d.ts} +0 -0
@@ -1,60 +0,0 @@
1
- import { isHtmlDisabled } from "@modern-js/uni-builder";
2
- import { MAIN_ENTRY_NAME, getEntryOptions, removeTailSlash } from "@modern-js/utils";
3
- import { template as lodashTemplate } from "@modern-js/utils/lodash";
4
- import { BottomTemplatePlugin } from "../bundlerPlugins";
5
- const createVirtualModule = (content) => `data:text/javascript,${content}`;
6
- const builderPluginAdapterHtml = (options) => ({
7
- name: "builder-plugin-adapter-modern-html",
8
- setup(api) {
9
- api.modifyBundlerChain(async (chain, { CHAIN_ID, target, HtmlPlugin: HtmlBundlerPlugin, environment }) => {
10
- const builderConfig = environment.config;
11
- if (!isHtmlDisabled(builderConfig, target)) {
12
- applyBottomHtmlPlugin({
13
- options,
14
- chain,
15
- CHAIN_ID,
16
- HtmlBundlerPlugin,
17
- htmlPaths: environment.htmlPaths
18
- });
19
- await injectAssetPrefix({
20
- chain
21
- });
22
- }
23
- });
24
- }
25
- });
26
- async function injectAssetPrefix({ chain }) {
27
- const entries = chain.entryPoints.entries() || {};
28
- const entryNames = Object.keys(entries);
29
- const assetPrefix = removeTailSlash(chain.output.get("publicPath") || "");
30
- const code = `window.__assetPrefix__ = '${assetPrefix}';`;
31
- entryNames.forEach((entryName) => {
32
- entries[entryName].prepend(createVirtualModule(code));
33
- });
34
- }
35
- function applyBottomHtmlPlugin({ chain, options, CHAIN_ID, HtmlBundlerPlugin, htmlPaths }) {
36
- const { normalizedConfig: modernConfig, appContext } = options;
37
- for (const entryName of Object.keys(htmlPaths)) {
38
- const { source: { mainEntryName } } = modernConfig;
39
- const isMainEntry = entryName === (mainEntryName || MAIN_ENTRY_NAME);
40
- const baseTemplateParams = {
41
- entryName,
42
- title: getEntryOptions(entryName, isMainEntry, modernConfig.html.title, modernConfig.html.titleByEntries, appContext.packageName),
43
- mountId: modernConfig.html.mountId,
44
- ...getEntryOptions(entryName, isMainEntry, modernConfig.html.templateParameters, modernConfig.html.templateParametersByEntries, appContext.packageName)
45
- };
46
- chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap((args) => [
47
- {
48
- ...args[0] || {},
49
- __internal__: true,
50
- bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && lodashTemplate(appContext.htmlTemplates[`__${entryName}-bottom__`])(baseTemplateParams)
51
- }
52
- ]);
53
- }
54
- chain.plugin("bottom-template").use(BottomTemplatePlugin, [
55
- HtmlBundlerPlugin
56
- ]);
57
- }
58
- export {
59
- builderPluginAdapterHtml
60
- };
@@ -1,156 +0,0 @@
1
- import * as path from "path";
2
- import { mergeRsbuildConfig } from "@rsbuild/core";
3
- import { fs, isUseSSRBundle } from "@modern-js/utils";
4
- import { isHtmlDisabled, SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
5
- import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins";
6
- import { getServerCombinedModueFile } from "../../../plugins/analyze/utils";
7
- const builderPluginAdapterSSR = (options) => ({
8
- name: "builder-plugin-adapter-modern-ssr",
9
- setup(api) {
10
- const { normalizedConfig } = options;
11
- api.modifyRsbuildConfig((config) => {
12
- return mergeRsbuildConfig(config, {
13
- html: {
14
- inject: isStreamingSSR(normalizedConfig) ? "body" : void 0
15
- },
16
- server: {
17
- // the http-compression can't handler stream http.
18
- // so we disable compress when user use stream ssr temporarily.
19
- compress: isStreamingSSR(normalizedConfig) || isSSRPreload(normalizedConfig) ? false : void 0
20
- }
21
- });
22
- });
23
- api.modifyBundlerChain(async (chain, { target, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer, environment }) => {
24
- const builderConfig = environment.config;
25
- const { normalizedConfig: normalizedConfig2 } = options;
26
- applyRouterPlugin(chain, "route-plugin", options, HtmlBundlerPlugin);
27
- if (isUseSSRBundle(normalizedConfig2)) {
28
- await applySSRLoaderEntry(chain, options, isServer);
29
- applySSRDataLoader(chain, options);
30
- }
31
- const isServiceWorker = environment.name === SERVICE_WORKER_ENVIRONMENT_NAME;
32
- if (target === "node" || isServiceWorker) {
33
- applyFilterEntriesBySSRConfig({
34
- isProd,
35
- chain,
36
- appNormalizedConfig: normalizedConfig2
37
- });
38
- }
39
- if (!isHtmlDisabled(builderConfig, target)) {
40
- applyAsyncChunkHtmlPlugin({
41
- chain,
42
- modernConfig: options.normalizedConfig,
43
- HtmlBundlerPlugin
44
- });
45
- }
46
- });
47
- }
48
- });
49
- const isSSRPreload = (userConfig) => {
50
- const { server: { ssr, ssrByEntries } } = userConfig;
51
- const checkUsePreload = (ssr2) => typeof ssr2 === "object" && Boolean(ssr2.preload);
52
- return checkUsePreload(ssr) || Object.values(ssrByEntries || {}).some((ssr2) => checkUsePreload(ssr2));
53
- };
54
- const isStreamingSSR = (userConfig) => {
55
- const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
56
- const { server } = userConfig;
57
- if (isStreaming(server.ssr)) {
58
- return true;
59
- }
60
- if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
61
- for (const name of Object.keys(server.ssrByEntries)) {
62
- if (isStreaming(server.ssrByEntries[name])) {
63
- return true;
64
- }
65
- }
66
- }
67
- return false;
68
- };
69
- function applyAsyncChunkHtmlPlugin({ chain, modernConfig, HtmlBundlerPlugin }) {
70
- if (isStreamingSSR(modernConfig)) {
71
- chain.plugin("html-async-chunk").use(HtmlAsyncChunkPlugin, [
72
- HtmlBundlerPlugin
73
- ]);
74
- }
75
- }
76
- function applyRouterPlugin(chain, pluginName, options, HtmlBundlerPlugin) {
77
- var _normalizedConfig_runtime, _normalizedConfig_deploy_worker;
78
- const { appContext, normalizedConfig } = options;
79
- const { entrypoints } = appContext;
80
- const existNestedRoutes = entrypoints.some((entrypoint) => entrypoint.nestedRoutesEntry);
81
- const routerConfig = normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_runtime = normalizedConfig.runtime) === null || _normalizedConfig_runtime === void 0 ? void 0 : _normalizedConfig_runtime.router;
82
- const routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
83
- const workerSSR = Boolean((_normalizedConfig_deploy_worker = normalizedConfig.deploy.worker) === null || _normalizedConfig_deploy_worker === void 0 ? void 0 : _normalizedConfig_deploy_worker.ssr);
84
- const { enableInlineRouteManifests, disableInlineRouteManifests } = normalizedConfig.output;
85
- const inlineRouteManifests = disableInlineRouteManifests ? !disableInlineRouteManifests : enableInlineRouteManifests;
86
- if (existNestedRoutes || routerManifest || workerSSR) {
87
- var _normalizedConfig_output_distPath, _normalizedConfig_output, _normalizedConfig_output1, _normalizedConfig_html, _normalizedConfig_security;
88
- chain.plugin(pluginName).use(RouterPlugin, [
89
- {
90
- HtmlBundlerPlugin,
91
- enableInlineRouteManifests: inlineRouteManifests,
92
- staticJsDir: (_normalizedConfig_output = normalizedConfig.output) === null || _normalizedConfig_output === void 0 ? void 0 : (_normalizedConfig_output_distPath = _normalizedConfig_output.distPath) === null || _normalizedConfig_output_distPath === void 0 ? void 0 : _normalizedConfig_output_distPath.js,
93
- disableFilenameHash: (_normalizedConfig_output1 = normalizedConfig.output) === null || _normalizedConfig_output1 === void 0 ? void 0 : _normalizedConfig_output1.disableFilenameHash,
94
- scriptLoading: (_normalizedConfig_html = normalizedConfig.html) === null || _normalizedConfig_html === void 0 ? void 0 : _normalizedConfig_html.scriptLoading,
95
- nonce: (_normalizedConfig_security = normalizedConfig.security) === null || _normalizedConfig_security === void 0 ? void 0 : _normalizedConfig_security.nonce
96
- }
97
- ]);
98
- }
99
- }
100
- function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
101
- var _this;
102
- const { server: serverConfig, output: outputConfig } = appNormalizedConfig;
103
- const entries = chain.entryPoints.entries();
104
- if (isProd && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof ((_this = outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === null || _this === void 0 ? void 0 : _this[0]) === "function")) {
105
- return;
106
- }
107
- if (typeof entries === "undefined") {
108
- throw new Error("No entry found, one of src/routes/layout.tsx, src/App.tsx, src/index.tsx is required");
109
- }
110
- const entryNames = Object.keys(entries);
111
- if (isProd && entryNames.length === 1 && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
112
- return;
113
- }
114
- const ssgEntries = [];
115
- if (isProd && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
116
- const { ssg } = outputConfig;
117
- entryNames.forEach((name) => {
118
- if (ssg[name]) {
119
- ssgEntries.push(name);
120
- }
121
- });
122
- }
123
- const { ssr, ssrByEntries } = serverConfig || {};
124
- entryNames.forEach((name) => {
125
- if (!ssgEntries.includes(name) && !name.includes("server-loaders") && (ssr && (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]))) {
126
- chain.entryPoints.delete(name);
127
- }
128
- });
129
- }
130
- async function applySSRLoaderEntry(chain, optinos, isServer) {
131
- const { appContext } = optinos;
132
- const { internalDirectory } = appContext;
133
- const { entrypoints } = appContext;
134
- await Promise.all(entrypoints.map(async (entrypoint) => {
135
- const { entryName } = entrypoint;
136
- const serverLoadersFile = getServerCombinedModueFile(internalDirectory, entryName);
137
- if (isServer) {
138
- try {
139
- await fs.access(serverLoadersFile, fs.constants.F_OK);
140
- chain.entry(`${entryName}-server-loaders`).add(serverLoadersFile);
141
- } catch (err) {
142
- }
143
- }
144
- }));
145
- }
146
- function applySSRDataLoader(chain, options) {
147
- const { normalizedConfig, appContext } = options;
148
- const { appDirectory } = appContext;
149
- const { entriesDir = "./src" } = normalizedConfig.source;
150
- const absolutePath = path.resolve(appDirectory, entriesDir).split(path.sep).join("(\\\\|/)");
151
- const reg = new RegExp(`${absolutePath}.*\\.(loader|data|data.client)\\.[t|j]sx?$`);
152
- chain.module.rule("ssr-data-loader").test(reg).use("data-loader").loader(require.resolve("@modern-js/plugin-data-loader/loader")).end();
153
- }
154
- export {
155
- builderPluginAdapterSSR
156
- };
@@ -1,27 +0,0 @@
1
- import { posix } from "path";
2
- import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
3
- const getDistPath = (outputConfig, type) => {
4
- const { distPath } = outputConfig;
5
- const ret = distPath[type];
6
- if (typeof ret !== "string") {
7
- throw new Error(`unknown key ${type} in "output.distPath"`);
8
- }
9
- return ret;
10
- };
11
- const builderPluginAdapterWorker = () => ({
12
- name: "builder-plugin-adapter-worker",
13
- setup(api) {
14
- api.modifyBundlerChain(async (chain, { environment }) => {
15
- const { config, name } = environment;
16
- const isServiceWorker = name === SERVICE_WORKER_ENVIRONMENT_NAME;
17
- if (isServiceWorker) {
18
- const workerPath = getDistPath(config.output, "root");
19
- const filename = posix.join(workerPath, `[name].js`);
20
- chain.output.filename(filename).chunkFilename(filename).libraryTarget("commonjs2");
21
- }
22
- });
23
- }
24
- });
25
- export {
26
- builderPluginAdapterWorker
27
- };
@@ -1,4 +0,0 @@
1
- export * from "./adapterBasic";
2
- export * from "./adapterHtml";
3
- export * from "./adapterSSR";
4
- export * from "./adapterWorker";
@@ -1,30 +0,0 @@
1
- class HtmlAsyncChunkPlugin {
2
- apply(compiler) {
3
- compiler.hooks.compilation.tap(this.name, (compilation) => {
4
- const hooks = this.htmlWebpackPlugin.getHooks(compilation);
5
- hooks.alterAssetTagGroups.tap(this.name, (assets) => {
6
- const tags = [
7
- ...assets.headTags,
8
- ...assets.bodyTags
9
- ];
10
- for (const tag of tags) {
11
- if (tag.tagName === "script") {
12
- const { attributes } = tag;
13
- if (attributes && attributes.defer === true) {
14
- attributes.async = true;
15
- delete attributes.defer;
16
- }
17
- }
18
- }
19
- return assets;
20
- });
21
- });
22
- }
23
- constructor(htmlWebpackPlugin) {
24
- this.name = "HtmlAsyncChunkPlugin";
25
- this.htmlWebpackPlugin = htmlWebpackPlugin;
26
- }
27
- }
28
- export {
29
- HtmlAsyncChunkPlugin
30
- };
@@ -1,31 +0,0 @@
1
- class BottomTemplatePlugin {
2
- apply(compiler) {
3
- compiler.hooks.compilation.tap(this.name, (compilation) => {
4
- this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(this.name, (data) => {
5
- var _data_plugin_options;
6
- if (!((_data_plugin_options = data.plugin.options) === null || _data_plugin_options === void 0 ? void 0 : _data_plugin_options.__internal__)) {
7
- return data;
8
- }
9
- if (this.bottomTemplateReg.test(data.html)) {
10
- data.html = data.html.replace(this.bottomTemplateReg, "");
11
- const { bottomTemplate } = data.plugin.options;
12
- if (bottomTemplate) {
13
- data.html = data.html.replace(this.bodyRegExp, (match) => `
14
- ${bottomTemplate}
15
- ${match}`);
16
- }
17
- }
18
- return data;
19
- });
20
- });
21
- }
22
- constructor(htmlWebpackPlugin) {
23
- this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
24
- this.bodyRegExp = /(<\/\s*body\s*>)/i;
25
- this.htmlWebpackPlugin = htmlWebpackPlugin;
26
- this.name = "bottom-template";
27
- }
28
- }
29
- export {
30
- BottomTemplatePlugin
31
- };
@@ -1,231 +0,0 @@
1
- import { createHash } from "crypto";
2
- import { merge, mergeWith } from "@modern-js/utils/lodash";
3
- import { ROUTE_MANIFEST_FILE } from "@modern-js/utils";
4
- import { ROUTE_MANIFEST } from "@modern-js/utils/universal/constants";
5
- const PLUGIN_NAME = "ModernjsRoutePlugin";
6
- const generateContentHash = (content) => {
7
- return createHash("md5").update(content).digest("hex").slice(0, 8);
8
- };
9
- class RouterPlugin {
10
- isTargetNodeOrWebWorker(target) {
11
- if (target === "node" || Array.isArray(target) && target.includes("node")) {
12
- return true;
13
- }
14
- if (target === "webworker" || Array.isArray(target) && target.includes("webworker")) {
15
- return true;
16
- }
17
- return false;
18
- }
19
- getEntryChunks(compilation, chunks) {
20
- const entrypointsArray = Array.from(compilation.entrypoints.entries());
21
- const entryChunkIds = entrypointsArray.map((entrypoint) => entrypoint[0]);
22
- const entryChunks = [
23
- ...chunks
24
- ].filter((chunk) => {
25
- var _chunk_names;
26
- return (_chunk_names = chunk.names) === null || _chunk_names === void 0 ? void 0 : _chunk_names.some((name) => entryChunkIds.includes(name));
27
- });
28
- return entryChunks;
29
- }
30
- getEntryChunkFiles(entryChunks) {
31
- return entryChunks.map((chunk) => [
32
- ...chunk.files || []
33
- ].find((fname) => fname.includes(".js")));
34
- }
35
- apply(compiler) {
36
- const { target } = compiler.options;
37
- if (this.isTargetNodeOrWebWorker(target)) {
38
- return;
39
- }
40
- const { webpack } = compiler;
41
- const isRspack = "rspackVersion" in webpack;
42
- const { Compilation, sources } = webpack;
43
- const { RawSource } = sources;
44
- const normalizePath = (path) => {
45
- if (!path.endsWith("/")) {
46
- return `${path}/`;
47
- }
48
- return path;
49
- };
50
- const chunksToHtmlName = /* @__PURE__ */ new Map();
51
- const ROUTE_MANIFEST_HOLDER = `route-manifest`;
52
- const placeholder = `<!--<?- ${ROUTE_MANIFEST_HOLDER} ?>-->`;
53
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
54
- this.HtmlBundlerPlugin.getHooks(compilation).beforeEmit.tapAsync("RouterManifestPlugin", (data, callback) => {
55
- const { outputName } = data;
56
- const { chunks } = data.plugin.options;
57
- chunksToHtmlName.set(chunks, outputName);
58
- data.html = data.html.replace("</script>", `</script>${placeholder}`);
59
- callback(null, data);
60
- });
61
- compilation.hooks.processAssets.tapPromise({
62
- name: PLUGIN_NAME,
63
- stage: Compilation.PROCESS_ASSETS_STAGE_REPORT
64
- }, async () => {
65
- const stats = compilation.getStats().toJson({
66
- all: false,
67
- publicPath: true,
68
- assets: true,
69
- chunkGroups: true,
70
- chunks: true,
71
- ids: true
72
- });
73
- const { publicPath, chunks = [], namedChunkGroups } = stats;
74
- const routeAssets = {};
75
- if (!namedChunkGroups) {
76
- return;
77
- }
78
- const prevManifestAsset = compilation.getAsset(ROUTE_MANIFEST_FILE);
79
- const prevManifestStr = prevManifestAsset ? prevManifestAsset.source.source().toString() : JSON.stringify({
80
- routeAssets: {}
81
- });
82
- const prevManifest = JSON.parse(prevManifestStr);
83
- const asyncEntryNames = [];
84
- for (const [name, chunkGroup] of Object.entries(namedChunkGroups)) {
85
- if (name.startsWith("async-")) {
86
- asyncEntryNames.push(name);
87
- }
88
- const assets = chunkGroup.assets.map((asset) => {
89
- const filename = asset.name;
90
- return publicPath ? normalizePath(publicPath) + filename : filename;
91
- });
92
- const referenceCssAssets = assets.filter((asset) => /\.css$/.test(asset));
93
- routeAssets[name] = {
94
- chunkIds: chunkGroup.chunks,
95
- assets,
96
- referenceCssAssets
97
- };
98
- if (prevManifest.routeAssets[name]) {
99
- mergeWith(routeAssets[name], prevManifest.routeAssets[name], (obj, source) => {
100
- if (Array.isArray(obj)) {
101
- return obj.concat(source);
102
- }
103
- return Object.assign(source, obj);
104
- });
105
- }
106
- }
107
- if (asyncEntryNames.length > 0) {
108
- for (const asyncEntryName of asyncEntryNames) {
109
- const syncEntryName = asyncEntryName.replace("async-", "");
110
- const syncEntry = routeAssets[syncEntryName];
111
- const asyncEntry = routeAssets[asyncEntryName];
112
- merge(syncEntry, asyncEntry);
113
- }
114
- }
115
- const manifest = {
116
- routeAssets
117
- };
118
- const entryNames = Array.from(compilation.entrypoints.keys());
119
- let entryChunks = [];
120
- if (isRspack) {
121
- entryChunks = this.getEntryChunks(compilation, chunks);
122
- } else {
123
- const orignalEntryIds = Object.keys(compilation.options.entry).map((entryName) => {
124
- const chunk = compilation.namedChunks.get(entryName);
125
- if (chunk) {
126
- return chunk.id;
127
- }
128
- return entryName;
129
- });
130
- entryChunks = this.getEntryChunks(compilation, chunks).filter((chunk) => orignalEntryIds.includes(chunk.id));
131
- }
132
- const entryChunkFiles = this.getEntryChunkFiles(entryChunks);
133
- const entryChunkFileIds = entryChunks.map((chunk) => chunk.id);
134
- for (let i = 0; i < entryChunkFiles.length; i++) {
135
- const entryName = entryNames[i];
136
- const file = entryChunkFiles[i];
137
- const chunkNames = entryChunks[i].names;
138
- const chunkId = entryChunkFileIds[i];
139
- const asset = compilation.assets[file];
140
- if (!asset || !chunkId) {
141
- continue;
142
- }
143
- let relatedAssets = {};
144
- if (entryChunkFiles.length > 1) {
145
- Object.keys(routeAssets).forEach((routeId) => {
146
- const segments = routeId.split("_");
147
- const chunkName = segments[0];
148
- if (chunkNames === null || chunkNames === void 0 ? void 0 : chunkNames.includes(chunkName)) {
149
- relatedAssets[routeId] = routeAssets[routeId];
150
- }
151
- });
152
- } else {
153
- relatedAssets = routeAssets;
154
- }
155
- const manifest2 = {
156
- routeAssets: relatedAssets
157
- };
158
- const injectedContent = `
159
- ;(function(){
160
- window.${ROUTE_MANIFEST} = ${JSON.stringify(manifest2, (k, v) => {
161
- if ((k === "assets" || k === "referenceCssAssets") && Array.isArray(v)) {
162
- return v.map((item) => {
163
- return item.replace(publicPath, "");
164
- });
165
- }
166
- return v;
167
- })};
168
- })();
169
- `;
170
- let htmlName;
171
- for (const [chunks2, name] of chunksToHtmlName.entries()) {
172
- if (Array.isArray(chunkNames) && Array.isArray(chunks2) && chunkNames.every((value, index) => value === chunks2[index])) {
173
- htmlName = name;
174
- break;
175
- }
176
- }
177
- const oldHtml = compilation.assets[htmlName];
178
- const { enableInlineRouteManifests, disableFilenameHash, staticJsDir, scriptLoading, nonce } = this;
179
- const nonceAttr = nonce ? `nonce="${nonce}"` : "";
180
- if (oldHtml) {
181
- if (enableInlineRouteManifests) {
182
- compilation.updateAsset(
183
- htmlName,
184
- new RawSource(oldHtml.source().toString().replace(placeholder, `<script ${nonceAttr}>${injectedContent}</script>`)),
185
- // FIXME: The arguments third of updatgeAsset is a optional function in webpack.
186
- void 0
187
- );
188
- } else {
189
- const scriptPath = `${staticJsDir}/${ROUTE_MANIFEST_HOLDER}-${entryName}${disableFilenameHash ? ".js" : `.${generateContentHash(injectedContent)}.js`}`;
190
- const scriptUrl = `${publicPath}${scriptPath}`;
191
- const scriptLoadingAttr = (
192
- // eslint-disable-next-line no-nested-ternary
193
- scriptLoading === "defer" ? scriptLoading : scriptLoading === "module" ? `type="module"` : ""
194
- );
195
- const script = `<script ${scriptLoadingAttr} ${nonceAttr} src="${scriptUrl}"></script>`;
196
- compilation.updateAsset(
197
- htmlName,
198
- new RawSource(oldHtml.source().toString().replace(placeholder, script)),
199
- // FIXME: The arguments third of updatgeAsset is a optional function in webpack.
200
- void 0
201
- );
202
- compilation.emitAsset(scriptPath, new RawSource(injectedContent));
203
- }
204
- }
205
- }
206
- if (prevManifestAsset) {
207
- compilation.updateAsset(
208
- ROUTE_MANIFEST_FILE,
209
- new RawSource(JSON.stringify(manifest, null, 2)),
210
- // FIXME: The arguments third of updatgeAsset is a optional function in webpack.
211
- void 0
212
- );
213
- } else {
214
- compilation.emitAsset(ROUTE_MANIFEST_FILE, new RawSource(JSON.stringify(manifest, null, 2)));
215
- }
216
- });
217
- });
218
- }
219
- constructor({ staticJsDir = "static/js", HtmlBundlerPlugin, enableInlineRouteManifests, disableFilenameHash = false, scriptLoading = "defer", nonce }) {
220
- this.name = "RouterPlugin";
221
- this.HtmlBundlerPlugin = HtmlBundlerPlugin;
222
- this.enableInlineRouteManifests = enableInlineRouteManifests;
223
- this.staticJsDir = staticJsDir;
224
- this.disableFilenameHash = disableFilenameHash;
225
- this.scriptLoading = scriptLoading;
226
- this.nonce = nonce;
227
- }
228
- }
229
- export {
230
- RouterPlugin
231
- };
@@ -1,3 +0,0 @@
1
- export * from "./HtmlAsyncChunkPlugin";
2
- export * from "./HtmlBottomTemplate";
3
- export * from "./RouterPlugin";
@@ -1,14 +0,0 @@
1
- import path from "path";
2
- function createCopyInfo(appContext, config) {
3
- const configDir = path.resolve(appContext.appDirectory, config.source.configDir || "./config");
4
- const uploadDir = path.posix.join(configDir.replace(/\\/g, "/"), "upload");
5
- const publicDir = path.posix.join(configDir.replace(/\\/g, "/"), "public");
6
- return {
7
- configDir,
8
- uploadDir,
9
- publicDir
10
- };
11
- }
12
- export {
13
- createCopyInfo
14
- };
@@ -1,3 +0,0 @@
1
- export * from "./types";
2
- export * from "./builderPlugins";
3
- export * from "./createCopyInfo";
@@ -1,7 +0,0 @@
1
- function loader() {
2
- return `module.exports = {}`;
3
- }
4
- var serverModuleLoader_default = loader;
5
- export {
6
- serverModuleLoader_default as default
7
- };
File without changes
@@ -1,55 +0,0 @@
1
- import { ResolvedConfigContext } from "@modern-js/core";
2
- import { logger } from "@modern-js/utils";
3
- import { loadServerPlugins } from "../utils/loadPlugins";
4
- import { generateRoutes } from "../utils/routes";
5
- import { buildServerConfig } from "../utils/config";
6
- import { registerCompiler } from "../utils/register";
7
- const build = async (api, options) => {
8
- var _resolvedConfig_source;
9
- if (options === null || options === void 0 ? void 0 : options.analyze) {
10
- process.env.BUNDLE_ANALYZE = "true";
11
- }
12
- let resolvedConfig = api.useResolvedConfigContext();
13
- const appContext = api.useAppContext();
14
- const hookRunners = api.useHookRunners();
15
- await loadServerPlugins(api, appContext.appDirectory, appContext.metaName);
16
- await registerCompiler(appContext.appDirectory, appContext.distDirectory, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias);
17
- const { apiOnly } = appContext;
18
- if (apiOnly) {
19
- const { appDirectory: appDirectory2, distDirectory: distDirectory2, serverConfigFile: serverConfigFile2 } = appContext;
20
- await hookRunners.beforeBuild({
21
- // "null" bundlerConfigs
22
- bundlerConfigs: void 0
23
- });
24
- await buildServerConfig({
25
- appDirectory: appDirectory2,
26
- distDirectory: distDirectory2,
27
- configFile: serverConfigFile2
28
- });
29
- await generateRoutes(appContext);
30
- await hookRunners.afterBuild({
31
- // "null" stats
32
- stats: void 0
33
- });
34
- return;
35
- }
36
- resolvedConfig = {
37
- ...resolvedConfig,
38
- cliOptions: options
39
- };
40
- ResolvedConfigContext.set(resolvedConfig);
41
- const { distDirectory, appDirectory, serverConfigFile } = appContext;
42
- await buildServerConfig({
43
- appDirectory,
44
- distDirectory,
45
- configFile: serverConfigFile
46
- });
47
- logger.info("Starting production build...");
48
- if (!appContext.builder) {
49
- throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
50
- }
51
- await appContext.builder.build();
52
- };
53
- export {
54
- build
55
- };
@@ -1,12 +0,0 @@
1
- import { getServerPlugins } from "../utils/loadPlugins";
2
- const deploy = async (api, options) => {
3
- const hookRunners = api.useHookRunners();
4
- const { metaName } = api.useAppContext();
5
- await getServerPlugins(api, metaName);
6
- await hookRunners.beforeDeploy(options);
7
- await hookRunners.deploy(options);
8
- await hookRunners.afterDeploy(options);
9
- };
10
- export {
11
- deploy
12
- };