@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.9 → 3.5.0-ultramodern.90

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 (258) hide show
  1. package/bin/modern.js +0 -0
  2. package/dist/cjs/builder/generator/getBuilderEnvironments.js +13 -16
  3. package/dist/cjs/builder/shared/builderPlugins/adapterPrecompress.js +13 -4
  4. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +14 -11
  5. package/dist/cjs/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.js +72 -0
  6. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +28 -11
  7. package/dist/cjs/builder/shared/bundlerPlugins/index.js +13 -6
  8. package/dist/cjs/builder/shared/lazyCompilation.js +2 -10
  9. package/dist/cjs/commands/index.js +0 -4
  10. package/dist/cjs/config/build-environment.js +268 -0
  11. package/dist/cjs/config/index.js +11 -4
  12. package/dist/cjs/config/public.js +46 -0
  13. package/dist/cjs/index.js +39 -62
  14. package/dist/cjs/plugins/analyze/getServerRoutes.js +19 -0
  15. package/dist/cjs/plugins/analyze/index.js +20 -12
  16. package/dist/cjs/plugins/backend-federation/codegen.js +255 -0
  17. package/dist/cjs/plugins/backend-federation/config.js +204 -0
  18. package/dist/cjs/plugins/backend-federation/emit.js +148 -0
  19. package/dist/cjs/plugins/backendFederationBuild.js +53 -0
  20. package/dist/cjs/plugins/deploy/index.js +4 -4
  21. package/dist/cjs/plugins/deploy/platforms/cloudflare/artifacts.js +127 -0
  22. package/dist/cjs/plugins/deploy/platforms/cloudflare/constants.js +141 -0
  23. package/dist/cjs/plugins/deploy/platforms/cloudflare/delivery-unit.js +139 -0
  24. package/dist/cjs/plugins/deploy/platforms/cloudflare/i18n-worker.js +135 -0
  25. package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +150 -0
  26. package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +205 -0
  27. package/dist/cjs/plugins/deploy/platforms/cloudflare/types.js +18 -0
  28. package/dist/cjs/plugins/deploy/platforms/cloudflare/utils.js +66 -0
  29. package/dist/cjs/plugins/deploy/platforms/cloudflare/worker-manifest.js +208 -0
  30. package/dist/cjs/plugins/deploy/platforms/cloudflare/wrangler-config.js +204 -0
  31. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-contract.js +108 -0
  32. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-plan.js +93 -0
  33. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/identity.js +83 -0
  34. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +188 -0
  35. package/dist/cjs/{baseline.js → plugins/deploy/platforms/cloudflare-output-verifier/issues.js} +19 -10
  36. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/manifest.js +89 -0
  37. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +151 -0
  38. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +302 -0
  39. package/dist/cjs/plugins/deploy/platforms/node.js +20 -2
  40. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
  41. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
  42. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
  43. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
  44. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
  45. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
  46. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
  47. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
  48. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
  49. package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
  50. package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
  51. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
  52. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
  53. package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
  54. package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
  55. package/dist/cjs/plugins/deploy/utils/npmAliases.js +226 -0
  56. package/dist/cjs/plugins/ultramodernReleaseEnvelope.js +100 -0
  57. package/dist/cjs/presetUltramodern.js +33 -2
  58. package/dist/cjs/ultramodern-release-envelope/canonical.js +68 -0
  59. package/dist/cjs/ultramodern-release-envelope/framework-output.js +597 -0
  60. package/dist/cjs/ultramodern-release-envelope/index.js +399 -0
  61. package/dist/cjs/ultramodern-release-envelope/types.js +51 -0
  62. package/dist/cjs/ultramodern-release-identity.js +110 -0
  63. package/dist/esm/builder/generator/getBuilderEnvironments.mjs +12 -15
  64. package/dist/esm/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
  65. package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +15 -12
  66. package/dist/esm/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +30 -0
  67. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.mjs +24 -10
  68. package/dist/esm/builder/shared/bundlerPlugins/index.mjs +1 -0
  69. package/dist/esm/builder/shared/lazyCompilation.mjs +1 -3
  70. package/dist/esm/commands/index.mjs +0 -1
  71. package/dist/esm/config/build-environment.mjs +224 -0
  72. package/dist/esm/config/index.mjs +1 -0
  73. package/dist/esm/config/public.mjs +1 -0
  74. package/dist/esm/index.mjs +5 -4
  75. package/dist/esm/plugins/analyze/getHtmlTemplate.mjs +2 -2
  76. package/dist/esm/plugins/analyze/getServerRoutes.mjs +17 -1
  77. package/dist/esm/plugins/analyze/index.mjs +20 -12
  78. package/dist/esm/plugins/analyze/isDefaultExportFunction.mjs +2 -2
  79. package/dist/esm/plugins/backend-federation/codegen.mjs +204 -0
  80. package/dist/esm/plugins/backend-federation/config.mjs +128 -0
  81. package/dist/esm/plugins/backend-federation/emit.mjs +97 -0
  82. package/dist/esm/plugins/backendFederationBuild.mjs +1 -0
  83. package/dist/esm/plugins/deploy/index.mjs +1 -1
  84. package/dist/esm/plugins/deploy/platforms/cloudflare/artifacts.mjs +64 -0
  85. package/dist/esm/plugins/deploy/platforms/cloudflare/constants.mjs +34 -0
  86. package/dist/esm/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +88 -0
  87. package/dist/esm/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +97 -0
  88. package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +102 -0
  89. package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +167 -0
  90. package/dist/esm/plugins/deploy/platforms/cloudflare/types.mjs +0 -0
  91. package/dist/esm/plugins/deploy/platforms/cloudflare/utils.mjs +12 -0
  92. package/dist/esm/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +148 -0
  93. package/dist/esm/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +150 -0
  94. package/dist/esm/plugins/deploy/platforms/cloudflare-output-contract.mjs +31 -0
  95. package/dist/esm/plugins/deploy/platforms/cloudflare-output-plan.mjs +45 -0
  96. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +45 -0
  97. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +133 -0
  98. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +10 -0
  99. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +51 -0
  100. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +99 -0
  101. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +238 -0
  102. package/dist/esm/plugins/deploy/platforms/node.mjs +20 -2
  103. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
  104. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
  105. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
  106. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
  107. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
  108. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
  109. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
  110. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
  111. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
  112. package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
  113. package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
  114. package/dist/esm/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
  115. package/dist/esm/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
  116. package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
  117. package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
  118. package/dist/esm/plugins/deploy/utils/npmAliases.mjs +174 -0
  119. package/dist/esm/plugins/ultramodernReleaseEnvelope.mjs +52 -0
  120. package/dist/esm/presetUltramodern.mjs +33 -2
  121. package/dist/esm/ultramodern-release-envelope/canonical.mjs +21 -0
  122. package/dist/esm/ultramodern-release-envelope/framework-output.mjs +524 -0
  123. package/dist/esm/ultramodern-release-envelope/index.mjs +335 -0
  124. package/dist/esm/ultramodern-release-envelope/types.mjs +7 -0
  125. package/dist/esm/ultramodern-release-identity.mjs +66 -0
  126. package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +12 -15
  127. package/dist/esm-node/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
  128. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +15 -12
  129. package/dist/esm-node/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +31 -0
  130. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.mjs +24 -10
  131. package/dist/esm-node/builder/shared/bundlerPlugins/index.mjs +1 -0
  132. package/dist/esm-node/builder/shared/lazyCompilation.mjs +1 -3
  133. package/dist/esm-node/commands/index.mjs +0 -1
  134. package/dist/esm-node/config/build-environment.mjs +225 -0
  135. package/dist/esm-node/config/index.mjs +1 -0
  136. package/dist/esm-node/config/public.mjs +2 -0
  137. package/dist/esm-node/index.mjs +5 -4
  138. package/dist/esm-node/plugins/analyze/getHtmlTemplate.mjs +2 -2
  139. package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +17 -1
  140. package/dist/esm-node/plugins/analyze/index.mjs +20 -12
  141. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +2 -2
  142. package/dist/esm-node/plugins/backend-federation/codegen.mjs +205 -0
  143. package/dist/esm-node/plugins/backend-federation/config.mjs +129 -0
  144. package/dist/esm-node/plugins/backend-federation/emit.mjs +98 -0
  145. package/dist/esm-node/plugins/backendFederationBuild.mjs +2 -0
  146. package/dist/esm-node/plugins/deploy/index.mjs +1 -1
  147. package/dist/esm-node/plugins/deploy/platforms/cloudflare/artifacts.mjs +65 -0
  148. package/dist/esm-node/plugins/deploy/platforms/cloudflare/constants.mjs +35 -0
  149. package/dist/esm-node/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +89 -0
  150. package/dist/esm-node/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +98 -0
  151. package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +103 -0
  152. package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +168 -0
  153. package/dist/esm-node/plugins/deploy/platforms/cloudflare/types.mjs +1 -0
  154. package/dist/esm-node/plugins/deploy/platforms/cloudflare/utils.mjs +13 -0
  155. package/dist/esm-node/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +149 -0
  156. package/dist/esm-node/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +151 -0
  157. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-contract.mjs +32 -0
  158. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-plan.mjs +46 -0
  159. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +46 -0
  160. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +134 -0
  161. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +11 -0
  162. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +52 -0
  163. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +100 -0
  164. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +239 -0
  165. package/dist/esm-node/plugins/deploy/platforms/node.mjs +20 -2
  166. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
  167. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
  168. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
  169. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
  170. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
  171. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
  172. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
  173. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
  174. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
  175. package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
  176. package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
  177. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
  178. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
  179. package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
  180. package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
  181. package/dist/esm-node/plugins/deploy/utils/npmAliases.mjs +175 -0
  182. package/dist/esm-node/plugins/ultramodernReleaseEnvelope.mjs +53 -0
  183. package/dist/esm-node/presetUltramodern.mjs +33 -2
  184. package/dist/esm-node/ultramodern-release-envelope/canonical.mjs +22 -0
  185. package/dist/esm-node/ultramodern-release-envelope/framework-output.mjs +525 -0
  186. package/dist/esm-node/ultramodern-release-envelope/index.mjs +336 -0
  187. package/dist/esm-node/ultramodern-release-envelope/types.mjs +8 -0
  188. package/dist/esm-node/ultramodern-release-identity.mjs +67 -0
  189. package/dist/types/builder/generator/createCopyPattern.d.ts +7 -5
  190. package/dist/types/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.d.ts +6 -0
  191. package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -0
  192. package/dist/types/builder/shared/bundlerPlugins/index.d.ts +1 -0
  193. package/dist/types/builder/shared/lazyCompilation.d.ts +2 -4
  194. package/dist/types/commands/index.d.ts +0 -1
  195. package/dist/types/config/build-environment.d.ts +22 -0
  196. package/dist/types/config/index.d.ts +1 -0
  197. package/dist/types/config/public.d.ts +2 -0
  198. package/dist/types/index.d.ts +0 -2
  199. package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -0
  200. package/dist/types/plugins/backend-federation/codegen.d.ts +83 -0
  201. package/dist/types/plugins/backend-federation/config.d.ts +103 -0
  202. package/dist/types/plugins/backend-federation/emit.d.ts +13 -0
  203. package/dist/types/plugins/backendFederationBuild.d.ts +2 -0
  204. package/dist/types/plugins/deploy/platforms/cloudflare/artifacts.d.ts +15 -0
  205. package/dist/types/plugins/deploy/platforms/cloudflare/constants.d.ts +24 -0
  206. package/dist/types/plugins/deploy/platforms/cloudflare/delivery-unit.d.ts +23 -0
  207. package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +22 -0
  208. package/dist/types/plugins/deploy/platforms/{cloudflare.d.ts → cloudflare/index.d.ts} +1 -1
  209. package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +51 -0
  210. package/dist/types/plugins/deploy/platforms/cloudflare/types.d.ts +5 -0
  211. package/dist/types/plugins/deploy/platforms/cloudflare/utils.d.ts +6 -0
  212. package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +122 -0
  213. package/dist/types/plugins/deploy/platforms/cloudflare/wrangler-config.d.ts +46 -0
  214. package/dist/types/plugins/deploy/platforms/cloudflare-output-contract.d.ts +14 -0
  215. package/dist/types/plugins/deploy/platforms/cloudflare-output-plan.d.ts +34 -0
  216. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/identity.d.ts +4 -0
  217. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +18 -0
  218. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/issues.d.ts +14 -0
  219. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/manifest.d.ts +2 -0
  220. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +14 -0
  221. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +20 -0
  222. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -0
  223. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.d.mts +1 -0
  224. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.d.mts +1 -0
  225. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.d.mts +1 -0
  226. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.d.mts +1 -0
  227. package/dist/types/plugins/deploy/utils/npmAliases.d.ts +14 -0
  228. package/dist/types/plugins/ultramodernReleaseEnvelope.d.ts +3 -0
  229. package/dist/types/presetUltramodern.d.ts +10 -0
  230. package/dist/types/run/index.d.ts +1 -1
  231. package/dist/types/types/config/cloudflareDeploy.d.ts +41 -0
  232. package/dist/types/types/config/deploy.d.ts +15 -2
  233. package/dist/types/ultramodern-release-envelope/canonical.d.ts +5 -0
  234. package/dist/types/ultramodern-release-envelope/framework-output.d.ts +31 -0
  235. package/dist/types/ultramodern-release-envelope/index.d.ts +6 -0
  236. package/dist/types/ultramodern-release-envelope/types.d.ts +62 -0
  237. package/dist/types/ultramodern-release-identity.d.ts +16 -0
  238. package/lib/types.d.ts +2 -3
  239. package/package.json +38 -23
  240. package/rslib.config.mts +11 -12
  241. package/dist/cjs/commands/runtime.js +0 -196
  242. package/dist/cjs/plugins/deploy/platforms/cloudflare.js +0 -540
  243. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  244. package/dist/cjs/ultramodern/designSystem.js +0 -123
  245. package/dist/esm/baseline.mjs +0 -4
  246. package/dist/esm/commands/runtime.mjs +0 -146
  247. package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +0 -492
  248. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  249. package/dist/esm/ultramodern/designSystem.mjs +0 -73
  250. package/dist/esm-node/baseline.mjs +0 -5
  251. package/dist/esm-node/commands/runtime.mjs +0 -147
  252. package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +0 -493
  253. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  254. package/dist/esm-node/ultramodern/designSystem.mjs +0 -74
  255. package/dist/types/baseline.d.ts +0 -16
  256. package/dist/types/commands/runtime.d.ts +0 -12
  257. package/dist/types/ultramodern/designSystem.d.ts +0 -54
  258. /package/dist/types/plugins/deploy/platforms/templates/{cloudflare-entry.d.mts → cloudflare-entry.006-fetch-handler.d.mts} +0 -0
