@bleedingdev/modern-js-app-tools 3.8.2-ultramodern.9 → 3.8.3-ultramodern.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/bin/modern-bundle-docs.js +11 -0
  2. package/bin/modern.js +11 -0
  3. package/dist/cjs/builder/generator/getBuilderEnvironments.js +13 -241
  4. package/dist/cjs/builder/generator/index.js +0 -1
  5. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +37 -9
  6. package/dist/cjs/builder/shared/builderPlugins/index.js +6 -13
  7. package/dist/cjs/builder/shared/bundlerPlugins/index.js +6 -13
  8. package/dist/cjs/builder/shared/lazyCompilation.js +9 -9
  9. package/dist/cjs/bundleDocs.js +1 -1
  10. package/dist/cjs/index.js +59 -60
  11. package/dist/cjs/plugins/analyze/getServerRoutes.js +1 -1
  12. package/dist/cjs/plugins/analyze/isDefaultExportFunction.js +1 -9
  13. package/dist/cjs/plugins/backend-federation/codegen.js +2 -1
  14. package/dist/cjs/plugins/backend-federation/config.js +2 -2
  15. package/dist/cjs/plugins/backend-federation/emit.js +6 -4
  16. package/dist/cjs/plugins/deploy/index.js +4 -4
  17. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +23 -149
  18. package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.cjs +41 -62
  19. package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.mjs +41 -63
  20. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.cjs +35 -52
  21. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.mjs +35 -53
  22. package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.cjs +41 -61
  23. package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.mjs +40 -61
  24. package/dist/cjs/plugins/ultramodernReleaseEnvelope.js +3 -59
  25. package/dist/cjs/presetUltramodern.js +15 -8
  26. package/dist/cjs/run/index.js +9 -9
  27. package/dist/cjs/utils/env.js +1 -1
  28. package/dist/cjs/utils/register.js +6 -3
  29. package/dist/esm/builder/generator/getBuilderEnvironments.mjs +12 -231
  30. package/dist/esm/builder/generator/index.mjs +1 -2
  31. package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +34 -9
  32. package/dist/esm/builder/shared/builderPlugins/index.mjs +0 -1
  33. package/dist/esm/builder/shared/bundlerPlugins/index.mjs +0 -1
  34. package/dist/esm/builder/shared/lazyCompilation.mjs +4 -4
  35. package/dist/esm/bundleDocs.mjs +1 -1
  36. package/dist/esm/index.mjs +3 -3
  37. package/dist/esm/plugins/analyze/getServerRoutes.mjs +1 -1
  38. package/dist/esm/plugins/analyze/isDefaultExportFunction.mjs +1 -9
  39. package/dist/esm/plugins/backend-federation/codegen.mjs +2 -1
  40. package/dist/esm/plugins/backend-federation/config.mjs +1 -1
  41. package/dist/esm/plugins/backend-federation/emit.mjs +5 -3
  42. package/dist/esm/plugins/deploy/index.mjs +1 -1
  43. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +1 -133
  44. package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.cjs +41 -62
  45. package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.mjs +41 -63
  46. package/dist/esm/plugins/deploy/platforms/templates/node-entry.cjs +35 -52
  47. package/dist/esm/plugins/deploy/platforms/templates/node-entry.mjs +35 -53
  48. package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.cjs +41 -61
  49. package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.mjs +40 -61
  50. package/dist/esm/plugins/ultramodernReleaseEnvelope.mjs +3 -49
  51. package/dist/esm/presetUltramodern.mjs +8 -5
  52. package/dist/esm/run/index.mjs +9 -9
  53. package/dist/esm/utils/env.mjs +1 -1
  54. package/dist/esm/utils/register.mjs +6 -3
  55. package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +12 -234
  56. package/dist/esm-node/builder/generator/index.mjs +1 -2
  57. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +34 -9
  58. package/dist/esm-node/builder/shared/builderPlugins/index.mjs +0 -1
  59. package/dist/esm-node/builder/shared/bundlerPlugins/index.mjs +0 -1
  60. package/dist/esm-node/builder/shared/lazyCompilation.mjs +4 -4
  61. package/dist/esm-node/bundleDocs.mjs +1 -1
  62. package/dist/esm-node/index.mjs +3 -3
  63. package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +1 -1
  64. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +1 -9
  65. package/dist/esm-node/plugins/backend-federation/codegen.mjs +2 -1
  66. package/dist/esm-node/plugins/backend-federation/config.mjs +1 -1
  67. package/dist/esm-node/plugins/backend-federation/emit.mjs +5 -3
  68. package/dist/esm-node/plugins/deploy/index.mjs +1 -1
  69. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +1 -133
  70. package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.cjs +41 -62
  71. package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.mjs +41 -63
  72. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.cjs +35 -52
  73. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.mjs +35 -53
  74. package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.cjs +41 -61
  75. package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.mjs +40 -61
  76. package/dist/esm-node/plugins/ultramodernReleaseEnvelope.mjs +3 -49
  77. package/dist/esm-node/presetUltramodern.mjs +8 -5
  78. package/dist/esm-node/run/index.mjs +9 -9
  79. package/dist/esm-node/utils/env.mjs +1 -1
  80. package/dist/esm-node/utils/register.mjs +6 -3
  81. package/dist/types/builder/generator/getBuilderEnvironments.d.ts +0 -29
  82. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +11 -0
  83. package/dist/types/builder/shared/builderPlugins/index.d.ts +0 -1
  84. package/dist/types/builder/shared/bundlerPlugins/index.d.ts +0 -1
  85. package/dist/types/builder/shared/lazyCompilation.d.ts +7 -7
  86. package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -1
  87. package/dist/types/plugins/backend-federation/codegen.d.ts +4 -1
  88. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +1 -18
  89. package/dist/types/presetUltramodern.d.ts +23 -2
  90. package/dist/types/types/config/deploy.d.ts +2 -2
  91. package/docs/community/showcase.md +3 -5
  92. package/docs/configure/app/bff/effect.md +7 -7
  93. package/docs/guides/advanced-features/bff/frameworks.md +1 -1
  94. package/docs/guides/basic-features/deploy.md +2 -2
  95. package/docs/guides/get-started/quick-start.md +10 -9
  96. package/docs/guides/get-started/tech-stack.md +1 -1
  97. package/docs/guides/get-started/ultramodern.md +123 -38
  98. package/docs/guides/troubleshooting/cli.md +1 -1
  99. package/docs/llms.txt +2 -2
  100. package/docs/tutorials/examples/csr-auth.md +1 -1
  101. package/package.json +16 -28
  102. package/rslib.config.mts +4 -7
  103. package/dist/cjs/builder/shared/builderPlugins/adapterLazyCompilation.js +0 -74
  104. package/dist/cjs/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.js +0 -72
  105. package/dist/cjs/plugins/deploy/platforms/cloudflare/artifacts.js +0 -127
  106. package/dist/cjs/plugins/deploy/platforms/cloudflare/constants.js +0 -141
  107. package/dist/cjs/plugins/deploy/platforms/cloudflare/delivery-unit.js +0 -139
  108. package/dist/cjs/plugins/deploy/platforms/cloudflare/i18n-worker.js +0 -135
  109. package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +0 -150
  110. package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +0 -205
  111. package/dist/cjs/plugins/deploy/platforms/cloudflare/types.js +0 -18
  112. package/dist/cjs/plugins/deploy/platforms/cloudflare/utils.js +0 -66
  113. package/dist/cjs/plugins/deploy/platforms/cloudflare/worker-manifest.js +0 -208
  114. package/dist/cjs/plugins/deploy/platforms/cloudflare/wrangler-config.js +0 -204
  115. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-contract.js +0 -108
  116. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-plan.js +0 -93
  117. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/identity.js +0 -83
  118. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/issues.js +0 -54
  119. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/manifest.js +0 -89
  120. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +0 -151
  121. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +0 -378
  122. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +0 -251
  123. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -191
  124. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -514
  125. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -1012
  126. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -363
  127. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +0 -93
  128. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +0 -11
  129. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +0 -281
  130. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +0 -14
  131. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +0 -98
  132. package/dist/cjs/types/config/cloudflareDeploy.js +0 -18
  133. package/dist/cjs/ultramodern-release-envelope/canonical.js +0 -68
  134. package/dist/cjs/ultramodern-release-envelope/framework-output.js +0 -649
  135. package/dist/cjs/ultramodern-release-envelope/index.js +0 -399
  136. package/dist/cjs/ultramodern-release-envelope/types.js +0 -51
  137. package/dist/cjs/ultramodern-release-identity.js +0 -110
  138. package/dist/esm/builder/shared/builderPlugins/adapterLazyCompilation.mjs +0 -36
  139. package/dist/esm/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +0 -30
  140. package/dist/esm/plugins/deploy/platforms/cloudflare/artifacts.mjs +0 -64
  141. package/dist/esm/plugins/deploy/platforms/cloudflare/constants.mjs +0 -34
  142. package/dist/esm/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +0 -88
  143. package/dist/esm/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +0 -97
  144. package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +0 -102
  145. package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +0 -167
  146. package/dist/esm/plugins/deploy/platforms/cloudflare/types.mjs +0 -0
  147. package/dist/esm/plugins/deploy/platforms/cloudflare/utils.mjs +0 -12
  148. package/dist/esm/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +0 -148
  149. package/dist/esm/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +0 -150
  150. package/dist/esm/plugins/deploy/platforms/cloudflare-output-contract.mjs +0 -31
  151. package/dist/esm/plugins/deploy/platforms/cloudflare-output-plan.mjs +0 -45
  152. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +0 -45
  153. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +0 -10
  154. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +0 -51
  155. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +0 -99
  156. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +0 -313
  157. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +0 -251
  158. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -191
  159. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -514
  160. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -1012
  161. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -363
  162. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +0 -93
  163. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +0 -11
  164. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +0 -281
  165. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +0 -14
  166. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +0 -98
  167. package/dist/esm/types/config/cloudflareDeploy.mjs +0 -0
  168. package/dist/esm/ultramodern-release-envelope/canonical.mjs +0 -21
  169. package/dist/esm/ultramodern-release-envelope/framework-output.mjs +0 -573
  170. package/dist/esm/ultramodern-release-envelope/index.mjs +0 -335
  171. package/dist/esm/ultramodern-release-envelope/types.mjs +0 -7
  172. package/dist/esm/ultramodern-release-identity.mjs +0 -66
  173. package/dist/esm-node/builder/shared/builderPlugins/adapterLazyCompilation.mjs +0 -37
  174. package/dist/esm-node/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +0 -31
  175. package/dist/esm-node/plugins/deploy/platforms/cloudflare/artifacts.mjs +0 -65
  176. package/dist/esm-node/plugins/deploy/platforms/cloudflare/constants.mjs +0 -35
  177. package/dist/esm-node/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +0 -89
  178. package/dist/esm-node/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +0 -98
  179. package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +0 -103
  180. package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +0 -168
  181. package/dist/esm-node/plugins/deploy/platforms/cloudflare/types.mjs +0 -1
  182. package/dist/esm-node/plugins/deploy/platforms/cloudflare/utils.mjs +0 -13
  183. package/dist/esm-node/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +0 -149
  184. package/dist/esm-node/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +0 -151
  185. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-contract.mjs +0 -32
  186. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-plan.mjs +0 -46
  187. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +0 -46
  188. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +0 -11
  189. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +0 -52
  190. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +0 -100
  191. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +0 -314
  192. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +0 -251
  193. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -191
  194. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -514
  195. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -1012
  196. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -363
  197. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +0 -93
  198. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +0 -11
  199. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +0 -281
  200. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +0 -14
  201. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +0 -98
  202. package/dist/esm-node/types/config/cloudflareDeploy.mjs +0 -1
  203. package/dist/esm-node/ultramodern-release-envelope/canonical.mjs +0 -22
  204. package/dist/esm-node/ultramodern-release-envelope/framework-output.mjs +0 -574
  205. package/dist/esm-node/ultramodern-release-envelope/index.mjs +0 -336
  206. package/dist/esm-node/ultramodern-release-envelope/types.mjs +0 -8
  207. package/dist/esm-node/ultramodern-release-identity.mjs +0 -67
  208. package/dist/types/builder/shared/builderPlugins/adapterLazyCompilation.d.ts +0 -3
  209. package/dist/types/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.d.ts +0 -6
  210. package/dist/types/plugins/deploy/platforms/cloudflare/artifacts.d.ts +0 -15
  211. package/dist/types/plugins/deploy/platforms/cloudflare/constants.d.ts +0 -24
  212. package/dist/types/plugins/deploy/platforms/cloudflare/delivery-unit.d.ts +0 -23
  213. package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +0 -22
  214. package/dist/types/plugins/deploy/platforms/cloudflare/index.d.ts +0 -2
  215. package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +0 -51
  216. package/dist/types/plugins/deploy/platforms/cloudflare/types.d.ts +0 -5
  217. package/dist/types/plugins/deploy/platforms/cloudflare/utils.d.ts +0 -6
  218. package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +0 -122
  219. package/dist/types/plugins/deploy/platforms/cloudflare/wrangler-config.d.ts +0 -46
  220. package/dist/types/plugins/deploy/platforms/cloudflare-output-contract.d.ts +0 -14
  221. package/dist/types/plugins/deploy/platforms/cloudflare-output-plan.d.ts +0 -34
  222. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/identity.d.ts +0 -4
  223. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/issues.d.ts +0 -14
  224. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/manifest.d.ts +0 -2
  225. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +0 -14
  226. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +0 -20
  227. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +0 -1
  228. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.d.mts +0 -1
  229. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.d.mts +0 -1
  230. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.d.mts +0 -1
  231. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.d.mts +0 -1
  232. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.d.mts +0 -4
  233. package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.d.mts +0 -5
  234. package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.d.mts +0 -48
  235. package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.d.mts +0 -13
  236. package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-path.d.mts +0 -21
  237. package/dist/types/types/config/cloudflareDeploy.d.ts +0 -161
  238. package/dist/types/ultramodern-release-envelope/canonical.d.ts +0 -5
  239. package/dist/types/ultramodern-release-envelope/framework-output.d.ts +0 -32
  240. package/dist/types/ultramodern-release-envelope/index.d.ts +0 -6
  241. package/dist/types/ultramodern-release-envelope/types.d.ts +0 -62
  242. package/dist/types/ultramodern-release-identity.d.ts +0 -16
