@ecopages/core 0.2.0-rc.8 → 0.2.0

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 (216) hide show
  1. package/README.md +39 -38
  2. package/package.json +22 -152
  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/server-adapter.d.ts +14 -0
  7. package/src/adapters/abstract/server-adapter.js +10 -0
  8. package/src/adapters/abstract/ws-pattern-matcher.d.ts +0 -5
  9. package/src/adapters/abstract/ws-pattern-matcher.js +0 -9
  10. package/src/adapters/bun/create-app.d.ts +12 -16
  11. package/src/adapters/bun/create-app.js +25 -55
  12. package/src/adapters/bun/hmr-manager.d.ts +0 -1
  13. package/src/adapters/bun/hmr-manager.js +2 -4
  14. package/src/adapters/bun/server-adapter.d.ts +15 -21
  15. package/src/adapters/bun/server-adapter.js +33 -67
  16. package/src/adapters/bun/static-preview-host.d.ts +1 -0
  17. package/src/adapters/bun/static-preview-host.js +1 -1
  18. package/src/adapters/create-app.d.ts +63 -8
  19. package/src/adapters/create-app.js +62 -5
  20. package/src/adapters/node/create-app.d.ts +8 -12
  21. package/src/adapters/node/create-app.js +22 -14
  22. package/src/adapters/node/runtime-host.d.ts +10 -10
  23. package/src/adapters/node/runtime-host.js +13 -8
  24. package/src/adapters/node/server-adapter-dependencies.d.ts +2 -10
  25. package/src/adapters/node/server-adapter-dependencies.js +8 -13
  26. package/src/adapters/node/server-adapter.d.ts +30 -32
  27. package/src/adapters/node/server-adapter.js +59 -65
  28. package/src/adapters/shared/hmr/shared-hmr-manager.d.ts +0 -4
  29. package/src/adapters/shared/hmr/shared-hmr-manager.js +0 -12
  30. package/src/adapters/shared/http/api-request-pipeline.d.ts +27 -1
  31. package/src/adapters/shared/http/api-request-pipeline.js +31 -16
  32. package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
  33. package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -9
  34. package/src/adapters/shared/http/fs-server-response-factory.js +5 -33
  35. package/src/adapters/shared/http/fs-server-response-matcher.d.ts +24 -24
  36. package/src/adapters/shared/http/fs-server-response-matcher.js +59 -83
  37. package/src/adapters/shared/runtime/application-adapter.d.ts +1 -0
  38. package/src/adapters/shared/runtime/application-adapter.js +12 -0
  39. package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
  40. package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
  41. package/src/adapters/shared/runtime/collect-dev-prewarm-plan.d.ts +1 -3
  42. package/src/adapters/shared/runtime/collect-dev-prewarm-plan.js +1 -4
  43. package/src/adapters/shared/runtime/port-manager-default-prompt.d.ts +6 -0
  44. package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
  45. package/src/adapters/shared/runtime/port-manager.d.ts +3 -3
  46. package/src/adapters/shared/runtime/port-manager.js +14 -45
  47. package/src/adapters/shared/runtime/runtime-app-bootstrap.d.ts +0 -10
  48. package/src/adapters/shared/runtime/runtime-app-bootstrap.js +0 -7
  49. package/src/adapters/shared/runtime/runtime-host.d.ts +5 -2
  50. package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +1 -1
  51. package/src/adapters/shared/runtime/runtime-server-lifecycle.js +1 -1
  52. package/src/adapters/shared/runtime/server-adapter.d.ts +26 -5
  53. package/src/adapters/shared/runtime/server-adapter.js +35 -8
  54. package/src/adapters/shared/runtime/server-route-handler.js +11 -3
  55. package/src/adapters/shared/runtime/server-static-builder.d.ts +9 -3
  56. package/src/adapters/shared/runtime/server-static-builder.js +59 -37
  57. package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +9 -1
  58. package/src/adapters/shared/ws/node-http-websocket-upgrades.js +8 -2
  59. package/src/build/README.md +12 -8
  60. package/src/build/cache/cache-constants.d.ts +0 -2
  61. package/src/build/cache/cache-constants.js +0 -2
  62. package/src/build/cache/cache-keys.d.ts +0 -2
  63. package/src/build/cache/cache-keys.js +0 -2
  64. package/src/build/cache/output-imports.d.ts +35 -0
  65. package/src/build/cache/output-imports.js +87 -0
  66. package/src/build/cache/pages-unified-graph-build.d.ts +15 -1
  67. package/src/build/cache/pages-unified-graph-build.js +73 -22
  68. package/src/build/cache/production-build-cache.d.ts +2 -2
  69. package/src/build/cache/production-build-cache.js +2 -2
  70. package/src/build/cache/server-entry-build-cache.d.ts +25 -3
  71. package/src/build/cache/server-entry-build-cache.js +129 -13
  72. package/src/build/contracts/build-contracts.d.ts +1 -13
  73. package/src/build/rolldown/runtime-build-output-normalizer.js +3 -6
  74. package/src/build/runtime/build-request-identity.d.ts +2 -6
  75. package/src/build/runtime/build-request-identity.js +2 -8
  76. package/src/build/runtime/build-request-policy.js +1 -1
  77. package/src/build/runtime/deduping-build-executor.d.ts +0 -1
  78. package/src/build/runtime/deduping-build-executor.js +0 -1
  79. package/src/build/server-bundle-publication.d.ts +14 -0
  80. package/src/build/server-bundle-publication.js +49 -0
  81. package/src/cache/index.d.ts +1 -1
  82. package/src/cache/index.js +1 -1
  83. package/src/cache/module-parse-cache.d.ts +2 -29
  84. package/src/cache/module-parse-cache.js +6 -39
  85. package/src/config/README.md +17 -2
  86. package/src/config/apply-user-config.d.ts +8 -0
  87. package/src/config/apply-user-config.js +68 -0
  88. package/src/config/config-builder.d.ts +11 -1
  89. package/src/config/config-builder.js +53 -12
  90. package/src/config/constants.d.ts +4 -4
  91. package/src/config/constants.js +4 -4
  92. package/src/config/define-config.d.ts +9 -0
  93. package/src/config/define-config.js +10 -0
  94. package/src/config/index.d.ts +5 -0
  95. package/src/config/index.js +4 -0
  96. package/src/config/is-finalized-app-config.d.ts +6 -0
  97. package/src/config/is-finalized-app-config.js +11 -0
  98. package/src/config/load-eco-config.d.ts +21 -0
  99. package/src/config/load-eco-config.js +107 -0
  100. package/src/config/resolve-eco-config-path.d.ts +32 -0
  101. package/src/config/resolve-eco-config-path.js +58 -0
  102. package/src/config/server-config-bundle.d.ts +25 -0
  103. package/src/config/server-config-bundle.js +148 -0
  104. package/src/config/user-config-types.d.ts +170 -0
  105. package/src/config/user-config-types.js +1 -0
  106. package/src/dev/README.md +4 -0
  107. package/src/dev/development-restart-watch-paths.d.ts +13 -0
  108. package/src/dev/development-restart-watch-paths.js +37 -0
  109. package/src/dev/development-restart.d.ts +13 -0
  110. package/src/dev/development-restart.js +21 -0
  111. package/src/dev/host-runtime.d.ts +0 -1
  112. package/src/dev/host-runtime.js +0 -3
  113. package/src/dev/sc-server.d.ts +4 -1
  114. package/src/dev/sc-server.js +11 -20
  115. package/src/dev/transform-server/dev-transform-import-rewriter.js +2 -2
  116. package/src/eco/eco.js +4 -0
  117. package/src/errors/http-error-page-contract.d.ts +77 -0
  118. package/src/errors/http-error-page-contract.js +106 -0
  119. package/src/hmr/hmr-file-change-prep.d.ts +0 -1
  120. package/src/hmr/hmr-file-change-prep.js +2 -5
  121. package/src/hmr/hmr-strategy.d.ts +3 -8
  122. package/src/hmr/hmr-strategy.js +3 -8
  123. package/src/index.browser.d.ts +1 -2
  124. package/src/index.browser.js +1 -2
  125. package/src/index.d.ts +5 -6
  126. package/src/index.js +5 -6
  127. package/src/islands/island-host.d.ts +0 -9
  128. package/src/islands/island-host.js +1 -13
  129. package/src/plugins/component-import-discovery.js +2 -2
  130. package/src/plugins/eco-component-meta-plugin.js +5 -5
  131. package/src/plugins/integration-plugin.d.ts +0 -1
  132. package/src/plugins/integration-plugin.js +0 -4
  133. package/src/plugins/processor.d.ts +6 -2
  134. package/src/route-renderer/README.md +4 -0
  135. package/src/{adapters/shared/http/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +3 -3
  136. package/src/route-renderer/orchestration/custom-element-scripts/README.md +2 -2
  137. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +14 -2
  138. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +12 -5
  139. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +8 -0
  140. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +19 -0
  141. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +1 -4
  142. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +25 -24
  143. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +18 -20
  144. package/src/route-renderer/orchestration/integration-renderer.d.ts +24 -7
  145. package/src/route-renderer/orchestration/integration-renderer.js +44 -33
  146. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +1 -1
  147. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -1
  148. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -1
  149. package/src/route-renderer/route-renderer.d.ts +9 -0
  150. package/src/route-renderer/route-renderer.js +18 -0
  151. package/src/services/README.md +2 -1
  152. package/src/services/assets/browser-bundle.service.d.ts +1 -6
  153. package/src/services/error-pages/README.md +9 -0
  154. package/src/services/error-pages/default-error-pages.d.ts +39 -0
  155. package/src/services/error-pages/default-error-pages.js +199 -0
  156. package/src/services/error-pages/error-page-renderer.d.ts +58 -0
  157. package/src/services/error-pages/error-page-renderer.js +146 -0
  158. package/src/services/error-pages/semantic-error-page-exporter.d.ts +23 -0
  159. package/src/services/error-pages/semantic-error-page-exporter.js +35 -0
  160. package/src/services/html/html-rewriter.d.ts +77 -0
  161. package/src/services/html/html-rewriter.js +751 -0
  162. package/src/services/html/html-rewriter.parity.test.bun.d.ts +1 -0
  163. package/src/services/html/html-rewriter.parity.test.bun.js +74 -0
  164. package/src/services/html/html-transformer.service.d.ts +29 -42
  165. package/src/services/html/html-transformer.service.js +85 -157
  166. package/src/services/invalidation/development-invalidation.service.d.ts +9 -20
  167. package/src/services/invalidation/development-invalidation.service.js +26 -39
  168. package/src/services/module-loading/README.md +20 -15
  169. package/src/services/module-loading/app-module-loader.service.d.ts +0 -2
  170. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +1 -1
  171. package/src/services/module-loading/app-server-module-transpiler.service.js +2 -10
  172. package/src/services/module-loading/collection-server-module-build.service.d.ts +0 -1
  173. package/src/services/module-loading/collection-server-module-build.service.js +0 -3
  174. package/src/services/module-loading/host-module-loader-registry.d.ts +0 -1
  175. package/src/services/module-loading/host-module-loader-registry.js +0 -3
  176. package/src/services/module-loading/route-module-build-cache-registry.d.ts +0 -4
  177. package/src/services/module-loading/route-module-build-cache-registry.js +0 -4
  178. package/src/services/module-loading/route-module-build-cache.store.d.ts +8 -0
  179. package/src/services/module-loading/route-module-build-cache.store.js +25 -7
  180. package/src/services/module-loading/route-module-build-manifest.d.ts +12 -1
  181. package/src/services/module-loading/route-module-build-manifest.js +7 -3
  182. package/src/services/module-loading/route-module-dependency-hasher.d.ts +3 -2
  183. package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
  184. package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -15
  185. package/src/services/module-loading/server-module-transpiler.service.js +0 -24
  186. package/src/services/module-loading/view-module-loader.d.ts +10 -0
  187. package/src/services/module-loading/view-module-loader.js +46 -0
  188. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -12
  189. package/src/services/runtime-state/server-invalidation-state.service.d.ts +4 -2
  190. package/src/services/runtime-state/server-invalidation-state.service.js +7 -14
  191. package/src/static-site-generator/README.md +12 -8
  192. package/src/static-site-generator/static-site-generator.d.ts +3 -2
  193. package/src/static-site-generator/static-site-generator.js +17 -3
  194. package/src/types/internal-types.d.ts +1 -38
  195. package/src/types/public-types.d.ts +28 -130
  196. package/src/watchers/project-watcher.d.ts +9 -16
  197. package/src/watchers/project-watcher.js +35 -28
  198. package/src/watchers/project-watcher.test-helpers.d.ts +10 -1
  199. package/src/watchers/project-watcher.test-helpers.js +12 -0
  200. package/src/adapters/abstract/router-adapter.d.ts +0 -26
  201. package/src/adapters/abstract/router-adapter.js +0 -13
  202. package/src/adapters/bun/index.d.ts +0 -2
  203. package/src/adapters/bun/index.js +0 -2
  204. package/src/adapters/index.d.ts +0 -2
  205. package/src/adapters/index.js +0 -2
  206. package/src/eco/eco.utils.d.ts +0 -1
  207. package/src/eco/eco.utils.js +0 -1
  208. package/src/services/cache/index.d.ts +0 -9
  209. package/src/services/cache/index.js +0 -8
  210. package/src/services/html/html-rewriter-provider.service.d.ts +0 -40
  211. package/src/services/html/html-rewriter-provider.service.js +0 -68
  212. package/src/services/module-loading/route-module-build-cache.d.ts +0 -4
  213. package/src/services/module-loading/route-module-build-cache.js +0 -3
  214. package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
  215. package/src/services/runtime-state/dev-graph.service.js +0 -170
  216. /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
@@ -0,0 +1,106 @@
1
+ import { HttpError } from './http-error.js';
2
+ /**
3
+ * HTTP statuses that own a semantic HTML error page (`pages/{status}.*` and
4
+ * matching `app.*()` loaders).
5
+ */
6
+ export const HTTP_ERROR_PAGE_STATUSES = [400, 401, 403, 404, 409, 500];
7
+ export const ERROR_PAGE_KIND_BY_STATUS = {
8
+ 400: 'badRequest',
9
+ 401: 'unauthorized',
10
+ 403: 'forbidden',
11
+ 404: 'notFound',
12
+ 409: 'conflict',
13
+ 500: 'serverError',
14
+ };
15
+ export const ERROR_PAGE_STATUS_BY_KIND = {
16
+ badRequest: 400,
17
+ unauthorized: 401,
18
+ forbidden: 403,
19
+ notFound: 404,
20
+ conflict: 409,
21
+ serverError: 500,
22
+ };
23
+ export const SEMANTIC_ERROR_PAGE_PATHNAMES = HTTP_ERROR_PAGE_STATUSES.map((status) => `/${status}`);
24
+ /**
25
+ * Built-in copy and CSS modifier suffix for each semantic HTML error page.
26
+ */
27
+ export const ERROR_PAGE_COPY = {
28
+ 400: {
29
+ title: 'Bad Request',
30
+ message: 'The request could not be understood.',
31
+ modifier: 'bad-request',
32
+ },
33
+ 401: {
34
+ title: 'Unauthorized',
35
+ message: 'Authentication is required to access this page.',
36
+ modifier: 'unauthorized',
37
+ },
38
+ 403: {
39
+ title: 'Forbidden',
40
+ message: 'You do not have permission to access this page.',
41
+ modifier: 'forbidden',
42
+ },
43
+ 404: {
44
+ title: 'Not Found',
45
+ message: 'The page you requested could not be found.',
46
+ modifier: 'not-found',
47
+ },
48
+ 409: {
49
+ title: 'Conflict',
50
+ message: 'The request could not be completed due to a conflict.',
51
+ modifier: 'conflict',
52
+ },
53
+ 500: {
54
+ title: 'Something went wrong',
55
+ message: 'An error occurred while handling this request.',
56
+ modifier: 'server-error',
57
+ },
58
+ };
59
+ export function isHttpErrorPageStatus(status) {
60
+ return HTTP_ERROR_PAGE_STATUSES.includes(status);
61
+ }
62
+ export function isHttpErrorStatus(status) {
63
+ return Number.isInteger(status) && status >= 400 && status <= 599;
64
+ }
65
+ /**
66
+ * Resolves the semantic page kind for an HTTP status.
67
+ *
68
+ * @remarks
69
+ * Factory statuses map 1:1. Other 5xx statuses reuse the server-error page
70
+ * with the original status. Other 4xx statuses have no custom page and use a
71
+ * built-in document.
72
+ */
73
+ export function kindForStatus(status) {
74
+ if (isHttpErrorPageStatus(status)) {
75
+ return ERROR_PAGE_KIND_BY_STATUS[status];
76
+ }
77
+ if (status >= 500 && status <= 599) {
78
+ return 'serverError';
79
+ }
80
+ return undefined;
81
+ }
82
+ export function classifyPageFailure(error) {
83
+ if (error instanceof Response) {
84
+ return {
85
+ status: error.status,
86
+ kind: kindForStatus(error.status),
87
+ logAsServerError: error.status >= 500,
88
+ };
89
+ }
90
+ if (HttpError.isHttpError(error)) {
91
+ const status = isHttpErrorStatus(error.status) ? error.status : 500;
92
+ return {
93
+ status,
94
+ kind: kindForStatus(status),
95
+ logAsServerError: status >= 500,
96
+ };
97
+ }
98
+ return {
99
+ status: 500,
100
+ kind: 'serverError',
101
+ logAsServerError: true,
102
+ };
103
+ }
104
+ export function shouldLogPageFailure(error) {
105
+ return classifyPageFailure(error).logAsServerError;
106
+ }
@@ -2,7 +2,6 @@ import type { EcoPagesAppConfig } from '../types/internal-types.js';
2
2
  import { type AffectedGraphIdentity } from '../route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js';
3
3
  export type HmrFileChangePreparation = {
4
4
  affectedGraphIdentities: AffectedGraphIdentity[];
5
- invalidatedGraphCount: number;
6
5
  };
7
6
  /**
8
7
  * Invalidates affected Page Browser Graph records before HMR strategy dispatch.
@@ -6,9 +6,6 @@ import { getAffectedPageBrowserGraphIdentities, invalidatePageBrowserGraphSessio
6
6
  export function prepareHmrFileChange(appConfig, filePath) {
7
7
  const resolvedFilePath = path.resolve(filePath);
8
8
  const affectedGraphIdentities = getAffectedPageBrowserGraphIdentities(appConfig, resolvedFilePath);
9
- const invalidatedGraphCount = invalidatePageBrowserGraphSession(appConfig, resolvedFilePath);
10
- return {
11
- affectedGraphIdentities,
12
- invalidatedGraphCount,
13
- };
9
+ invalidatePageBrowserGraphSession(appConfig, resolvedFilePath);
10
+ return { affectedGraphIdentities };
14
11
  }
@@ -26,7 +26,7 @@ import type { ClientBridgeEvent } from '../types/public-types.js';
26
26
  */
27
27
  /**
28
28
  * Defines the category of an HMR strategy, which determines its execution priority.
29
- * Strategies are evaluated in descending order: INTEGRATION → ASSET → SCRIPT → FALLBACK.
29
+ * Strategies are evaluated in descending order: INTEGRATION → SCRIPT → FALLBACK.
30
30
  *
31
31
  * @remarks
32
32
  * The numeric values represent base priorities. Strategies can fine-tune their priority
@@ -38,11 +38,6 @@ export declare const HmrStrategyType: {
38
38
  * Highest priority to allow framework-specific HMR handling.
39
39
  */
40
40
  readonly INTEGRATION: 100;
41
- /**
42
- * Asset processing strategies (CSS, images, etc.)
43
- * High priority for specialized asset handling.
44
- */
45
- readonly ASSET: 50;
46
41
  /**
47
42
  * Generic script bundling strategies (JS/TS)
48
43
  * Medium priority for standard script processing.
@@ -82,8 +77,8 @@ export interface HmrAction {
82
77
  *
83
78
  * @example
84
79
  * ```typescript
85
- * class MyAssetStrategy extends HmrStrategy {
86
- * readonly type = HmrStrategyType.ASSET;
80
+ * class MyImageStrategy extends HmrStrategy {
81
+ * readonly type = HmrStrategyType.INTEGRATION;
87
82
  * readonly priorityOffset = 5;
88
83
  *
89
84
  * matches(filePath: string): boolean {
@@ -25,7 +25,7 @@
25
25
  */
26
26
  /**
27
27
  * Defines the category of an HMR strategy, which determines its execution priority.
28
- * Strategies are evaluated in descending order: INTEGRATION → ASSET → SCRIPT → FALLBACK.
28
+ * Strategies are evaluated in descending order: INTEGRATION → SCRIPT → FALLBACK.
29
29
  *
30
30
  * @remarks
31
31
  * The numeric values represent base priorities. Strategies can fine-tune their priority
@@ -37,11 +37,6 @@ export const HmrStrategyType = {
37
37
  * Highest priority to allow framework-specific HMR handling.
38
38
  */
39
39
  INTEGRATION: 100,
40
- /**
41
- * Asset processing strategies (CSS, images, etc.)
42
- * High priority for specialized asset handling.
43
- */
44
- ASSET: 50,
45
40
  /**
46
41
  * Generic script bundling strategies (JS/TS)
47
42
  * Medium priority for standard script processing.
@@ -66,8 +61,8 @@ export const HmrStrategyType = {
66
61
  *
67
62
  * @example
68
63
  * ```typescript
69
- * class MyAssetStrategy extends HmrStrategy {
70
- * readonly type = HmrStrategyType.ASSET;
64
+ * class MyImageStrategy extends HmrStrategy {
65
+ * readonly type = HmrStrategyType.INTEGRATION;
71
66
  * readonly priorityOffset = 5;
72
67
  *
73
68
  * matches(filePath: string): boolean {
@@ -3,5 +3,4 @@ export type * from './eco/eco.types.js';
3
3
  export { eco } from './eco/eco.browser.js';
4
4
  export { bindComponentIdentity, getComponentIdentity, type ComponentIdentity } from './eco/component-identity.js';
5
5
  export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
6
- export { listFileOwnedDependencyContributions, mergePageDependencies } from './eco/page-dependency-contributions.js';
7
- export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
6
+ export { mergePageDependencies } from './eco/page-dependency-contributions.js';
@@ -1,5 +1,4 @@
1
1
  export { eco } from './eco/eco.browser.js';
2
2
  export { bindComponentIdentity, getComponentIdentity } from './eco/component-identity.js';
3
3
  export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
4
- export { listFileOwnedDependencyContributions, mergePageDependencies } from './eco/page-dependency-contributions.js';
5
- export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
4
+ export { mergePageDependencies } from './eco/page-dependency-contributions.js';
package/src/index.d.ts CHANGED
@@ -2,11 +2,10 @@ export type * from './types/public-types.js';
2
2
  export type * from './eco/eco.types.js';
3
3
  export { eco } from './eco/eco.js';
4
4
  export { defineApiHandler, defineGroupHandler, defineGet, definePost, definePut, defineDelete, definePatch, defineOptions, defineHead, json, html, redirect, type GroupHandler, } from './adapters/shared/http/define-api-handler.js';
5
- export { createEcoBuildPluginFromSourceTransform, createVitePluginsFromAppSourceTransforms, getAppSourceTransforms, createVitePluginFromSourceTransform, normalizeTransformId, type EcoSourceTransform, type EcoSourceTransformResult, type EcoViteCompatiblePlugin, } from './plugins/source-transform.js';
6
- export { attributeComponentIdentity, attributeMdxComponentIdentity, createEcoComponentMetaTransform, } from './plugins/eco-component-meta-plugin.js';
5
+ export { createVitePluginsFromAppSourceTransforms, createVitePluginFromSourceTransform, type EcoSourceTransform, type EcoSourceTransformResult, type EcoViteCompatiblePlugin, } from './plugins/source-transform.js';
6
+ export { attributeMdxComponentIdentity, createEcoComponentMetaTransform } from './plugins/eco-component-meta-plugin.js';
7
7
  export { bindComponentIdentity, getComponentIdentity, type ComponentIdentity } from './eco/component-identity.js';
8
- export { attachDiscoveredDependencies, registerDiscoveredDependencies, getInferredStylesheets, type DiscoveredDependencies, } from './eco/discovered-dependencies.js';
9
- export { listFileOwnedDependencyContributions, mergePageDependencies } from './eco/page-dependency-contributions.js';
10
- export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
8
+ export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
9
+ export { mergePageDependencies } from './eco/page-dependency-contributions.js';
11
10
  export { SchemaError, validateStandardSchema } from './services/validation/validate-standard-schema.js';
12
- export { buildIslandHostAttributes, ECO_ISLAND_HOST_ATTRIBUTE, ECO_ISLAND_INTEGRATION_ATTRIBUTE, finalizeIslandComponentRender, isIslandHostElement, mergeIslandHostAttributes, } from './islands/island-host.js';
11
+ export { buildIslandHostAttributes, finalizeIslandComponentRender } from './islands/island-host.js';
package/src/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
  export { eco } from './eco/eco.js';
2
2
  export { defineApiHandler, defineGroupHandler, defineGet, definePost, definePut, defineDelete, definePatch, defineOptions, defineHead, json, html, redirect, } from './adapters/shared/http/define-api-handler.js';
3
- export { createEcoBuildPluginFromSourceTransform, createVitePluginsFromAppSourceTransforms, getAppSourceTransforms, createVitePluginFromSourceTransform, normalizeTransformId, } from './plugins/source-transform.js';
4
- export { attributeComponentIdentity, attributeMdxComponentIdentity, createEcoComponentMetaTransform, } from './plugins/eco-component-meta-plugin.js';
3
+ export { createVitePluginsFromAppSourceTransforms, createVitePluginFromSourceTransform, } from './plugins/source-transform.js';
4
+ export { attributeMdxComponentIdentity, createEcoComponentMetaTransform } from './plugins/eco-component-meta-plugin.js';
5
5
  export { bindComponentIdentity, getComponentIdentity } from './eco/component-identity.js';
6
- export { attachDiscoveredDependencies, registerDiscoveredDependencies, getInferredStylesheets, } from './eco/discovered-dependencies.js';
7
- export { listFileOwnedDependencyContributions, mergePageDependencies } from './eco/page-dependency-contributions.js';
8
- export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
6
+ export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
7
+ export { mergePageDependencies } from './eco/page-dependency-contributions.js';
9
8
  export { SchemaError, validateStandardSchema } from './services/validation/validate-standard-schema.js';
10
- export { buildIslandHostAttributes, ECO_ISLAND_HOST_ATTRIBUTE, ECO_ISLAND_INTEGRATION_ATTRIBUTE, finalizeIslandComponentRender, isIslandHostElement, mergeIslandHostAttributes, } from './islands/island-host.js';
9
+ export { buildIslandHostAttributes, finalizeIslandComponentRender } from './islands/island-host.js';
@@ -10,16 +10,7 @@ export type IslandHostAttributesInput = {
10
10
  props?: Record<string, unknown>;
11
11
  existing?: Record<string, string>;
12
12
  };
13
- /**
14
- * @remarks Presence marker for hydratable component hosts, similar in spirit to Astro's `astro-island`.
15
- */
16
- export declare function mergeIslandHostAttributes(input: {
17
- integrationName: string;
18
- componentInstanceId: string;
19
- existing?: Record<string, string>;
20
- }): Record<string, string>;
21
13
  export declare function buildIslandHostAttributes(input: IslandHostAttributesInput): Record<string, string>;
22
- export declare function isIslandHostElement(element: Element): boolean;
23
14
  export declare function componentRenderHasIslandBootstrap(assets: Array<{
24
15
  kind: string;
25
16
  }> | undefined): boolean;
@@ -6,7 +6,7 @@ export const ECO_ISLAND_PROPS_ATTRIBUTE = 'data-eco-props';
6
6
  /**
7
7
  * @remarks Presence marker for hydratable component hosts, similar in spirit to Astro's `astro-island`.
8
8
  */
9
- export function mergeIslandHostAttributes(input) {
9
+ function mergeIslandHostAttributes(input) {
10
10
  return {
11
11
  ...input.existing,
12
12
  [ECO_ISLAND_HOST_ATTRIBUTE]: '',
@@ -24,18 +24,6 @@ export function buildIslandHostAttributes(input) {
24
24
  }
25
25
  return attributes;
26
26
  }
27
- export function isIslandHostElement(element) {
28
- if (element.hasAttribute(ECO_ISLAND_HOST_ATTRIBUTE)) {
29
- return true;
30
- }
31
- if (element.hasAttribute(ECO_ISLAND_COMPONENT_KEY_ATTRIBUTE)) {
32
- return true;
33
- }
34
- if (element.tagName.toLowerCase() === 'eco-island') {
35
- return true;
36
- }
37
- return element.hasAttribute(ECO_ISLAND_COMPONENT_ID_ATTRIBUTE) && element.hasAttribute(ECO_ISLAND_PROPS_ATTRIBUTE);
38
- }
39
27
  export function componentRenderHasIslandBootstrap(assets) {
40
28
  return (assets ?? []).some((asset) => asset.kind === 'script');
41
29
  }
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import { existsSync, readFileSync, realpathSync } from 'node:fs';
3
- import { cachedParseSync } from '../cache/module-parse-cache.js';
3
+ import { parseModuleSource } from '../cache/module-parse-cache.js';
4
4
  import { loadTsconfigPathPrefixes, matchesTsconfigPathPrefix, resolveProjectModulePath, } from './tsconfig-import-resolver.js';
5
5
  function node(value) {
6
6
  return typeof value === 'object' && value !== null ? value : undefined;
@@ -90,7 +90,7 @@ function indexModuleExports(file, cache) {
90
90
  if (cached)
91
91
  return cached;
92
92
  const source = readFileSync(file, 'utf8');
93
- const parsed = cachedParseSync(file, source, { sourceType: 'module' });
93
+ const parsed = parseModuleSource(file, source, { sourceType: 'module' });
94
94
  const body = nodes(parsed.program.body);
95
95
  const { declared, factories } = collectDeclaredFactoryBindings(body);
96
96
  const namedReexports = new Map();
@@ -1,6 +1,6 @@
1
1
  import { prependJsxImportSourceIfMissing } from './jsx-import-source.utils.js';
2
2
  import { createEcoBuildPluginFromSourceTransform, createVitePluginFromSourceTransform } from './source-transform.js';
3
- import { cachedParseSync } from '../cache/module-parse-cache.js';
3
+ import { parseModuleSource } from '../cache/module-parse-cache.js';
4
4
  import { rapidhash } from '../utils/hash.js';
5
5
  import { discoverComponentImports } from './component-import-discovery.js';
6
6
  function integrationForFile(filePath, config) {
@@ -98,7 +98,7 @@ export function attributeComponentIdentity(contents, filePath, integration, proj
98
98
  return contents;
99
99
  let program;
100
100
  try {
101
- program = cachedParseSync(filePath, contents, { sourceType: 'module' }).program;
101
+ program = parseModuleSource(filePath, contents, { sourceType: 'module' }).program;
102
102
  }
103
103
  catch {
104
104
  return contents;
@@ -133,7 +133,7 @@ export function attributeComponentIdentity(contents, filePath, integration, proj
133
133
  for (const edit of edits.sort((left, right) => right.start - left.start)) {
134
134
  transformed = `${transformed.slice(0, edit.start)}${edit.replacement}${transformed.slice(edit.end)}`;
135
135
  }
136
- return addIdentityBindingImport(transformed, cachedParseSync(filePath, transformed, { sourceType: 'module' }).program);
136
+ return addIdentityBindingImport(transformed, parseModuleSource(filePath, transformed, { sourceType: 'module' }).program);
137
137
  }
138
138
  function findMdxConfigDeclarator(program) {
139
139
  for (const statement of nodes(program?.body)) {
@@ -180,7 +180,7 @@ export function attributeMdxComponentIdentity(contents, filePath, integration, p
180
180
  }
181
181
  let program;
182
182
  try {
183
- program = cachedParseSync(filePath, contents, { lang: 'jsx', sourceType: 'module' })
183
+ program = parseModuleSource(filePath, contents, { lang: 'jsx', sourceType: 'module' })
184
184
  .program;
185
185
  }
186
186
  catch {
@@ -206,7 +206,7 @@ export function attributeMdxComponentIdentity(contents, filePath, integration, p
206
206
  transformed = `${transformed.slice(0, edit.start)}${edit.replacement}${transformed.slice(edit.end)}`;
207
207
  }
208
208
  transformed = `${transformed}\n${appended}`;
209
- return addNamedImport(transformed, cachedParseSync(filePath, transformed, { lang: 'jsx', sourceType: 'module' }).program, '@ecopages/core', ['bindComponentIdentity', 'attachDiscoveredDependencies']);
209
+ return addNamedImport(transformed, parseModuleSource(filePath, transformed, { lang: 'jsx', sourceType: 'module' }).program, '@ecopages/core', ['bindComponentIdentity', 'attachDiscoveredDependencies']);
210
210
  }
211
211
  export function createEcoComponentMetaTransform(options) {
212
212
  const extensions = options.config.integrations
@@ -25,7 +25,6 @@ export declare const INTEGRATION_PLUGIN_ERRORS: {
25
25
  readonly NOT_INITIALIZED_WITH_ASSET_SERVICE: "Plugin not initialized with asset dependency service";
26
26
  };
27
27
  export declare function mergeIntegrationOptions<TDefaults, TOverrides>(defaults: TDefaults, overrides: TOverrides): TDefaults & TOverrides;
28
- export declare function assertIntegrationInvariant(condition: boolean, message?: string): asserts condition;
29
28
  /**
30
29
  * Base configuration shared by all integration plugins.
31
30
  *
@@ -1,7 +1,6 @@
1
1
  import { createBrowserRuntimeManifest, } from '../build/browser/browser-runtime-manifest.js';
2
2
  import { AssetProcessingService } from '../services/assets/asset-processing-service/asset-processing.service.js';
3
3
  import { deepMerge } from '../utils/deep-merge.js';
4
- import { invariant } from '../utils/invariant.js';
5
4
  export const INTEGRATION_PLUGIN_ERRORS = {
6
5
  NOT_INITIALIZED_WITH_APP_CONFIG: 'Plugin not initialized with app config',
7
6
  NOT_INITIALIZED_WITH_ASSET_SERVICE: 'Plugin not initialized with asset dependency service',
@@ -9,9 +8,6 @@ export const INTEGRATION_PLUGIN_ERRORS = {
9
8
  export function mergeIntegrationOptions(defaults, overrides) {
10
9
  return deepMerge(defaults, overrides);
11
10
  }
12
- export function assertIntegrationInvariant(condition, message) {
13
- invariant(condition, message);
14
- }
15
11
  /**
16
12
  * Base class for framework integrations.
17
13
  *
@@ -62,7 +62,7 @@ export interface ProcessorAssetCapability {
62
62
  */
63
63
  extensions?: ProcessorExtensionPattern[];
64
64
  }
65
- export interface ProcessorConfig<TOptions = Record<string, unknown>> {
65
+ export interface ProcessorConfig<TOptions = unknown> {
66
66
  name: string;
67
67
  description?: string;
68
68
  options?: TOptions;
@@ -77,6 +77,10 @@ export interface ProcessorContext {
77
77
  distDir: string;
78
78
  cache?: string;
79
79
  }
80
+ /**
81
+ * Unconstrained processor type for heterogeneous processor collections.
82
+ */
83
+ export type AnyProcessor = Processor<unknown>;
80
84
  /**
81
85
  * Base class for content and asset processors that contribute build plugins.
82
86
  *
@@ -90,7 +94,7 @@ export interface ProcessorContext {
90
94
  * Virtual modules that must resolve during route-module transpile belong in
91
95
  * `plugins`. Browser-only bundler hooks belong in `buildPlugins`.
92
96
  */
93
- export declare abstract class Processor<TOptions = Record<string, unknown>> {
97
+ export declare abstract class Processor<TOptions = unknown> {
94
98
  readonly name: string;
95
99
  protected context?: ProcessorContext;
96
100
  protected options?: TOptions;
@@ -52,6 +52,10 @@ See [`../build/README.md`](../build/README.md) for the JSX ownership helper spli
52
52
  - `RouteRendererFactory` chooses integration renderers from route files
53
53
  - `RouteRenderer` delegates execution to the selected renderer
54
54
 
55
+ ### `explicit-view-render-preparation.ts`
56
+
57
+ Resolves the integration renderer and static props for one `eco.page()` view. Explicit static routes, static export, and registered error pages share this helper so view rendering does not fork per caller.
58
+
55
59
  ### `orchestration/`
56
60
 
57
61
  Root renderer classes:
@@ -1,6 +1,6 @@
1
- import type { EcoPagesAppConfig } from '../../../types/internal-types.js';
2
- import type { EcoFunctionComponent, EcoPageComponent } from '../../../types/public-types.js';
3
- import type { ExplicitViewRenderer, ExplicitViewRendererResolver } from '../../../route-renderer/route-renderer.js';
1
+ import type { EcoPagesAppConfig } from '../types/internal-types.js';
2
+ import type { EcoFunctionComponent, EcoPageComponent } from '../types/public-types.js';
3
+ import type { ExplicitViewRenderer, ExplicitViewRendererResolver } from './route-renderer.js';
4
4
  type ExplicitStaticRenderPreparationResult = {
5
5
  renderer: ExplicitViewRenderer;
6
6
  props: Record<string, unknown>;
@@ -4,6 +4,6 @@ Shared orchestration for `dependencies.scripts` entries marked `ssr: true`.
4
4
 
5
5
  Lit and Ecopages JSX construct a {@link CustomElementScriptPreloader} with a stable `cacheScope` so imports are deduplicated across concurrent renders and dev invalidation can clear preload state without per-renderer registries.
6
6
 
7
- Server evaluation uses `appConfig.runtime.appModuleLoader` via {@link createCustomElementServerModuleImporter} when no {@link createCustomElementSsrPreloadEntrypointResolver} is configured. Lit's main-thread session and Ecopages JSX pass a resolver so Node preloads through the asset pipeline and Bun can import source. The resolver skips {@link importServerModule}; Lit's static-render worker therefore omits it and uses the app module loader so `@lit-labs/ssr` sees registered custom elements.
7
+ Server evaluation uses `appConfig.runtime.appModuleLoader` via {@link createCustomElementServerModuleImporter} when no {@link createCustomElementSsrPreloadEntrypointResolver} is configured. Lit passes a resolver so Node preloads through the asset pipeline and Bun can import source. The resolver skips {@link importServerModule}; Lit's static-render worker therefore omits it and uses the app module loader so `@lit-labs/ssr` sees registered custom elements. Ecopages JSX does not pass a resolver. On Bun, `preferSourceImports` imports the script source directly. On Node it imports through the page server-module loader with external packages, because the dev asset pipeline still points at `.tsx` source and a browser bundle would register a second Radiant graph.
8
8
 
9
- Lit only preloads lazy `ssr: true` script entries (`requireLazyScriptEntry`) so eager registrations are not evaluated in an isolated graph that would break `@lit-labs/ssr`.
9
+ Lit only preloads lazy `ssr: true` script entries (`requireLazyScriptEntry`) so eager registrations are not evaluated in an isolated graph that would break `@lit-labs/ssr`. Ecopages JSX sets `collectForIntegration` so foreign integration scripts in shared dependency trees are not preloaded here; Lit and other hosts keep owning their registrations.
@@ -13,7 +13,7 @@ export declare function isExpectedCustomElementSsrPreloadError(error: unknown):
13
13
  /**
14
14
  * Collects `dependencies.scripts` paths marked `ssr: true` from a component tree.
15
15
  */
16
- export declare function collectCustomElementSsrPreloadScripts(components: Array<CustomElementSsrPreloadComponent | undefined>, resolveDependencyPath: (componentDir: string, sourcePath: string) => string, requireLazyScriptEntry?: boolean): string[];
16
+ export declare function collectCustomElementSsrPreloadScripts(components: Array<CustomElementSsrPreloadComponent | undefined>, resolveDependencyPath: (componentDir: string, sourcePath: string) => string, requireLazyScriptEntry?: boolean, collectForIntegration?: string): string[];
17
17
  export interface CustomElementScriptPreloaderOptions {
18
18
  cacheScope: string;
19
19
  enabled?: boolean;
@@ -36,6 +36,17 @@ export interface CustomElementScriptPreloaderOptions {
36
36
  */
37
37
  resolvePreloadEntrypoint?: (scriptPath: string) => Promise<string>;
38
38
  importServerModule?: (scriptPath: string, registryKey: string) => Promise<unknown>;
39
+ /**
40
+ * Limits script collection to components owned by one integration.
41
+ *
42
+ * @remarks
43
+ * Dependency trees may include foreign integrations whose `ssr: true` scripts
44
+ * are preloaded by their own renderer. Ownership uses
45
+ * `config.integration ?? identity.integration`, matching render routing.
46
+ * Ecopages JSX still walks nested components so it can find owned Radiant
47
+ * hosts deeper in the graph.
48
+ */
49
+ collectForIntegration?: string;
39
50
  logLabel?: string;
40
51
  }
41
52
  /**
@@ -54,8 +65,9 @@ export declare class CustomElementScriptPreloader {
54
65
  private readonly preferSourceImports;
55
66
  private readonly resolvePreloadEntrypoint?;
56
67
  private readonly importServerModule?;
68
+ private readonly collectForIntegration?;
57
69
  private readonly logLabel;
58
- constructor({ cacheScope, enabled, requireLazyScriptEntry, resolveDependencyPath, preferSourceImports, resolvePreloadEntrypoint, importServerModule, logLabel, }: CustomElementScriptPreloaderOptions);
70
+ constructor({ cacheScope, enabled, requireLazyScriptEntry, resolveDependencyPath, preferSourceImports, resolvePreloadEntrypoint, importServerModule, collectForIntegration, logLabel, }: CustomElementScriptPreloaderOptions);
59
71
  invalidateScript(scriptPath: string): void;
60
72
  isExpectedSsrPreloadError(error: unknown): boolean;
61
73
  collectSsrPreloadScripts(components: Array<CustomElementSsrPreloadComponent | undefined>): string[];
@@ -45,7 +45,7 @@ function collectSsrScriptsFromConfig(config, scriptPaths, resolveDependencyPath,
45
45
  /**
46
46
  * Collects `dependencies.scripts` paths marked `ssr: true` from a component tree.
47
47
  */
48
- export function collectCustomElementSsrPreloadScripts(components, resolveDependencyPath, requireLazyScriptEntry = false) {
48
+ export function collectCustomElementSsrPreloadScripts(components, resolveDependencyPath, requireLazyScriptEntry = false, collectForIntegration) {
49
49
  const scriptPaths = new Set();
50
50
  const visitedConfigs = new Set();
51
51
  const collect = (component) => {
@@ -54,8 +54,13 @@ export function collectCustomElementSsrPreloadScripts(components, resolveDepende
54
54
  return;
55
55
  }
56
56
  visitedConfigs.add(config);
57
- const componentFile = getComponentIdentity(component?.config)?.file;
58
- collectSsrScriptsFromConfig(config, scriptPaths, resolveDependencyPath, componentFile, requireLazyScriptEntry);
57
+ const identity = getComponentIdentity(config);
58
+ const integration = config.integration ?? identity?.integration;
59
+ const ownsScripts = !collectForIntegration || integration === collectForIntegration;
60
+ const componentFile = ownsScripts ? identity?.file : undefined;
61
+ if (ownsScripts) {
62
+ collectSsrScriptsFromConfig(config, scriptPaths, resolveDependencyPath, componentFile, requireLazyScriptEntry);
63
+ }
59
64
  for (const layout of config.layouts ?? []) {
60
65
  collect(layout);
61
66
  }
@@ -84,8 +89,9 @@ export class CustomElementScriptPreloader {
84
89
  preferSourceImports;
85
90
  resolvePreloadEntrypoint;
86
91
  importServerModule;
92
+ collectForIntegration;
87
93
  logLabel;
88
- constructor({ cacheScope, enabled = true, requireLazyScriptEntry = false, resolveDependencyPath, preferSourceImports, resolvePreloadEntrypoint, importServerModule, logLabel = 'ecopages', }) {
94
+ constructor({ cacheScope, enabled = true, requireLazyScriptEntry = false, resolveDependencyPath, preferSourceImports, resolvePreloadEntrypoint, importServerModule, collectForIntegration, logLabel = 'ecopages', }) {
89
95
  this.cacheScope = cacheScope;
90
96
  this.enabled = enabled;
91
97
  this.requireLazyScriptEntry = requireLazyScriptEntry;
@@ -93,6 +99,7 @@ export class CustomElementScriptPreloader {
93
99
  this.preferSourceImports = preferSourceImports ?? typeof Bun !== 'undefined';
94
100
  this.resolvePreloadEntrypoint = resolvePreloadEntrypoint;
95
101
  this.importServerModule = importServerModule;
102
+ this.collectForIntegration = collectForIntegration;
96
103
  this.logLabel = logLabel;
97
104
  }
98
105
  invalidateScript(scriptPath) {
@@ -102,7 +109,7 @@ export class CustomElementScriptPreloader {
102
109
  return isExpectedCustomElementSsrPreloadError(error);
103
110
  }
104
111
  collectSsrPreloadScripts(components) {
105
- return collectCustomElementSsrPreloadScripts(components, this.resolveDependencyPath, this.requireLazyScriptEntry);
112
+ return collectCustomElementSsrPreloadScripts(components, this.resolveDependencyPath, this.requireLazyScriptEntry, this.collectForIntegration);
106
113
  }
107
114
  /**
108
115
  * Preloads SSR-eligible scripts to register custom elements before render.
@@ -7,3 +7,11 @@ import type { EcoPagesAppConfig } from '../../../types/internal-types.js';
7
7
  * not share mutable module evaluation state.
8
8
  */
9
9
  export declare function createCustomElementServerModuleImporter(appConfig: EcoPagesAppConfig, outdirSegment: string): (filePath: string, registryKey: string) => Promise<unknown>;
10
+ /**
11
+ * Imports an `ssr: true` script through the same server-module graph as pages.
12
+ *
13
+ * @remarks A per-registry outdir with `forceBuild` compiles a second copy of
14
+ * Radiant and breaks host SSR. This outdir matches page imports and keeps
15
+ * package specifiers external.
16
+ */
17
+ export declare function createSharedServerModuleImporter(appConfig: EcoPagesAppConfig): (filePath: string) => Promise<unknown>;
@@ -1,4 +1,6 @@
1
1
  import path from 'node:path';
2
+ import { getAppModuleLoader } from '../../../services/module-loading/app-server-module-transpiler.service.js';
3
+ import { resolveInternalExecutionDir } from '../../../utils/resolve-work-dir.js';
2
4
  /**
3
5
  * Imports one registered script through the app server module loader for SSR.
4
6
  *
@@ -20,3 +22,20 @@ export function createCustomElementServerModuleImporter(appConfig, outdirSegment
20
22
  });
21
23
  };
22
24
  }
25
+ /**
26
+ * Imports an `ssr: true` script through the same server-module graph as pages.
27
+ *
28
+ * @remarks A per-registry outdir with `forceBuild` compiles a second copy of
29
+ * Radiant and breaks host SSR. This outdir matches page imports and keeps
30
+ * package specifiers external.
31
+ */
32
+ export function createSharedServerModuleImporter(appConfig) {
33
+ return async (filePath) => {
34
+ return getAppModuleLoader(appConfig).importModule({
35
+ filePath,
36
+ rootDir: appConfig.rootDir,
37
+ outdir: `${resolveInternalExecutionDir(appConfig)}/.server-modules`,
38
+ externalPackages: true,
39
+ });
40
+ };
41
+ }
@@ -150,8 +150,5 @@ export async function finalizeDocumentShellHtml(htmlTransformer, options) {
150
150
  if (!shouldTransform) {
151
151
  return html;
152
152
  }
153
- const transformedResponse = await htmlTransformer.transform(new Response(html, {
154
- headers: { 'Content-Type': 'text/html' },
155
- }), options.htmlContributions);
156
- return await transformedResponse.text();
153
+ return htmlTransformer.transformHtml(html, options.htmlContributions);
157
154
  }