@@ -0,0 +1,129 @@
1
+ import "node:module";
2
+ import { existsSync } from "node:fs";
3
+ import promises from "node:fs/promises";
4
+ import node_path from "node:path";
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";
6
+ import { resolveUltramodernSourceRevision } from "../../ultramodern-release-identity.mjs";
7
+ const COMPACT_CONFIG_PATH = '.modernjs/ultramodern.json';
8
+ const normalizeRelativePath = (value)=>value.replace(/\\/gu, '/').replace(/^\.\/+/u, '');
9
+ const isRecord = (value)=>'object' == typeof value && null !== value;
10
+ const readJsonFile = async (filePath)=>JSON.parse(await promises.readFile(filePath, 'utf8'));
11
+ const buildArtifactPathFor = (appDirectory)=>node_path.join(appDirectory, ULTRAMODERN_BUILD_ARTIFACT_PATH);
12
+ const buildModulePathFor = (appDirectory)=>node_path.join(appDirectory, ULTRAMODERN_BUILD_MODULE_PATH);
13
+ const readBuildIdentity = async (appDirectory)=>{
14
+ const buildArtifactPath = buildArtifactPathFor(appDirectory);
15
+ if (existsSync(buildArtifactPath)) {
16
+ const artifact = await readJsonFile(buildArtifactPath);
17
+ const artifactValidation = validateUltramodernBuildArtifact(artifact, buildArtifactPath);
18
+ if (!artifactValidation.ok) throw new Error(`[backend-federation-build] Invalid delivery-unit build artifact at ${buildArtifactPath}.`);
19
+ if (!isUltramodernBuildArtifact(artifact)) throw new Error(`[backend-federation-build] Invalid delivery-unit build artifact at ${buildArtifactPath}.`);
20
+ const deliveryUnit = artifact.deliveryUnit;
21
+ return {
22
+ artifact,
23
+ appId: deliveryUnit.appId,
24
+ buildVersion: deliveryUnit.buildMarker,
25
+ packageName: deliveryUnit.packageName,
26
+ version: deliveryUnit.version,
27
+ unitId: deliveryUnit.unitId,
28
+ sourceRevision: deliveryUnit.sourceRevision
29
+ };
30
+ }
31
+ const buildModulePath = buildModulePathFor(appDirectory);
32
+ if (!existsSync(buildModulePath)) return {};
33
+ console.warn(`[backend-federation-build] ${buildArtifactPath} missing; falling back to legacy regex parsing of ${buildModulePath}. Regenerate the workspace to emit ${ULTRAMODERN_BUILD_ARTIFACT_FILE}.`);
34
+ const source = await promises.readFile(buildModulePath, 'utf8');
35
+ return {
36
+ appId: source.match(/\bappId:\s*['"]([^'"]+)['"]/u)?.[1],
37
+ buildVersion: source.match(/\bbuild:\s*['"]([^'"]+)['"]/u)?.[1],
38
+ packageName: source.match(/\bpackageName:\s*['"]([^'"]+)['"]/u)?.[1],
39
+ version: source.match(/\bversion:\s*['"]([^'"]+)['"]/u)?.[1],
40
+ unitId: source.match(/\bunitId:\s*['"]([^'"]+)['"]/u)?.[1],
41
+ sourceRevision: source.match(/\bsourceRevision:\s*['"]([^'"]+)['"]/u)?.[1]
42
+ };
43
+ };
44
+ const toPascalCase = (value)=>value.split(/[^a-zA-Z0-9]+/u).filter(Boolean).map((part)=>part.charAt(0).toUpperCase() + part.slice(1)).join('');
45
+ const stringValue = (value)=>'string' == typeof value && value.length > 0 ? value : void 0;
46
+ const createBackendName = (app, id)=>{
47
+ const configuredName = stringValue(app.backendFederation?.name) ?? stringValue(app.backendFederation?.executionSurfaces?.node?.remoteName) ?? stringValue(app.serverExecution?.node?.remoteName);
48
+ if (configuredName) return configuredName;
49
+ const mfName = stringValue(app.moduleFederation?.name);
50
+ return mfName ? `${mfName}Backend` : `vertical${toPascalCase(id)}Backend`;
51
+ };
52
+ const findWorkspaceRoot = (appDirectory)=>{
53
+ let current = appDirectory;
54
+ while(true){
55
+ if (existsSync(node_path.join(current, COMPACT_CONFIG_PATH))) return current;
56
+ const parent = node_path.dirname(current);
57
+ if (parent === current) return;
58
+ current = parent;
59
+ }
60
+ };
61
+ const resolveWorkspaceSourceRevision = async (workspaceRoot)=>resolveUltramodernSourceRevision(workspaceRoot);
62
+ const createStampedDeliveryUnit = (input)=>{
63
+ if (!input.unitId || !input.buildMarker || !input.packageName || !input.version) return;
64
+ const record = {
65
+ schemaVersion: DELIVERY_UNIT_SCHEMA_VERSION,
66
+ kind: DELIVERY_UNIT_KIND,
67
+ appId: input.appId,
68
+ unitId: input.unitId,
69
+ packageName: input.packageName,
70
+ version: input.version,
71
+ buildMarker: input.buildMarker,
72
+ sourceRevision: input.sourceRevision,
73
+ deployProfile: DELIVERY_UNIT_DEPLOY_PROFILE
74
+ };
75
+ const validation = validateDeliveryUnitRecord(record);
76
+ if (!validation.ok) return;
77
+ return deliveryUnitContractBlock(record);
78
+ };
79
+ const createAppFromCompactMetadata = (workspaceRoot, appDirectory, compactApp)=>{
80
+ const id = stringValue(compactApp.id);
81
+ const appPath = stringValue(compactApp.path);
82
+ if (!id || 'vertical' !== compactApp.kind || !isRecord(compactApp.api)) return;
83
+ const directory = appPath ? normalizeRelativePath(appPath) : `verticals/${id}`;
84
+ if (node_path.resolve(workspaceRoot, directory) !== node_path.resolve(appDirectory)) return;
85
+ const port = 'number' == typeof compactApp.port ? compactApp.port : void 0;
86
+ if (void 0 === port) return;
87
+ const apiPrefix = stringValue(compactApp.api.prefix) ?? `/${id}-api`;
88
+ const apiStem = stringValue(compactApp.api.stem) ?? id;
89
+ const backendName = createBackendName(compactApp, id);
90
+ const manifestUrl = stringValue(compactApp.backendFederation?.executionSurfaces?.node?.manifestUrl) ?? stringValue(compactApp.serverExecution?.node?.manifestUrl) ?? `http://localhost:${port}/${BACKEND_FEDERATION_MANIFEST_FILE}`;
91
+ const containerEntry = stringValue(compactApp.backendFederation?.executionSurfaces?.node?.containerEntry) ?? stringValue(compactApp.serverExecution?.node?.containerEntry) ?? `http://localhost:${port}/${BACKEND_FEDERATION_REMOTE_ENTRY_FILE}`;
92
+ const configuredRemoteType = stringValue(compactApp.backendFederation?.executionSurfaces?.node?.remoteType) ?? stringValue(compactApp.serverExecution?.node?.remoteType);
93
+ if (void 0 !== configuredRemoteType && 'commonjs-module' !== configuredRemoteType) throw new Error(`[backend-federation-build] Node backend federation remoteType must be "commonjs-module"; received "${configuredRemoteType}" for ${id}.`);
94
+ if (!new URL(containerEntry).pathname.endsWith(`/${BACKEND_FEDERATION_REMOTE_ENTRY_FILE}`)) throw new Error(`[backend-federation-build] Node backend federation containerEntry must end with "/${BACKEND_FEDERATION_REMOTE_ENTRY_FILE}"; received "${containerEntry}" for ${id}.`);
95
+ const remoteType = 'commonjs-module';
96
+ const packageName = stringValue(compactApp.package);
97
+ const uiManifestUrl = stringValue(compactApp.backendFederation?.versionBoundary?.ui?.manifestUrl) ?? stringValue(compactApp.moduleFederation?.manifestUrl);
98
+ const compactDeliveryUnit = isRecord(compactApp.deliveryUnit) ? {
99
+ unitId: stringValue(compactApp.deliveryUnit.unitId),
100
+ buildMarker: stringValue(compactApp.deliveryUnit.buildMarker),
101
+ sourceRevision: stringValue(compactApp.deliveryUnit.sourceRevision),
102
+ packageName: stringValue(compactApp.deliveryUnit.packageName),
103
+ version: stringValue(compactApp.deliveryUnit.version)
104
+ } : void 0;
105
+ return {
106
+ id,
107
+ directory,
108
+ packageName,
109
+ port,
110
+ apiPrefix,
111
+ apiStem,
112
+ backendName,
113
+ manifestUrl,
114
+ containerEntry,
115
+ remoteType,
116
+ uiManifestUrl,
117
+ compactDeliveryUnit
118
+ };
119
+ };
120
+ const findBackendFederationApp = async (workspaceRoot, appDirectory)=>{
121
+ const compactConfigPath = node_path.join(workspaceRoot, COMPACT_CONFIG_PATH);
122
+ const compactConfig = await readJsonFile(compactConfigPath);
123
+ const apps = Array.isArray(compactConfig.topology?.apps) ? compactConfig.topology.apps : [];
124
+ for (const app of apps){
125
+ const resolved = createAppFromCompactMetadata(workspaceRoot, appDirectory, app);
126
+ if (resolved) return resolved;
127
+ }
128
+ };
129
+ export { COMPACT_CONFIG_PATH, buildArtifactPathFor, buildModulePathFor, createAppFromCompactMetadata, createStampedDeliveryUnit, findBackendFederationApp, findWorkspaceRoot, normalizeRelativePath, readBuildIdentity, resolveWorkspaceSourceRevision };
@@ -0,0 +1,98 @@
1
+ import "node:module";
2
+ import { existsSync } from "node:fs";
3
+ import promises from "node:fs/promises";
4
+ import node_path from "node:path";
5
+ import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, ULTRAMODERN_BUILD_ARTIFACT_FILE, stampUltramodernBuildArtifactIdentity } from "@modern-js/utils/universal";
6
+ import { resolveUltramodernReleaseIdentity } from "../../ultramodern-release-identity.mjs";
7
+ import { createBackendManifest, createBackendRemoteEntrySource } from "./codegen.mjs";
8
+ import { COMPACT_CONFIG_PATH, buildArtifactPathFor, buildModulePathFor, createStampedDeliveryUnit, findBackendFederationApp, findWorkspaceRoot, readBuildIdentity, resolveWorkspaceSourceRevision } from "./config.mjs";
9
+ const emitBackendFederationArtifacts = async (appDirectory, distDirectory)=>{
10
+ const workspaceRoot = findWorkspaceRoot(appDirectory);
11
+ if (!workspaceRoot) return;
12
+ const effectApiPath = node_path.join(appDirectory, 'api/effect-api.ts');
13
+ const backendFederationConfigPath = node_path.join(appDirectory, 'backend-federation.config.ts');
14
+ if (!existsSync(effectApiPath) || !existsSync(backendFederationConfigPath)) return;
15
+ const app = await findBackendFederationApp(workspaceRoot, appDirectory);
16
+ if (!app) return;
17
+ const buildIdentity = await readBuildIdentity(appDirectory);
18
+ const compactDeliveryUnit = app.compactDeliveryUnit;
19
+ const hasCompactDeliveryUnit = void 0 !== compactDeliveryUnit && (void 0 !== compactDeliveryUnit.unitId || void 0 !== compactDeliveryUnit.buildMarker || void 0 !== compactDeliveryUnit.packageName || void 0 !== compactDeliveryUnit.version);
20
+ const hasBuildIdentity = void 0 !== buildIdentity.unitId || void 0 !== buildIdentity.buildVersion || void 0 !== buildIdentity.packageName || void 0 !== buildIdentity.version;
21
+ if (hasBuildIdentity) {
22
+ const compactConfigPath = node_path.join(workspaceRoot, COMPACT_CONFIG_PATH);
23
+ const buildIdentityPath = existsSync(buildArtifactPathFor(appDirectory)) ? buildArtifactPathFor(appDirectory) : buildModulePathFor(appDirectory);
24
+ const mismatches = [];
25
+ const compare = (label, a, b, leftLabel = 'deliveryUnit')=>{
26
+ if (void 0 !== a && void 0 !== b && a !== b) mismatches.push(`${label}: ${leftLabel}=${a} vs ultramodern-build=${b}`);
27
+ };
28
+ compare('appId', app.id, buildIdentity.appId, 'topology');
29
+ if (hasCompactDeliveryUnit) {
30
+ compare('unitId', compactDeliveryUnit?.unitId, buildIdentity.unitId);
31
+ compare('buildMarker/build', compactDeliveryUnit?.buildMarker, buildIdentity.buildVersion);
32
+ compare('packageName', compactDeliveryUnit?.packageName, buildIdentity.packageName);
33
+ compare('version', compactDeliveryUnit?.version, buildIdentity.version);
34
+ }
35
+ if (mismatches.length > 0) throw new Error(`[backend-federation-build] Delivery-unit identity drift between ${compactConfigPath} (topology) and ${buildIdentityPath}: ${mismatches.join('; ')}`);
36
+ }
37
+ const unitId = compactDeliveryUnit?.unitId ?? buildIdentity.unitId;
38
+ const generationBuildMarker = compactDeliveryUnit?.buildMarker ?? buildIdentity.buildVersion;
39
+ const sourceRevision = await resolveWorkspaceSourceRevision(workspaceRoot);
40
+ const buildVersion = generationBuildMarker && unitId ? resolveUltramodernReleaseIdentity({
41
+ generationBuildMarker,
42
+ unitId,
43
+ workspaceRoot
44
+ }).buildMarker : void 0;
45
+ const packageName = compactDeliveryUnit?.packageName ?? buildIdentity.packageName ?? app.packageName;
46
+ const version = compactDeliveryUnit?.version ?? buildIdentity.version;
47
+ const deliveryUnit = createStampedDeliveryUnit({
48
+ appId: app.id,
49
+ unitId,
50
+ buildMarker: buildVersion,
51
+ packageName,
52
+ version,
53
+ sourceRevision
54
+ });
55
+ const stampedBuildArtifact = buildIdentity.artifact ? stampUltramodernBuildArtifactIdentity(buildIdentity.artifact, {
56
+ buildMarker: buildVersion ?? buildIdentity.artifact.deliveryUnit.buildMarker,
57
+ sourceRevision
58
+ }) : void 0;
59
+ const resolvedApp = {
60
+ ...app,
61
+ packageName,
62
+ version,
63
+ buildVersion,
64
+ unitId,
65
+ sourceRevision,
66
+ deliveryUnit
67
+ };
68
+ const manifestPath = node_path.join(distDirectory, BACKEND_FEDERATION_MANIFEST_FILE);
69
+ const entryPath = node_path.join(distDirectory, BACKEND_FEDERATION_REMOTE_ENTRY_FILE);
70
+ const deliveryUnitArtifactPath = stampedBuildArtifact ? node_path.join(distDirectory, ULTRAMODERN_BUILD_ARTIFACT_FILE) : void 0;
71
+ await promises.mkdir(distDirectory, {
72
+ recursive: true
73
+ });
74
+ await promises.writeFile(entryPath, await createBackendRemoteEntrySource(workspaceRoot, resolvedApp, effectApiPath, entryPath));
75
+ await promises.writeFile(manifestPath, `${JSON.stringify(createBackendManifest(workspaceRoot, distDirectory, resolvedApp), null, 2)}\n`);
76
+ if (stampedBuildArtifact && deliveryUnitArtifactPath) await promises.writeFile(deliveryUnitArtifactPath, `${JSON.stringify(stampedBuildArtifact, null, 2)}\n`);
77
+ return {
78
+ appId: resolvedApp.id,
79
+ manifestPath,
80
+ containerPath: entryPath,
81
+ ...deliveryUnitArtifactPath ? {
82
+ deliveryUnitArtifactPath
83
+ } : {},
84
+ remoteName: resolvedApp.backendName,
85
+ remoteType: resolvedApp.remoteType
86
+ };
87
+ };
88
+ const emit = ()=>({
89
+ name: '@modern-js/backend-federation-build',
90
+ setup (api) {
91
+ api.onAfterBuild(async ()=>{
92
+ const { appDirectory, distDirectory } = api.getAppContext();
93
+ await emitBackendFederationArtifacts(appDirectory, distDirectory);
94
+ });
95
+ }
96
+ });
97
+ export default emit;
98
+ export { emitBackendFederationArtifacts };
@@ -0,0 +1,2 @@
1
+ import "node:module";
2
+ export { default, emitBackendFederationArtifacts } from "./backend-federation/emit.mjs";
@@ -1,6 +1,6 @@
1
1
  import "node:module";
