@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,148 +0,0 @@
1
- import node_path from "node:path";
2
- import { fs } from "@modern-js/utils";
3
- import { readRouteSpec } from "./artifacts.mjs";
4
- import { ASSETS_BINDING, BFF_EFFECT_WORKER_DISPATCHER_EXPORT, BFF_EFFECT_WORKER_ENTRY, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_BUNDLE_FORMAT, DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES, EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE, LOADABLE_STATS_FILE, PUBLIC_ASSETS_DIRECTORY, ROUTE_MANIFEST_FILE, ROUTE_SPEC_FILE, ROUTE_SPEC_OUTPUT, SERVER_BUNDLE_DIRECTORY, WORKER_BUNDLE_DIRECTORY, WORKER_ENTRY } from "./constants.mjs";
5
- import { createI18nWorkerManifest } from "./i18n-worker.mjs";
6
- import { createCloudflareWorkerSecurityPolicy } from "./security-policies.mjs";
7
- import { isRecord, normalizeRelativePath } from "./utils.mjs";
8
- import { createWorkerManifestServiceBindings, createWorkerServiceBindings } from "./wrangler-config.mjs";
9
- const createMissingEffectBffWorkerError = (outputDirectory, worker)=>new Error(`Cloudflare Effect API runtime is configured, but the BFF worker bundle is missing: ${node_path.join(outputDirectory, worker)}. ${EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE}`);
10
- const createModuleFederationWorkerManifest = async (outputDirectory)=>{
11
- const manifestPath = node_path.join(outputDirectory, PUBLIC_ASSETS_DIRECTORY, 'mf-manifest.json');
12
- if (!await fs.pathExists(manifestPath)) return;
13
- const manifest = await fs.readJson(manifestPath);
14
- const name = isRecord(manifest) && 'string' == typeof manifest.name ? manifest.name : void 0;
15
- const manifestExposes = isRecord(manifest) && Array.isArray(manifest.exposes) ? manifest.exposes : [];
16
- const exposes = manifestExposes.filter(isRecord).flatMap((expose)=>{
17
- if ('string' != typeof expose.path) return [];
18
- const assets = isRecord(expose.assets) ? expose.assets : void 0;
19
- const css = assets && isRecord(assets.css) ? assets.css : void 0;
20
- return [
21
- {
22
- path: expose.path,
23
- css: [
24
- ...css && Array.isArray(css.sync) ? css.sync : [],
25
- ...css && Array.isArray(css.async) ? css.async : []
26
- ].filter((asset)=>'string' == typeof asset && asset.endsWith('.css'))
27
- }
28
- ];
29
- });
30
- return name && exposes.length > 0 ? {
31
- name,
32
- exposes
33
- } : void 0;
34
- };
35
- const createWorkerManifest = async (outputDirectory, modernConfig, appContext, deliveryUnitStamp)=>{
36
- const routeSpec = await readRouteSpec(outputDirectory);
37
- const routes = await Promise.all(routeSpec.routes.map(async (route)=>{
38
- const worker = 'string' == typeof route.worker ? route.worker : void 0;
39
- return {
40
- urlPath: route.urlPath,
41
- entryName: route.entryName,
42
- entryPath: route.entryPath,
43
- isSSR: Boolean(route.isSSR),
44
- worker,
45
- workerExists: worker ? await fs.pathExists(node_path.join(outputDirectory, worker)) : false
46
- };
47
- }));
48
- const bffPrefix = modernConfig.bff?.prefix;
49
- const primaryBffPrefix = Array.isArray(bffPrefix) ? bffPrefix[0] : bffPrefix;
50
- const isEffectApi = Boolean(modernConfig.bff) && modernConfig.bff?.runtimeFramework !== 'hono';
51
- const effectApiWorkerExists = await fs.pathExists(node_path.join(outputDirectory, BFF_EFFECT_WORKER_ENTRY));
52
- const serviceBindings = createWorkerManifestServiceBindings(createWorkerServiceBindings(modernConfig, void 0));
53
- const moduleFederation = await createModuleFederationWorkerManifest(outputDirectory);
54
- if (isEffectApi && primaryBffPrefix && !effectApiWorkerExists) throw createMissingEffectBffWorkerError(outputDirectory, BFF_EFFECT_WORKER_ENTRY);
55
- return {
56
- version: 1,
57
- runtime: {
58
- type: CLOUDFLARE_RUNTIME_TYPE,
59
- entry: WORKER_ENTRY,
60
- fetchExport: true,
61
- nodeListen: false
62
- },
63
- assets: {
64
- binding: ASSETS_BINDING,
65
- directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
66
- runWorkerFirst: true
67
- },
68
- routeSpec: {
69
- file: ROUTE_SPEC_OUTPUT,
70
- routes
71
- },
72
- workerBundles: {
73
- directory: WORKER_BUNDLE_DIRECTORY,
74
- format: CLOUDFLARE_WORKER_BUNDLE_FORMAT,
75
- importableFromModuleWorker: true,
76
- requestHandlerExport: 'requestHandler'
77
- },
78
- resources: {
79
- loadableStats: LOADABLE_STATS_FILE,
80
- routeManifest: ROUTE_MANIFEST_FILE
81
- },
82
- security: createCloudflareWorkerSecurityPolicy(modernConfig),
83
- ...void 0 === moduleFederation ? {} : {
84
- moduleFederation
85
- },
86
- ...deliveryUnitStamp ? {
87
- deliveryUnit: deliveryUnitStamp
88
- } : {},
89
- i18n: createI18nWorkerManifest(routeSpec, appContext),
90
- bff: isEffectApi && primaryBffPrefix && effectApiWorkerExists ? {
91
- dispatcherExport: BFF_EFFECT_WORKER_DISPATCHER_EXPORT,
92
- runtimeFramework: 'effect',
93
- prefix: primaryBffPrefix,
94
- worker: BFF_EFFECT_WORKER_ENTRY
95
- } : void 0,
96
- ...void 0 === serviceBindings ? {} : {
97
- serviceBindings
98
- }
99
- };
100
- };
101
- const createWorkerModuleLoaders = (manifest)=>{
102
- const imports = new Map();
103
- for (const route of manifest.routeSpec.routes)if (route.worker && route.workerExists) {
104
- const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
105
- imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
106
- }
107
- if (manifest.bff?.worker) {
108
- const importPath = `../${String(manifest.bff.worker).replace(/^\/+/u, '')}`;
109
- imports.set(manifest.bff.worker, `() => import(${JSON.stringify(importPath)})`);
110
- }
111
- if (0 === imports.size) return '{}';
112
- const loaders = [
113
- ...imports.entries()
114
- ].map(([worker, loader])=>`${JSON.stringify(worker)}: ${loader}`);
115
- return `{\n${loaders.join(',\n')}\n}`;
116
- };
117
- const getPublicAssetExcludes = (appDirectory, modernConfig)=>[
118
- ...DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES.filter((directory)=>{
119
- try {
120
- return fs.statSync(node_path.join(appDirectory, directory)).isDirectory();
121
- } catch {
122
- return false;
123
- }
124
- }),
125
- ...modernConfig.deploy?.worker?.publicAssetExcludes ?? []
126
- ].map((entry)=>normalizeRelativePath(entry, 'deploy.worker.publicAssetExcludes'));
127
- const shouldCopyToPublicAssets = (src, distDirectory, publicAssetExcludes)=>{
128
- const relativePath = node_path.relative(distDirectory, src);
129
- if (!relativePath) return true;
130
- const normalizedRelativePath = relativePath.replace(/\\/g, '/');
131
- const [topLevelDirectory] = normalizedRelativePath.split('/');
132
- const basename = normalizedRelativePath.split('/').pop() ?? '';
133
- return normalizedRelativePath !== ROUTE_SPEC_FILE && topLevelDirectory !== WORKER_BUNDLE_DIRECTORY && topLevelDirectory !== SERVER_BUNDLE_DIRECTORY && '.env' !== basename && !basename.startsWith('.env.') && !publicAssetExcludes.some((exclude)=>normalizedRelativePath === exclude || normalizedRelativePath.startsWith(`${exclude}/`));
134
- };
135
- const shouldCopyToWorkerBundle = (src, workerBundleDirectory)=>{
136
- const relativePath = node_path.relative(workerBundleDirectory, src);
137
- if (!relativePath) return true;
138
- const normalizedRelativePath = relativePath.replace(/\\/g, '/');
139
- const basename = node_path.basename(normalizedRelativePath);
140
- if (basename.startsWith('.') || normalizedRelativePath.includes('/.')) return false;
141
- if (fs.statSync(src).isDirectory()) return true;
142
- return [
143
- '.cjs',
144
- '.js',
145
- '.mjs'
146
- ].includes(node_path.extname(normalizedRelativePath));
147
- };
148
- export { createWorkerManifest, createWorkerModuleLoaders, getPublicAssetExcludes, shouldCopyToPublicAssets, shouldCopyToWorkerBundle };
@@ -1,150 +0,0 @@
1
- import node_path from "node:path";
2
- import { ASSETS_BINDING, COMPATIBILITY_DATE_PATTERN, DEFAULT_COMPATIBILITY_DATE, PUBLIC_ASSETS_DIRECTORY, REQUIRED_COMPATIBILITY_FLAGS, WORKER_ENTRY } from "./constants.mjs";
3
- import { isJsonRecord, normalizeRelativePath } from "./utils.mjs";
4
- const getCompatibilityDate = (modernConfig)=>{
5
- const configuredDate = modernConfig.deploy?.worker?.compatibilityDate?.trim();
6
- const compatibilityDate = configuredDate || DEFAULT_COMPATIBILITY_DATE;
7
- if (!COMPATIBILITY_DATE_PATTERN.test(compatibilityDate)) throw new Error(`deploy.worker.compatibilityDate must use YYYY-MM-DD, received ${JSON.stringify(compatibilityDate)}.`);
8
- return compatibilityDate;
9
- };
10
- const getWorkerName = (appDirectory)=>{
11
- const basename = node_path.basename(appDirectory);
12
- return basename.replace(/[^a-zA-Z0-9-_]/g, '-') || 'modern-cloudflare-worker';
13
- };
14
- const getConfiguredWorkerName = (appDirectory, modernConfig)=>{
15
- const configuredName = modernConfig.deploy?.worker?.name?.trim();
16
- return configuredName || getWorkerName(appDirectory);
17
- };
18
- const getConfiguredWrangler = (modernConfig)=>{
19
- const wrangler = modernConfig.deploy?.worker?.wrangler;
20
- if (void 0 === wrangler) return {};
21
- if (!isJsonRecord(wrangler)) throw new Error('deploy.worker.wrangler must be a JSON object.');
22
- return wrangler;
23
- };
24
- const createWranglerCompatibilityFlags = (configuredFlags)=>{
25
- if (void 0 === configuredFlags) return [
26
- ...REQUIRED_COMPATIBILITY_FLAGS
27
- ];
28
- if (!Array.isArray(configuredFlags) || configuredFlags.some((flag)=>'string' != typeof flag)) throw new Error('deploy.worker.wrangler.compatibility_flags must be an array of strings.');
29
- return [
30
- ...new Set([
31
- ...configuredFlags,
32
- ...REQUIRED_COMPATIBILITY_FLAGS
33
- ])
34
- ];
35
- };
36
- const createWranglerAssetsConfig = (configuredAssets)=>{
37
- if (void 0 !== configuredAssets && !isJsonRecord(configuredAssets)) throw new Error('deploy.worker.wrangler.assets must be an object.');
38
- return {
39
- ...isJsonRecord(configuredAssets) ? configuredAssets : {},
40
- directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
41
- binding: ASSETS_BINDING,
42
- run_worker_first: true
43
- };
44
- };
45
- const assertNonEmptyString = (value, label)=>{
46
- if ('string' != typeof value || 0 === value.trim().length) throw new Error(`${label} must be a non-empty string.`);
47
- return value.trim();
48
- };
49
- const normalizeD1Database = (database, index)=>{
50
- const binding = assertNonEmptyString(database.binding, `deploy.worker.d1Databases[${index}].binding`);
51
- const databaseName = assertNonEmptyString(database.databaseName, `deploy.worker.d1Databases[${index}].databaseName`);
52
- const databaseId = assertNonEmptyString(database.databaseId, `deploy.worker.d1Databases[${index}].databaseId`);
53
- const migrationsDir = void 0 === database.migrationsDir ? void 0 : normalizeRelativePath(database.migrationsDir, `deploy.worker.d1Databases[${index}].migrationsDir`, 'app root');
54
- const previewDatabaseId = void 0 === database.previewDatabaseId ? void 0 : assertNonEmptyString(database.previewDatabaseId, `deploy.worker.d1Databases[${index}].previewDatabaseId`);
55
- return {
56
- binding,
57
- database_name: databaseName,
58
- database_id: databaseId,
59
- ...void 0 === migrationsDir ? {} : {
60
- migrations_dir: migrationsDir
61
- },
62
- ...void 0 === previewDatabaseId ? {} : {
63
- preview_database_id: previewDatabaseId
64
- },
65
- ...void 0 === database.remote ? {} : {
66
- remote: database.remote
67
- }
68
- };
69
- };
70
- const createWranglerD1Databases = (modernConfig, configuredWranglerD1)=>{
71
- const d1Databases = modernConfig.deploy?.worker?.d1Databases;
72
- if (void 0 === d1Databases) return configuredWranglerD1;
73
- if (void 0 !== configuredWranglerD1) throw new Error('Use deploy.worker.d1Databases or deploy.worker.wrangler.d1_databases, not both.');
74
- if (!Array.isArray(d1Databases)) throw new Error('deploy.worker.d1Databases must be an array.');
75
- return d1Databases.map(normalizeD1Database);
76
- };
77
- const normalizeServiceBinding = (service, index)=>{
78
- const binding = assertNonEmptyString(service.binding, `deploy.worker.services[${index}].binding`);
79
- const serviceName = assertNonEmptyString(service.service, `deploy.worker.services[${index}].service`);
80
- const prefix = void 0 === service.prefix ? void 0 : assertNonEmptyString(service.prefix, `deploy.worker.services[${index}].prefix`);
81
- if (void 0 !== service.fragments && !Array.isArray(service.fragments)) throw new Error(`deploy.worker.services[${index}].fragments must be an array.`);
82
- const fragments = void 0 === service.fragments ? void 0 : service.fragments.map((fragment, fragmentIndex)=>({
83
- remote: assertNonEmptyString(fragment.remote, `deploy.worker.services[${index}].fragments[${fragmentIndex}].remote`),
84
- expose: assertNonEmptyString(fragment.expose, `deploy.worker.services[${index}].fragments[${fragmentIndex}].expose`),
85
- boundaryId: assertNonEmptyString(fragment.boundaryId, `deploy.worker.services[${index}].fragments[${fragmentIndex}].boundaryId`),
86
- path: assertNonEmptyString(fragment.path, `deploy.worker.services[${index}].fragments[${fragmentIndex}].path`)
87
- }));
88
- return {
89
- binding,
90
- service: serviceName,
91
- ...void 0 === prefix ? {} : {
92
- prefix
93
- },
94
- ...void 0 === fragments ? {} : {
95
- fragments
96
- }
97
- };
98
- };
99
- const createWorkerServiceBindings = (modernConfig, configuredWranglerServices)=>{
100
- const services = modernConfig.deploy?.worker?.services;
101
- if (void 0 === services) return configuredWranglerServices;
102
- if (void 0 !== configuredWranglerServices) throw new Error('Use deploy.worker.services or deploy.worker.wrangler.services, not both.');
103
- if (!Array.isArray(services)) throw new Error('deploy.worker.services must be an array.');
104
- return services.map(normalizeServiceBinding);
105
- };
106
- const createWranglerServices = (serviceBindings)=>{
107
- if (!Array.isArray(serviceBindings)) return serviceBindings;
108
- if (!serviceBindings.every(isJsonRecord)) return serviceBindings;
109
- return serviceBindings.map((service)=>{
110
- const { prefix, fragments, ...wranglerService } = service;
111
- return wranglerService;
112
- });
113
- };
114
- const createWorkerManifestServiceBindings = (serviceBindings)=>{
115
- if (!Array.isArray(serviceBindings)) return;
116
- const manifestBindings = serviceBindings.filter((service)=>isJsonRecord(service) && 'string' == typeof service.binding && 'string' == typeof service.service && ('string' == typeof service.prefix || Array.isArray(service.fragments) && service.fragments.length > 0)).map((service)=>({
117
- binding: service.binding,
118
- service: service.service,
119
- interface: 'fetch',
120
- ...void 0 === service.prefix ? {} : {
121
- prefix: service.prefix
122
- },
123
- ...void 0 === service.fragments ? {} : {
124
- fragments: service.fragments
125
- }
126
- }));
127
- return manifestBindings.length > 0 ? manifestBindings : void 0;
128
- };
129
- const createWranglerConfig = (appDirectory, modernConfig)=>{
130
- const wrangler = getConfiguredWrangler(modernConfig);
131
- const d1Databases = createWranglerD1Databases(modernConfig, wrangler.d1_databases);
132
- const serviceBindings = createWorkerServiceBindings(modernConfig, wrangler.services);
133
- const wranglerServices = createWranglerServices(serviceBindings);
134
- return {
135
- $schema: 'node_modules/wrangler/config-schema.json',
136
- name: getConfiguredWorkerName(appDirectory, modernConfig),
137
- compatibility_date: getCompatibilityDate(modernConfig),
138
- ...wrangler,
139
- main: WORKER_ENTRY,
140
- compatibility_flags: createWranglerCompatibilityFlags(wrangler.compatibility_flags),
141
- assets: createWranglerAssetsConfig(wrangler.assets),
142
- ...void 0 === d1Databases ? {} : {
143
- d1_databases: d1Databases
144
- },
145
- ...void 0 === wranglerServices ? {} : {
146
- services: wranglerServices
147
- }
148
- };
149
- };
150
- export { createWorkerManifestServiceBindings, createWorkerServiceBindings, createWranglerConfig };
@@ -1,31 +0,0 @@
1
- const CLOUDFLARE_WORKER_ENTRY = 'server/index.mjs';
2
- const CLOUDFLARE_WORKER_MANIFEST = 'server/modern-worker-manifest.json';
3
- const CLOUDFLARE_WRANGLER_CONFIG_FILE = 'wrangler.json';
4
- const CLOUDFLARE_OUTPUT_PACKAGE_FILE = 'package.json';
5
- const CLOUDFLARE_WORKER_PACKAGE_FILE = 'worker/package.json';
6
- const CLOUDFLARE_ASSETS_BINDING = 'ASSETS';
7
- const CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY = 'public';
8
- const CLOUDFLARE_WORKER_BUNDLE_DIRECTORY = 'worker';
9
- const CLOUDFLARE_RUNTIME_TYPE = 'cloudflare-module-worker';
10
- const CLOUDFLARE_OUTPUT_PACKAGE_TYPE = 'module';
11
- const CLOUDFLARE_WORKER_PACKAGE_TYPE = 'commonjs';
12
- const CLOUDFLARE_WORKER_BUNDLE_FORMAT = 'commonjs';
13
- const CLOUDFLARE_WORKER_NODE_BUILTINS = [
14
- 'async_hooks',
15
- 'buffer',
16
- 'crypto',
17
- 'events',
18
- 'fs/promises',
19
- 'module',
20
- 'path',
21
- 'process',
22
- 'stream',
23
- 'string_decoder',
24
- 'url',
25
- 'util'
26
- ];
27
- const CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS = [
28
- 'nodejs_compat',
29
- 'global_fetch_strictly_public'
30
- ];
31
- export { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_OUTPUT_PACKAGE_FILE, CLOUDFLARE_OUTPUT_PACKAGE_TYPE, 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_WORKER_NODE_BUILTINS, CLOUDFLARE_WORKER_PACKAGE_FILE, CLOUDFLARE_WORKER_PACKAGE_TYPE, CLOUDFLARE_WRANGLER_CONFIG_FILE };
@@ -1,45 +0,0 @@
1
- import node_path from "node:path";
2
- import { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_OUTPUT_PACKAGE_FILE, CLOUDFLARE_OUTPUT_PACKAGE_TYPE, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY, CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY, CLOUDFLARE_WORKER_ENTRY, CLOUDFLARE_WORKER_MANIFEST, CLOUDFLARE_WORKER_PACKAGE_FILE, CLOUDFLARE_WORKER_PACKAGE_TYPE, CLOUDFLARE_WRANGLER_CONFIG_FILE } from "./cloudflare-output-contract.mjs";
3
- const resolveOutput = (outputDirectory, relativePath)=>node_path.join(outputDirectory, relativePath);
4
- function createCloudflareOutputPlan(outputDirectory) {
5
- return {
6
- outputDirectory,
7
- requiredFiles: [
8
- CLOUDFLARE_WORKER_ENTRY,
9
- CLOUDFLARE_WORKER_MANIFEST,
10
- CLOUDFLARE_WRANGLER_CONFIG_FILE,
11
- CLOUDFLARE_OUTPUT_PACKAGE_FILE
12
- ],
13
- publicLeakDirectories: [
14
- 'server',
15
- CLOUDFLARE_WORKER_BUNDLE_DIRECTORY
16
- ],
17
- paths: {
18
- workerEntry: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_ENTRY),
19
- workerManifest: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_MANIFEST),
20
- wranglerConfig: resolveOutput(outputDirectory, CLOUDFLARE_WRANGLER_CONFIG_FILE),
21
- outputPackage: resolveOutput(outputDirectory, CLOUDFLARE_OUTPUT_PACKAGE_FILE),
22
- workerPackage: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_PACKAGE_FILE),
23
- publicAssets: resolveOutput(outputDirectory, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY),
24
- workerBundle: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY)
25
- },
26
- packages: {
27
- output: {
28
- type: CLOUDFLARE_OUTPUT_PACKAGE_TYPE
29
- },
30
- worker: {
31
- type: CLOUDFLARE_WORKER_PACKAGE_TYPE
32
- }
33
- },
34
- wrangler: {
35
- main: CLOUDFLARE_WORKER_ENTRY,
36
- assets: {
37
- binding: CLOUDFLARE_ASSETS_BINDING,
38
- directory: `./${CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY}`,
39
- run_worker_first: true
40
- },
41
- requiredCompatibilityFlags: CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS
42
- }
43
- };
44
- }
45
- export { createCloudflareOutputPlan };
@@ -1,45 +0,0 @@
1
- import { DELIVERY_UNIT_IDENTITY_FIELDS, deliveryUnitIdentityFieldValue } from "@modern-js/utils/universal";
2
- import { addIssue, assertEqual } from "./issues.mjs";
3
- const verifyDeliveryUnitIdentity = (issues, manifest, manifestPath, declared)=>{
4
- const stamped = manifest?.deliveryUnit;
5
- const hasStamp = Boolean(stamped) && 'object' == typeof stamped;
6
- if (declared) {
7
- if (!hasStamp) return void addIssue(issues, {
8
- code: 'missing-delivery-unit',
9
- message: `Cloudflare worker manifest is missing the delivery-unit identity declared by the workspace topology (expected unitId ${declared.unitId}, buildMarker ${declared.buildMarker}).`,
10
- path: manifestPath
11
- });
12
- for (const field of DELIVERY_UNIT_IDENTITY_FIELDS){
13
- const stampedValue = deliveryUnitIdentityFieldValue(stamped, field);
14
- assertEqual(issues, stampedValue, declared[field], {
15
- code: 'delivery-unit-drift',
16
- message: `Cloudflare worker manifest deliveryUnit.${field} must match the topology delivery-unit record (expected ${declared[field]}, received ${stampedValue ?? 'undefined'}).`,
17
- path: manifestPath
18
- });
19
- }
20
- }
21
- if (hasStamp && stamped.surfaces && 'object' == typeof stamped.surfaces) for (const surface of [
22
- 'ui',
23
- 'api'
24
- ]){
25
- const marker = stamped.surfaces[surface];
26
- if (!marker || 'object' != typeof marker) {
27
- addIssue(issues, {
28
- code: 'missing-delivery-unit',
29
- message: `Cloudflare worker manifest is missing the ${surface} delivery-unit surface marker.`,
30
- path: manifestPath
31
- });
32
- continue;
33
- }
34
- for (const field of DELIVERY_UNIT_IDENTITY_FIELDS){
35
- const markerValue = deliveryUnitIdentityFieldValue(marker, field);
36
- const stampedValue = deliveryUnitIdentityFieldValue(stamped, field);
37
- assertEqual(issues, markerValue, stampedValue, {
38
- code: 'delivery-unit-drift',
39
- message: `Cloudflare worker manifest ${surface} surface deliveryUnit.${field} must derive from one delivery-unit record (expected ${stampedValue ?? 'undefined'}, received ${markerValue ?? 'undefined'}).`,
40
- path: manifestPath
41
- });
42
- }
43
- }
44
- };
45
- export { verifyDeliveryUnitIdentity };
@@ -1,10 +0,0 @@
1
- const addIssue = (issues, issue)=>{
2
- issues.push(issue);
3
- };
4
- const assertEqual = (issues, actual, expected, issue)=>{
5
- if (actual !== expected) addIssue(issues, issue);
6
- };
7
- const assertFlag = (issues, flags, flag, issue)=>{
8
- if (!Array.isArray(flags) || !flags.includes(flag)) addIssue(issues, issue);
9
- };
10
- export { addIssue, assertEqual, assertFlag };
@@ -1,51 +0,0 @@
1
- import { BFF_EFFECT_WORKER_DISPATCHER_EXPORT } from "../cloudflare/constants.mjs";
2
- import { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_ENTRY } from "../cloudflare-output-contract.mjs";
3
- import { addIssue, assertEqual } from "./issues.mjs";
4
- const verifyManifestShape = (issues, manifest, manifestPath)=>{
5
- assertEqual(issues, manifest.runtime?.type, CLOUDFLARE_RUNTIME_TYPE, {
6
- code: 'invalid-manifest',
7
- message: 'Cloudflare output manifest runtime.type must be cloudflare-module-worker.',
8
- path: manifestPath
9
- });
10
- assertEqual(issues, manifest.runtime?.entry, CLOUDFLARE_WORKER_ENTRY, {
11
- code: 'invalid-manifest',
12
- message: `Cloudflare output manifest runtime.entry must be ${CLOUDFLARE_WORKER_ENTRY}.`,
13
- path: manifestPath
14
- });
15
- assertEqual(issues, manifest.runtime?.fetchExport, true, {
16
- code: 'invalid-manifest',
17
- message: 'Cloudflare output manifest runtime.fetchExport must be true.',
18
- path: manifestPath
19
- });
20
- assertEqual(issues, manifest.runtime?.nodeListen, false, {
21
- code: 'invalid-manifest',
22
- message: 'Cloudflare output manifest runtime.nodeListen must be false.',
23
- path: manifestPath
24
- });
25
- assertEqual(issues, manifest.assets?.binding, CLOUDFLARE_ASSETS_BINDING, {
26
- code: 'invalid-manifest',
27
- message: 'Cloudflare output manifest assets.binding must be ASSETS.',
28
- path: manifestPath
29
- });
30
- assertEqual(issues, manifest.assets?.directory, `./${CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY}`, {
31
- code: 'invalid-manifest',
32
- message: 'Cloudflare output manifest assets.directory must be ./public.',
33
- path: manifestPath
34
- });
35
- assertEqual(issues, manifest.assets?.runWorkerFirst, true, {
36
- code: 'invalid-manifest',
37
- message: 'Cloudflare output manifest assets.runWorkerFirst must be true.',
38
- path: manifestPath
39
- });
40
- if (!Array.isArray(manifest.routeSpec?.routes)) addIssue(issues, {
41
- code: 'invalid-manifest',
42
- message: 'Cloudflare output manifest routeSpec.routes must be array.',
43
- path: manifestPath
44
- });
45
- if (manifest.bff?.runtimeFramework === 'effect') assertEqual(issues, manifest.bff.dispatcherExport, BFF_EFFECT_WORKER_DISPATCHER_EXPORT, {
46
- code: 'invalid-manifest',
47
- message: `Cloudflare Effect BFF manifest dispatcherExport must be ${BFF_EFFECT_WORKER_DISPATCHER_EXPORT}.`,
48
- path: manifestPath
49
- });
50
- };
51
- export { verifyManifestShape };
@@ -1,99 +0,0 @@
1
- import promises from "node:fs/promises";
2
- import node_path from "node:path";
3
- import { addIssue } from "./issues.mjs";
4
- const SOURCE_SCAN_FILE_PATTERN = /\.(?:[cm]?[jt]s|json)$/u;
5
- const SOURCE_SCAN_IGNORED_DIRECTORY_NAMES = new Set([
6
- '.codex',
7
- '.fastcontext',
8
- '.git',
9
- '.mf',
10
- '.modernjs',
11
- '.output',
12
- 'coverage',
13
- 'dist',
14
- 'dist-cloudflare',
15
- 'node_modules',
16
- 'repos',
17
- 'topology'
18
- ]);
19
- const FORBIDDEN_MUTATION_PATTERNS = [
20
- {
21
- code: 'forbidden-mutation-pattern',
22
- message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
23
- pattern: /\.output\/server\/index\.mjs/u
24
- },
25
- {
26
- code: 'forbidden-mutation-pattern',
27
- message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
28
- pattern: /path\.(?:join|resolve)\(\s*['"`]\.output['"`]\s*,\s*['"`]server['"`]\s*,\s*['"`]index\.mjs['"`]\s*\)/u
29
- },
30
- {
31
- code: 'forbidden-mutation-pattern',
32
- message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
33
- pattern: /\.output\/worker\/[^'"`]*\.(?:mjs|cjs|js)/u
34
- },
35
- {
36
- code: 'forbidden-mutation-pattern',
37
- message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
38
- pattern: /path\.(?:join|resolve)\(\s*['"`]\.output['"`]\s*,\s*['"`]worker['"`]\s*,\s*['"`][^'"`]+\.(?:mjs|cjs|js)['"`]\s*\)/u
39
- },
40
- {
41
- code: 'forbidden-mutation-pattern',
42
- message: "Drizzle entityKind worker bundle markers must be fixed in the framework toolchain, not post-build scripts.",
43
- pattern: /replaceAll\(\s*['"`];entityKind(?:,entityKind)?;/u
44
- },
45
- {
46
- code: 'forbidden-mutation-pattern',
47
- message: "Effect BFF Cloudflare dispatch must not depend on duck-typed runtime helper probing in app scripts.",
48
- pattern: /(?:typeof\s+[^;\n]*dispatchEffectBffRequest|['"`]dispatchEffectBffRequest['"`]\s+in\s+|\.dispatchEffectBffRequest\b)/u
49
- },
50
- {
51
- code: 'forbidden-mutation-pattern',
52
- message: "Effect BFF Cloudflare dispatch must not branch on handler.length in app scripts.",
53
- pattern: /\bhandler\s*\.\s*length\b/u
54
- }
55
- ];
56
- const pathExists = async (filePath)=>{
57
- try {
58
- await promises.access(filePath);
59
- return true;
60
- } catch {
61
- return false;
62
- }
63
- };
64
- const walkFiles = async (root)=>{
65
- if (!await pathExists(root)) return [];
66
- const entries = await promises.readdir(root, {
67
- withFileTypes: true
68
- });
69
- const files = [];
70
- for (const entry of entries){
71
- if (SOURCE_SCAN_IGNORED_DIRECTORY_NAMES.has(entry.name)) continue;
72
- const entryPath = node_path.join(root, entry.name);
73
- if (entry.isDirectory()) {
74
- files.push(...await walkFiles(entryPath));
75
- continue;
76
- }
77
- if (SOURCE_SCAN_FILE_PATTERN.test(entry.name)) files.push(entryPath);
78
- }
79
- return files;
80
- };
81
- const verifyCloudflareOutputMutationPolicy = async (options)=>{
82
- const issues = [];
83
- const excludedFiles = new Set((options.excludePaths ?? []).map((entry)=>node_path.resolve(entry)));
84
- const files = (await Promise.all(options.scanRoots.map((scanRoot)=>walkFiles(node_path.resolve(scanRoot))))).flat();
85
- for (const file of files){
86
- if (excludedFiles.has(file)) continue;
87
- const source = await promises.readFile(file, 'utf-8');
88
- for (const forbidden of FORBIDDEN_MUTATION_PATTERNS)if (forbidden.pattern.test(source)) addIssue(issues, {
89
- code: forbidden.code,
90
- message: forbidden.message,
91
- path: file
92
- });
93
- }
94
- return {
95
- ok: 0 === issues.length,
96
- issues
97
- };
98
- };
99
- export { verifyCloudflareOutputMutationPolicy, walkFiles };