@ecopages/core 0.2.0-beta.26 → 0.2.0-beta.28

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 (177) hide show
  1. package/README.md +1 -1
  2. package/package.json +98 -74
  3. package/src/adapters/bun/server-adapter.js +2 -2
  4. package/src/adapters/node/server-adapter.js +2 -2
  5. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +10 -0
  6. package/src/adapters/shared/hmr-entrypoint-registrar.js +34 -10
  7. package/src/adapters/shared/runtime-server-lifecycle.js +1 -1
  8. package/src/adapters/shared/server-static-builder.d.ts +2 -1
  9. package/src/adapters/shared/server-static-builder.js +16 -14
  10. package/src/adapters/shared/shared-hmr-manager.d.ts +11 -4
  11. package/src/adapters/shared/shared-hmr-manager.js +22 -3
  12. package/src/build/README.md +92 -46
  13. package/src/build/app-build-manifest-runtime.d.ts +28 -2
  14. package/src/build/app-build-manifest-runtime.js +26 -10
  15. package/src/build/{browser-runtime-plugin.d.ts → browser/browser-runtime-plugin.d.ts} +1 -1
  16. package/src/build/{browser-runtime-plugin.js → browser/browser-runtime-plugin.js} +1 -1
  17. package/src/build/{jsx-ownership-plugins.d.ts → browser/jsx-ownership-plugins.d.ts} +2 -2
  18. package/src/build/{jsx-ownership-plugins.js → browser/jsx-ownership-plugins.js} +2 -2
  19. package/src/build/build-adapter.d.ts +18 -21
  20. package/src/build/build-adapter.js +8 -43
  21. package/src/build/{build-input-fingerprint.d.ts → cache/build-input-fingerprint.d.ts} +3 -3
  22. package/src/build/cache/cache-constants.d.ts +4 -0
  23. package/src/build/cache/cache-constants.js +6 -0
  24. package/src/build/cache/cache-keys.d.ts +22 -0
  25. package/src/build/cache/cache-keys.js +63 -0
  26. package/src/build/{dev-browser-script-cache.d.ts → cache/dev-browser-script-cache.d.ts} +2 -2
  27. package/src/build/{dev-browser-script-cache.js → cache/dev-browser-script-cache.js} +4 -4
  28. package/src/build/{pages-unified-graph-build.d.ts → cache/pages-unified-graph-build.d.ts} +1 -1
  29. package/src/build/{pages-unified-graph-build.js → cache/pages-unified-graph-build.js} +18 -26
  30. package/src/build/{production-build-cache.d.ts → cache/production-build-cache.d.ts} +1 -1
  31. package/src/build/{production-build-cache.js → cache/production-build-cache.js} +2 -2
  32. package/src/build/{server-entry-build-cache.d.ts → cache/server-entry-build-cache.d.ts} +3 -4
  33. package/src/build/{server-entry-build-cache.js → cache/server-entry-build-cache.js} +16 -12
  34. package/src/build/{build-contracts.d.ts → contracts/build-contracts.d.ts} +1 -2
  35. package/src/build/contracts/build-manifest.d.ts +90 -0
  36. package/src/build/{build-manifest.js → contracts/build-manifest.js} +2 -2
  37. package/src/build/{rolldown-adapter-helpers.d.ts → rolldown/rolldown-adapter-helpers.d.ts} +20 -3
  38. package/src/build/{rolldown-adapter-helpers.js → rolldown/rolldown-adapter-helpers.js} +26 -6
  39. package/src/build/{rolldown-build-adapter.d.ts → rolldown/rolldown-build-adapter.d.ts} +1 -1
  40. package/src/build/{rolldown-plugin-bridge.d.ts → rolldown/rolldown-plugin-bridge.d.ts} +2 -2
  41. package/src/build/{rolldown-plugin-bridge.js → rolldown/rolldown-plugin-bridge.js} +1 -1
  42. package/src/build/{rolldown-source-transform-pass.d.ts → rolldown/rolldown-source-transform-pass.d.ts} +1 -1
  43. package/src/build/{rolldown-source-transform-pass.js → rolldown/rolldown-source-transform-pass.js} +4 -1
  44. package/src/build/{runtime-build-output-normalizer.js → rolldown/runtime-build-output-normalizer.js} +2 -2
  45. package/src/build/{build-profile-options.d.ts → runtime/build-profile-options.d.ts} +2 -2
  46. package/src/build/runtime/build-request-identity.d.ts +17 -0
  47. package/src/build/runtime/build-request-identity.js +54 -0
  48. package/src/build/runtime/build-request-policy.d.ts +59 -0
  49. package/src/build/runtime/build-request-policy.js +46 -0
  50. package/src/build/{build-runtime.d.ts → runtime/build-runtime.d.ts} +8 -4
  51. package/src/build/{build-runtime.js → runtime/build-runtime.js} +11 -11
  52. package/src/build/{deduping-build-executor.d.ts → runtime/deduping-build-executor.d.ts} +2 -9
  53. package/src/build/runtime/deduping-build-executor.js +34 -0
  54. package/src/build/{parallel-build-executor.d.ts → runtime/parallel-build-executor.d.ts} +1 -1
  55. package/src/build/{serialized-build-executor.d.ts → runtime/serialized-build-executor.d.ts} +1 -1
  56. package/src/config/config-builder.d.ts +1 -1
  57. package/src/diagnostics/startup-trace.d.ts +49 -2
  58. package/src/diagnostics/startup-trace.js +140 -8
  59. package/src/eco/eco.js +2 -2
  60. package/src/eco/eco.utils.d.ts +1 -1
  61. package/src/eco/eco.utils.js +1 -1
  62. package/src/hmr/client/hmr-runtime.js +2 -2
  63. package/src/hmr/hmr-file-change-prep.d.ts +10 -0
  64. package/src/hmr/hmr-file-change-prep.js +17 -0
  65. package/src/plugins/alias-resolver-plugin.d.ts +1 -1
  66. package/src/plugins/eco-component-meta-plugin.d.ts +1 -1
  67. package/src/plugins/foreign-jsx-override-plugin.d.ts +1 -1
  68. package/src/plugins/integration-plugin.d.ts +16 -5
  69. package/src/plugins/integration-plugin.js +11 -1
  70. package/src/plugins/processor.d.ts +36 -8
  71. package/src/plugins/source-transform.d.ts +1 -1
  72. package/src/route-renderer/GRAPH.md +22 -28
  73. package/src/route-renderer/README.md +12 -7
  74. package/src/route-renderer/orchestration/{document-shell-render.service.d.ts → document-shell/document-shell-render.service.d.ts} +19 -2
  75. package/src/route-renderer/orchestration/{document-shell-render.service.js → document-shell/document-shell-render.service.js} +28 -0
  76. package/src/route-renderer/orchestration/{layout-shell-props.service.d.ts → document-shell/layout-shell-props.service.d.ts} +1 -1
  77. package/src/route-renderer/orchestration/{component-render-context.d.ts → foreign-child/component-render-context.d.ts} +5 -5
  78. package/src/route-renderer/orchestration/{component-render-context.js → foreign-child/component-render-context.js} +1 -1
  79. package/src/route-renderer/orchestration/{render-output.utils.d.ts → foreign-child/foreign-child-output.utils.d.ts} +15 -7
  80. package/src/route-renderer/orchestration/{render-output.utils.js → foreign-child/foreign-child-output.utils.js} +31 -26
  81. package/src/route-renderer/orchestration/{foreign-subtree-execution.service.d.ts → foreign-child/foreign-subtree-execution.service.d.ts} +5 -5
  82. package/src/route-renderer/orchestration/{foreign-subtree-execution.service.js → foreign-child/foreign-subtree-execution.service.js} +7 -3
  83. package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.d.ts +19 -0
  84. package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.js +35 -0
  85. package/src/route-renderer/orchestration/integration-renderer.d.ts +14 -97
  86. package/src/route-renderer/orchestration/integration-renderer.js +90 -247
  87. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.d.ts +75 -0
  88. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +177 -0
  89. package/src/route-renderer/orchestration/{component-graph-collectors.d.ts → ownership-graph/component-graph-collectors.d.ts} +4 -4
  90. package/src/route-renderer/orchestration/{component-graph-collectors.js → ownership-graph/component-graph-collectors.js} +1 -1
  91. package/src/route-renderer/orchestration/{component-graph.d.ts → ownership-graph/component-graph.d.ts} +1 -3
  92. package/src/route-renderer/orchestration/{component-graph.js → ownership-graph/component-graph.js} +0 -2
  93. package/src/route-renderer/orchestration/{ownership-validation.service.d.ts → ownership-graph/ownership-validation.service.d.ts} +2 -2
  94. package/src/route-renderer/orchestration/{ownership-validation.service.js → ownership-graph/ownership-validation.service.js} +3 -4
  95. package/src/route-renderer/orchestration/{global-injector-assets.service.d.ts → page-browser-graph/global-injector-assets.service.d.ts} +3 -3
  96. package/src/route-renderer/orchestration/{global-injector-assets.service.js → page-browser-graph/global-injector-assets.service.js} +2 -2
  97. package/src/route-renderer/orchestration/{page-browser-graph-contribution.loader.d.ts → page-browser-graph/page-browser-graph-contribution.loader.d.ts} +1 -1
  98. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts +12 -0
  99. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js +29 -0
  100. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +106 -0
  101. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +436 -0
  102. package/src/route-renderer/orchestration/{page-browser-graph.service.d.ts → page-browser-graph/page-browser-graph.service.d.ts} +12 -6
  103. package/src/route-renderer/orchestration/{page-browser-graph.service.js → page-browser-graph/page-browser-graph.service.js} +91 -42
  104. package/src/route-renderer/orchestration/{processed-asset-dedupe.d.ts → page-browser-graph/processed-asset-dedupe.d.ts} +1 -1
  105. package/src/route-renderer/orchestration/{integration-route-render-adapter.d.ts → route-pipeline/integration-route-render-adapter.d.ts} +3 -10
  106. package/src/route-renderer/orchestration/{integration-route-render-adapter.js → route-pipeline/integration-route-render-adapter.js} +1 -3
  107. package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.d.ts +6 -0
  108. package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.js +27 -0
  109. package/src/route-renderer/orchestration/{route-html-finalization.service.d.ts → route-pipeline/route-html-finalization.service.d.ts} +2 -3
  110. package/src/route-renderer/orchestration/route-pipeline/route-html-finalization.service.js +21 -0
  111. package/src/route-renderer/orchestration/{route-prepared-options.builder.d.ts → route-pipeline/route-prepared-options.builder.d.ts} +3 -4
  112. package/src/route-renderer/orchestration/{route-prepared-options.builder.js → route-pipeline/route-prepared-options.builder.js} +3 -12
  113. package/src/route-renderer/orchestration/{route-prepared-options.utils.js → route-pipeline/route-prepared-options.utils.js} +1 -1
  114. package/src/route-renderer/orchestration/{route-render-orchestrator.d.ts → route-pipeline/route-render-orchestrator.d.ts} +8 -17
  115. package/src/route-renderer/orchestration/{route-render-orchestrator.js → route-pipeline/route-render-orchestrator.js} +12 -19
  116. package/src/route-renderer/orchestration/string-markup-renderer.js +1 -1
  117. package/src/services/assets/asset-processing-service/asset-processing.service.js +1 -1
  118. package/src/services/assets/asset-processing-service/assets.types.d.ts +1 -1
  119. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +1 -1
  120. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +0 -2
  121. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +2 -15
  122. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +1 -1
  123. package/src/services/assets/browser-bundle.service.d.ts +27 -31
  124. package/src/services/assets/browser-bundle.service.js +12 -23
  125. package/src/services/html/html-transformer.service.js +1 -1
  126. package/src/services/invalidation/development-invalidation.service.d.ts +5 -0
  127. package/src/services/invalidation/development-invalidation.service.js +8 -9
  128. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +8 -0
  129. package/src/services/module-loading/app-server-module-transpiler.service.js +1 -7
  130. package/src/services/module-loading/page-module-import.service.d.ts +1 -1
  131. package/src/services/module-loading/page-module-import.service.js +40 -28
  132. package/src/services/module-loading/route-module-build-cache.store.js +1 -1
  133. package/src/services/module-loading/route-module-build-manifest.d.ts +2 -9
  134. package/src/services/module-loading/route-module-build-manifest.js +12 -43
  135. package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -1
  136. package/src/static-site-generator/README.md +1 -1
  137. package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +28 -0
  138. package/src/static-site-generator/production-page-browser-graph-prebuild.js +22 -0
  139. package/src/static-site-generator/static-build-invalidation.d.ts +2 -2
  140. package/src/static-site-generator/static-build-invalidation.js +3 -3
  141. package/src/static-site-generator/static-site-generator.js +23 -1
  142. package/src/types/internal-types.d.ts +10 -4
  143. package/src/types/public-types.d.ts +59 -10
  144. package/src/watchers/project-watcher.d.ts +3 -3
  145. package/src/watchers/project-watcher.js +15 -5
  146. package/src/build/build-manifest.d.ts +0 -33
  147. package/src/build/deduping-build-executor.js +0 -56
  148. package/src/build/runtime-build-executor.d.ts +0 -14
  149. package/src/build/runtime-build-executor.js +0 -16
  150. package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +0 -1
  151. package/src/route-renderer/orchestration/declared-ownership-graph.js +0 -8
  152. package/src/route-renderer/orchestration/route-html-finalization.service.js +0 -26
  153. package/src/route-renderer/orchestration/template-serialization.d.ts +0 -38
  154. package/src/route-renderer/orchestration/template-serialization.js +0 -45
  155. /package/src/build/{browser-runtime-manifest.d.ts → browser/browser-runtime-manifest.d.ts} +0 -0
  156. /package/src/build/{browser-runtime-manifest.js → browser/browser-runtime-manifest.js} +0 -0
  157. /package/src/build/{browser-runtime-plugin-helpers.d.ts → browser/browser-runtime-plugin-helpers.d.ts} +0 -0
  158. /package/src/build/{browser-runtime-plugin-helpers.js → browser/browser-runtime-plugin-helpers.js} +0 -0
  159. /package/src/build/{lit-static-render-worker-context.d.ts → browser/lit-static-render-worker-context.d.ts} +0 -0
  160. /package/src/build/{lit-static-render-worker-context.js → browser/lit-static-render-worker-context.js} +0 -0
  161. /package/src/build/{build-input-fingerprint.js → cache/build-input-fingerprint.js} +0 -0
  162. /package/src/build/{build-contracts.js → contracts/build-contracts.js} +0 -0
  163. /package/src/build/{build-types.d.ts → contracts/build-types.d.ts} +0 -0
  164. /package/src/build/{build-types.js → contracts/build-types.js} +0 -0
  165. /package/src/build/{rolldown-build-adapter.js → rolldown/rolldown-build-adapter.js} +0 -0
  166. /package/src/build/{rolldown-build-invocation-metrics.d.ts → rolldown/rolldown-build-invocation-metrics.d.ts} +0 -0
  167. /package/src/build/{rolldown-build-invocation-metrics.js → rolldown/rolldown-build-invocation-metrics.js} +0 -0
  168. /package/src/build/{runtime-build-output-normalizer.d.ts → rolldown/runtime-build-output-normalizer.d.ts} +0 -0
  169. /package/src/build/{server-side-css-shim-plugin.d.ts → rolldown/server-side-css-shim-plugin.d.ts} +0 -0
  170. /package/src/build/{server-side-css-shim-plugin.js → rolldown/server-side-css-shim-plugin.js} +0 -0
  171. /package/src/build/{build-profile-options.js → runtime/build-profile-options.js} +0 -0
  172. /package/src/build/{parallel-build-executor.js → runtime/parallel-build-executor.js} +0 -0
  173. /package/src/build/{serialized-build-executor.js → runtime/serialized-build-executor.js} +0 -0
  174. /package/src/route-renderer/orchestration/{layout-shell-props.service.js → document-shell/layout-shell-props.service.js} +0 -0
  175. /package/src/route-renderer/orchestration/{page-browser-graph-contribution.loader.js → page-browser-graph/page-browser-graph-contribution.loader.js} +0 -0
  176. /package/src/route-renderer/orchestration/{processed-asset-dedupe.js → page-browser-graph/processed-asset-dedupe.js} +0 -0
  177. /package/src/route-renderer/orchestration/{route-prepared-options.utils.d.ts → route-pipeline/route-prepared-options.utils.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { fileSystem } from "@ecopages/file-system";
3
- import { getAppBrowserBuildPlugins } from "./build-adapter.js";
3
+ import { getAppBrowserBuildPlugins } from "../build-adapter.js";
4
4
  import { createBuildInputsFingerprint, hashAppConfigFile } from "./build-input-fingerprint.js";
5
5
  import {
6
6
  readProductionCacheManifest,
@@ -8,9 +8,9 @@ import {
8
8
  isProductionCacheManifestCurrent,
9
9
  matchesProductionCacheFingerprint
10
10
  } from "./production-build-cache.js";
11
- import { getCorePackageVersion } from "../services/module-loading/route-module-build-manifest.js";
12
- import { resolveInternalExecutionDir } from "../utils/resolve-work-dir.js";
13
- import { isDevelopmentRuntime } from "../utils/runtime.js";
11
+ import { getCorePackageVersion } from "./cache-keys.js";
12
+ import { resolveInternalExecutionDir } from "../../utils/resolve-work-dir.js";
13
+ import { isDevelopmentRuntime } from "../../utils/runtime.js";
14
14
  const DEV_BROWSER_SCRIPT_CACHE_DIR = ".browser-script-bundles";
15
15
  const DEV_BROWSER_SCRIPT_CACHE_FILENAME = ".build-cache.json";
16
16
  function getDevBrowserScriptCacheDir(appConfig) {
@@ -5,7 +5,7 @@
5
5
  * `ECOPAGES_UNIFIED_PAGES_GRAPH=0`. Covers all static page template extensions
6
6
  * registered on the app config.
7
7
  */
8
- import type { EcoPagesAppConfig } from '../types/internal-types.js';
8
+ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
9
9
  export declare const PAGES_UNIFIED_GRAPH_CACHE_DIR = ".server-pages-graph";
10
10
  export declare const PAGES_UNIFIED_GRAPH_CACHE_FILENAME = ".build-cache.json";
11
11
  export interface PagesUnifiedGraphCacheManifest {
@@ -1,10 +1,10 @@
1
1
  import path from "node:path";
2
2
  import { pathToFileURL } from "node:url";
3
3
  import { fileSystem } from "@ecopages/file-system";
4
- import { appLogger } from "../global/app-logger.js";
5
- import { build, getAppServerBuildPlugins } from "./build-adapter.js";
6
- import { requireBuildRuntime } from "./build-runtime.js";
7
- import { resolveBuildProfileOptions } from "./build-profile-options.js";
4
+ import { appLogger } from "../../global/app-logger.js";
5
+ import { build } from "../build-adapter.js";
6
+ import { requireBuildRuntime } from "../runtime/build-runtime.js";
7
+ import { createServerBuildRequest, resolveServerAppBuildPlugins } from "../runtime/build-request-policy.js";
8
8
  import { createBuildInputsFingerprint, hashAppConfigFile } from "./build-input-fingerprint.js";
9
9
  import {
10
10
  isProductionCacheManifestCurrent,
@@ -13,12 +13,10 @@ import {
13
13
  readProductionCacheManifest,
14
14
  writeProductionCacheManifest
15
15
  } from "./production-build-cache.js";
16
- import { getCorePackageVersion } from "../services/module-loading/route-module-build-manifest.js";
17
- import { resolveInternalExecutionDir } from "../utils/resolve-work-dir.js";
18
- import { getSharedRouteModuleBuildCache } from "../services/module-loading/route-module-build-cache-registry.js";
19
- import { normalizeNodeRuntimeBuildOutputFile } from "./runtime-build-output-normalizer.js";
20
- import { resolveRouteModuleDependencyPaths } from "../services/module-loading/route-module-dependency-hasher.js";
21
- import { getJsxOwnershipPlugins } from "./jsx-ownership-plugins.js";
16
+ import { getCorePackageVersion } from "./cache-keys.js";
17
+ import { resolveInternalExecutionDir } from "../../utils/resolve-work-dir.js";
18
+ import { getSharedRouteModuleBuildCache } from "../../services/module-loading/route-module-build-cache-registry.js";
19
+ import { resolveRouteModuleDependencyPaths } from "../../services/module-loading/route-module-dependency-hasher.js";
22
20
  const PAGES_UNIFIED_GRAPH_CACHE_DIR = ".server-pages-graph";
23
21
  const PAGES_UNIFIED_GRAPH_CACHE_FILENAME = ".build-cache.json";
24
22
  function isPagesUnifiedGraphEnabled() {
@@ -45,8 +43,7 @@ function getPagesUnifiedGraphCachePath(appConfig) {
45
43
  );
46
44
  }
47
45
  function createPagesUnifiedGraphBuildKey(appConfig, outdir) {
48
- const plugins = appConfig.runtime?.buildManifest ? getAppServerBuildPlugins(appConfig) : [];
49
- const pluginNames = [...plugins, ...getJsxOwnershipPlugins(appConfig)].map((plugin) => plugin.name).sort().join("|");
46
+ const pluginNames = resolveServerAppBuildPlugins(appConfig).map((plugin) => plugin.name).sort().join("|");
50
47
  const templateExtensions = [...appConfig.templatesExt].sort().join("|");
51
48
  return [
52
49
  path.resolve(outdir),
@@ -121,8 +118,6 @@ async function ensurePagesUnifiedGraphBuilt(options) {
121
118
  appLogger.debug("Reusing pages unified graph cache");
122
119
  return existingManifest;
123
120
  }
124
- const plugins = options.appConfig.runtime?.buildManifest ? getAppServerBuildPlugins(options.appConfig) : [];
125
- const mergedPlugins = [...plugins, ...getJsxOwnershipPlugins(options.appConfig)];
126
121
  const routeModuleBuildCache = getSharedRouteModuleBuildCache(outdir, options.appConfig);
127
122
  const entryRecord = {};
128
123
  const entryKeysByPath = /* @__PURE__ */ new Map();
@@ -132,16 +127,14 @@ async function ensurePagesUnifiedGraphBuilt(options) {
132
127
  entryKeysByPath.set(entryPath, entryKey);
133
128
  }
134
129
  appLogger.debugTime("pagesUnifiedGraphBuild");
135
- const buildOptions = {
136
- ...resolveBuildProfileOptions("route-module", options.appConfig, {
137
- entrypoints: entryRecord,
138
- outdir,
139
- splitting: true,
140
- naming: "[name]-[hash].[ext]",
141
- plugins: mergedPlugins.length > 0 ? mergedPlugins : void 0
142
- }),
143
- entrypoints: entryRecord
144
- };
130
+ const buildOptions = createServerBuildRequest(options.appConfig, {
131
+ profile: "route-module",
132
+ entrypoints: entryRecord,
133
+ outdir,
134
+ splitting: true,
135
+ naming: "[name]-[hash].[ext]"
136
+ });
137
+ const plugins = buildOptions.plugins ?? [];
145
138
  const buildResult = await build(buildOptions, requireBuildRuntime(options.appConfig).getProfile("route-module"));
146
139
  appLogger.debugTimeEnd("pagesUnifiedGraphBuild");
147
140
  if (!buildResult.success) {
@@ -156,7 +149,6 @@ async function ensurePagesUnifiedGraphBuilt(options) {
156
149
  if (!compiledOutput) {
157
150
  throw new Error(`Pages unified graph build produced no output for ${entryPath}`);
158
151
  }
159
- normalizeNodeRuntimeBuildOutputFile(compiledOutput, options.appConfig.rootDir);
160
152
  outputs[entryPath] = compiledOutput;
161
153
  routeModuleBuildCache.recordBuild({
162
154
  filePath: entryPath,
@@ -166,7 +158,7 @@ async function ensurePagesUnifiedGraphBuilt(options) {
166
158
  outputPath: compiledOutput,
167
159
  dependencyModulePaths: resolveRouteModuleDependencyPaths(buildResult, entryPath, options.appConfig.rootDir),
168
160
  externalPackages: true,
169
- plugins: mergedPlugins
161
+ plugins
170
162
  });
171
163
  }
172
164
  const manifest = {
@@ -1,4 +1,4 @@
1
- import type { EcoPagesAppConfig } from '../types/internal-types.js';
1
+ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
2
2
  /**
3
3
  * Shared manifest fields for persisted production build caches.
4
4
  */
@@ -1,7 +1,7 @@
1
1
  import { fileSystem } from "@ecopages/file-system";
2
2
  import path from "node:path";
3
- import { ROUTE_MODULE_BUILD_CACHE_FILENAME } from "../services/module-loading/route-module-build-manifest.js";
4
- import { resolveInternalExecutionDir } from "../utils/resolve-work-dir.js";
3
+ import { ROUTE_MODULE_BUILD_CACHE_FILENAME } from "./cache-constants.js";
4
+ import { resolveInternalExecutionDir } from "../../utils/resolve-work-dir.js";
5
5
  const ROUTE_MODULE_CACHE_OUTDIRS = [".server-modules", ".server-route-modules"];
6
6
  const PAGES_GRAPH_CACHE_DIR = ".server-pages-graph";
7
7
  function getProductionBuildCacheManifestPaths(appConfig) {
@@ -1,7 +1,6 @@
1
- import type { BuildResult } from './build-adapter.js';
2
- import type { EcoPagesAppConfig } from '../types/internal-types.js';
3
- /** @deprecated Use {@link ROUTE_MODULE_BUILD_CACHE_FILENAME}; both caches share the same manifest filename. */
4
- export declare const SERVER_ENTRY_BUILD_CACHE_FILENAME = ".build-cache.json";
1
+ import type { BuildResult } from '../build-adapter.js';
2
+ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
3
+ export { SERVER_ENTRY_BUILD_CACHE_FILENAME } from './cache-constants.js';
5
4
  export declare const SERVER_BUNDLE_MANIFEST_FILENAME = "manifest.json";
6
5
  export interface ServerBundleDeployManifest {
7
6
  serverEntry: string;
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { fileSystem } from "@ecopages/file-system";
3
- import { getAppServerBuildPlugins } from "./build-adapter.js";
3
+ import { resolveServerAppBuildPlugins } from "../runtime/build-request-policy.js";
4
4
  import { createBuildInputsFingerprint } from "./build-input-fingerprint.js";
5
5
  import {
6
6
  isProductionCacheManifestCurrent,
@@ -9,15 +9,15 @@ import {
9
9
  readProductionCacheManifest,
10
10
  writeProductionCacheManifest
11
11
  } from "./production-build-cache.js";
12
- import { getCorePackageVersion } from "../services/module-loading/route-module-build-manifest.js";
12
+ import { createPluginCacheKey, getCorePackageVersion } from "./cache-keys.js";
13
13
  import {
14
14
  RouteModuleDependencyHasher,
15
15
  createRouteModuleDependencyHashes
16
- } from "../services/module-loading/route-module-dependency-hasher.js";
17
- import { resolveInternalExecutionDir } from "../utils/resolve-work-dir.js";
18
- import { SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME } from "../utils/resolve-entry-file.js";
19
- import { ROUTE_MODULE_BUILD_CACHE_FILENAME } from "../services/module-loading/route-module-build-manifest.js";
20
- const SERVER_ENTRY_BUILD_CACHE_FILENAME = ROUTE_MODULE_BUILD_CACHE_FILENAME;
16
+ } from "../../services/module-loading/route-module-dependency-hasher.js";
17
+ import { resolveInternalExecutionDir } from "../../utils/resolve-work-dir.js";
18
+ import { SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME } from "../../utils/resolve-entry-file.js";
19
+ import { SERVER_ENTRY_BUILD_CACHE_FILENAME } from "./cache-constants.js";
20
+ import { SERVER_ENTRY_BUILD_CACHE_FILENAME as SERVER_ENTRY_BUILD_CACHE_FILENAME2 } from "./cache-constants.js";
21
21
  const SERVER_BUNDLE_MANIFEST_FILENAME = "manifest.json";
22
22
  function getServerEntryCacheDir(appConfig) {
23
23
  return path.join(resolveInternalExecutionDir(appConfig), ".server-entry");
@@ -33,11 +33,15 @@ function hashDependencyGraph(entryPath, dependencyGraph, hasher, rootDir) {
33
33
  }
34
34
  function createServerEntryBuildKey(appConfig) {
35
35
  try {
36
- const plugins = getAppServerBuildPlugins(appConfig);
37
- const pluginNames = plugins.map((plugin) => plugin.name).sort().join("|");
38
- return ["node", "esm", "external-packages", pluginNames].join("::");
36
+ return [
37
+ "server-entry-request-v2",
38
+ "node",
39
+ "esm",
40
+ "external-packages",
41
+ createPluginCacheKey(resolveServerAppBuildPlugins(appConfig))
42
+ ].join("::");
39
43
  } catch {
40
- return "node::esm::external-packages";
44
+ return "server-entry-request-v2::node::esm::external-packages";
41
45
  }
42
46
  }
43
47
  function getServerBundleOutputPaths(appConfig) {
@@ -151,7 +155,7 @@ function resolveProductionServerEntry(cwd = process.cwd()) {
151
155
  }
152
156
  export {
153
157
  SERVER_BUNDLE_MANIFEST_FILENAME,
154
- SERVER_ENTRY_BUILD_CACHE_FILENAME,
158
+ SERVER_ENTRY_BUILD_CACHE_FILENAME2 as SERVER_ENTRY_BUILD_CACHE_FILENAME,
155
159
  getServerBundleOutputPaths,
156
160
  lookupServerEntryBuildCache,
157
161
  readServerEntryBuildCacheManifest,
@@ -1,4 +1,4 @@
1
- import type { EcoSourceTransform } from '../plugins/source-transform.js';
1
+ import type { EcoSourceTransform } from '../../plugins/source-transform.js';
2
2
  import type { EcoBuildPlugin } from './build-types.js';
3
3
  /**
4
4
  * Which backend owns the app's build pipeline.
@@ -74,7 +74,6 @@ export interface BuildOptions {
74
74
  };
75
75
  plugins?: EcoBuildPlugin[];
76
76
  sourceTransforms?: EcoSourceTransform[];
77
- [key: string]: unknown;
78
77
  }
79
78
  /** Stable profile identifiers for `BuildAdapter.getTranspileOptions`. */
80
79
  export type BuildTranspileProfile = 'browser-script' | 'hmr-runtime' | 'hmr-entrypoint';
@@ -0,0 +1,90 @@
1
+ import type { EcoBuildPlugin } from './build-types.js';
2
+ import { type BrowserRuntimeManifest } from '../browser/browser-runtime-manifest.js';
3
+ /**
4
+ * Sealed, app-owned registry of build plugins and browser runtime assets.
5
+ *
6
+ * @remarks
7
+ * Core assembles one manifest during {@link ConfigBuilder.build} and stores it on
8
+ * `appConfig.runtime.buildManifest`. Request policy reads from this manifest when
9
+ * constructing server and browser {@link BuildOptions}; profiles do not inject
10
+ * plugins themselves.
11
+ *
12
+ * Contributor naming differs by layer but maps to the same buckets:
13
+ *
14
+ * | Integration getter | Processor getter | Manifest bucket |
15
+ * | --- | --- | --- |
16
+ * | `plugins` | `plugins` | `runtimePlugins` |
17
+ * | `browserBuildPlugins` | `buildPlugins` | `browserBundlePlugins` |
18
+ * | `browserRuntimeManifest` | — | `browserRuntimeManifest` |
19
+ * | — (file loaders on config) | — | `loaderPlugins` |
20
+ *
21
+ * Use {@link getServerBuildPlugins} and {@link getBrowserBuildPlugins} to turn
22
+ * buckets into the plugin lists passed to Rolldown. App-aware call sites should
23
+ * prefer {@link getAppServerBuildPlugins} and {@link getAppBrowserBuildPlugins},
24
+ * which add alias resolution, JSX ownership, and browser source-transform
25
+ * deduplication on top of the manifest lists.
26
+ */
27
+ export interface AppBuildManifest {
28
+ /** File-extension loaders registered on the app config (for example `.mdx`). */
29
+ loaderPlugins: EcoBuildPlugin[];
30
+ /**
31
+ * Shared plugins for server-oriented and browser-oriented builds.
32
+ *
33
+ * @remarks
34
+ * Sourced from integration `plugins` and processor `plugins`. Virtual-module
35
+ * loaders and transforms that must run during route-module transpile belong
36
+ * here.
37
+ */
38
+ runtimePlugins: EcoBuildPlugin[];
39
+ /**
40
+ * Browser-bundle-only plugins.
41
+ *
42
+ * @remarks
43
+ * Sourced from integration `browserBuildPlugins` and processor `buildPlugins`.
44
+ * Do not register server route or static-page transforms here.
45
+ */
46
+ browserBundlePlugins: EcoBuildPlugin[];
47
+ /**
48
+ * Specifier → public URL map for client bundles.
49
+ *
50
+ * @remarks
51
+ * Not a plugin list. {@link getBrowserBuildPlugins} synthesizes
52
+ * `browser-runtime-plugin` from this map to rewrite manifest-owned imports.
53
+ */
54
+ browserRuntimeManifest: BrowserRuntimeManifest;
55
+ }
56
+ /**
57
+ * Merges plugin lists while preserving first-registration precedence by name.
58
+ *
59
+ * @remarks
60
+ * Build manifests treat plugin names as stable identities. The first plugin
61
+ * with a given name wins so config-time assembly stays deterministic across
62
+ * loader, runtime, and browser buckets.
63
+ */
64
+ export declare function mergeEcoBuildPlugins(...pluginLists: Array<EcoBuildPlugin[] | undefined>): EcoBuildPlugin[];
65
+ /**
66
+ * Creates one app-owned build manifest from the supplied plugin buckets.
67
+ */
68
+ export declare function createAppBuildManifest(input?: Partial<AppBuildManifest>): AppBuildManifest;
69
+ /**
70
+ * Returns the shared browser runtime asset manifest sealed into the app build manifest.
71
+ */
72
+ export declare function getBrowserRuntimeManifest(manifest: AppBuildManifest): BrowserRuntimeManifest;
73
+ /**
74
+ * Returns the plugin list used for server-oriented builds.
75
+ *
76
+ * @remarks
77
+ * Merges `loaderPlugins` then `runtimePlugins`. Browser-only buckets and the
78
+ * synthesized browser-runtime rewrite plugin are excluded.
79
+ */
80
+ export declare function getServerBuildPlugins(manifest: AppBuildManifest): EcoBuildPlugin[];
81
+ /**
82
+ * Returns the plugin list used for browser-oriented builds.
83
+ *
84
+ * @remarks
85
+ * Merges, in order: `loaderPlugins`, `runtimePlugins`, a synthesized
86
+ * `browser-runtime-plugin` when `browserRuntimeManifest` has entries, then
87
+ * `browserBundlePlugins`. Plugin names dedupe with first-registration wins via
88
+ * {@link mergeEcoBuildPlugins}.
89
+ */
90
+ export declare function getBrowserBuildPlugins(manifest: AppBuildManifest): EcoBuildPlugin[];
@@ -1,8 +1,8 @@
1
- import { createBrowserRuntimePlugin, DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME } from "./browser-runtime-plugin.js";
1
+ import { createBrowserRuntimePlugin, DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME } from "../browser/browser-runtime-plugin.js";
2
2
  import {
3
3
  createBrowserRuntimeManifest,
4
4
  mergeBrowserRuntimeManifests
5
- } from "./browser-runtime-manifest.js";
5
+ } from "../browser/browser-runtime-manifest.js";
6
6
  function mergeEcoBuildPlugins(...pluginLists) {
7
7
  const byName = /* @__PURE__ */ new Map();
8
8
  for (const plugins of pluginLists) {
@@ -8,10 +8,27 @@
8
8
  *
9
9
  * @module
10
10
  */
11
- import type { InputOptions, OutputOptions } from 'rolldown';
12
- import type { EcoBuildPlugin } from './build-types.js';
13
- import type { BuildDependencyGraph, BuildLog, BuildOptions, BuildResult, BuildTranspileOptions, BuildTranspileProfile } from './build-adapter.js';
11
+ import type { InputOptions, OutputOptions, RolldownPlugin } from 'rolldown';
12
+ import type { EcoBuildPlugin } from '../contracts/build-types.js';
13
+ import type { BuildDependencyGraph, BuildLog, BuildOptions, BuildResult, BuildTranspileOptions, BuildTranspileProfile } from '../build-adapter.js';
14
14
  export declare function transpileProfileToOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
15
+ /**
16
+ * Resolves Node builtins as external before Rolldown falls back to file resolution.
17
+ *
18
+ * @remarks
19
+ * Rolldown documents two first-class externalization points: its `external`
20
+ * option is checked before resolution, and a plugin `resolveId` hook can return
21
+ * `{ id, external: true }`. Core uses the latter to keep Node-builtin ownership
22
+ * explicit in the Node-target plugin pipeline.
23
+ *
24
+ * The hook runs before Rolldown's internal filesystem resolver, leaving imports
25
+ * such as `node:fs` intact for the Node runtime. It is installed only for
26
+ * Node-target builds, so browser bundles still surface accidental Node builtin
27
+ * imports as resolver failures.
28
+ *
29
+ * See {@link https://rolldown.rs/in-depth/external-modules | Rolldown external modules}.
30
+ */
31
+ export declare function createNodeBuiltinExternalPlugin(): RolldownPlugin;
15
32
  export declare function extractDependencyGraph(chunks: Array<{
16
33
  facadeModuleId: string | null;
17
34
  moduleIds: string[];
@@ -1,8 +1,11 @@
1
- import { createRequire } from "node:module";
1
+ import { builtinModules, createRequire } from "node:module";
2
2
  import { readFileSync } from "node:fs";
3
3
  import path from "node:path";
4
- import { isBarePackageImportSpecifier } from "../plugins/tsconfig-import-resolver.js";
5
- import { collectBrowserRuntimeImportRewriteMap, rewriteBrowserRuntimeImports } from "./browser-runtime-plugin.js";
4
+ import { isBarePackageImportSpecifier } from "../../plugins/tsconfig-import-resolver.js";
5
+ import {
6
+ collectBrowserRuntimeImportRewriteMap,
7
+ rewriteBrowserRuntimeImports
8
+ } from "../browser/browser-runtime-plugin.js";
6
9
  import { createServerSideCssShimPlugin } from "./server-side-css-shim-plugin.js";
7
10
  import { createRolldownPluginBridge } from "./rolldown-plugin-bridge.js";
8
11
  import {
@@ -10,13 +13,14 @@ import {
10
13
  isWorkspacePackageImport,
11
14
  normalizeNodeRuntimeBuildOutputs
12
15
  } from "./runtime-build-output-normalizer.js";
13
- const corePackageRequire = createRequire(new URL("../../package.json", import.meta.url));
16
+ const corePackageRequire = createRequire(new URL("../../../package.json", import.meta.url));
17
+ const nodeBuiltinSpecifiers = new Set(builtinModules);
14
18
  let corePackageNames;
15
19
  function getCorePackageNames() {
16
20
  if (corePackageNames) {
17
21
  return corePackageNames;
18
22
  }
19
- const packageJsonPath = new URL("../../package.json", import.meta.url);
23
+ const packageJsonPath = new URL("../../../package.json", import.meta.url);
20
24
  corePackageNames = /* @__PURE__ */ new Set();
21
25
  try {
22
26
  const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
@@ -99,6 +103,17 @@ function createExternalMatcher(options, appRootRequireCache) {
99
103
  return !shouldBundlePackageImport(id, contextRoot, appRootRequireCache);
100
104
  };
101
105
  }
106
+ function isNodeBuiltinSpecifier(id) {
107
+ return id.startsWith("node:") || nodeBuiltinSpecifiers.has(id);
108
+ }
109
+ function createNodeBuiltinExternalPlugin() {
110
+ return {
111
+ name: "ecopages-node-builtin-external",
112
+ resolveId(id) {
113
+ return isNodeBuiltinSpecifier(id) ? { id, external: true } : null;
114
+ }
115
+ };
116
+ }
102
117
  function mapRolldownFormat(value) {
103
118
  switch (value) {
104
119
  case "cjs":
@@ -204,7 +219,11 @@ function resolveRolldownOptions(options, contextRoot, outdir, appRootRequireCach
204
219
  const bundlePlugins = options.plugins ?? [];
205
220
  const sourceTransforms = options.target === "browser" ? options.sourceTransforms ?? [] : [];
206
221
  const appPlugins = createRolldownPluginBridge(bundlePlugins, contextRoot, sourceTransforms);
207
- const allPlugins = [...options.target !== "browser" ? [createServerSideCssShimPlugin()] : [], ...appPlugins];
222
+ const allPlugins = [
223
+ ...mapRolldownPlatform(options.target) === "node" ? [createNodeBuiltinExternalPlugin()] : [],
224
+ ...options.target !== "browser" ? [createServerSideCssShimPlugin()] : [],
225
+ ...appPlugins
226
+ ];
208
227
  const inputOptions = {
209
228
  input: options.entrypoints,
210
229
  cwd: contextRoot,
@@ -322,6 +341,7 @@ function buildResultFromRolldownOutput(output, outdir, contextRoot) {
322
341
  export {
323
342
  buildResultFromRolldownOutput,
324
343
  clearRewriteCacheForTests,
344
+ createNodeBuiltinExternalPlugin,
325
345
  extractDependencyGraph,
326
346
  resolveRolldownOptions,
327
347
  rewriteBrowserRuntimeImportsInOutputs,
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Each `build()` creates a fresh `rolldown()` bundler.
10
10
  */
11
- import type { BuildAdapter, BuildOptions, BuildResult, BuildTranspileOptions, BuildTranspileProfile } from './build-adapter.js';
11
+ import type { BuildAdapter, BuildOptions, BuildResult, BuildTranspileOptions, BuildTranspileProfile } from '../build-adapter.js';
12
12
  export declare class RolldownBuildAdapter implements BuildAdapter {
13
13
  readonly ownership: "rolldown";
14
14
  /** Per-adapter require cache, keyed on resolved context root. */
@@ -40,8 +40,8 @@
40
40
  * on every source file.
41
41
  */
42
42
  import type { Plugin } from 'rolldown';
43
- import type { EcoSourceTransform } from '../plugins/source-transform.js';
44
- import type { EcoBuildPlugin } from './build-types.js';
43
+ import type { EcoSourceTransform } from '../../plugins/source-transform.js';
44
+ import type { EcoBuildPlugin } from '../contracts/build-types.js';
45
45
  /**
46
46
  * Creates a Rolldown `Plugin` array that drives the supplied
47
47
  * `EcoBuildPlugin` instances.
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { finalizeLoadResultWithSourceTransforms } from "./rolldown-source-transform-pass.js";
3
- import { escapeRegExp } from "./browser-runtime-plugin-helpers.js";
3
+ import { escapeRegExp } from "../browser/browser-runtime-plugin-helpers.js";
4
4
  const NAMESPACE_SEPARATOR = ":";
5
5
  function joinNamespace(namespace, value) {
6
6
  return namespace ? `${namespace}${NAMESPACE_SEPARATOR}${value}` : value;
@@ -1,5 +1,5 @@
1
1
  import type { LoadResult, SourceDescription } from 'rolldown';
2
- import { type EcoSourceTransform } from '../plugins/source-transform.js';
2
+ import { type EcoSourceTransform } from '../../plugins/source-transform.js';
3
3
  /**
4
4
  * Runs app-owned source transforms after first-wins `onLoad` plugins produce
5
5
  * module contents for one Rolldown load request.
@@ -1,6 +1,9 @@
1
1
  import path from "node:path";
2
2
  import { fileSystem } from "@ecopages/file-system";
3
- import { applySourceTransforms, normalizeTransformId } from "../plugins/source-transform.js";
3
+ import {
4
+ applySourceTransforms,
5
+ normalizeTransformId
6
+ } from "../../plugins/source-transform.js";
4
7
  const TRANSFORMABLE_SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mdx"]);
5
8
  function shouldApplySourceTransforms(namespace, sourcePath) {
6
9
  if (namespace !== void 0) {
@@ -2,8 +2,8 @@ import { createRequire } from "node:module";
2
2
  import { readFileSync } from "node:fs";
3
3
  import path from "node:path";
4
4
  import { pathToFileURL } from "node:url";
5
- import { isBarePackageImportSpecifier } from "../plugins/tsconfig-import-resolver.js";
6
- const corePackageRequire = createRequire(new URL("../../package.json", import.meta.url));
5
+ import { isBarePackageImportSpecifier } from "../../plugins/tsconfig-import-resolver.js";
6
+ const corePackageRequire = createRequire(new URL("../../../package.json", import.meta.url));
7
7
  const appDeclaredPackageCache = /* @__PURE__ */ new Map();
8
8
  const appWorkspacePackageCache = /* @__PURE__ */ new Map();
9
9
  const CORE_RUNTIME_BARE_SPECIFIER_PACKAGES = /* @__PURE__ */ new Set(["ws"]);
@@ -1,6 +1,6 @@
1
- import type { BuildOptions } from './build-adapter.js';
1
+ import type { BuildOptions } from '../build-adapter.js';
2
2
  import type { BuildProfile } from './build-runtime.js';
3
- import type { EcoPagesAppConfig } from '../types/internal-types.js';
3
+ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
4
4
  /**
5
5
  * Resolves shared Rolldown options for a build profile.
6
6
  */
@@ -0,0 +1,17 @@
1
+ import type { BuildOptions } from '../contracts/build-contracts.js';
2
+ /**
3
+ * Canonical identity for one complete {@link BuildOptions} request.
4
+ *
5
+ * @remarks
6
+ * Semantically unordered collections (`external`, `define` keys, array entrypoints)
7
+ * are sorted. Plugin, `conditions`, and source-transform order is preserved because
8
+ * Rolldown hook and `conditionNames` precedence depend on it.
9
+ *
10
+ * Deprecated / ignored adapter fields (`splitting`, `bundle`, `outbase`) still
11
+ * participate in the key so requests that differ only on those fields do not
12
+ * coalesce. Empty `conditions` / `define` / `external` normalize to the same
13
+ * sentinel as `undefined`.
14
+ */
15
+ export declare function createBuildRequestIdentity(options: BuildOptions): string;
16
+ /** @deprecated Use {@link createBuildRequestIdentity}. */
17
+ export declare const createBuildOptionsDedupeKey: typeof createBuildRequestIdentity;
@@ -0,0 +1,54 @@
1
+ import path from "node:path";
2
+ import { createJsxCacheKey, createPluginCacheKey, createSourceTransformCacheKey } from "../cache/cache-keys.js";
3
+ function normalizeEntrypoints(entrypoints) {
4
+ if (Array.isArray(entrypoints)) {
5
+ return entrypoints.map((entrypoint) => path.resolve(entrypoint)).sort().join("|");
6
+ }
7
+ return Object.entries(entrypoints).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${key}:${path.resolve(value)}`).join("|");
8
+ }
9
+ function normalizeOrderedStringList(values, label) {
10
+ if (!values || values.length === 0) {
11
+ return `${label}:default`;
12
+ }
13
+ return `${label}:${values.join(",")}`;
14
+ }
15
+ function normalizeUnorderedStringList(values, label) {
16
+ if (!values || values.length === 0) {
17
+ return `${label}:default`;
18
+ }
19
+ return `${label}:${[...values].sort().join(",")}`;
20
+ }
21
+ function normalizeDefine(define) {
22
+ if (!define || Object.keys(define).length === 0) {
23
+ return "define:default";
24
+ }
25
+ return `define:${Object.entries(define).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${key}=${value}`).join(",")}`;
26
+ }
27
+ function createBuildRequestIdentity(options) {
28
+ return [
29
+ normalizeEntrypoints(options.entrypoints),
30
+ options.root ? path.resolve(options.root) : "root:default",
31
+ options.outdir ? path.resolve(options.outdir) : "outdir:default",
32
+ options.outbase ? path.resolve(options.outbase) : "outbase:default",
33
+ options.splitting ?? "splitting:default",
34
+ options.bundle ?? "bundle:default",
35
+ options.externalPackages ?? "externalPackages:default",
36
+ options.target ?? "target:default",
37
+ options.format ?? "format:default",
38
+ options.sourcemap ?? "sourcemap:default",
39
+ options.minify ?? "minify:default",
40
+ options.treeshaking ?? "treeshaking:default",
41
+ options.naming ?? "naming:default",
42
+ normalizeOrderedStringList(options.conditions, "conditions"),
43
+ normalizeDefine(options.define),
44
+ normalizeUnorderedStringList(options.external, "external"),
45
+ createJsxCacheKey(options.jsx),
46
+ createPluginCacheKey(options.plugins),
47
+ createSourceTransformCacheKey(options.sourceTransforms)
48
+ ].join("::");
49
+ }
50
+ const createBuildOptionsDedupeKey = createBuildRequestIdentity;
51
+ export {
52
+ createBuildOptionsDedupeKey,
53
+ createBuildRequestIdentity
54
+ };
@@ -0,0 +1,59 @@
1
+ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
2
+ import type { EcoBuildPlugin } from '../contracts/build-types.js';
3
+ import type { BuildOptions, BuildTranspileProfile } from '../contracts/build-contracts.js';
4
+ import type { BuildProfile } from './build-runtime.js';
5
+ /**
6
+ * Resolves app-owned server plugins plus JSX ownership for one config.
7
+ *
8
+ * @remarks
9
+ * Always goes through {@link getAppServerBuildPlugins} so sealed-manifest and
10
+ * loader-fallback apps share one plugin list with the alias resolver. Used by
11
+ * both request assembly and unified-graph cache keys.
12
+ */
13
+ export declare function resolveServerAppBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[];
14
+ /**
15
+ * Merges caller plugins with app-owned manifest plugins.
16
+ *
17
+ * @remarks
18
+ * App-manifest plugins cannot be silently replaced by same-name caller plugins.
19
+ * Unique caller plugins are prepended so first-wins Rolldown hooks (for example
20
+ * React vendor/alias rewrites) still run before general app loaders. Use
21
+ * `excludeAppBuildPlugins` on browser requests to omit app-owned plugins.
22
+ */
23
+ export declare function mergeCallerBuildPlugins(appPlugins: EcoBuildPlugin[], callerPlugins?: EcoBuildPlugin[]): EcoBuildPlugin[];
24
+ export type ServerBuildRequestInput = Partial<BuildOptions> & {
25
+ entrypoints: BuildOptions['entrypoints'];
26
+ profile?: Extract<BuildProfile, 'server-entry' | 'route-module'>;
27
+ };
28
+ export type BrowserBuildRequestInput = Partial<BuildOptions> & {
29
+ entrypoints: BuildOptions['entrypoints'];
30
+ profile: BuildTranspileProfile;
31
+ excludeAppBuildPlugins?: string[];
32
+ };
33
+ /**
34
+ * Assembles a complete server-oriented {@link BuildOptions} before scheduling.
35
+ *
36
+ * @remarks
37
+ * Defaults `profile` to `'route-module'`. Plugins are
38
+ * {@link resolveServerAppBuildPlugins} plus unique caller contributions via
39
+ * {@link mergeCallerBuildPlugins}. Does not attach `sourceTransforms` — unlike
40
+ * {@link createBrowserBuildRequest}. Pass the returned options into
41
+ * {@link BuildRuntime.getProfile}; the runtime no longer injects plugins.
42
+ */
43
+ export declare function createServerBuildRequest(appConfig: EcoPagesAppConfig, input: ServerBuildRequestInput): BuildOptions;
44
+ /**
45
+ * Assembles a complete browser-oriented {@link BuildOptions} before scheduling.
46
+ *
47
+ * @remarks
48
+ * Applies {@link resolveBuildProfileOptions} for `'browser-hmr'` (browser target
49
+ * defaults), then overlays {@link getAppTranspileOptions} for the given
50
+ * {@link BuildTranspileProfile}. That profile selects transpile settings only;
51
+ * the {@link BuildRuntime} executor slot is chosen later by the caller
52
+ * (typically {@link BrowserBundleService}).
53
+ *
54
+ * Always attaches {@link getAppSourceTransforms}. App browser plugins come from
55
+ * {@link getAppBrowserBuildPlugins} (includes JSX ownership); use
56
+ * `excludeAppBuildPlugins` to omit app-owned names. Caller plugins cannot
57
+ * replace app-manifest names ({@link mergeCallerBuildPlugins}).
58
+ */
59
+ export declare function createBrowserBuildRequest(appConfig: EcoPagesAppConfig, input: BrowserBuildRequestInput): BuildOptions;