@ecopages/core 0.2.0-rc.1 → 0.2.0-rc.11

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 (278) hide show
  1. package/README.md +50 -41
  2. package/package.json +50 -145
  3. package/src/adapters/README.md +11 -3
  4. package/src/adapters/abstract/application-adapter.d.ts +32 -36
  5. package/src/adapters/abstract/application-adapter.js +61 -47
  6. package/src/adapters/abstract/segment-path-matcher.js +56 -38
  7. package/src/adapters/abstract/server-adapter.d.ts +14 -0
  8. package/src/adapters/abstract/server-adapter.js +10 -0
  9. package/src/adapters/abstract/ws-pattern-matcher.d.ts +0 -5
  10. package/src/adapters/abstract/ws-pattern-matcher.js +0 -9
  11. package/src/adapters/bun/create-app.d.ts +15 -15
  12. package/src/adapters/bun/create-app.js +52 -67
  13. package/src/adapters/bun/hmr-manager.d.ts +0 -1
  14. package/src/adapters/bun/hmr-manager.js +2 -4
  15. package/src/adapters/bun/server-adapter.d.ts +15 -21
  16. package/src/adapters/bun/server-adapter.js +33 -67
  17. package/src/adapters/bun/static-preview-host.d.ts +1 -0
  18. package/src/adapters/bun/static-preview-host.js +1 -1
  19. package/src/adapters/create-app.d.ts +63 -8
  20. package/src/adapters/create-app.js +62 -5
  21. package/src/adapters/node/create-app.d.ts +8 -12
  22. package/src/adapters/node/create-app.js +22 -14
  23. package/src/adapters/node/runtime-host.d.ts +10 -10
  24. package/src/adapters/node/runtime-host.js +13 -8
  25. package/src/adapters/node/server-adapter-dependencies.d.ts +2 -10
  26. package/src/adapters/node/server-adapter-dependencies.js +8 -13
  27. package/src/adapters/node/server-adapter.d.ts +30 -32
  28. package/src/adapters/node/server-adapter.js +59 -65
  29. package/src/adapters/shared/hmr/shared-hmr-manager.d.ts +0 -4
  30. package/src/adapters/shared/hmr/shared-hmr-manager.js +0 -12
  31. package/src/adapters/shared/http/api-request-pipeline.d.ts +27 -1
  32. package/src/adapters/shared/http/api-request-pipeline.js +31 -16
  33. package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
  34. package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -9
  35. package/src/adapters/shared/http/fs-server-response-factory.js +5 -33
  36. package/src/adapters/shared/http/fs-server-response-matcher.d.ts +24 -24
  37. package/src/adapters/shared/http/fs-server-response-matcher.js +59 -83
  38. package/src/adapters/shared/runtime/application-adapter.d.ts +1 -0
  39. package/src/adapters/shared/runtime/application-adapter.js +12 -0
  40. package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
  41. package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
  42. package/src/adapters/shared/runtime/collect-dev-prewarm-plan.d.ts +1 -3
  43. package/src/adapters/shared/runtime/collect-dev-prewarm-plan.js +1 -4
  44. package/src/adapters/shared/runtime/port-manager-default-prompt.d.ts +6 -0
  45. package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
  46. package/src/adapters/shared/runtime/port-manager.d.ts +3 -3
  47. package/src/adapters/shared/runtime/port-manager.js +14 -45
  48. package/src/adapters/shared/runtime/runtime-app-bootstrap.d.ts +0 -10
  49. package/src/adapters/shared/runtime/runtime-app-bootstrap.js +0 -7
  50. package/src/adapters/shared/runtime/runtime-host.d.ts +5 -2
  51. package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +1 -1
  52. package/src/adapters/shared/runtime/runtime-server-lifecycle.js +1 -1
  53. package/src/adapters/shared/runtime/server-adapter.d.ts +27 -5
  54. package/src/adapters/shared/runtime/server-adapter.js +44 -30
  55. package/src/adapters/shared/runtime/server-route-handler.js +11 -3
  56. package/src/adapters/shared/runtime/server-static-builder.d.ts +9 -3
  57. package/src/adapters/shared/runtime/server-static-builder.js +59 -37
  58. package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +9 -1
  59. package/src/adapters/shared/ws/node-http-websocket-upgrades.js +8 -2
  60. package/src/build/README.md +9 -6
  61. package/src/build/cache/cache-constants.d.ts +0 -2
  62. package/src/build/cache/cache-constants.js +0 -2
  63. package/src/build/cache/cache-keys.d.ts +0 -2
  64. package/src/build/cache/cache-keys.js +0 -2
  65. package/src/build/cache/output-imports.d.ts +27 -0
  66. package/src/build/cache/output-imports.js +80 -0
  67. package/src/build/cache/pages-unified-graph-build.d.ts +6 -1
  68. package/src/build/cache/pages-unified-graph-build.js +42 -17
  69. package/src/build/cache/production-build-cache.d.ts +2 -2
  70. package/src/build/cache/production-build-cache.js +2 -2
  71. package/src/build/cache/server-entry-build-cache.d.ts +25 -3
  72. package/src/build/cache/server-entry-build-cache.js +129 -13
  73. package/src/build/contracts/build-contracts.d.ts +1 -13
  74. package/src/build/contracts/content-virtual-modules.d.ts +3 -1
  75. package/src/build/contracts/content-virtual-modules.js +8 -0
  76. package/src/build/rolldown/rolldown-adapter-helpers.js +41 -25
  77. package/src/build/rolldown/rolldown-plugin-bridge.js +25 -21
  78. package/src/build/rolldown/runtime-build-output-normalizer.js +3 -6
  79. package/src/build/runtime/build-request-identity.d.ts +2 -6
  80. package/src/build/runtime/build-request-identity.js +2 -8
  81. package/src/build/runtime/build-request-policy.js +1 -1
  82. package/src/build/runtime/deduping-build-executor.d.ts +0 -1
  83. package/src/build/runtime/deduping-build-executor.js +0 -1
  84. package/src/build/server-bundle-publication.d.ts +14 -0
  85. package/src/build/server-bundle-publication.js +49 -0
  86. package/src/cache/index.d.ts +1 -1
  87. package/src/cache/index.js +1 -1
  88. package/src/cache/module-parse-cache.d.ts +2 -29
  89. package/src/cache/module-parse-cache.js +6 -39
  90. package/src/config/README.md +17 -2
  91. package/src/config/apply-user-config.d.ts +8 -0
  92. package/src/config/apply-user-config.js +68 -0
  93. package/src/config/config-builder.d.ts +11 -1
  94. package/src/config/config-builder.js +53 -12
  95. package/src/config/constants.d.ts +4 -4
  96. package/src/config/constants.js +4 -4
  97. package/src/config/define-config.d.ts +9 -0
  98. package/src/config/define-config.js +10 -0
  99. package/src/config/index.d.ts +5 -0
  100. package/src/config/index.js +4 -0
  101. package/src/config/is-finalized-app-config.d.ts +6 -0
  102. package/src/config/is-finalized-app-config.js +11 -0
  103. package/src/config/load-eco-config.d.ts +21 -0
  104. package/src/config/load-eco-config.js +107 -0
  105. package/src/config/resolve-eco-config-path.d.ts +32 -0
  106. package/src/config/resolve-eco-config-path.js +58 -0
  107. package/src/config/server-config-bundle.d.ts +25 -0
  108. package/src/config/server-config-bundle.js +148 -0
  109. package/src/config/user-config-types.d.ts +170 -0
  110. package/src/config/user-config-types.js +1 -0
  111. package/src/css-imports.d.ts +4 -0
  112. package/src/declarations.d.ts +11 -5
  113. package/src/dev/README.md +6 -0
  114. package/src/dev/development-restart-watch-paths.d.ts +13 -0
  115. package/src/dev/development-restart-watch-paths.js +37 -0
  116. package/src/dev/development-restart.d.ts +13 -0
  117. package/src/dev/development-restart.js +21 -0
  118. package/src/dev/host-runtime.d.ts +0 -1
  119. package/src/dev/host-runtime.js +0 -3
  120. package/src/dev/sc-server.d.ts +4 -1
  121. package/src/dev/sc-server.js +11 -20
  122. package/src/dev/transform-server/dev-transform-import-rewriter.js +2 -2
  123. package/src/dev/transform-server/dev-transform-server.d.ts +6 -0
  124. package/src/dev/transform-server/dev-transform-server.js +16 -5
  125. package/src/eco/README.md +73 -5
  126. package/src/eco/component-identity.d.ts +3 -2
  127. package/src/eco/component-identity.js +5 -2
  128. package/src/eco/discovered-dependencies.d.ts +45 -0
  129. package/src/eco/discovered-dependencies.js +87 -0
  130. package/src/eco/eco.js +6 -0
  131. package/src/eco/eco.types.d.ts +18 -2
  132. package/src/eco/lazy-injector-map.js +57 -41
  133. package/src/eco/page-dependency-contributions.d.ts +19 -0
  134. package/src/eco/page-dependency-contributions.js +52 -0
  135. package/src/errors/http-error-page-contract.d.ts +77 -0
  136. package/src/errors/http-error-page-contract.js +106 -0
  137. package/src/hmr/hmr-file-change-prep.d.ts +0 -1
  138. package/src/hmr/hmr-file-change-prep.js +2 -5
  139. package/src/hmr/hmr-strategy.d.ts +3 -8
  140. package/src/hmr/hmr-strategy.js +3 -8
  141. package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -0
  142. package/src/hmr/strategies/js-hmr-strategy.js +24 -16
  143. package/src/index.browser.d.ts +2 -0
  144. package/src/index.browser.js +2 -0
  145. package/src/index.d.ts +5 -3
  146. package/src/index.js +5 -3
  147. package/src/islands/README.md +5 -1
  148. package/src/islands/island-host.d.ts +0 -9
  149. package/src/islands/island-host.js +1 -13
  150. package/src/plugins/README.md +8 -1
  151. package/src/plugins/component-import-discovery.d.ts +19 -0
  152. package/src/plugins/component-import-discovery.js +241 -0
  153. package/src/plugins/eco-component-meta-plugin.d.ts +3 -1
  154. package/src/plugins/eco-component-meta-plugin.js +120 -18
  155. package/src/plugins/integration-plugin.d.ts +0 -1
  156. package/src/plugins/integration-plugin.js +0 -4
  157. package/src/plugins/processor.d.ts +10 -2
  158. package/src/plugins/processor.js +4 -0
  159. package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
  160. package/src/plugins/tsconfig-import-resolver.js +4 -2
  161. package/src/route-renderer/GRAPH.md +1 -1
  162. package/src/route-renderer/README.md +15 -2
  163. package/src/{adapters/shared/http/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +3 -3
  164. package/src/route-renderer/orchestration/custom-element-scripts/README.md +9 -0
  165. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +16 -0
  166. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +34 -0
  167. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +80 -0
  168. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +190 -0
  169. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +17 -0
  170. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +41 -0
  171. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +10 -0
  172. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +46 -0
  173. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +7 -2
  174. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +3 -4
  175. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +11 -2
  176. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +10 -2
  177. package/src/route-renderer/orchestration/integration-renderer.d.ts +9 -11
  178. package/src/route-renderer/orchestration/integration-renderer.js +43 -40
  179. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +1 -1
  180. package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +2 -5
  181. package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +2 -68
  182. package/src/route-renderer/orchestration/ownership-graph/component-graph.js +55 -39
  183. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -1
  184. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -1
  185. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +6 -0
  186. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +59 -36
  187. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +8 -10
  188. package/src/route-renderer/orchestration/string-markup-renderer.d.ts +1 -1
  189. package/src/route-renderer/orchestration/string-markup-renderer.js +2 -1
  190. package/src/route-renderer/page-loading/component-dependency-collection.d.ts +6 -2
  191. package/src/route-renderer/page-loading/component-dependency-collection.js +113 -68
  192. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +41 -28
  193. package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +10 -3
  194. package/src/route-renderer/page-loading/file-scoped-dependency-components.js +62 -25
  195. package/src/route-renderer/page-loading/page-dependency-bundling.js +14 -8
  196. package/src/route-renderer/page-loading/resolved-page-dependencies.d.ts +1 -2
  197. package/src/route-renderer/page-loading/resolved-page-dependencies.js +8 -7
  198. package/src/route-renderer/route-renderer.d.ts +9 -0
  199. package/src/route-renderer/route-renderer.js +18 -0
  200. package/src/router/README.md +7 -1
  201. package/src/router/server/route-registry.d.ts +13 -0
  202. package/src/router/server/route-registry.js +46 -32
  203. package/src/services/README.md +6 -1
  204. package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +36 -9
  205. package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.js +122 -37
  206. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +2 -0
  207. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +13 -2
  208. package/src/services/assets/asset-processing-service/page-package.js +42 -39
  209. package/src/services/assets/browser-bundle.service.d.ts +1 -6
  210. package/src/services/error-pages/README.md +9 -0
  211. package/src/services/error-pages/default-error-pages.d.ts +39 -0
  212. package/src/services/error-pages/default-error-pages.js +199 -0
  213. package/src/services/error-pages/error-page-renderer.d.ts +58 -0
  214. package/src/services/error-pages/error-page-renderer.js +146 -0
  215. package/src/services/error-pages/semantic-error-page-exporter.d.ts +23 -0
  216. package/src/services/error-pages/semantic-error-page-exporter.js +35 -0
  217. package/src/services/html/html-rewriter.d.ts +77 -0
  218. package/src/services/html/html-rewriter.js +751 -0
  219. package/src/services/html/html-rewriter.parity.test.bun.d.ts +1 -0
  220. package/src/services/html/html-rewriter.parity.test.bun.js +74 -0
  221. package/src/services/html/html-transformer.service.d.ts +26 -39
  222. package/src/services/html/html-transformer.service.js +81 -153
  223. package/src/services/invalidation/development-invalidation.service.d.ts +9 -20
  224. package/src/services/invalidation/development-invalidation.service.js +35 -41
  225. package/src/services/module-loading/README.md +17 -14
  226. package/src/services/module-loading/app-module-loader.service.d.ts +0 -2
  227. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +1 -1
  228. package/src/services/module-loading/app-server-module-transpiler.service.js +2 -10
  229. package/src/services/module-loading/collection-server-module-build.service.d.ts +1 -1
  230. package/src/services/module-loading/collection-server-module-build.service.js +5 -5
  231. package/src/services/module-loading/host-module-loader-registry.d.ts +0 -1
  232. package/src/services/module-loading/host-module-loader-registry.js +0 -3
  233. package/src/services/module-loading/page-module-import.service.d.ts +8 -0
  234. package/src/services/module-loading/page-module-import.service.js +62 -28
  235. package/src/services/module-loading/route-module-build-cache-registry.d.ts +0 -4
  236. package/src/services/module-loading/route-module-build-cache-registry.js +0 -4
  237. package/src/services/module-loading/route-module-build-cache.store.d.ts +3 -0
  238. package/src/services/module-loading/route-module-build-cache.store.js +18 -5
  239. package/src/services/module-loading/route-module-build-manifest.d.ts +6 -1
  240. package/src/services/module-loading/route-module-build-manifest.js +1 -2
  241. package/src/services/module-loading/route-module-dependency-hasher.d.ts +3 -2
  242. package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
  243. package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -15
  244. package/src/services/module-loading/server-module-transpiler.service.js +0 -24
  245. package/src/services/module-loading/view-module-loader.d.ts +10 -0
  246. package/src/services/module-loading/view-module-loader.js +46 -0
  247. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -12
  248. package/src/services/runtime-state/server-invalidation-state.service.d.ts +4 -2
  249. package/src/services/runtime-state/server-invalidation-state.service.js +7 -14
  250. package/src/services/validation/schema-validation-service.d.ts +1 -0
  251. package/src/services/validation/schema-validation-service.js +23 -36
  252. package/src/static-site-generator/README.md +6 -1
  253. package/src/static-site-generator/static-site-generator.d.ts +7 -2
  254. package/src/static-site-generator/static-site-generator.js +90 -49
  255. package/src/types/internal-types.d.ts +6 -39
  256. package/src/types/public-types.d.ts +29 -131
  257. package/src/utils/parse-cli-args.js +29 -22
  258. package/src/watchers/project-watcher.d.ts +14 -16
  259. package/src/watchers/project-watcher.js +86 -61
  260. package/src/watchers/project-watcher.test-helpers.d.ts +10 -1
  261. package/src/watchers/project-watcher.test-helpers.js +12 -0
  262. package/src/adapters/abstract/router-adapter.d.ts +0 -26
  263. package/src/adapters/abstract/router-adapter.js +0 -13
  264. package/src/adapters/bun/index.d.ts +0 -2
  265. package/src/adapters/bun/index.js +0 -2
  266. package/src/adapters/index.d.ts +0 -2
  267. package/src/adapters/index.js +0 -2
  268. package/src/eco/eco.utils.d.ts +0 -1
  269. package/src/eco/eco.utils.js +0 -1
  270. package/src/services/cache/index.d.ts +0 -9
  271. package/src/services/cache/index.js +0 -8
  272. package/src/services/html/html-rewriter-provider.service.d.ts +0 -40
  273. package/src/services/html/html-rewriter-provider.service.js +0 -68
  274. package/src/services/module-loading/route-module-build-cache.d.ts +0 -4
  275. package/src/services/module-loading/route-module-build-cache.js +0 -3
  276. package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
  277. package/src/services/runtime-state/dev-graph.service.js +0 -170
  278. /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
@@ -8,7 +8,7 @@ import { ServerStaticBuilder } from './server-static-builder.js';
8
8
  import { FileSystemResponseMatcher } from '../http/fs-server-response-matcher.js';
9
9
  import { ServerRouteHandler } from './server-route-handler.js';
10
10
  import { ApiRequestPipeline } from '../http/api-request-pipeline.js';
11
- import type { ApiHandler, CacheInvalidator, ErrorHandler, IHmrManager, RenderContext, StaticRoute } from '../../../types/public-types.js';
11
+ import type { ApiHandler, CacheInvalidator, ErrorHandler, IHmrManager, RenderContext, StaticRoute, ErrorPageLoaders } from '../../../types/public-types.js';
12
12
  type SharedHmrAssetManager = IHmrManager;
13
13
  type SharedRequestContext<TServer = unknown> = {
14
14
  apiHandlers: ApiHandler[];
@@ -28,17 +28,24 @@ export declare abstract class SharedServerAdapter<TOptions extends ServerAdapter
28
28
  protected hostOwnsDevClient: boolean;
29
29
  private devStaticRoutePrewarmStarted;
30
30
  private sharedPageCacheService;
31
+ /** Propagates the actual listening port to every binding-dependent service. */
32
+ applyBoundPort(input: {
33
+ port: number;
34
+ runtimeOrigin: string;
35
+ }): void;
31
36
  /**
32
37
  * Warms declared static paths after the final watch-mode response pipeline exists.
33
38
  */
34
39
  protected startDevStaticRoutePrewarmWhenReady(): Promise<void>;
35
40
  protected initializeSharedRouteHandling(options: {
36
41
  staticRoutes: StaticRoute[];
42
+ errorPageLoaders?: ErrorPageLoaders;
37
43
  hmrManager?: SharedHmrAssetManager;
38
44
  }): Promise<void>;
39
45
  private ensureRouteRendererFactory;
40
46
  protected createSharedWatchRefreshCallback(options: {
41
47
  staticRoutes: StaticRoute[];
48
+ errorPageLoaders?: ErrorPageLoaders;
42
49
  hmrManager?: SharedHmrAssetManager;
43
50
  onRoutesReady?: () => Promise<void> | void;
44
51
  onError?: (error: Error) => Promise<void> | void;
@@ -60,12 +67,14 @@ export declare abstract class SharedServerAdapter<TOptions extends ServerAdapter
60
67
  * 1. How to render React/Lit pages via `RouteRendererFactory`
61
68
  * 2. How to match logical routes to physical filesystem artifacts via `FileSystemResponseMatcher`
62
69
  * 3. Whether to serve the response from the embedded `PageCacheService` or generate it fresh on the fly.
63
- *
64
- * @param staticRoutes - A map of explicitly served static assets.
65
- * @param hmrManager - The runtime-specific Hot Module Replacement orchestrator (if watching).
66
70
  */
67
- protected configureSharedResponseHandlers(staticRoutes: StaticRoute[], hmrManager?: IHmrManager): void;
71
+ protected configureSharedResponseHandlers(options: {
72
+ staticRoutes: StaticRoute[];
73
+ hmrManager?: IHmrManager;
74
+ errorPageLoaders?: ErrorPageLoaders;
75
+ }): void;
68
76
  private createSharedResponseHandlerDependencies;
77
+ private createSharedPageCacheServiceFromConfig;
69
78
  private getOrCreateSharedPageCacheService;
70
79
  protected getCacheService(): CacheInvalidator | null;
71
80
  protected getRenderContext(): RenderContext;
@@ -73,6 +82,19 @@ export declare abstract class SharedServerAdapter<TOptions extends ServerAdapter
73
82
  private tryHandleSharedHmrRequest;
74
83
  private injectSharedHmrHtmlResponse;
75
84
  private tryHandleSharedApiRequest;
85
+ /**
86
+ * Recognises a runtime-specific client disconnect so it answers 499.
87
+ *
88
+ * @remarks
89
+ * Only the Node adapter overrides it: its request bridge raises a dedicated
90
+ * error when the socket closes while the body is read.
91
+ */
92
+ protected isClientAbortError(_error: unknown): boolean;
93
+ /**
94
+ * Resolves an error that escaped {@link handleSharedRequest} with the same
95
+ * precedence as API handler errors, so `app.onError` sees it on every runtime.
96
+ */
97
+ protected handleUnexpectedRequestError(error: unknown, request: Request, context: SharedRequestContext): Promise<Response>;
76
98
  /**
77
99
  * Universally processes an incoming WinterCG Web standard Request.
78
100
  *
@@ -33,10 +33,17 @@ export class SharedServerAdapter extends AbstractServerAdapter {
33
33
  schemaValidator: this.schemaValidator,
34
34
  getRenderContext: () => this.getRenderContext(),
35
35
  getCacheService: () => this.getCacheService(),
36
+ isClientAbort: (error) => this.isClientAbortError(error),
36
37
  });
37
38
  hostOwnsDevClient = false;
38
39
  devStaticRoutePrewarmStarted = false;
39
40
  sharedPageCacheService;
41
+ /** Propagates the actual listening port to every binding-dependent service. */
42
+ applyBoundPort(input) {
43
+ super.applyBoundPort(input);
44
+ this.routeRendererFactory?.setRuntimeOrigin(input.runtimeOrigin);
45
+ this.staticBuilder?.setRuntimeBinding(input);
46
+ }
40
47
  /**
41
48
  * Warms declared static paths after the final watch-mode response pipeline exists.
42
49
  */
@@ -72,7 +79,7 @@ export class SharedServerAdapter extends AbstractServerAdapter {
72
79
  async initializeSharedRouteHandling(options) {
73
80
  this.ensureRouteRendererFactory();
74
81
  await this.initSharedRouter();
75
- this.configureSharedResponseHandlers(options.staticRoutes, options.hmrManager);
82
+ this.configureSharedResponseHandlers(options);
76
83
  }
77
84
  ensureRouteRendererFactory() {
78
85
  if (this.routeRendererFactory) {
@@ -89,6 +96,7 @@ export class SharedServerAdapter extends AbstractServerAdapter {
89
96
  try {
90
97
  await this.initializeSharedRouteHandling({
91
98
  staticRoutes: options.staticRoutes,
99
+ errorPageLoaders: options.errorPageLoaders,
92
100
  hmrManager: options.hmrManager,
93
101
  });
94
102
  if (options.onRoutesReady) {
@@ -147,22 +155,19 @@ export class SharedServerAdapter extends AbstractServerAdapter {
147
155
  * 1. How to render React/Lit pages via `RouteRendererFactory`
148
156
  * 2. How to match logical routes to physical filesystem artifacts via `FileSystemResponseMatcher`
149
157
  * 3. Whether to serve the response from the embedded `PageCacheService` or generate it fresh on the fly.
150
- *
151
- * @param staticRoutes - A map of explicitly served static assets.
152
- * @param hmrManager - The runtime-specific Hot Module Replacement orchestrator (if watching).
153
158
  */
154
- configureSharedResponseHandlers(staticRoutes, hmrManager) {
159
+ configureSharedResponseHandlers(options) {
155
160
  this.ensureRouteRendererFactory();
156
- const { fileSystemResponseMatcher, explicitStaticRouteMatcher } = this.createSharedResponseHandlerDependencies(staticRoutes);
161
+ const { fileSystemResponseMatcher, explicitStaticRouteMatcher } = this.createSharedResponseHandlerDependencies(options.staticRoutes, options.errorPageLoaders);
157
162
  this.fileSystemResponseMatcher = fileSystemResponseMatcher;
158
163
  this.routeHandler = new ServerRouteHandler({
159
164
  router: this.router,
160
165
  fileSystemResponseMatcher: this.fileSystemResponseMatcher,
161
166
  explicitStaticRouteMatcher,
162
- hmrManager,
167
+ hmrManager: options.hmrManager,
163
168
  });
164
169
  }
165
- createSharedResponseHandlerDependencies(staticRoutes) {
170
+ createSharedResponseHandlerDependencies(staticRoutes, errorPageLoaders) {
166
171
  const fileSystemResponseFactory = new FileSystemServerResponseFactory({
167
172
  options: {
168
173
  watchMode: !!this.options?.watch,
@@ -174,6 +179,7 @@ export class SharedServerAdapter extends AbstractServerAdapter {
174
179
  assetPrefix: path.join(this.appConfig.rootDir, this.appConfig.distDir),
175
180
  router: this.router,
176
181
  routeRendererFactory: this.routeRendererFactory,
182
+ errorPageLoaders,
177
183
  fileSystemResponseFactory,
178
184
  cacheService,
179
185
  defaultCacheStrategy: this.appConfig.cache?.defaultStrategy ?? 'static',
@@ -190,36 +196,23 @@ export class SharedServerAdapter extends AbstractServerAdapter {
190
196
  : undefined,
191
197
  };
192
198
  }
193
- getOrCreateSharedPageCacheService() {
194
- if (this.sharedPageCacheService !== undefined) {
195
- return this.sharedPageCacheService;
196
- }
199
+ createSharedPageCacheServiceFromConfig() {
197
200
  const cacheConfig = this.appConfig.cache;
198
201
  const watch = Boolean(this.options?.watch);
199
- if (watch) {
200
- if (cacheConfig?.enabled === false) {
201
- this.sharedPageCacheService = null;
202
- registerAppPageCacheService(this.appConfig, null);
203
- return null;
204
- }
205
- const store = cacheConfig?.store === 'memory' || !cacheConfig?.store
206
- ? new MemoryCacheStore({ maxEntries: cacheConfig?.maxEntries })
207
- : cacheConfig.store;
208
- const service = new PageCacheService({ store, enabled: true });
209
- this.sharedPageCacheService = service;
210
- registerAppPageCacheService(this.appConfig, service);
211
- return service;
212
- }
213
- const isCacheEnabled = cacheConfig?.enabled ?? true;
202
+ const isCacheEnabled = watch ? cacheConfig?.enabled !== false : (cacheConfig?.enabled ?? true);
214
203
  if (!isCacheEnabled) {
215
- this.sharedPageCacheService = null;
216
- registerAppPageCacheService(this.appConfig, null);
217
204
  return null;
218
205
  }
219
206
  const store = cacheConfig?.store === 'memory' || !cacheConfig?.store
220
207
  ? new MemoryCacheStore({ maxEntries: cacheConfig?.maxEntries })
221
208
  : cacheConfig.store;
222
- const service = new PageCacheService({ store, enabled: true });
209
+ return new PageCacheService({ store, enabled: true });
210
+ }
211
+ getOrCreateSharedPageCacheService() {
212
+ if (this.sharedPageCacheService !== undefined) {
213
+ return this.sharedPageCacheService;
214
+ }
215
+ const service = this.createSharedPageCacheServiceFromConfig();
223
216
  this.sharedPageCacheService = service;
224
217
  registerAppPageCacheService(this.appConfig, service);
225
218
  return service;
@@ -269,6 +262,27 @@ export class SharedServerAdapter extends AbstractServerAdapter {
269
262
  async tryHandleSharedApiRequest(request, context) {
270
263
  return await this.apiRequestPipeline.tryHandle(request, context.apiHandlers, context.serverInstance, context.errorHandler);
271
264
  }
265
+ /**
266
+ * Recognises a runtime-specific client disconnect so it answers 499.
267
+ *
268
+ * @remarks
269
+ * Only the Node adapter overrides it: its request bridge raises a dedicated
270
+ * error when the socket closes while the body is read.
271
+ */
272
+ isClientAbortError(_error) {
273
+ return false;
274
+ }
275
+ /**
276
+ * Resolves an error that escaped {@link handleSharedRequest} with the same
277
+ * precedence as API handler errors, so `app.onError` sees it on every runtime.
278
+ */
279
+ async handleUnexpectedRequestError(error, request, context) {
280
+ return await this.apiRequestPipeline.handleError(error, {
281
+ request,
282
+ serverInstance: context.serverInstance,
283
+ errorHandler: context.errorHandler,
284
+ });
285
+ }
272
286
  /**
273
287
  * Universally processes an incoming WinterCG Web standard Request.
274
288
  *
@@ -40,7 +40,15 @@ export class ServerRouteHandler {
40
40
  const pathname = new URL(request.url).pathname;
41
41
  const explicitMatch = this.explicitStaticRouteMatcher?.match(request.url);
42
42
  if (explicitMatch) {
43
- return await this.explicitStaticRouteMatcher.handleMatch(explicitMatch);
43
+ try {
44
+ return await this.explicitStaticRouteMatcher.handleMatch(explicitMatch);
45
+ }
46
+ catch (error) {
47
+ if (error instanceof Response) {
48
+ return error;
49
+ }
50
+ return await this.fileSystemResponseMatcher.renderServerError(pathname, error);
51
+ }
44
52
  }
45
53
  const fsMatch = !pathname.includes('.') && this.router.matchRequest(request.url);
46
54
  return await (fsMatch
@@ -59,8 +67,8 @@ export class ServerRouteHandler {
59
67
  * @throws HttpError for standard HTTP errors
60
68
  */
61
69
  async handleNoMatch(request) {
70
+ const pathname = new URL(request.url).pathname;
62
71
  try {
63
- const pathname = new URL(request.url).pathname;
64
72
  return await this.fileSystemResponseMatcher.handleNoMatch(pathname);
65
73
  }
66
74
  catch (error) {
@@ -71,7 +79,7 @@ export class ServerRouteHandler {
71
79
  this.hmrManager?.broadcast({ type: 'error', message: error.message });
72
80
  appLogger.error('Error handling no match:', error);
73
81
  }
74
- return new Response('Internal Server Error', { status: 500 });
82
+ return await this.fileSystemResponseMatcher.renderServerError(pathname, error);
75
83
  }
76
84
  }
77
85
  }
@@ -1,6 +1,6 @@
1
1
  import type { EcoPagesAppConfig, IHmrManager } from '../../../types/internal-types.js';
2
2
  import type { EcoBuildPlugin } from '../../../build/contracts/build-types.js';
3
- import type { StaticRoute } from '../../../types/public-types.js';
3
+ import type { ErrorPageLoaders, StaticRoute } from '../../../types/public-types.js';
4
4
  import type { RouteRegistry } from '../../../router/server/route-registry.js';
5
5
  import type { StaticSiteGenerator } from '../../../static-site-generator/static-site-generator.js';
6
6
  import type { StaticGenerationRendererResolver } from '../../../route-renderer/route-renderer.js';
@@ -43,14 +43,19 @@ export interface ServerStaticBuilderLogger {
43
43
  export declare class ServerStaticBuilder {
44
44
  private readonly appConfig;
45
45
  private readonly staticSiteGenerator;
46
- private readonly serveOptions;
47
- private readonly runtimeOrigin;
46
+ private serveOptions;
47
+ private runtimeOrigin;
48
48
  private readonly needsServerBundle;
49
49
  private readonly logger;
50
50
  private readonly entryFile;
51
51
  private readonly hmrManager?;
52
52
  private readonly onRuntimePlugin?;
53
53
  constructor({ appConfig, staticSiteGenerator, serveOptions, runtimeOrigin, needsServerBundle, logger, entryFile, hmrManager, onRuntimePlugin, }: ServerStaticBuilderParams);
54
+ /** Keeps build-time URLs aligned with the server's actual listening port. */
55
+ setRuntimeBinding(input: {
56
+ port: number;
57
+ runtimeOrigin: string;
58
+ }): void;
54
59
  private prepareExportDirectory;
55
60
  private refreshRuntimeAssets;
56
61
  /**
@@ -82,5 +87,6 @@ export declare class ServerStaticBuilder {
82
87
  router: RouteRegistry;
83
88
  routeRendererFactory: StaticGenerationRendererResolver;
84
89
  staticRoutes?: StaticRoute[];
90
+ errorPageLoaders?: ErrorPageLoaders;
85
91
  }): Promise<void>;
86
92
  }
@@ -2,12 +2,14 @@ import path from 'node:path';
2
2
  import { fileSystem } from '@ecopages/file-system';
3
3
  import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT } from '../../../config/constants.js';
4
4
  import { appLogger } from '../../../global/app-logger.js';
5
- import { build, getAppBuildAdapter, setupAppRuntimePlugins } from '../../../build/build-adapter.js';
5
+ import { build, setupAppRuntimePlugins } from '../../../build/build-adapter.js';
6
+ import { createServerBundleStagingDirectory, publishServerBundleDirectory, removeServerBundleStagingDirectory, resolvePublishedServerBundlePaths, } from '../../../build/server-bundle-publication.js';
6
7
  import { createServerBuildRequest } from '../../../build/runtime/build-request-policy.js';
7
8
  import { requireBuildRuntime } from '../../../build/runtime/build-runtime.js';
8
9
  import { attachHmrToIntegrations } from './runtime-server-lifecycle.js';
9
- import { getServerBundleOutputPaths, lookupServerEntryBuildCache, recordServerEntryBuildCache, writeServerBundleDeployManifest, } from '../../../build/cache/server-entry-build-cache.js';
10
+ import { getServerBundleOutputPaths, lookupServerEntryBuildCache, recordServerEntryBuildCache, SERVER_BUNDLE_MANIFEST_FILENAME, writeServerBundleDeployManifest, } from '../../../build/cache/server-entry-build-cache.js';
10
11
  import { clearProductionBuildCaches, shouldResetStaticExportDirectory, } from '../../../static-site-generator/static-build-invalidation.js';
12
+ import { assertCanBundleServerConfig, bundleEcoConfigModule, EMITTED_ECO_CONFIG_FILENAME, } from '../../../config/server-config-bundle.js';
11
13
  import { resolveEntryFile, SERVER_BUNDLE_FILENAME } from '../../../utils/resolve-entry-file.js';
12
14
  /**
13
15
  * Handles static site generation.
@@ -33,6 +35,11 @@ export class ServerStaticBuilder {
33
35
  this.hmrManager = hmrManager;
34
36
  this.onRuntimePlugin = onRuntimePlugin;
35
37
  }
38
+ /** Keeps build-time URLs aligned with the server's actual listening port. */
39
+ setRuntimeBinding(input) {
40
+ this.serveOptions = { ...this.serveOptions, port: input.port };
41
+ this.runtimeOrigin = input.runtimeOrigin;
42
+ }
36
43
  prepareExportDirectory(force) {
37
44
  if (force) {
38
45
  clearProductionBuildCaches(this.appConfig);
@@ -87,56 +94,70 @@ export class ServerStaticBuilder {
87
94
  * @throws If the build adapter is unavailable, is host-owned, or bundling fails.
88
95
  */
89
96
  async bundleServerEntry(options) {
90
- const buildAdapter = getAppBuildAdapter(this.appConfig);
91
- if (buildAdapter.ownership === 'vite-host') {
92
- throw new Error('Cannot bundle the server entry file: build ownership is "vite-host". ' +
93
- 'The host runtime is expected to produce its own server bundle.');
94
- }
97
+ assertCanBundleServerConfig(this.appConfig);
95
98
  const entryPath = path.isAbsolute(this.entryFile)
96
99
  ? this.entryFile
97
100
  : path.join(this.appConfig.rootDir, this.entryFile);
98
101
  if (!fileSystem.exists(entryPath)) {
99
102
  throw new Error(`Cannot bundle server entry: file "${this.entryFile}" not found in "${this.appConfig.rootDir}".`);
100
103
  }
101
- const { serverOutdir, serverEntryPath } = getServerBundleOutputPaths(this.appConfig);
104
+ const { serverOutdir } = getServerBundleOutputPaths(this.appConfig);
102
105
  const cached = lookupServerEntryBuildCache({
103
106
  appConfig: this.appConfig,
104
107
  entryPath,
105
108
  force: options?.force,
106
109
  });
107
110
  if (cached) {
108
- const hasBundle = cached.outputPaths.some((outputPath) => path.resolve(outputPath) === path.resolve(serverEntryPath) && fileSystem.exists(outputPath));
109
- if (hasBundle) {
110
- this.logger.info('Reusing cached server entry bundle');
111
- writeServerBundleDeployManifest(this.appConfig, serverEntryPath);
112
- return;
113
- }
111
+ this.logger.info('Reusing cached server entry bundle');
112
+ return;
114
113
  }
115
114
  this.logger.info('Bundling server entry file...');
116
- const buildOptions = createServerBuildRequest(this.appConfig, {
117
- profile: 'server-entry',
118
- entrypoints: [entryPath],
119
- outdir: serverOutdir,
120
- naming: SERVER_BUNDLE_FILENAME,
121
- sourcemap: 'hidden',
122
- });
123
- const result = await build(buildOptions, requireBuildRuntime(this.appConfig).getProfile('server-entry'));
124
- if (!result.success) {
125
- const errorMessages = result.logs.map((log) => log.message).join('\n');
126
- throw new Error(`Failed to bundle server entry file:\n${errorMessages}`);
115
+ const stagingDir = createServerBundleStagingDirectory(serverOutdir);
116
+ try {
117
+ const configBundle = await bundleEcoConfigModule(this.appConfig, {
118
+ outputDir: stagingDir,
119
+ runtimeDir: serverOutdir,
120
+ });
121
+ const stagedServerEntryPath = path.join(stagingDir, SERVER_BUNDLE_FILENAME);
122
+ const buildOptions = createServerBuildRequest(this.appConfig, {
123
+ profile: 'server-entry',
124
+ entrypoints: [entryPath],
125
+ outdir: stagingDir,
126
+ naming: SERVER_BUNDLE_FILENAME,
127
+ sourcemap: 'hidden',
128
+ });
129
+ const result = await build(buildOptions, requireBuildRuntime(this.appConfig).getProfile('server-entry'));
130
+ if (!result.success) {
131
+ const errorMessages = result.logs.map((log) => log.message).join('\n');
132
+ throw new Error(`Failed to bundle server entry file:\n${errorMessages}`);
133
+ }
134
+ writeServerBundleDeployManifest(this.appConfig, stagedServerEntryPath, {
135
+ sourceConfigPath: this.appConfig.absolutePaths.config,
136
+ emittedConfigModule: configBundle ? EMITTED_ECO_CONFIG_FILENAME : undefined,
137
+ outputDir: stagingDir,
138
+ });
139
+ const stagedOutputPaths = [
140
+ ...(result.outputs.length > 0
141
+ ? result.outputs.map((output) => output.path)
142
+ : fileSystem.exists(stagedServerEntryPath)
143
+ ? [stagedServerEntryPath]
144
+ : []),
145
+ ...(configBundle ? [configBundle.emittedConfigPath] : []),
146
+ path.join(stagingDir, SERVER_BUNDLE_MANIFEST_FILENAME),
147
+ ];
148
+ const outputPaths = resolvePublishedServerBundlePaths(stagedOutputPaths, stagingDir, serverOutdir);
149
+ publishServerBundleDirectory(stagingDir, serverOutdir);
150
+ recordServerEntryBuildCache({
151
+ appConfig: this.appConfig,
152
+ entryPath,
153
+ buildResult: result,
154
+ configBuildResult: configBundle?.buildResult,
155
+ outputPaths,
156
+ });
157
+ }
158
+ finally {
159
+ removeServerBundleStagingDirectory(stagingDir);
127
160
  }
128
- const outputPaths = result.outputs.length > 0
129
- ? result.outputs.map((output) => output.path)
130
- : fileSystem.exists(serverEntryPath)
131
- ? [serverEntryPath]
132
- : [];
133
- recordServerEntryBuildCache({
134
- appConfig: this.appConfig,
135
- entryPath,
136
- buildResult: result,
137
- outputPaths,
138
- });
139
- writeServerBundleDeployManifest(this.appConfig, serverEntryPath);
140
161
  this.logger.info('Server entry file bundled successfully');
141
162
  }
142
163
  /**
@@ -159,6 +180,7 @@ export class ServerStaticBuilder {
159
180
  baseUrl,
160
181
  routeRendererFactory: dependencies.routeRendererFactory,
161
182
  staticRoutes: dependencies.staticRoutes,
183
+ errorPageLoaders: dependencies.errorPageLoaders,
162
184
  force,
163
185
  preserveExportDirectory,
164
186
  });
@@ -12,10 +12,18 @@ export type AttachNodeHttpWebSocketUpgradesOptions = {
12
12
  passthroughUnmatched?: boolean;
13
13
  preflight?: NodeHttpWebSocketUpgradePreflight;
14
14
  };
15
+ /** Upgrade options a host passes when it attaches Ecopages to a server it shares. */
16
+ export type WebSocketUpgradeOptions = Pick<AttachNodeHttpWebSocketUpgradesOptions, 'passthroughUnmatched'>;
15
17
  /**
16
- * Wires Ecopages user WebSocket routes onto a Node HTTP server's `upgrade` event.
18
+ * Wires Ecopages WebSocket upgrades onto a Node HTTP server's `upgrade` event.
17
19
  *
18
20
  * Used by the Node adapter in standalone mode and by host integrations such as
19
21
  * the Vite plugin that embed Ecopages behind a foreign HTTP server.
22
+ *
23
+ * @remarks
24
+ * This is the single owner of the unmatched-upgrade policy: an upgrade claimed
25
+ * by `preflight` (for example `/_hmr`) or a user route is handled here, and
26
+ * anything else is destroyed unless `passthroughUnmatched` leaves it for other
27
+ * listeners on a shared server.
20
28
  */
21
29
  export declare function attachNodeHttpWebSocketUpgrades(server: NodeHttpServer, options: AttachNodeHttpWebSocketUpgradesOptions): void;
@@ -71,13 +71,19 @@ async function setupNodeWebSocketConnection(ws, wsMatch, req, runtimeOrigin, sea
71
71
  });
72
72
  }
73
73
  /**
74
- * Wires Ecopages user WebSocket routes onto a Node HTTP server's `upgrade` event.
74
+ * Wires Ecopages WebSocket upgrades onto a Node HTTP server's `upgrade` event.
75
75
  *
76
76
  * Used by the Node adapter in standalone mode and by host integrations such as
77
77
  * the Vite plugin that embed Ecopages behind a foreign HTTP server.
78
+ *
79
+ * @remarks
80
+ * This is the single owner of the unmatched-upgrade policy: an upgrade claimed
81
+ * by `preflight` (for example `/_hmr`) or a user route is handled here, and
82
+ * anything else is destroyed unless `passthroughUnmatched` leaves it for other
83
+ * listeners on a shared server.
78
84
  */
79
85
  export function attachNodeHttpWebSocketUpgrades(server, options) {
80
- if (options.websocketHandlers.size === 0) {
86
+ if (options.websocketHandlers.size === 0 && !options.preflight) {
81
87
  return;
82
88
  }
83
89
  if (attachedUpgradeServers.has(server)) {
@@ -45,6 +45,7 @@ build/
45
45
  app-build-manifest-runtime.ts contributor collection at startup
46
46
  contracts/ EcoBuildPlugin, BuildOptions, AppBuildManifest
47
47
  runtime/ profiles, executors, request policy/identity
48
+ server-bundle-publication.ts staged server/config artifact publication
48
49
  rolldown/ bundler adapter, plugin bridge, output normalization
49
50
  cache/ persisted caches, fingerprints, unified pages graph
50
51
  browser/ client runtime rewrites, JSX ownership, Lit worker guard
@@ -60,7 +61,9 @@ build/
60
61
  - `rolldown/rolldown-plugin-bridge.ts`: `EcoBuildPlugin[]` → bundler-plugin translation.
61
62
  - `runtime/serialized-build-executor.ts`: FIFO queue primitive.
62
63
  - `cache/server-entry-build-cache.ts`: production server-entry bundle cache (`.eco/.server-entry/.build-cache.json` + `dist/.server/manifest.json`).
64
+ - `server-bundle-publication.ts`: stages the server entry, emitted config, and deploy manifest together, then publishes the complete directory with rollback.
63
65
  - `cache/cache-constants.ts`: shared `.build-cache.json` filename for persisted production caches.
66
+ - `cache/output-imports.ts`: lists the local files reachable from a compiled module, including shared chunks, so a cached module is reused only while they exist.
64
67
  - `*.test.ts`: regression coverage colocated with each module.
65
68
 
66
69
  ## Default Flow
@@ -137,13 +140,9 @@ App-manifest plugins keep canonical registration order and cannot be silently re
137
140
 
138
141
  ## BuildOptions Caveats
139
142
 
140
- `BuildOptions` is modeled on the bundler's options shape. Most fields map cleanly. The exceptions:
143
+ `BuildOptions` is modeled on the bundler's options shape. Most fields map cleanly. The exception:
141
144
 
142
145
  - `splitting` — when `false` with a single entrypoint, maps to Rolldown `codeSplitting: false` so dynamic imports stay in one file. Multi-entrypoint builds ignore `splitting: false` because Rolldown cannot inline across multiple inputs.
143
- - `bundle` — accepted but ignored. The bundler always bundles.
144
- - `outbase` — accepted but ignored. The adapter derives the base from `options.root` directly.
145
-
146
- These fields are kept in the type so existing call-sites compile. The proper fix is a more focused `BuildOptions` schema in a follow-up.
147
146
 
148
147
  ## Dev / watch path
149
148
 
@@ -176,6 +175,8 @@ Two persisted cache layers accelerate production builds. Both use `.build-cache.
176
175
 
177
176
  `requireBuildRuntime(appConfig).getProfile('server-entry')` serves server-entry bundling. `clearProductionBuildCaches()` wipes both manifest trees, resets in-memory route-module state, and clears `buildRuntime`.
178
177
 
178
+ Server-entry cache hits require every recorded runtime artifact. Cache misses build the server entry and emitted config in a sibling staging directory; the deploy manifest joins that generation before the directory is published. A failed build therefore leaves the previous server generation intact.
179
+
179
180
  The route-module registry (`route-module-build-cache-registry.ts`) shares one `RouteModuleBuildCache` per `(app, outdir)` pair. Legacy `.server-route-modules` outdirs are still read for migration but new writes go to `.server-modules`.
180
181
 
181
182
  ## Unified pages graph
@@ -187,7 +188,9 @@ Production static exports compile all template pages in one Rolldown invocation
187
188
  | Graph manifest | `.eco/.server-pages-graph/.build-cache.json` |
188
189
  | Chunk outputs | `.eco/.server-modules/` (shared with per-route cache) |
189
190
 
190
- `StaticSiteGenerator` calls `ensurePagesUnifiedGraphBuilt()` before the export loop. `PageModuleImportService` imports prebuilt chunks via `importPagesUnifiedGraphModule()` and falls back to per-page Rolldown on miss. This is separate from production Page Browser Graph prebuild (`production-page-browser-graph-prebuild.ts`), which warms browser assets in `page-browser-graph-session`.
191
+ `StaticSiteGenerator` calls `ensurePagesUnifiedGraphBuilt()` before the export loop. `PageModuleImportService` imports prebuilt chunks via `importPagesUnifiedGraphModule()` and falls back to per-page Rolldown on miss.
192
+
193
+ A persisted graph is reused only when it matches the core package version, the build inputs and the build key, and every local file reachable from its outputs still exists. `importPagesUnifiedGraphModule()` applies the same check, because pages can be imported before the export loop runs. This is separate from production Page Browser Graph prebuild (`production-page-browser-graph-prebuild.ts`), which warms browser assets in `page-browser-graph-session`.
191
194
 
192
195
  `ECOPAGES_ROLLDOWN_BUILD_METRICS=1` enables `rolldown/rolldown-build-invocation-metrics.ts` counters used by bench and parity tests.
193
196
 
@@ -1,4 +1,2 @@
1
1
  /** Filename written beside persisted production build artifacts that store incremental metadata. */
2
2
  export declare const ROUTE_MODULE_BUILD_CACHE_FILENAME = ".build-cache.json";
3
- /** @deprecated Use {@link ROUTE_MODULE_BUILD_CACHE_FILENAME}; server-entry caches share the same filename. */
4
- export declare const SERVER_ENTRY_BUILD_CACHE_FILENAME = ".build-cache.json";
@@ -1,4 +1,2 @@
1
1
  /** Filename written beside persisted production build artifacts that store incremental metadata. */
2
2
  export const ROUTE_MODULE_BUILD_CACHE_FILENAME = '.build-cache.json';
3
- /** @deprecated Use {@link ROUTE_MODULE_BUILD_CACHE_FILENAME}; server-entry caches share the same filename. */
4
- export const SERVER_ENTRY_BUILD_CACHE_FILENAME = ROUTE_MODULE_BUILD_CACHE_FILENAME;
@@ -18,5 +18,3 @@ export declare function createSourceTransformCacheKey(sourceTransforms: BuildOpt
18
18
  * agree within one install; not stable across minifiers or renames.
19
19
  */
20
20
  export declare function hashFunctionIdentity(fn: (...args: never[]) => unknown): string;
21
- /** @deprecated Use {@link hashFunctionIdentity}. */
22
- export declare const hashPluginSetup: typeof hashFunctionIdentity;
@@ -67,5 +67,3 @@ export function hashFunctionIdentity(fn) {
67
67
  }
68
68
  return (hash >>> 0).toString(36);
69
69
  }
70
- /** @deprecated Use {@link hashFunctionIdentity}. */
71
- export const hashPluginSetup = hashFunctionIdentity;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Lists the local files a compiled module imports: relative, absolute and
3
+ * `file:` specifiers in static imports, re-exports and literal dynamic imports.
4
+ *
5
+ * @remarks
6
+ * Persisted build caches record these so a cached module is reused only while
7
+ * the shared chunks and generated modules it loads (for example
8
+ * `.server-collections`) still exist. Uses `parseSync` directly rather than the
9
+ * shared parse cache, so large compiled bundles are not retained in memory.
10
+ */
11
+ export declare function collectLocalImports(code: string, modulePath: string): string[];
12
+ export type LocalImportFileAccess = {
13
+ exists: (filePath: string) => boolean;
14
+ readFile: (filePath: string) => string;
15
+ };
16
+ /**
17
+ * Lists every local file reachable from `modulePath` through local imports.
18
+ *
19
+ * @remarks
20
+ * Direct {@link collectLocalImports} misses shared chunks that a page output
21
+ * only reaches through another chunk. Persisted caches walk this graph so reuse
22
+ * fails when any reachable file is gone. `modulePath` itself is omitted; callers
23
+ * already check that the compiled output exists.
24
+ */
25
+ export declare function collectReachableLocalImports(modulePath: string, fileAccess?: LocalImportFileAccess): string[];
26
+ /** Reads a compiled module from disk and lists its local imports. */
27
+ export declare function readLocalImports(modulePath: string): string[];