@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,335 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import promises from "node:fs/promises";
3
- import node_path from "node:path";
4
- import { canonicalSerializeMicroVerticalReleaseEnvelope, digestMicroVerticalReleaseEnvelopePayload, releaseEnvelopePayload } from "./canonical.mjs";
5
- import { MICROVERTICAL_RELEASE_ENVELOPE_KIND, MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION, MICROVERTICAL_RELEASE_TARGETS } from "./types.mjs";
6
- const SHA256_PATTERN = /^[a-f0-9]{64}$/u;
7
- const SOURCE_REVISION_PATTERN = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;
8
- const TARGETS = new Set(MICROVERTICAL_RELEASE_TARGETS);
9
- const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
10
- const assertRecord = (value, location)=>{
11
- if (!isRecord(value)) throw new Error(`${location} must be an object.`);
12
- return value;
13
- };
14
- const assertExactKeys = (value, expected, location)=>{
15
- const expectedKeys = new Set(expected);
16
- for (const key of Object.keys(value))if (!expectedKeys.has(key)) throw new Error(`${location} contains unknown field "${key}".`);
17
- for (const key of expected)if (!(key in value)) throw new Error(`${location}.${key} is required.`);
18
- };
19
- const assertNonEmptyString = (value, location)=>{
20
- if ('string' != typeof value || 0 === value.trim().length) throw new Error(`${location} must be a non-empty string.`);
21
- if (value !== value.trim()) throw new Error(`${location} must not contain surrounding whitespace.`);
22
- return value;
23
- };
24
- const assertTarget = (value, location = 'target')=>{
25
- const target = assertNonEmptyString(value, location);
26
- if (!TARGETS.has(target)) throw new Error(`${location} must be one of: ${MICROVERTICAL_RELEASE_TARGETS.join(', ')}.`);
27
- return target;
28
- };
29
- const assertReleaseIdentity = (value, location = 'identity')=>{
30
- const identity = assertRecord(value, location);
31
- assertExactKeys(identity, [
32
- 'unitId',
33
- 'buildMarker',
34
- 'sourceRevision',
35
- 'releaseVersion'
36
- ], location);
37
- const sourceRevision = assertNonEmptyString(identity.sourceRevision, `${location}.sourceRevision`);
38
- if (!SOURCE_REVISION_PATTERN.test(sourceRevision)) throw new Error(`${location}.sourceRevision must be an exact lowercase 40- or 64-character Git object ID; "${sourceRevision}" is not promotable.`);
39
- return {
40
- unitId: assertNonEmptyString(identity.unitId, `${location}.unitId`),
41
- buildMarker: assertNonEmptyString(identity.buildMarker, `${location}.buildMarker`),
42
- sourceRevision,
43
- releaseVersion: assertNonEmptyString(identity.releaseVersion, `${location}.releaseVersion`)
44
- };
45
- };
46
- const assertNormalizedLogicalPath = (value, location)=>{
47
- const logicalPath = assertNonEmptyString(value, location);
48
- if (logicalPath.includes('\\') || node_path.posix.isAbsolute(logicalPath) || node_path.posix.normalize(logicalPath) !== logicalPath || '.' === logicalPath || logicalPath.split('/').some((segment)=>'..' === segment || '.' === segment)) throw new Error(`${location} must be a normalized relative POSIX path.`);
49
- return logicalPath;
50
- };
51
- const isPathInside = (root, candidate)=>{
52
- const relative = node_path.relative(root, candidate);
53
- return '' === relative || !relative.startsWith(`..${node_path.sep}`) && '..' !== relative && !node_path.isAbsolute(relative);
54
- };
55
- const assertArtifactInput = (value, location)=>{
56
- const artifact = assertRecord(value, location);
57
- assertExactKeys(artifact, [
58
- 'logicalPath',
59
- 'runtime'
60
- ], location);
61
- return {
62
- logicalPath: assertNormalizedLogicalPath(artifact.logicalPath, `${location}.logicalPath`),
63
- runtime: assertNonEmptyString(artifact.runtime, `${location}.runtime`)
64
- };
65
- };
66
- const readFinalArtifact = async (artifactRoot, input, resolvedLogicalPath = input.logicalPath)=>{
67
- const artifactInput = {
68
- logicalPath: input.logicalPath,
69
- runtime: input.runtime
70
- };
71
- const logicalPath = assertNormalizedLogicalPath(resolvedLogicalPath, `staged path for ${input.logicalPath}`);
72
- const resolvedRoot = node_path.resolve(artifactRoot);
73
- const logicalSegments = logicalPath.split('/');
74
- const lexicalPath = node_path.resolve(resolvedRoot, ...logicalSegments);
75
- if (!isPathInside(resolvedRoot, lexicalPath)) throw new Error(`Artifact logicalPath "${logicalPath}" resolves outside artifactRoot.`);
76
- const realRoot = await promises.realpath(resolvedRoot);
77
- for(let index = 0; index < logicalSegments.length - 1; index++){
78
- const linkLogicalPath = logicalSegments.slice(0, index + 1).join('/');
79
- const candidate = node_path.join(resolvedRoot, ...logicalSegments.slice(0, index + 1));
80
- let candidateStat;
81
- try {
82
- candidateStat = await promises.lstat(candidate);
83
- } catch {
84
- throw new Error(`Artifact "${logicalPath}" does not exist.`);
85
- }
86
- if (candidateStat.isSymbolicLink()) throw new Error(`Artifact "${logicalPath}" traverses symbolic-link ancestor "${linkLogicalPath}"; bind the symbolic link itself.`);
87
- }
88
- let lexicalStat;
89
- try {
90
- lexicalStat = await promises.lstat(lexicalPath);
91
- } catch {
92
- throw new Error(`Artifact "${logicalPath}" does not exist.`);
93
- }
94
- if (lexicalStat.isSymbolicLink()) {
95
- let realTarget;
96
- try {
97
- realTarget = await promises.realpath(lexicalPath);
98
- } catch {
99
- throw new Error(`Artifact symbolic link "${logicalPath}" cannot be resolved.`);
100
- }
101
- if (!isPathInside(realRoot, realTarget)) throw new Error(`Artifact logicalPath "${logicalPath}" resolves outside artifactRoot.`);
102
- const targetStat = await promises.stat(realTarget);
103
- const targetKind = targetStat.isFile() ? 'file' : targetStat.isDirectory() ? 'directory' : void 0;
104
- if (!targetKind) throw new Error(`Artifact symbolic link "${logicalPath}" must resolve to a file or directory.`);
105
- const targetLogicalPath = node_path.relative(realRoot, realTarget).split(node_path.sep).join('/');
106
- if ('release' === targetLogicalPath || targetLogicalPath.startsWith('release/')) throw new Error(`Artifact symbolic link "${logicalPath}" targets private release metadata.`);
107
- if ('directory' === targetKind && isPathInside(realTarget, await promises.realpath(node_path.dirname(lexicalPath)))) throw new Error(`Artifact symbolic link "${logicalPath}" targets an ancestor directory.`);
108
- return {
109
- ...artifactInput,
110
- kind: 'symbolic-link',
111
- linkTarget: await promises.readlink(lexicalPath),
112
- targetKind,
113
- targetLogicalPath
114
- };
115
- }
116
- if (!lexicalStat.isFile()) throw new Error(`Artifact "${logicalPath}" must be a file or symlink.`);
117
- const realPath = await promises.realpath(lexicalPath);
118
- if (!isPathInside(realRoot, realPath)) throw new Error(`Artifact logicalPath "${logicalPath}" resolves outside artifactRoot.`);
119
- const bytes = await promises.readFile(realPath);
120
- return {
121
- ...artifactInput,
122
- kind: 'file',
123
- byteLength: bytes.byteLength,
124
- sha256: createHash('sha256').update(bytes).digest('hex')
125
- };
126
- };
127
- const assertReleaseArtifact = (value, location)=>{
128
- const artifact = assertRecord(value, location);
129
- const kind = assertNonEmptyString(artifact.kind, `${location}.kind`);
130
- const input = {
131
- logicalPath: artifact.logicalPath,
132
- runtime: artifact.runtime
133
- };
134
- if ('file' === kind) {
135
- assertExactKeys(artifact, [
136
- 'kind',
137
- 'logicalPath',
138
- 'runtime',
139
- 'byteLength',
140
- 'sha256'
141
- ], location);
142
- const byteLength = artifact.byteLength;
143
- if ('number' != typeof byteLength || !Number.isSafeInteger(byteLength) || byteLength < 0) throw new Error(`${location}.byteLength must be a non-negative integer.`);
144
- const sha256 = assertNonEmptyString(artifact.sha256, `${location}.sha256`);
145
- if (!SHA256_PATTERN.test(sha256)) throw new Error(`${location}.sha256 must be a lowercase SHA-256 digest.`);
146
- return {
147
- ...assertArtifactInput(input, location),
148
- kind,
149
- byteLength,
150
- sha256
151
- };
152
- }
153
- if ('symbolic-link' === kind) {
154
- assertExactKeys(artifact, [
155
- 'kind',
156
- 'logicalPath',
157
- 'runtime',
158
- 'linkTarget',
159
- 'targetKind',
160
- 'targetLogicalPath'
161
- ], location);
162
- const targetKind = assertNonEmptyString(artifact.targetKind, `${location}.targetKind`);
163
- if ('directory' !== targetKind && 'file' !== targetKind) throw new Error(`${location}.targetKind must be "directory" or "file".`);
164
- return {
165
- ...assertArtifactInput(input, location),
166
- kind,
167
- linkTarget: assertNonEmptyString(artifact.linkTarget, `${location}.linkTarget`),
168
- targetKind,
169
- targetLogicalPath: assertNormalizedLogicalPath(artifact.targetLogicalPath, `${location}.targetLogicalPath`)
170
- };
171
- }
172
- throw new Error(`${location}.kind must be "file" or "symbolic-link".`);
173
- };
174
- const assertUniqueSortedArtifacts = (artifacts, location)=>{
175
- const paths = artifacts.map((artifact)=>artifact.logicalPath);
176
- const unique = new Set(paths);
177
- if (unique.size !== paths.length) {
178
- const duplicate = paths.find((logicalPath, index)=>paths.indexOf(logicalPath) !== index);
179
- throw new Error(`Duplicate artifact logicalPath "${duplicate}".`);
180
- }
181
- const sorted = [
182
- ...paths
183
- ].sort((left, right)=>left.localeCompare(right));
184
- if (paths.some((logicalPath, index)=>logicalPath !== sorted[index])) throw new Error(`${location} must be sorted by logicalPath.`);
185
- };
186
- const assertSurfacePaths = (value, location)=>{
187
- if (!Array.isArray(value) || 0 === value.length) throw new Error(`${location} must contain at least one artifact path.`);
188
- const paths = value.map((item, index)=>assertNormalizedLogicalPath(item, `${location}[${index}]`));
189
- const sorted = [
190
- ...paths
191
- ].sort((left, right)=>left.localeCompare(right));
192
- if (paths.some((logicalPath, index)=>logicalPath !== sorted[index])) throw new Error(`${location} must be sorted by logicalPath.`);
193
- if (new Set(paths).size !== paths.length) throw new Error(`${location} must not contain duplicate artifact paths.`);
194
- return paths;
195
- };
196
- const assertSurfaces = (value)=>{
197
- const surfaces = assertRecord(value, 'surfaces');
198
- assertExactKeys(surfaces, [
199
- 'uiClient',
200
- 'ssr',
201
- 'apiBackend',
202
- 'backendFederation'
203
- ], 'surfaces');
204
- const backendFederation = assertRecord(surfaces.backendFederation, 'surfaces.backendFederation');
205
- assertExactKeys(backendFederation, [
206
- 'manifest',
207
- 'container'
208
- ], 'surfaces.backendFederation');
209
- return {
210
- uiClient: assertSurfacePaths(surfaces.uiClient, 'surfaces.uiClient'),
211
- ssr: assertSurfacePaths(surfaces.ssr, 'surfaces.ssr'),
212
- apiBackend: assertSurfacePaths(surfaces.apiBackend, 'surfaces.apiBackend'),
213
- backendFederation: {
214
- manifest: assertNormalizedLogicalPath(backendFederation.manifest, 'surfaces.backendFederation.manifest'),
215
- container: assertNormalizedLogicalPath(backendFederation.container, 'surfaces.backendFederation.container')
216
- }
217
- };
218
- };
219
- const assertSurfaceReferences = (artifacts, surfaces)=>{
220
- const artifactPaths = new Set(artifacts.map((artifact)=>artifact.logicalPath));
221
- for (const [surface, paths] of Object.entries({
222
- uiClient: surfaces.uiClient,
223
- ssr: surfaces.ssr,
224
- apiBackend: surfaces.apiBackend,
225
- 'backendFederation.manifest': [
226
- surfaces.backendFederation.manifest
227
- ],
228
- 'backendFederation.container': [
229
- surfaces.backendFederation.container
230
- ]
231
- }))for (const logicalPath of paths)if (!artifactPaths.has(logicalPath)) throw new Error(`surfaces.${surface} references unbound artifact "${logicalPath}".`);
232
- };
233
- const assertTargetSurfaceContract = (target, artifacts, surfaces)=>{
234
- const byPath = new Map(artifacts.map((artifact)=>[
235
- artifact.logicalPath,
236
- artifact
237
- ]));
238
- const assertRuntime = (paths, expected, surface)=>{
239
- for (const logicalPath of paths){
240
- const artifact = byPath.get(logicalPath);
241
- if (artifact?.runtime !== expected) throw new Error(`${target} ${surface} artifact "${logicalPath}" must use runtime "${expected}"; received "${String(artifact?.runtime)}".`);
242
- if ('kind' in artifact && 'file' !== artifact.kind) throw new Error(`${target} ${surface} artifact "${logicalPath}" must be a file.`);
243
- }
244
- };
245
- assertRuntime(surfaces.uiClient, 'browser', 'UI/client');
246
- assertRuntime(surfaces.ssr, 'node' === target ? 'nodejs' : 'workerd', 'SSR');
247
- assertRuntime(surfaces.apiBackend, 'node' === target ? 'nodejs' : 'workerd-effect', 'API/backend');
248
- assertRuntime([
249
- surfaces.backendFederation.manifest
250
- ], 'module-federation-manifest', 'backend federation manifest');
251
- assertRuntime([
252
- surfaces.backendFederation.container
253
- ], 'node' === target ? 'nodejs' : 'commonjs-module', 'backend federation container');
254
- };
255
- const deepFreeze = (value)=>{
256
- if (null !== value && 'object' == typeof value && !Object.isFrozen(value)) {
257
- Object.freeze(value);
258
- for (const child of Object.values(value))deepFreeze(child);
259
- }
260
- return value;
261
- };
262
- const assertEnvelope = (value)=>{
263
- const envelope = assertRecord(value, 'envelope');
264
- assertExactKeys(envelope, [
265
- 'schemaVersion',
266
- 'kind',
267
- 'target',
268
- 'identity',
269
- 'artifacts',
270
- 'surfaces',
271
- 'envelopeDigest'
272
- ], 'envelope');
273
- if (envelope.schemaVersion !== MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION) throw new Error(`envelope.schemaVersion must be ${MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION}.`);
274
- if (envelope.kind !== MICROVERTICAL_RELEASE_ENVELOPE_KIND) throw new Error(`envelope.kind must be "${MICROVERTICAL_RELEASE_ENVELOPE_KIND}".`);
275
- if (!Array.isArray(envelope.artifacts) || 0 === envelope.artifacts.length) throw new Error('envelope.artifacts must contain at least one artifact.');
276
- const artifacts = envelope.artifacts.map((artifact, index)=>assertReleaseArtifact(artifact, `envelope.artifacts[${index}]`));
277
- assertUniqueSortedArtifacts(artifacts, 'envelope.artifacts');
278
- const target = assertTarget(envelope.target, 'envelope.target');
279
- const surfaces = assertSurfaces(envelope.surfaces);
280
- assertSurfaceReferences(artifacts, surfaces);
281
- assertTargetSurfaceContract(target, artifacts, surfaces);
282
- const parsed = {
283
- schemaVersion: MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION,
284
- kind: MICROVERTICAL_RELEASE_ENVELOPE_KIND,
285
- target,
286
- identity: assertReleaseIdentity(envelope.identity, 'envelope.identity'),
287
- artifacts,
288
- surfaces,
289
- envelopeDigest: assertNonEmptyString(envelope.envelopeDigest, 'envelope.envelopeDigest')
290
- };
291
- if (!SHA256_PATTERN.test(parsed.envelopeDigest)) throw new Error('envelope.envelopeDigest must be a lowercase SHA-256 digest.');
292
- const expectedDigest = digestMicroVerticalReleaseEnvelopePayload(releaseEnvelopePayload(parsed));
293
- if (parsed.envelopeDigest !== expectedDigest) throw new Error('envelope.envelopeDigest does not match canonical payload.');
294
- return parsed;
295
- };
296
- const createMicroVerticalReleaseEnvelope = async (input)=>{
297
- const artifactRoot = await promises.realpath(node_path.resolve(input.artifactRoot));
298
- const target = assertTarget(input.target);
299
- const identity = assertReleaseIdentity(input.identity);
300
- if (!Array.isArray(input.artifacts) || 0 === input.artifacts.length) throw new Error('artifacts must contain at least one artifact.');
301
- const inputs = input.artifacts.map((artifact, index)=>assertArtifactInput(artifact, `artifacts[${index}]`));
302
- const sortedInputs = [
303
- ...inputs
304
- ].sort((left, right)=>left.logicalPath.localeCompare(right.logicalPath));
305
- assertUniqueSortedArtifacts(sortedInputs, 'artifacts');
306
- const surfaces = assertSurfaces(input.surfaces);
307
- assertSurfaceReferences(sortedInputs, surfaces);
308
- assertTargetSurfaceContract(target, sortedInputs, surfaces);
309
- const artifacts = await Promise.all(sortedInputs.map((artifact)=>readFinalArtifact(artifactRoot, artifact)));
310
- assertTargetSurfaceContract(target, artifacts, surfaces);
311
- const payload = {
312
- schemaVersion: MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION,
313
- kind: MICROVERTICAL_RELEASE_ENVELOPE_KIND,
314
- target,
315
- identity,
316
- artifacts,
317
- surfaces
318
- };
319
- return deepFreeze({
320
- ...payload,
321
- envelopeDigest: digestMicroVerticalReleaseEnvelopePayload(payload)
322
- });
323
- };
324
- const verifyMicroVerticalReleaseEnvelope = async (value, options)=>{
325
- const envelope = assertEnvelope(value);
326
- if (void 0 !== options.expectedTarget && envelope.target !== options.expectedTarget) throw new Error(`envelope.target must be "${options.expectedTarget}" for this staging target; received "${envelope.target}".`);
327
- const artifactRoot = await promises.realpath(node_path.resolve(options.artifactRoot));
328
- for (const artifact of envelope.artifacts){
329
- const finalArtifact = await readFinalArtifact(artifactRoot, artifact, options.logicalPathForArtifact?.(artifact) ?? artifact.logicalPath);
330
- const matches = finalArtifact.kind === artifact.kind && ('file' === artifact.kind && 'file' === finalArtifact.kind ? finalArtifact.byteLength === artifact.byteLength && finalArtifact.sha256 === artifact.sha256 : 'symbolic-link' === artifact.kind && 'symbolic-link' === finalArtifact.kind && finalArtifact.linkTarget === artifact.linkTarget && finalArtifact.targetKind === artifact.targetKind && finalArtifact.targetLogicalPath === artifact.targetLogicalPath);
331
- if (!matches) throw new Error('file' === artifact.kind && 'file' === finalArtifact.kind ? `Artifact "${artifact.logicalPath}" digest does not match final artifact bytes.` : `Artifact "${artifact.logicalPath}" does not match its final filesystem binding.`);
332
- }
333
- return deepFreeze(envelope);
334
- };
335
- export { MICROVERTICAL_RELEASE_ENVELOPE_KIND, MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION, MICROVERTICAL_RELEASE_TARGETS, canonicalSerializeMicroVerticalReleaseEnvelope, createMicroVerticalReleaseEnvelope, verifyMicroVerticalReleaseEnvelope };
@@ -1,7 +0,0 @@
1
- const MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION = 3;
2
- const MICROVERTICAL_RELEASE_ENVELOPE_KIND = 'ultramodern-target-microvertical-release-envelope';
3
- const MICROVERTICAL_RELEASE_TARGETS = [
4
- 'node',
5
- 'cloudflare'
6
- ];
7
- export { MICROVERTICAL_RELEASE_ENVELOPE_KIND, MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION, MICROVERTICAL_RELEASE_TARGETS };
@@ -1,66 +0,0 @@
1
- import { execFileSync } from "node:child_process";
2
- import { createHash } from "node:crypto";
3
- const BUILD_MARKER_NAMESPACE = 'ultramodern-delivery-unit-release-build-marker:v1';
4
- const PROMOTABLE_SOURCE_REVISION_PATTERN = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;
5
- const gitOutput = (workspaceRoot, args)=>{
6
- try {
7
- return execFileSync('git', [
8
- '-C',
9
- workspaceRoot,
10
- ...args
11
- ], {
12
- encoding: 'utf8',
13
- stdio: [
14
- 'ignore',
15
- 'pipe',
16
- 'ignore'
17
- ]
18
- }).trim();
19
- } catch {
20
- return;
21
- }
22
- };
23
- const createUltramodernReleaseBuildMarker = ({ generationBuildMarker, sourceRevision, unitId })=>createHash('sha256').update(`${BUILD_MARKER_NAMESPACE}:${unitId}:${generationBuildMarker}:${sourceRevision}`).digest('hex').slice(0, 16);
24
- const resolveUltramodernSourceRevision = (workspaceRoot = process.cwd(), configuredSourceRevision)=>{
25
- const configuredArgumentValue = configuredSourceRevision?.trim();
26
- const configuredEnvironmentValue = process.env.ULTRAMODERN_SOURCE_REVISION?.trim();
27
- const configuredArgument = configuredArgumentValue && 'workspace' !== configuredArgumentValue ? configuredArgumentValue : void 0;
28
- const configuredEnvironment = configuredEnvironmentValue && 'workspace' !== configuredEnvironmentValue ? configuredEnvironmentValue : void 0;
29
- if (configuredArgument && configuredEnvironment && configuredArgument !== configuredEnvironment) throw new Error(`Configured source revision ${configuredArgument} does not match environment source revision ${configuredEnvironment}.`);
30
- const configured = configuredArgument ?? configuredEnvironment;
31
- const gitRoot = gitOutput(workspaceRoot, [
32
- 'rev-parse',
33
- '--show-toplevel'
34
- ]);
35
- if (!gitRoot) {
36
- if (!configured) return 'workspace';
37
- if (!PROMOTABLE_SOURCE_REVISION_PATTERN.test(configured)) throw new Error(`Configured source revision ${configured} must be an exact lowercase 40- or 64-character Git object ID.`);
38
- return configured;
39
- }
40
- const revision = gitOutput(gitRoot, [
41
- 'rev-parse',
42
- 'HEAD'
43
- ]);
44
- const status = gitOutput(gitRoot, [
45
- 'status',
46
- '--porcelain=v1',
47
- '--untracked-files=all'
48
- ]);
49
- if (!revision || void 0 === status || status.length > 0) return 'workspace';
50
- if (!PROMOTABLE_SOURCE_REVISION_PATTERN.test(revision)) return 'workspace';
51
- if (configured && configured !== revision) throw new Error(`Configured source revision ${configured} does not match clean Git HEAD ${revision}.`);
52
- return revision;
53
- };
54
- const resolveUltramodernReleaseIdentity = ({ generationBuildMarker, sourceRevision: configuredSourceRevision, unitId, workspaceRoot })=>{
55
- const explicitSourceRevision = configuredSourceRevision?.trim();
56
- const sourceRevision = resolveUltramodernSourceRevision(workspaceRoot, explicitSourceRevision);
57
- return {
58
- buildMarker: 'workspace' === sourceRevision ? generationBuildMarker : createUltramodernReleaseBuildMarker({
59
- generationBuildMarker,
60
- sourceRevision,
61
- unitId
62
- }),
63
- sourceRevision
64
- };
65
- };
66
- export { createUltramodernReleaseBuildMarker, resolveUltramodernReleaseIdentity, resolveUltramodernSourceRevision };
@@ -1,37 +0,0 @@
1
- import "node:module";
2
- import { isUseRsc, logger } from "@modern-js/utils";
3
- import { aggregateEagerRouteComponentFiles, planRouteEagerLazyCompilation } from "../lazyCompilation.mjs";
4
- const builderPluginAdapterLazyCompilation = (options)=>({
5
- name: 'builder-plugin-adapter-modern-lazy-compilation',
6
- setup (api) {
7
- api.modifyRsbuildConfig((config)=>{
8
- const lazyCompilation = getRouteEagerLazyCompilation(options, config);
9
- if (void 0 === lazyCompilation) return config;
10
- return {
11
- ...config,
12
- dev: {
13
- ...config.dev,
14
- lazyCompilation
15
- }
16
- };
17
- });
18
- }
19
- });
20
- function getRouteEagerLazyCompilation(options, config) {
21
- const current = config.dev?.lazyCompilation;
22
- if (!current || isUseRsc(options.normalizedConfig)) return;
23
- const plan = planRouteEagerLazyCompilation(current, aggregateEagerRouteComponentFiles(options.eagerRouteComponentFilesByEntry));
24
- if (!plan.apply) {
25
- if (plan.unresolvedByEntry) warnUnresolvedRouteComponents(options.appContext.appDirectory, plan.unresolvedByEntry);
26
- return;
27
- }
28
- return plan.lazyCompilation;
29
- }
30
- const warnedLazyApps = new Set();
31
- function warnUnresolvedRouteComponents(appDirectory, unresolvedByEntry) {
32
- if (warnedLazyApps.has(appDirectory)) return;
33
- warnedLazyApps.add(appDirectory);
34
- const detail = Array.from(unresolvedByEntry).map(([entry, components])=>`${entry}: ${components.join(', ')}`).join('; ');
35
- logger.warn(`[lazyCompilation] Skipped route-eager optimization because some route components could not be resolved to a file (${detail}). Lazy compilation may delay route rendering for these routes.`);
36
- }
37
- export { builderPluginAdapterLazyCompilation };
@@ -1,31 +0,0 @@
1
- import "node:module";
2
- const PLUGIN_NAME = 'ModernjsCssExtractRuntimePlugin';
3
- const CSS_LOADING_RUNTIME_MODULE = 'webpack/runtime/css loading';
4
- const CSS_EXTRACT_STYLESHEET_MATCH = '\t\tif (tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return tag;';
5
- const CSS_EXTRACT_STYLESHEET_MATCH_WITH_NORMALIZED_URL = `\t\tvar absoluteHref = tag.href;
6
- \t\tvar absoluteFullHref = new URL(fullhref, document.baseURI).href;
7
- \t\tif (tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref || absoluteHref === absoluteFullHref)) return tag;`;
8
- const isAutomaticPublicPath = (publicPath)=>'auto' === publicPath || 'auto/' === publicPath;
9
- const normalizeCssExtractRuntimeStylesheetLookup = (source)=>{
10
- if (!source.includes('__webpack_require__.miniCssF')) return source;
11
- const occurrences = source.split(CSS_EXTRACT_STYLESHEET_MATCH).length - 1;
12
- if (1 !== occurrences) throw new Error(`Unsupported CssExtractRspackPlugin runtime shape: expected one stylesheet lookup, found ${occurrences}.`);
13
- return source.replace(CSS_EXTRACT_STYLESHEET_MATCH, CSS_EXTRACT_STYLESHEET_MATCH_WITH_NORMALIZED_URL);
14
- };
15
- class CssExtractRuntimePlugin {
16
- apply(compiler) {
17
- if (!isAutomaticPublicPath(compiler.options.output.publicPath)) return;
18
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation)=>{
19
- compilation.hooks.runtimeModule.tap(PLUGIN_NAME, (runtimeModule)=>{
20
- if (runtimeModule.identifier() !== CSS_LOADING_RUNTIME_MODULE) return;
21
- const runtimeSource = runtimeModule.source?.source;
22
- if ('string' != typeof runtimeSource) return;
23
- runtimeModule.source.source = normalizeCssExtractRuntimeStylesheetLookup(runtimeSource);
24
- });
25
- });
26
- }
27
- constructor(){
28
- this.name = PLUGIN_NAME;
29
- }
30
- }
31
- export { CssExtractRuntimePlugin, normalizeCssExtractRuntimeStylesheetLookup };
@@ -1,65 +0,0 @@
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 };
@@ -1,35 +0,0 @@
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 };