@@ -1,21 +1,31 @@
1
+ import { CssExtractRuntimePlugin } from "@modern-js/app-tools-extensions";
1
2
  import { SERVICE_WORKER_ENVIRONMENT_NAME, isHtmlDisabled } from "@modern-js/builder";
2
- import { fs, isUseRsc, isUseSSRBundle } from "@modern-js/utils";
3
+ import { fs, isUseRsc, isUseSSRBundle, logger } from "@modern-js/utils";
3
4
  import { mergeRsbuildConfig } from "@rsbuild/core";
4
5
  import { getServerCombinedModuleFile } from "../../../plugins/analyze/utils.mjs";
5
- import { CssExtractRuntimePlugin, HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins/index.mjs";
6
+ import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins/index.mjs";
7
+ import { aggregateEagerRouteComponentFiles, planSSRLazyCompilation } from "../lazyCompilation.mjs";
6
8
  import * as __rspack_external_path from "path";
7
9
  const builderPluginAdapterSSR = (options)=>({
8
10
  name: 'builder-plugin-adapter-modern-ssr',
9
11
  setup (api) {
10
- const { normalizedConfig, appContext } = options;
11
- api.modifyRsbuildConfig((config)=>mergeRsbuildConfig(config, {
12
+ const { normalizedConfig, appContext, eagerRouteComponentFilesByEntry } = options;
13
+ api.modifyRsbuildConfig((config)=>{
14
+ const merged = mergeRsbuildConfig(config, {
12
15
  html: {
13
16
  inject: isStreamingSSR(normalizedConfig) ? 'head' : void 0
14
17
  },
15
18
  server: {
16
19
  compress: isStreamingSSR(normalizedConfig) || isUseRsc(normalizedConfig) ? false : void 0
17
20
  }
18
- }));
21
+ });
22
+ const lazyCompilation = getSSRLazyCompilation(merged.dev?.lazyCompilation, normalizedConfig, appContext, eagerRouteComponentFilesByEntry);
23
+ if (void 0 !== lazyCompilation) merged.dev = {
24
+ ...merged.dev,
25
+ lazyCompilation
26
+ };
27
+ return merged;
28
+ });
19
29
  api.modifyBundlerChain(async (chain, { target, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer, environment })=>{
20
30
  const builderConfig = environment.config;
21
31
  const { normalizedConfig } = options;
@@ -51,6 +61,22 @@ const isStreamingSSR = (userConfig)=>{
51
61
  }
52
62
  return false;
53
63
  };
64
+ function getSSRLazyCompilation(current, normalizedConfig, appContext, eagerRouteComponentFilesByEntry) {
65
+ if (!current || isUseRsc(normalizedConfig) || !isStreamingSSR(normalizedConfig)) return;
66
+ const plan = planSSRLazyCompilation(current, aggregateEagerRouteComponentFiles(eagerRouteComponentFilesByEntry));
67
+ if (!plan.apply) {
68
+ if (plan.unresolvedByEntry) warnUnresolvedRouteComponents(appContext.appDirectory, plan.unresolvedByEntry);
69
+ return;
70
+ }
71
+ return plan.lazyCompilation;
72
+ }
73
+ const warnedLazyApps = new Set();
74
+ function warnUnresolvedRouteComponents(appDirectory, unresolvedByEntry) {
75
+ if (warnedLazyApps.has(appDirectory)) return;
76
+ warnedLazyApps.add(appDirectory);
77
+ const detail = Array.from(unresolvedByEntry).map(([entry, comps])=>`${entry}: ${comps.join(', ')}`).join('; ');
78
+ logger.warn(`[lazyCompilation] Skipped stream SSR route-eager optimization because some route components could not be resolved to a file (${detail}). Lazy compilation may break first-screen CSS/JS for these routes.`);
79
+ }
54
80
  function applyAsyncChunkHtmlPlugin({ chain, modernConfig, HtmlBundlerPlugin }) {
55
81
  if (isStreamingSSR(modernConfig) || isUseRsc(modernConfig)) chain.plugin('html-async-chunk').use(HtmlAsyncChunkPlugin, [
56
82
  HtmlBundlerPlugin
@@ -98,10 +124,9 @@ function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
98
124
  });
99
125
  }
100
126
  async function applySSRLoaderEntry(chain, optinos, isServer) {
101
- const { appContext, normalizedConfig } = optinos;
127
+ const { appContext } = optinos;
102
128
  const { internalDirectory } = appContext;
103
129
  const { entrypoints } = appContext;
104
- const isRsc = isUseRsc(normalizedConfig);
105
130
  await Promise.all(entrypoints.map(async (entrypoint)=>{
106
131
  const { entryName } = entrypoint;
107
132
  const serverLoadersFile = getServerCombinedModuleFile(internalDirectory, entryName);
@@ -109,7 +134,7 @@ async function applySSRLoaderEntry(chain, optinos, isServer) {
109
134
  await fs.access(serverLoadersFile, fs.constants.F_OK);
110
135
  chain.entry(`${entryName}-server-loaders`).add(serverLoadersFile);
111
136
  } catch (err) {}
112
- else if (isRsc) chain.entry(`${entryName}-server-loaders`).add("data:text/javascript,export%20{};");
137
+ else if (isUseRsc(optinos.normalizedConfig)) chain.entry(`${entryName}-server-loaders`).add("data:text/javascript,export%20{};");
113
138
  }));
114
139
  }
115
140
  function applySSRDataLoader(chain, options) {
@@ -120,4 +145,4 @@ function applySSRDataLoader(chain, options) {
120
145
  const reg = new RegExp(`${absolutePath}.*\\.(loader|data|data.client)\\.[t|j]sx?$`);
121
146
  chain.module.rule('ssr-data-loader').test(reg).use('data-loader').loader(require.resolve('@modern-js/plugin-data-loader/loader')).end();
122
147
  }
123
- export { builderPluginAdapterSSR };
148
+ export { builderPluginAdapterSSR, getSSRLazyCompilation };
@@ -1,6 +1,5 @@
1
1
  export * from "./adapterBasic.mjs";
2
2
  export * from "./adapterHtml.mjs";
3
- export * from "./adapterLazyCompilation.mjs";
4
3
  export * from "./adapterPrecompress.mjs";
5
4
  export * from "./adapterSSR.mjs";
6
5
  export * from "./builderHooks.mjs";
@@ -1,4 +1,3 @@
1
- export * from "./CssExtractRuntimePlugin.mjs";
2
1
  export * from "./HtmlAsyncChunkPlugin.mjs";
3
2
  export * from "./HtmlBottomTemplate.mjs";
4
3
  export * from "./RouterPlugin.mjs";
@@ -11,7 +11,7 @@ function aggregateEagerRouteComponentFiles(byEntry) {
11
11
  unresolvedByEntry
12
12
  };
13
13
  }
14
- function buildRouteEagerLazyCompilationTest(eagerRouteFiles, userTest) {
14
+ function buildSSRLazyCompilationTest(eagerRouteFiles, userTest) {
15
15
  const userTestFn = 'function' == typeof userTest ? userTest : userTest instanceof RegExp ? (m)=>userTest.test(m.resource || '') : ()=>true;
16
16
  return (m)=>{
17
17
  const resource = m.resource;
@@ -20,7 +20,7 @@ function buildRouteEagerLazyCompilationTest(eagerRouteFiles, userTest) {
20
20
  return userTestFn(m);
21
21
  };
22
22
  }
23
- function planRouteEagerLazyCompilation(current, info) {
23
+ function planSSRLazyCompilation(current, info) {
24
24
  if (!current) return {
25
25
  apply: false
26
26
  };
@@ -37,8 +37,8 @@ function planRouteEagerLazyCompilation(current, info) {
37
37
  apply: true,
38
38
  lazyCompilation: {
39
39
  ...base,
40
- test: buildRouteEagerLazyCompilationTest(info.files, userTest)
40
+ test: buildSSRLazyCompilationTest(info.files, userTest)
41
41
  }
42
42
  };
43
43
  }
44
- export { aggregateEagerRouteComponentFiles, buildRouteEagerLazyCompilationTest, collectRouteComponentFiles, normalizeModulePath, planRouteEagerLazyCompilation };
44
+ export { aggregateEagerRouteComponentFiles, buildSSRLazyCompilationTest, collectRouteComponentFiles, normalizeModulePath, planSSRLazyCompilation };
@@ -21,7 +21,7 @@ function bundleDocs({ source, target, indexFile = DEFAULT_INDEX_FILE, excludedDi
21
21
  withFileTypes: true
22
22
  })){
23
23
  if (!entry.isFile()) continue;
24
- const from = node_path.join(entry.parentPath ?? entry.path, entry.name);
24
+ const from = node_path.join(entry.parentPath, entry.name);
25
25
  const rel = node_path.relative(source, from);
26
26
  if (!isBundled(rel)) continue;
27
27
  const to = node_path.join(target, rel);
@@ -1,3 +1,4 @@
1
+ import { createCloudflareBuilderPlugin } from "@modern-js/app-tools-extensions/cloudflare-builder";
1
2
  import { castArray } from "@modern-js/builder";
2
3
  import { getLocaleLanguage } from "@modern-js/i18n-utils/language-detector";
3
4
  import { createAsyncHook } from "@modern-js/plugin";
@@ -13,7 +14,6 @@ import deploy from "./plugins/deploy/index.mjs";
13
14
  import initialize from "./plugins/initialize/index.mjs";
14
15
  import serverBuild from "./plugins/serverBuild.mjs";
15
16
  import serverRuntime from "./plugins/serverRuntime.mjs";
16
- import ultramodernReleaseEnvelope from "./plugins/ultramodernReleaseEnvelope.mjs";
17
17
  import { generateWatchFiles } from "./utils/generateWatchFiles.mjs";
18
18
  import { initAppContext } from "./utils/initAppContext.mjs";
19
19
  import { restart } from "./utils/restart.mjs";
@@ -29,8 +29,8 @@ const appTools = ()=>({
29
29
  analyze(),
30
30
  serverBuild(),
31
31
  backendFederationBuild(),
32
- ultramodernReleaseEnvelope(),
33
- deploy()
32
+ deploy(),
33
+ createCloudflareBuilderPlugin()
34
34
  ],
35
35
  post: [
36
36
  '@modern-js/plugin-initialize',
@@ -1,4 +1,4 @@
1
- import { ROUTE_SPEC_FILE, SERVER_BUNDLE_DIRECTORY, SERVER_WORKER_BUNDLE_DIRECTORY, fs, getEntryOptions, isPlainObject, removeLeadingSlash, removeTailSlash, urlJoin } from "@modern-js/utils";
1
+ import { MAIN_ENTRY_NAME, ROUTE_SPEC_FILE, SERVER_BUNDLE_DIRECTORY, SERVER_WORKER_BUNDLE_DIRECTORY, fs, getEntryOptions, isPlainObject, removeLeadingSlash, removeTailSlash, urlJoin } from "@modern-js/utils";
2
2
  import path from "path";
3
3
  import { isMainEntry } from "../../utils/routes.mjs";
4
4
  import { walkDirectory } from "./utils.mjs";
@@ -10,23 +10,15 @@ const isDefaultExportFunction = (file)=>{
10
10
  plugins: [
11
11
  'jsx',
12
12
  "typescript",
13
- 'classProperties',
14
- 'dynamicImport',
15
13
  'exportDefaultFrom',
16
- 'exportNamespaceFrom',
17
14
  'decorators-legacy',
18
15
  'functionBind',
19
- 'classPrivateMethods',
20
16
  [
21
17
  'pipelineOperator',
22
18
  {
23
19
  proposal: 'fsharp'
24
20
  }
25
- ],
26
- 'optionalChaining',
27
- 'optionalCatchBinding',
28
- 'objectRestSpread',
29
- 'numericSeparator'
21
+ ]
30
22
  ]
31
23
  });
32
24
  let isExportFunction = false;
@@ -98,7 +98,7 @@ module.exports = { __modernjsBackendFederation, get, init };
98
98
  if (!output) throw new Error('[backend-federation-build] CommonJS backend federation container emitted no output.');
99
99
  return output.text;
100
100
  };
101
- const createBackendManifest = (workspaceRoot, distDirectory, app)=>{
101
+ const createBackendManifest = (workspaceRoot, distDirectory, app, entryIntegrity)=>{
102
102
  const sourceModule = `${app.directory}/api/effect-api.ts`;
103
103
  const publicPath = createPublicPath(app.containerEntry, app.port);
104
104
  const manifest = {
@@ -129,6 +129,7 @@ const createBackendManifest = (workspaceRoot, distDirectory, app)=>{
129
129
  ssrPublicPath: publicPath
130
130
  },
131
131
  entry: {
132
+ ...entryIntegrity,
132
133
  file: BACKEND_FEDERATION_REMOTE_ENTRY_FILE,
133
134
  path: normalizeRelativePath(node_path.relative(workspaceRoot, node_path.join(distDirectory, BACKEND_FEDERATION_REMOTE_ENTRY_FILE))),
134
135
  type: app.remoteType,
@@ -1,8 +1,8 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import promises from "node:fs/promises";
3
3
  import node_path from "node:path";
4
+ import { resolveUltramodernSourceRevision } from "@modern-js/app-tools-extensions/release-identity";
4
5
  import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, DELIVERY_UNIT_DEPLOY_PROFILE, DELIVERY_UNIT_KIND, DELIVERY_UNIT_SCHEMA_VERSION, ULTRAMODERN_BUILD_ARTIFACT_FILE, ULTRAMODERN_BUILD_ARTIFACT_PATH, ULTRAMODERN_BUILD_MODULE_PATH, deliveryUnitContractBlock, isUltramodernBuildArtifact, validateDeliveryUnitRecord, validateUltramodernBuildArtifact } from "@modern-js/utils/universal";
5
- import { resolveUltramodernSourceRevision } from "../../ultramodern-release-identity.mjs";
6
6
  const COMPACT_CONFIG_PATH = '.modernjs/ultramodern.json';
7
7
  const normalizeRelativePath = (value)=>value.replace(/\\/gu, '/').replace(/^\.\/+/u, '');
8
8
  const isRecord = (value)=>'object' == typeof value && null !== value;
@@ -1,8 +1,9 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import promises from "node:fs/promises";
3
3
  import node_path from "node:path";
4
+ import { resolveUltramodernReleaseIdentity } from "@modern-js/app-tools-extensions/release-identity";
5
+ import { createBackendFederationEntryIntegrity } from "@modern-js/server-runtime-extensions/backend-federation-security/node";
4
6
  import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, ULTRAMODERN_BUILD_ARTIFACT_FILE, stampUltramodernBuildArtifactIdentity } from "@modern-js/utils/universal";
5
- import { resolveUltramodernReleaseIdentity } from "../../ultramodern-release-identity.mjs";
6
7
  import { createBackendManifest, createBackendRemoteEntrySource } from "./codegen.mjs";
7
8
  import { COMPACT_CONFIG_PATH, buildArtifactPathFor, buildModulePathFor, createStampedDeliveryUnit, findBackendFederationApp, findWorkspaceRoot, readBuildIdentity, resolveWorkspaceSourceRevision } from "./config.mjs";
8
9
  const emitBackendFederationArtifacts = async (appDirectory, distDirectory)=>{
@@ -67,11 +68,12 @@ const emitBackendFederationArtifacts = async (appDirectory, distDirectory)=>{
67
68
  const manifestPath = node_path.join(distDirectory, BACKEND_FEDERATION_MANIFEST_FILE);
68
69
  const entryPath = node_path.join(distDirectory, BACKEND_FEDERATION_REMOTE_ENTRY_FILE);
69
70
  const deliveryUnitArtifactPath = stampedBuildArtifact ? node_path.join(distDirectory, ULTRAMODERN_BUILD_ARTIFACT_FILE) : void 0;
71
+ const entrySource = await createBackendRemoteEntrySource(workspaceRoot, resolvedApp, effectApiPath, entryPath);
70
72
  await promises.mkdir(distDirectory, {
71
73
  recursive: true
72
74
  });
73
- await promises.writeFile(entryPath, await createBackendRemoteEntrySource(workspaceRoot, resolvedApp, effectApiPath, entryPath));
74
- await promises.writeFile(manifestPath, `${JSON.stringify(createBackendManifest(workspaceRoot, distDirectory, resolvedApp), null, 2)}\n`);
75
+ await promises.writeFile(entryPath, entrySource);
76
+ await promises.writeFile(manifestPath, `${JSON.stringify(createBackendManifest(workspaceRoot, distDirectory, resolvedApp, createBackendFederationEntryIntegrity(entrySource)), null, 2)}\n`);
75
77
  if (stampedBuildArtifact && deliveryUnitArtifactPath) await promises.writeFile(deliveryUnitArtifactPath, `${JSON.stringify(stampedBuildArtifact, null, 2)}\n`);
76
78
  return {
77
79
  appId: resolvedApp.id,
@@ -1,5 +1,5 @@
1
+ import { createCloudflarePreset } from "@modern-js/app-tools-extensions/cloudflare";
1
2
  import { provider } from "std-env";
2
- import { createCloudflarePreset } from "./platforms/cloudflare/index.mjs";
3
3
  import { createGhPagesPreset } from "./platforms/gh-pages.mjs";
4
4
  import { createNetlifyPreset } from "./platforms/netlify.mjs";
5
5
  import { createNodePreset } from "./platforms/node.mjs";
@@ -1,133 +1 @@
1
- import promises from "node:fs/promises";
2
- import node_path from "node:path";
3
- import { createCloudflareOutputPlan } from "../cloudflare-output-plan.mjs";
4
- import { verifyDeliveryUnitIdentity } from "./identity.mjs";
5
- import { addIssue, assertEqual, assertFlag } from "./issues.mjs";
6
- import { verifyManifestShape } from "./manifest.mjs";
7
- import { getEffectBffWorker, getWorkerBundleReferences, missingWorkerBundleMessage, resolveWorkerBundleReference, verifyWorkerBundleReferences, verifyWorkerImport } from "./worker-bundles.mjs";
8
- const pathExists = async (filePath)=>{
9
- try {
10
- await promises.access(filePath);
11
- return true;
12
- } catch {
13
- return false;
14
- }
15
- };
16
- const readJson = async (filePath)=>JSON.parse(await promises.readFile(filePath, 'utf-8'));
17
- const verifyCloudflareOutput = async (options)=>{
18
- const outputDirectory = node_path.resolve(options.outputDirectory);
19
- const issues = [];
20
- const outputPlan = createCloudflareOutputPlan(outputDirectory);
21
- for (const relativePath of outputPlan.requiredFiles){
22
- const filePath = node_path.join(outputDirectory, relativePath);
23
- if (!await pathExists(filePath)) addIssue(issues, {
24
- code: 'missing-file',
25
- message: `Cloudflare output is missing ${relativePath}.`,
26
- path: filePath
27
- });
28
- }
29
- const manifestPath = outputPlan.paths.workerManifest;
30
- const wranglerPath = outputPlan.paths.wranglerConfig;
31
- const packagePath = outputPlan.paths.outputPackage;
32
- const workerPackagePath = outputPlan.paths.workerPackage;
33
- const manifest = await pathExists(manifestPath) ? await readJson(manifestPath) : void 0;
34
- const wrangler = await pathExists(wranglerPath) ? await readJson(wranglerPath) : void 0;
35
- const outputPackage = await pathExists(packagePath) ? await readJson(packagePath) : void 0;
36
- const workerPackage = await pathExists(workerPackagePath) ? await readJson(workerPackagePath) : void 0;
37
- if (manifest) {
38
- verifyManifestShape(issues, manifest, manifestPath);
39
- verifyDeliveryUnitIdentity(issues, manifest, manifestPath, options.deliveryUnit);
40
- const workerReferences = getWorkerBundleReferences(manifest);
41
- const providedWorkerPackages = new Set(workerPackage?.dependencies && 'object' == typeof workerPackage.dependencies ? Object.keys(workerPackage.dependencies) : []);
42
- if (workerReferences.length > 0 && !await pathExists(workerPackagePath)) addIssue(issues, {
43
- code: 'missing-file',
44
- message: 'Cloudflare output is missing worker/package.json for referenced worker bundles.',
45
- path: workerPackagePath
46
- });
47
- if (manifest.bff?.runtimeFramework === 'effect' && !getEffectBffWorker(manifest)) addIssue(issues, {
48
- code: 'missing-worker-bundle',
49
- message: 'Cloudflare Effect BFF manifest points to a missing worker bundle.'
50
- });
51
- for (const workerReference of workerReferences){
52
- const resolvedWorker = resolveWorkerBundleReference(issues, outputDirectory, workerReference, manifestPath);
53
- if (!resolvedWorker) continue;
54
- const workerExists = await pathExists(resolvedWorker.path);
55
- if (!workerExists) addIssue(issues, {
56
- code: 'missing-worker-bundle',
57
- message: missingWorkerBundleMessage(workerReference),
58
- path: resolvedWorker.path
59
- });
60
- if (workerExists) {
61
- const workerSource = await promises.readFile(resolvedWorker.path, 'utf-8');
62
- await verifyWorkerBundleReferences(issues, resolvedWorker, workerSource, {
63
- providedPackages: providedWorkerPackages,
64
- workerRoot: outputPlan.paths.workerBundle
65
- });
66
- if ('effect-bff' === resolvedWorker.kind && (workerSource.includes(';entityKind;') || workerSource.includes(';entityKind,entityKind;'))) addIssue(issues, {
67
- code: 'invalid-worker-bundle',
68
- message: 'Cloudflare Effect BFF worker bundle contains invalid Drizzle entityKind marker references.',
69
- path: resolvedWorker.path
70
- });
71
- }
72
- }
73
- }
74
- if (wrangler) {
75
- assertEqual(issues, wrangler.main, outputPlan.wrangler.main, {
76
- code: 'invalid-wrangler',
77
- message: `wrangler.json main must be ${outputPlan.wrangler.main}.`,
78
- path: wranglerPath
79
- });
80
- assertEqual(issues, wrangler.assets?.binding, outputPlan.wrangler.assets.binding, {
81
- code: 'invalid-wrangler',
82
- message: 'wrangler.json assets.binding must be ASSETS.',
83
- path: wranglerPath
84
- });
85
- assertEqual(issues, wrangler.assets?.directory, outputPlan.wrangler.assets.directory, {
86
- code: 'invalid-wrangler',
87
- message: 'wrangler.json assets.directory must be ./public.',
88
- path: wranglerPath
89
- });
90
- assertEqual(issues, wrangler.assets?.run_worker_first, outputPlan.wrangler.assets.run_worker_first, {
91
- code: 'invalid-wrangler',
92
- message: 'wrangler.json assets.run_worker_first must be true.',
93
- path: wranglerPath
94
- });
95
- for (const flag of outputPlan.wrangler.requiredCompatibilityFlags)assertFlag(issues, wrangler.compatibility_flags, flag, {
96
- code: 'invalid-wrangler',
97
- message: `wrangler.json compatibility_flags must include ${flag}.`,
98
- path: wranglerPath
99
- });
100
- }
101
- if (outputPackage) assertEqual(issues, outputPackage.type, outputPlan.packages.output.type, {
102
- code: 'invalid-package',
103
- message: '.output/package.json must declare type module.',
104
- path: packagePath
105
- });
106
- if (workerPackage) assertEqual(issues, workerPackage.type, outputPlan.packages.worker.type, {
107
- code: 'invalid-package',
108
- message: '.output/worker/package.json must declare type commonjs.',
109
- path: workerPackagePath
110
- });
111
- for (const leakedPath of outputPlan.publicLeakDirectories){
112
- const publicPath = node_path.join(outputPlan.paths.publicAssets, leakedPath);
113
- if (await pathExists(publicPath)) addIssue(issues, {
114
- code: 'public-output-leak',
115
- message: `Framework-owned ${leakedPath} output leaked into public assets.`,
116
- path: publicPath
117
- });
118
- }
119
- if (false !== options.importWorker && await pathExists(outputPlan.paths.workerEntry)) await verifyWorkerImport(issues, outputPlan.paths.workerEntry, manifest);
120
- return {
121
- ok: 0 === issues.length,
122
- issues
123
- };
124
- };
125
- const assertCloudflareOutput = async (options)=>{
126
- const result = await verifyCloudflareOutput(options);
127
- if (!result.ok) throw new Error([
128
- 'Cloudflare output verification failed:',
129
- ...result.issues.map((issue)=>`- ${issue.code}: ${issue.message}${issue.path ? ` (${issue.path})` : ''}`)
130
- ].join('\n'));
131
- };
132
- export { verifyCloudflareOutputMutationPolicy } from "./mutation-policy.mjs";
133
- export { assertCloudflareOutput, verifyCloudflareOutput };
1
+ export * from "@modern-js/app-tools-extensions/cloudflare-output-verifier";
@@ -1,78 +1,57 @@
1
1
  const fs = require('node:fs/promises');
2
2
  const path = require('node:path');
3
3
  const { createNetlifyFunction } = require('@modern-js/prod-server/netlify');
4
-
5
4
  p_genPluginImportsCode;
6
-
7
- if (!process.env.NODE_ENV) {
8
- process.env.NODE_ENV = 'production';
9
- }
10
-
5
+ if (!process.env.NODE_ENV) process.env.NODE_ENV = 'production';
11
6
  let requestHandler = null;
12
7
  let handlerCreationPromise = null;
13
-
14
8
  async function loadRoutes(routeFilepath) {
15
- try {
16
- await fs.access(routeFilepath);
17
- const content = await fs.readFile(routeFilepath, 'utf-8');
18
- const routeSpec = JSON.parse(content);
19
- return routeSpec.routes || [];
20
- } catch (error) {
21
- console.warn(
22
- 'route.json not found or invalid, continuing with empty routes.',
23
- );
24
- return [];
25
- }
9
+ try {
10
+ await fs.access(routeFilepath);
11
+ const content = await fs.readFile(routeFilepath, 'utf-8');
12
+ const routeSpec = JSON.parse(content);
13
+ return routeSpec.routes || [];
14
+ } catch (error) {
15
+ console.warn('route.json not found or invalid, continuing with empty routes.');
16
+ return [];
17
+ }
26
18
  }
27
-
28
19
  async function initServer() {
29
- const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
30
- const routes = await loadRoutes(routeFilepath);
31
-
32
- const dynamicProdOptions = p_dynamicProdOptions;
33
-
34
- const prodServerOptions = {
35
- pwd: __dirname,
36
- routes,
37
- disableCustomHook: true,
38
- appContext: {
39
- sharedDirectory: p_sharedDirectory,
40
- apiDirectory: p_apiDirectory,
41
- lambdaDirectory: p_lambdaDirectory,
42
- bffRuntimeFramework: p_bffRuntimeFramework,
43
- },
44
- plugins: p_plugins,
45
- serverConfigPath: p_serverDirectory,
46
- ...dynamicProdOptions,
47
- };
48
-
49
- const requestHandler = await createNetlifyFunction(prodServerOptions);
50
-
51
- return requestHandler;
20
+ const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
21
+ const routes = await loadRoutes(routeFilepath);
22
+ const dynamicProdOptions = p_dynamicProdOptions;
23
+ const prodServerOptions = {
24
+ pwd: __dirname,
25
+ routes,
26
+ disableCustomHook: true,
27
+ appContext: {
28
+ sharedDirectory: p_sharedDirectory,
29
+ apiDirectory: p_apiDirectory,
30
+ lambdaDirectory: p_lambdaDirectory,
31
+ bffRuntimeFramework: p_bffRuntimeFramework
32
+ },
33
+ plugins: p_plugins,
34
+ serverConfigPath: p_serverDirectory,
35
+ ...dynamicProdOptions
36
+ };
37
+ const requestHandler = await createNetlifyFunction(prodServerOptions);
38
+ return requestHandler;
52
39
  }
53
-
54
40
  async function createHandler() {
55
- if (!handlerCreationPromise) {
56
- handlerCreationPromise = (async () => {
57
- try {
58
- requestHandler = await initServer();
59
- } catch (error) {
60
- console.error('Error creating server:', error);
61
- process.exit(1);
62
- }
41
+ if (!handlerCreationPromise) handlerCreationPromise = (async ()=>{
42
+ try {
43
+ requestHandler = await initServer();
44
+ } catch (error) {
45
+ console.error('Error creating server:', error);
46
+ process.exit(1);
47
+ }
63
48
  })();
64
- }
65
- await handlerCreationPromise;
66
- return requestHandler;
49
+ await handlerCreationPromise;
50
+ return requestHandler;
67
51
  }
68
-
69
52
  createHandler();
70
-
71
- const handler = async (request, context) => {
72
- if (!requestHandler) {
73
- await createHandler();
74
- }
75
- return requestHandler(request, context);
53
+ const handler = async (request, context)=>{
54
+ if (!requestHandler) await createHandler();
55
+ return requestHandler(request, context);
76
56
  };
77
-
78
57
  module.exports.default = handler;
@@ -2,80 +2,58 @@ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { createNetlifyFunction } from '@modern-js/prod-server/netlify';
5
-
6
5
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
-
8
6
  p_genPluginImportsCode;
9
-
10
- if (!process.env.NODE_ENV) {
11
- process.env.NODE_ENV = 'production';
12
- }
13
-
7
+ if (!process.env.NODE_ENV) process.env.NODE_ENV = 'production';
14
8
  let requestHandler = null;
15
9
  let handlerCreationPromise = null;
16
-
17
10
  async function loadRoutes(routeFilepath) {
18
- try {
19
- await fs.access(routeFilepath);
20
- const content = await fs.readFile(routeFilepath, 'utf-8');
21
- const routeSpec = JSON.parse(content);
22
- return routeSpec.routes || [];
23
- } catch (error) {
24
- console.warn(
25
- 'route.json not found or invalid, continuing with empty routes.',
26
- );
27
- return [];
28
- }
11
+ try {
12
+ await fs.access(routeFilepath);
13
+ const content = await fs.readFile(routeFilepath, 'utf-8');
14
+ const routeSpec = JSON.parse(content);
15
+ return routeSpec.routes || [];
16
+ } catch (error) {
17
+ console.warn('route.json not found or invalid, continuing with empty routes.');
18
+ return [];
19
+ }
29
20
  }
30
-
31
21
  async function initServer() {
32
- const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
33
- const routes = await loadRoutes(routeFilepath);
34
-
35
- const dynamicProdOptions = p_dynamicProdOptions;
36
-
37
- const prodServerOptions = {
38
- pwd: __dirname,
39
- routes,
40
- disableCustomHook: true,
41
- appContext: {
42
- sharedDirectory: p_sharedDirectory,
43
- apiDirectory: p_apiDirectory,
44
- lambdaDirectory: p_lambdaDirectory,
45
- bffRuntimeFramework: p_bffRuntimeFramework,
46
- },
47
- plugins: p_plugins,
48
- serverConfigPath: p_serverDirectory,
49
- ...dynamicProdOptions,
50
- };
51
-
52
- const requestHandler = await createNetlifyFunction(prodServerOptions);
53
-
54
- return requestHandler;
22
+ const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
23
+ const routes = await loadRoutes(routeFilepath);
24
+ const dynamicProdOptions = p_dynamicProdOptions;
25
+ const prodServerOptions = {
26
+ pwd: __dirname,
27
+ routes,
28
+ disableCustomHook: true,
29
+ appContext: {
30
+ sharedDirectory: p_sharedDirectory,
31
+ apiDirectory: p_apiDirectory,
32
+ lambdaDirectory: p_lambdaDirectory,
33
+ bffRuntimeFramework: p_bffRuntimeFramework
34
+ },
35
+ plugins: p_plugins,
36
+ serverConfigPath: p_serverDirectory,
37
+ ...dynamicProdOptions
38
+ };
39
+ const requestHandler = await createNetlifyFunction(prodServerOptions);
40
+ return requestHandler;
55
41
  }
56
-
57
42
  async function createHandler() {
58
- if (!handlerCreationPromise) {
59
- handlerCreationPromise = (async () => {
60
- try {
61
- requestHandler = await initServer();
62
- } catch (error) {
63
- console.error('Error creating server:', error);
64
- process.exit(1);
65
- }
43
+ if (!handlerCreationPromise) handlerCreationPromise = (async ()=>{
44
+ try {
45
+ requestHandler = await initServer();
46
+ } catch (error) {
47
+ console.error('Error creating server:', error);
48
+ process.exit(1);
49
+ }
66
50
  })();
67
- }
68
- await handlerCreationPromise;
69
- return requestHandler;
51
+ await handlerCreationPromise;
52
+ return requestHandler;
70
53
  }
71
-
72
54
  createHandler();
73
-
74
- const handler = async (request, context) => {
75
- if (!requestHandler) {
76
- await createHandler();
77
- }
78
- return requestHandler(request, context);
55
+ const handler = async (request, context)=>{
56
+ if (!requestHandler) await createHandler();
57
+ return requestHandler(request, context);
79
58
  };
80
-
81
59
  export default handler;