2
2
  import { provider } from "std-env";
3
- import { createCloudflarePreset } from "./platforms/cloudflare.mjs";
3
+ import { createCloudflarePreset } from "./platforms/cloudflare/index.mjs";
4
4
  import { createGhPagesPreset } from "./platforms/gh-pages.mjs";
5
5
  import { createNetlifyPreset } from "./platforms/netlify.mjs";
6
6
  import { createNodePreset } from "./platforms/node.mjs";
@@ -0,0 +1,65 @@
1
+ import "node:module";
2
+ import node_path from "node:path";
3
+ import { fs } from "@modern-js/utils";
4
+ import { RESERVED_ARTIFACT_DESTINATION_DIRECTORIES, RESERVED_ARTIFACT_DESTINATION_FILES, ROUTE_SPEC_OUTPUT } from "./constants.mjs";
5
+ import { normalizeRelativePath } from "./utils.mjs";
6
+ const normalizeCloudflareArtifact = (artifact, index)=>{
7
+ const from = normalizeRelativePath(artifact.from, `deploy.worker.artifacts[${index}].from`, 'app root');
8
+ const to = normalizeRelativePath(artifact.to, `deploy.worker.artifacts[${index}].to`, 'Cloudflare output');
9
+ const [topLevelDestination] = to.split('/');
10
+ const reservedDestination = RESERVED_ARTIFACT_DESTINATION_FILES.has(to) ? to : topLevelDestination;
11
+ if (RESERVED_ARTIFACT_DESTINATION_FILES.has(to) || RESERVED_ARTIFACT_DESTINATION_DIRECTORIES.has(topLevelDestination)) throw new Error(`deploy.worker.artifacts[${index}].to must not target generated Cloudflare output path ${JSON.stringify(reservedDestination)}.`);
12
+ return {
13
+ from,
14
+ to,
15
+ index
16
+ };
17
+ };
18
+ const getCloudflareArtifacts = (modernConfig)=>(modernConfig.deploy?.worker?.artifacts ?? []).map(normalizeCloudflareArtifact);
19
+ const normalizeCloudflarePublicAsset = (asset, index)=>{
20
+ const from = normalizeRelativePath(asset.from, `deploy.worker.publicAssets[${index}].from`, 'app root');
21
+ const to = normalizeRelativePath(asset.to, `deploy.worker.publicAssets[${index}].to`, 'Cloudflare public output', {
22
+ allowRoot: true
23
+ });
24
+ return {
25
+ from,
26
+ to,
27
+ index
28
+ };
29
+ };
30
+ const getCloudflarePublicAssets = (modernConfig)=>(modernConfig.deploy?.worker?.publicAssets ?? []).map(normalizeCloudflarePublicAsset);
31
+ const copyCloudflareArtifacts = async (appDirectory, outputDirectory, artifacts)=>{
32
+ for (const artifact of artifacts){
33
+ const sourcePath = node_path.join(appDirectory, artifact.from);
34
+ if (!await fs.pathExists(sourcePath)) throw new Error(`deploy.worker.artifacts[${artifact.index}].from does not exist: ${artifact.from}`);
35
+ await fs.copy(sourcePath, node_path.join(outputDirectory, artifact.to));
36
+ }
37
+ };
38
+ const copyCloudflarePublicAssets = async (appDirectory, publicDirectory, publicAssets)=>{
39
+ for (const asset of publicAssets){
40
+ const sourcePath = node_path.join(appDirectory, asset.from);
41
+ if (!await fs.pathExists(sourcePath)) throw new Error(`deploy.worker.publicAssets[${asset.index}].from does not exist: ${asset.from}`);
42
+ await fs.copy(sourcePath, node_path.join(publicDirectory, asset.to));
43
+ }
44
+ };
45
+ const copyCloudflareD1Migrations = async (appDirectory, outputDirectory, modernConfig)=>{
46
+ for (const [index, database] of (modernConfig.deploy?.worker?.d1Databases ?? []).entries()){
47
+ if (!database.migrationsDir) continue;
48
+ const migrationsDir = normalizeRelativePath(database.migrationsDir, `deploy.worker.d1Databases[${index}].migrationsDir`, 'app root');
49
+ const sourcePath = node_path.join(appDirectory, migrationsDir);
50
+ if (!await fs.pathExists(sourcePath)) throw new Error(`deploy.worker.d1Databases[${index}].migrationsDir does not exist: ${migrationsDir}`);
51
+ await fs.copy(sourcePath, node_path.join(outputDirectory, migrationsDir));
52
+ }
53
+ };
54
+ const readRouteSpec = async (outputDirectory)=>{
55
+ const routeSpecPath = node_path.join(outputDirectory, ROUTE_SPEC_OUTPUT);
56
+ if (!await fs.pathExists(routeSpecPath)) return {
57
+ routes: []
58
+ };
59
+ const routeSpec = await fs.readJSON(routeSpecPath);
60
+ return {
61
+ ...routeSpec,
62
+ routes: Array.isArray(routeSpec.routes) ? routeSpec.routes : []
63
+ };
64
+ };
65
+ export { copyCloudflareArtifacts, copyCloudflareD1Migrations, copyCloudflarePublicAssets, getCloudflareArtifacts, getCloudflarePublicAssets, readRouteSpec };
@@ -0,0 +1,35 @@
1
+ import "node:module";
2
+ import { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_OUTPUT_PACKAGE_FILE, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY, CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY, CLOUDFLARE_WORKER_BUNDLE_FORMAT, CLOUDFLARE_WORKER_ENTRY, CLOUDFLARE_WORKER_MANIFEST, CLOUDFLARE_WRANGLER_CONFIG_FILE } from "../cloudflare-output-contract.mjs";
3
+ const WORKER_ENTRY = CLOUDFLARE_WORKER_ENTRY;
4
+ const WORKER_MANIFEST = CLOUDFLARE_WORKER_MANIFEST;
5
+ const WRANGLER_CONFIG_FILE = CLOUDFLARE_WRANGLER_CONFIG_FILE;
6
+ const OUTPUT_PACKAGE_FILE = CLOUDFLARE_OUTPUT_PACKAGE_FILE;
7
+ const ASSETS_BINDING = CLOUDFLARE_ASSETS_BINDING;
8
+ const ROUTE_SPEC_FILE = 'route.json';
9
+ const ROUTE_SPEC_OUTPUT = `server/${ROUTE_SPEC_FILE}`;
10
+ const LOADABLE_STATS_FILE = 'loadable-stats.json';
11
+ const ROUTE_MANIFEST_FILE = 'routes-manifest.json';
12
+ const PUBLIC_ASSETS_DIRECTORY = CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY;
13
+ const WORKER_BUNDLE_DIRECTORY = CLOUDFLARE_WORKER_BUNDLE_DIRECTORY;
14
+ const SERVER_BUNDLE_DIRECTORY = 'bundles';
15
+ const SERVER_OUTPUT_DIRECTORY = 'server';
16
+ const DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES = [
17
+ 'api',
18
+ 'shared'
19
+ ];
20
+ const BFF_EFFECT_WORKER_ENTRY = `${WORKER_BUNDLE_DIRECTORY}/__modern_bff_effect.js`;
21
+ const BFF_EFFECT_WORKER_DISPATCHER_EXPORT = '__modern_create_effect_bff_dispatcher';
22
+ const EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE = 'Ensure the Effect API entry exists at api/index.ts or bff.effect.entry, and import Cloudflare edge handlers from @modern-js/plugin-bff/effect-edge instead of lambda/Hono server helpers.';
23
+ const DEFAULT_COMPATIBILITY_DATE = '2026-06-02';
24
+ const COMPATIBILITY_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/u;
25
+ const REQUIRED_COMPATIBILITY_FLAGS = CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS;
26
+ const RESERVED_ARTIFACT_DESTINATION_FILES = new Set([
27
+ WRANGLER_CONFIG_FILE,
28
+ OUTPUT_PACKAGE_FILE
29
+ ]);
30
+ const RESERVED_ARTIFACT_DESTINATION_DIRECTORIES = new Set([
31
+ PUBLIC_ASSETS_DIRECTORY,
32
+ SERVER_OUTPUT_DIRECTORY,
33
+ WORKER_BUNDLE_DIRECTORY
34
+ ]);
35
+ export { ASSETS_BINDING, BFF_EFFECT_WORKER_DISPATCHER_EXPORT, BFF_EFFECT_WORKER_ENTRY, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_BUNDLE_FORMAT, COMPATIBILITY_DATE_PATTERN, DEFAULT_COMPATIBILITY_DATE, DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES, EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE, LOADABLE_STATS_FILE, OUTPUT_PACKAGE_FILE, PUBLIC_ASSETS_DIRECTORY, REQUIRED_COMPATIBILITY_FLAGS, RESERVED_ARTIFACT_DESTINATION_DIRECTORIES, RESERVED_ARTIFACT_DESTINATION_FILES, ROUTE_MANIFEST_FILE, ROUTE_SPEC_FILE, ROUTE_SPEC_OUTPUT, SERVER_BUNDLE_DIRECTORY, SERVER_OUTPUT_DIRECTORY, WORKER_BUNDLE_DIRECTORY, WORKER_ENTRY, WORKER_MANIFEST, WRANGLER_CONFIG_FILE };
@@ -0,0 +1,89 @@
1
+ import "node:module";
2
+ import node_path from "node:path";
3
+ import { fs } from "@modern-js/utils";
4
+ import { ULTRAMODERN_BUILD_ARTIFACT_PATH, ULTRAMODERN_BUILD_MODULE_PATH, isUltramodernBuildArtifact, nonEmptyString, toDeliveryUnitIdentity } from "@modern-js/utils/universal";
5
+ import { resolveUltramodernReleaseIdentity } from "../../../../ultramodern-release-identity.mjs";
6
+ import { isRecord } from "./utils.mjs";
7
+ const COMPACT_CONFIG_PATH = '.modernjs/ultramodern.json';
8
+ const findWorkspaceRoot = async (appDirectory)=>{
9
+ let current = node_path.resolve(appDirectory);
10
+ for(;;){
11
+ if (await fs.pathExists(node_path.join(current, COMPACT_CONFIG_PATH))) return current;
12
+ const parent = node_path.dirname(current);
13
+ if (parent === current) return;
14
+ current = parent;
15
+ }
16
+ };
17
+ const stampReleaseIdentity = (identity, workspaceRoot)=>{
18
+ if ('workspace' !== identity.sourceRevision) return identity;
19
+ return {
20
+ ...identity,
21
+ ...resolveUltramodernReleaseIdentity({
22
+ generationBuildMarker: identity.buildMarker,
23
+ unitId: identity.unitId,
24
+ workspaceRoot
25
+ })
26
+ };
27
+ };
28
+ const resolveTopologyDeliveryUnit = async (appDirectory)=>{
29
+ const workspaceRoot = await findWorkspaceRoot(appDirectory);
30
+ if (!workspaceRoot) return;
31
+ let compactConfig;
32
+ try {
33
+ compactConfig = await fs.readJSON(node_path.join(workspaceRoot, COMPACT_CONFIG_PATH));
34
+ } catch {
35
+ return;
36
+ }
37
+ if (!isRecord(compactConfig)) return;
38
+ const topology = isRecord(compactConfig.topology) ? compactConfig.topology : void 0;
39
+ const apps = Array.isArray(topology?.apps) ? topology.apps : void 0;
40
+ const resolvedAppDirectory = node_path.resolve(appDirectory);
41
+ if (apps) {
42
+ for (const app of apps){
43
+ if (!isRecord(app)) continue;
44
+ const appPath = nonEmptyString(app.path);
45
+ if (appPath && node_path.resolve(workspaceRoot, appPath.replace(/^\.\/+/u, '')) === resolvedAppDirectory) {
46
+ const identity = toDeliveryUnitIdentity(app.deliveryUnit);
47
+ return identity ? stampReleaseIdentity(identity, workspaceRoot) : void 0;
48
+ }
49
+ }
50
+ return;
51
+ }
52
+ const identity = toDeliveryUnitIdentity(compactConfig.deliveryUnit);
53
+ return identity ? stampReleaseIdentity(identity, workspaceRoot) : void 0;
54
+ };
55
+ const resolveWorkerDeliveryUnitStamp = async (appDirectory)=>{
56
+ const buildArtifactPath = node_path.join(appDirectory, ULTRAMODERN_BUILD_ARTIFACT_PATH);
57
+ const buildModulePath = node_path.join(appDirectory, ULTRAMODERN_BUILD_MODULE_PATH);
58
+ let identity;
59
+ if (await fs.pathExists(buildArtifactPath)) {
60
+ const artifact = await fs.readJSON(buildArtifactPath);
61
+ if (!isUltramodernBuildArtifact(artifact)) return;
62
+ identity = toDeliveryUnitIdentity(artifact.deliveryUnit);
63
+ } else if (await fs.pathExists(buildModulePath)) {
64
+ console.warn(`[cloudflare] ${buildArtifactPath} missing; falling back to legacy regex parsing of ${buildModulePath}. Regenerate the workspace to emit ultramodern-build.json.`);
65
+ const source = await fs.readFile(buildModulePath, 'utf8');
66
+ identity = toDeliveryUnitIdentity({
67
+ buildMarker: source.match(/\bbuild:\s*['"]([^'"]+)['"]/u)?.[1],
68
+ unitId: source.match(/\bunitId:\s*['"]([^'"]+)['"]/u)?.[1],
69
+ sourceRevision: source.match(/\bsourceRevision:\s*['"]([^'"]+)['"]/u)?.[1]
70
+ });
71
+ }
72
+ if (!identity) return;
73
+ const workspaceRoot = await findWorkspaceRoot(appDirectory);
74
+ if (workspaceRoot) identity = stampReleaseIdentity(identity, workspaceRoot);
75
+ return {
76
+ ...identity,
77
+ surfaces: {
78
+ ui: {
79
+ ...identity,
80
+ surface: 'ui'
81
+ },
82
+ api: {
83
+ ...identity,
84
+ surface: 'api'
85
+ }
86
+ }
87
+ };
88
+ };
89
+ export { resolveTopologyDeliveryUnit, resolveWorkerDeliveryUnitStamp };
@@ -0,0 +1,98 @@
1
+ import "node:module";
2
+ import { isRecord } from "./utils.mjs";
3
+ const I18N_SERVER_PLUGIN_NAME = 'plugin-i18n/server';
4
+ const DEFAULT_I18NEXT_DETECTION_OPTIONS = {
5
+ order: [
6
+ 'querystring',
7
+ 'cookie',
8
+ 'localStorage',
9
+ 'header',
10
+ 'navigator',
11
+ 'htmlTag',
12
+ 'path',
13
+ 'subdomain'
14
+ ],
15
+ lookupQuerystring: 'lng',
16
+ lookupCookie: 'i18next',
17
+ lookupHeader: 'accept-language'
18
+ };
19
+ const SERVER_SIDE_I18N_DETECTORS = new Set([
20
+ 'querystring',
21
+ 'cookie',
22
+ 'header'
23
+ ]);
24
+ const toStringArray = (value)=>Array.isArray(value) ? value.filter((entry)=>'string' == typeof entry) : [];
25
+ const getI18nServerPlugin = (appContext)=>appContext.serverPlugins?.find((plugin)=>plugin.name.includes(I18N_SERVER_PLUGIN_NAME));
26
+ const removeLocaleDetectionByEntry = (config)=>{
27
+ const { localeDetectionByEntry: _localeDetectionByEntry, ...rest } = config;
28
+ return rest;
29
+ };
30
+ const getEntryLocaleDetection = (entryName, localeDetection)=>{
31
+ const byEntry = isRecord(localeDetection.localeDetectionByEntry) ? localeDetection.localeDetectionByEntry : void 0;
32
+ const entryConfig = byEntry?.[entryName];
33
+ const globalConfig = removeLocaleDetectionByEntry(localeDetection);
34
+ return isRecord(entryConfig) ? {
35
+ ...globalConfig,
36
+ ...entryConfig
37
+ } : globalConfig;
38
+ };
39
+ const normalizeI18nDetection = (detection)=>{
40
+ const configured = isRecord(detection) ? detection : {};
41
+ const rawOrder = Array.isArray(configured.order) ? configured.order : DEFAULT_I18NEXT_DETECTION_OPTIONS.order;
42
+ const order = rawOrder.filter((entry)=>'string' == typeof entry && SERVER_SIDE_I18N_DETECTORS.has(entry));
43
+ return {
44
+ order: order.length > 0 ? order : [
45
+ 'querystring',
46
+ 'cookie',
47
+ 'header'
48
+ ],
49
+ lookupQuerystring: 'string' == typeof configured.lookupQuerystring && configured.lookupQuerystring ? configured.lookupQuerystring : DEFAULT_I18NEXT_DETECTION_OPTIONS.lookupQuerystring,
50
+ lookupCookie: 'string' == typeof configured.lookupCookie && configured.lookupCookie ? configured.lookupCookie : DEFAULT_I18NEXT_DETECTION_OPTIONS.lookupCookie,
51
+ lookupHeader: 'string' == typeof configured.lookupHeader && configured.lookupHeader ? configured.lookupHeader : DEFAULT_I18NEXT_DETECTION_OPTIONS.lookupHeader
52
+ };
53
+ };
54
+ const normalizeLocalisedUrls = (localisedUrls)=>{
55
+ if (!isRecord(localisedUrls) || 0 === Object.keys(localisedUrls).length) return;
56
+ const normalized = {};
57
+ for (const [canonicalPath, languageMap] of Object.entries(localisedUrls)){
58
+ if (!isRecord(languageMap)) continue;
59
+ const normalizedLanguageMap = Object.fromEntries(Object.entries(languageMap).filter((entry)=>'string' == typeof entry[1] && entry[1].length > 0));
60
+ if (Object.keys(normalizedLanguageMap).length > 0) normalized[canonicalPath] = normalizedLanguageMap;
61
+ }
62
+ return Object.keys(normalized).length > 0 ? normalized : void 0;
63
+ };
64
+ const normalizeWorkerI18nEntry = (entryName, localeDetection, staticRoutePrefixes)=>{
65
+ const entryConfig = getEntryLocaleDetection(entryName, localeDetection);
66
+ const languages = toStringArray(entryConfig.languages);
67
+ if (true !== entryConfig.localePathRedirect || 0 === languages.length) return;
68
+ const fallbackLanguage = 'string' == typeof entryConfig.fallbackLanguage && entryConfig.fallbackLanguage ? entryConfig.fallbackLanguage : 'en';
69
+ const ignoreRedirectRoutes = Array.isArray(entryConfig.ignoreRedirectRoutes) ? toStringArray(entryConfig.ignoreRedirectRoutes) : [];
70
+ const localisedUrls = normalizeLocalisedUrls(entryConfig.localisedUrls);
71
+ return {
72
+ i18nextDetector: false !== entryConfig.i18nextDetector,
73
+ languages,
74
+ fallbackLanguage,
75
+ detection: normalizeI18nDetection(entryConfig.detection),
76
+ ignoreRedirectRoutes,
77
+ staticRoutePrefixes,
78
+ ...localisedUrls ? {
79
+ localisedUrls
80
+ } : {}
81
+ };
82
+ };
83
+ const createI18nWorkerManifest = (routeSpec, appContext)=>{
84
+ const i18nServerPlugin = getI18nServerPlugin(appContext);
85
+ const localeDetection = i18nServerPlugin?.options?.localeDetection;
86
+ if (!isRecord(localeDetection)) return;
87
+ const staticRoutePrefixes = toStringArray(i18nServerPlugin?.options?.staticRoutePrefixes);
88
+ const entries = {};
89
+ for (const route of routeSpec.routes){
90
+ if ('string' != typeof route.entryName || entries[route.entryName]) continue;
91
+ const entry = normalizeWorkerI18nEntry(route.entryName, localeDetection, staticRoutePrefixes);
92
+ if (entry) entries[route.entryName] = entry;
93
+ }
94
+ return Object.keys(entries).length > 0 ? {
95
+ entries
96
+ } : void 0;
97
+ };
98
+ export { createI18nWorkerManifest };
@@ -0,0 +1,103 @@
1
+ import "node:module";
2
+ import node_path from "node:path";
3
+ import { fs } from "@modern-js/utils";
4
+ import { MICROVERTICAL_RELEASE_ENVELOPE_PATH, emitCloudflareStagedReleaseEnvelope, emitFrameworkMicroVerticalReleaseEnvelope, stageCloudflareReleaseEnvelope, verifyBuildOutputReleaseEnvelope, verifyCloudflareReleaseEnvelopeStaging } from "../../../../ultramodern-release-envelope/framework-output.mjs";
5
+ import { readTemplate } from "../../utils/index.mjs";
6
+ import { createCloudflareOutputPlan } from "../cloudflare-output-plan.mjs";
7
+ import { assertCloudflareOutput } from "../cloudflare-output-verifier/index.mjs";
8
+ import { copyCloudflareArtifacts, copyCloudflareD1Migrations, copyCloudflarePublicAssets, getCloudflareArtifacts, getCloudflarePublicAssets } from "./artifacts.mjs";
9
+ import { ROUTE_SPEC_FILE, ROUTE_SPEC_OUTPUT, WORKER_BUNDLE_DIRECTORY } from "./constants.mjs";
10
+ import { resolveTopologyDeliveryUnit, resolveWorkerDeliveryUnitStamp } from "./delivery-unit.mjs";
11
+ import { createWorkerManifest, createWorkerModuleLoaders, getPublicAssetExcludes, shouldCopyToPublicAssets, shouldCopyToWorkerBundle } from "./worker-manifest.mjs";
12
+ import { createWranglerConfig } from "./wrangler-config.mjs";
13
+ const CLOUDFLARE_ENTRY_TEMPLATE_FRAGMENTS = [
14
+ 'cloudflare-entry.001-bootstrap-security.mjs',
15
+ 'cloudflare-entry.002-assets-routes.mjs',
16
+ 'cloudflare-entry.003-i18n-locales.mjs',
17
+ 'cloudflare-entry.004-rendering-css.mjs',
18
+ 'cloudflare-entry.005-worker-dispatch.mjs',
19
+ 'cloudflare-entry.006-fetch-handler.mjs'
20
+ ];
21
+ const readCloudflareEntryTemplate = async ()=>(await Promise.all(CLOUDFLARE_ENTRY_TEMPLATE_FRAGMENTS.map((fragment)=>readTemplate(fragment)))).join('');
22
+ const createCloudflarePreset = ({ appContext, modernConfig })=>{
23
+ const { apiOnly, appDirectory, distDirectory } = appContext;
24
+ const outputDirectory = node_path.join(appDirectory, '.output');
25
+ const outputPlan = createCloudflareOutputPlan(outputDirectory);
26
+ const publicDirectory = outputPlan.paths.publicAssets;
27
+ const workerEntryPath = outputPlan.paths.workerEntry;
28
+ const workerManifestPath = outputPlan.paths.workerManifest;
29
+ const routeSpecOutputPath = node_path.join(outputDirectory, ROUTE_SPEC_OUTPUT);
30
+ const wranglerConfigPath = outputPlan.paths.wranglerConfig;
31
+ const cloudflareArtifacts = getCloudflareArtifacts(modernConfig);
32
+ const publicAssetExcludes = getPublicAssetExcludes(appDirectory, modernConfig);
33
+ let hasReleaseEnvelope = false;
34
+ return {
35
+ async prepare () {
36
+ await fs.remove(outputDirectory);
37
+ },
38
+ async writeOutput () {
39
+ if (await fs.pathExists(node_path.join(distDirectory, MICROVERTICAL_RELEASE_ENVELOPE_PATH))) await emitFrameworkMicroVerticalReleaseEnvelope({
40
+ apiOnly,
41
+ distDirectory,
42
+ target: 'cloudflare'
43
+ });
44
+ await verifyBuildOutputReleaseEnvelope(distDirectory, 'cloudflare');
45
+ await fs.copy(distDirectory, publicDirectory, {
46
+ filter: (src)=>{
47
+ const relativePath = node_path.relative(distDirectory, src).replace(/\\/gu, '/');
48
+ return 'release' !== relativePath && !relativePath.startsWith('release/') && 'public' !== relativePath && !relativePath.startsWith('public/') && shouldCopyToPublicAssets(src, distDirectory, publicAssetExcludes);
49
+ }
50
+ });
51
+ const generatedPublicDirectory = node_path.join(distDirectory, 'public');
52
+ if (await fs.pathExists(generatedPublicDirectory)) await fs.copy(generatedPublicDirectory, publicDirectory);
53
+ await fs.ensureDir(node_path.dirname(workerEntryPath));
54
+ await fs.ensureDir(node_path.dirname(workerManifestPath));
55
+ const routeSpecSourcePath = node_path.join(distDirectory, ROUTE_SPEC_FILE);
56
+ if (await fs.pathExists(routeSpecSourcePath)) await fs.copy(routeSpecSourcePath, routeSpecOutputPath);
57
+ const workerBundleSourceDirectory = node_path.join(distDirectory, WORKER_BUNDLE_DIRECTORY);
58
+ const workerBundleOutputDirectory = outputPlan.paths.workerBundle;
59
+ if (await fs.pathExists(workerBundleSourceDirectory)) {
60
+ await fs.copy(workerBundleSourceDirectory, workerBundleOutputDirectory, {
61
+ filter: (src)=>shouldCopyToWorkerBundle(src, workerBundleSourceDirectory)
62
+ });
63
+ await fs.writeJSON(outputPlan.paths.workerPackage, outputPlan.packages.worker);
64
+ }
65
+ await copyCloudflareArtifacts(appDirectory, outputDirectory, cloudflareArtifacts);
66
+ await copyCloudflarePublicAssets(appDirectory, publicDirectory, getCloudflarePublicAssets(modernConfig));
67
+ await copyCloudflareD1Migrations(appDirectory, outputDirectory, modernConfig);
68
+ await fs.writeJSON(wranglerConfigPath, createWranglerConfig(appDirectory, modernConfig), {
69
+ spaces: 2
70
+ });
71
+ const deliveryUnitStamp = await resolveWorkerDeliveryUnitStamp(appDirectory);
72
+ await fs.writeJSON(workerManifestPath, await createWorkerManifest(outputDirectory, modernConfig, appContext, deliveryUnitStamp), {
73
+ spaces: 2
74
+ });
75
+ await fs.writeJSON(outputPlan.paths.outputPackage, outputPlan.packages.output);
76
+ hasReleaseEnvelope = Boolean(await stageCloudflareReleaseEnvelope({
77
+ distDirectory,
78
+ outputDirectory
79
+ }));
80
+ },
81
+ async genEntry () {
82
+ const template = await readCloudflareEntryTemplate();
83
+ const manifest = await fs.readJSON(workerManifestPath);
84
+ await fs.writeFile(workerEntryPath, template.replace('p_workerManifest', JSON.stringify(manifest, null, 2)).replace('p_workerModuleLoaders', createWorkerModuleLoaders(manifest)));
85
+ const topologyDeliveryUnit = await resolveTopologyDeliveryUnit(appDirectory);
86
+ await assertCloudflareOutput({
87
+ outputDirectory,
88
+ importWorker: false,
89
+ ...topologyDeliveryUnit ? {
90
+ deliveryUnit: topologyDeliveryUnit
91
+ } : {}
92
+ });
93
+ if (hasReleaseEnvelope) {
94
+ await emitCloudflareStagedReleaseEnvelope({
95
+ distDirectory,
96
+ outputDirectory
97
+ });
98
+ await verifyCloudflareReleaseEnvelopeStaging(outputDirectory);
99
+ } else if (await fs.pathExists(node_path.join(outputDirectory, MICROVERTICAL_RELEASE_ENVELOPE_PATH))) throw new Error('[ultramodern-release-envelope] Cloudflare staging contains an envelope not selected from this MicroVertical build.');
100
+ }
101
+ };
102
+ };
103
+ export { createCloudflarePreset };