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

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/core",
3
- "version": "0.2.0-rc.11",
3
+ "version": "0.2.0-rc.14",
4
4
  "description": "Core package for Ecopages",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@clack/prompts": "^1.7.0",
24
- "@ecopages/file-system": "0.2.0-rc.11",
24
+ "@ecopages/file-system": "0.2.0-rc.14",
25
25
  "@ecopages/logger": "^0.2.3",
26
26
  "@ecopages/scripts-injector": "^0.1.5",
27
27
  "@oxc-project/runtime": "0.141.0",
@@ -34,7 +34,7 @@
34
34
  "@standard-schema/utils": "^0.3.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "@ecopages/dev-toolbar": "0.2.0-rc.11"
37
+ "@ecopages/dev-toolbar": "0.2.0-rc.14"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@ecopages/dev-toolbar": {
@@ -102,10 +102,6 @@
102
102
  "types": "./src/route-renderer/page-loading/file-scoped-dependency-components.d.ts",
103
103
  "default": "./src/route-renderer/page-loading/file-scoped-dependency-components.js"
104
104
  },
105
- "./route-renderer/orchestration/foreign-child/owning-renderer-resolution": {
106
- "types": "./src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.d.ts",
107
- "default": "./src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.js"
108
- },
109
105
  "./router/navigation-coordinator": {
110
106
  "types": "./src/router/client/navigation-coordinator.d.ts",
111
107
  "default": "./src/router/client/navigation-coordinator.js"
@@ -345,10 +341,6 @@
345
341
  "types": "./src/route-renderer/page-loading/file-scoped-dependency-components.d.ts",
346
342
  "default": "./src/route-renderer/page-loading/file-scoped-dependency-components.js"
347
343
  },
348
- "./route-renderer/orchestration/foreign-child/owning-renderer-resolution.ts": {
349
- "types": "./src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.d.ts",
350
- "default": "./src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.js"
351
- },
352
344
  "./router/navigation-coordinator.ts": {
353
345
  "types": "./src/router/client/navigation-coordinator.d.ts",
354
346
  "default": "./src/router/client/navigation-coordinator.js"
@@ -166,14 +166,15 @@ Set `ECOPAGES_ROLLDOWN_BUILD_METRICS=1` to log Rolldown invocation counts during
166
166
 
167
167
  ## Production build caches
168
168
 
169
- Two persisted cache layers accelerate production builds. Both use `.build-cache.json` manifests keyed by dependency hashes and a build-inputs fingerprint.
169
+ Three persisted cache layers accelerate production builds. All use `.build-cache.json` manifests keyed by dependency hashes and build-input fingerprints.
170
170
 
171
171
  | Cache | On-disk location | Module |
172
172
  | -------------------------------------- | --------------------------------------------------- | ---------------------------------------------------- |
173
173
  | Server-entry bundle | `.eco/.server-entry/.build-cache.json` | `cache/server-entry-build-cache.ts` |
174
174
  | Route-module transpile + static render | `<server-outdir>/.server-modules/.build-cache.json` | `route-module-build-cache.store.ts` (module-loading) |
175
+ | Unified pages graph | `.eco/.server-pages-graph/.build-cache.json` | `cache/pages-unified-graph-build.ts` |
175
176
 
176
- `requireBuildRuntime(appConfig).getProfile('server-entry')` serves server-entry bundling. `clearProductionBuildCaches()` wipes both manifest trees, resets in-memory route-module state, and clears `buildRuntime`.
177
+ `requireBuildRuntime(appConfig).getProfile('server-entry')` serves server-entry bundling. `clearProductionBuildCaches()` wipes all three manifest trees, resets in-memory route-module state, and clears `buildRuntime`.
177
178
 
178
179
  Server-entry cache hits require every recorded runtime artifact. Cache misses build the server entry and emitted config in a sibling staging directory; the deploy manifest joins that generation before the directory is published. A failed build therefore leaves the previous server generation intact.
179
180
 
@@ -190,7 +191,7 @@ Production static exports compile all template pages in one Rolldown invocation
190
191
 
191
192
  `StaticSiteGenerator` calls `ensurePagesUnifiedGraphBuilt()` before the export loop. `PageModuleImportService` imports prebuilt chunks via `importPagesUnifiedGraphModule()` and falls back to per-page Rolldown on miss.
192
193
 
193
- A persisted graph is reused only when it matches the core package version, the build inputs and the build key, and every local file reachable from its outputs still exists. `importPagesUnifiedGraphModule()` applies the same check, because pages can be imported before the export loop runs. This is separate from production Page Browser Graph prebuild (`production-page-browser-graph-prebuild.ts`), which warms browser assets in `page-browser-graph-session`.
194
+ A persisted graph is reused only when it matches the core package version, the build inputs and the build key, every local file reachable from its outputs still exists, every recorded source-file hash still matches, and the exact active template route set matches recorded outputs. Manifests without `dependencyHashes` are treated as absent, so a deleted layout or component cannot keep serving its compiled chunk. `importPagesUnifiedGraphModule()` applies the same check, because pages can be imported before the export loop runs. This is separate from production Page Browser Graph prebuild (`production-page-browser-graph-prebuild.ts`), which warms browser assets in `page-browser-graph-session`.
194
195
 
195
196
  `ECOPAGES_ROLLDOWN_BUILD_METRICS=1` enables `rolldown/rolldown-build-invocation-metrics.ts` counters used by bench and parity tests.
196
197
 
@@ -3,10 +3,11 @@
3
3
  * `file:` specifiers in static imports, re-exports and literal dynamic imports.
4
4
  *
5
5
  * @remarks
6
- * Persisted build caches record these so a cached module is reused only while
7
- * the shared chunks and generated modules it loads (for example
8
- * `.server-collections`) still exist. Uses `parseSync` directly rather than the
9
- * shared parse cache, so large compiled bundles are not retained in memory.
6
+ * {@link collectReachableLocalImports} follows these edges so persisted build
7
+ * caches can check that the shared chunks and generated modules a cached module
8
+ * loads (for example `.server-collections`) still exist. Uses `parseSync`
9
+ * directly rather than the shared parse cache, so large compiled bundles are not
10
+ * retained in memory.
10
11
  */
11
12
  export declare function collectLocalImports(code: string, modulePath: string): string[];
12
13
  export type LocalImportFileAccess = {
@@ -17,11 +18,18 @@ export type LocalImportFileAccess = {
17
18
  * Lists every local file reachable from `modulePath` through local imports.
18
19
  *
19
20
  * @remarks
20
- * Direct {@link collectLocalImports} misses shared chunks that a page output
21
- * only reaches through another chunk. Persisted caches walk this graph so reuse
22
- * fails when any reachable file is gone. `modulePath` itself is omitted; callers
23
- * already check that the compiled output exists.
21
+ * {@link collectLocalImports} alone misses shared chunks that a page output only
22
+ * reaches through another chunk. Persisted caches record this full set and are
23
+ * reused only while every file in it exists. `modulePath` itself is omitted,
24
+ * because callers already check that the compiled output exists.
25
+ *
26
+ * A missing file is listed but not followed, so a cache recorded against it
27
+ * never validates.
28
+ *
29
+ * Pass one `directImportsCache` to every walk of a single build so shared chunks
30
+ * are read and parsed once instead of once per output.
24
31
  */
25
- export declare function collectReachableLocalImports(modulePath: string, fileAccess?: LocalImportFileAccess): string[];
26
- /** Reads a compiled module from disk and lists its local imports. */
27
- export declare function readLocalImports(modulePath: string): string[];
32
+ export declare function collectReachableLocalImports(modulePath: string, options?: {
33
+ fileAccess?: LocalImportFileAccess;
34
+ directImportsCache?: Map<string, string[]>;
35
+ }): string[];
@@ -7,10 +7,11 @@ import { parseSync } from 'oxc-parser';
7
7
  * `file:` specifiers in static imports, re-exports and literal dynamic imports.
8
8
  *
9
9
  * @remarks
10
- * Persisted build caches record these so a cached module is reused only while
11
- * the shared chunks and generated modules it loads (for example
12
- * `.server-collections`) still exist. Uses `parseSync` directly rather than the
13
- * shared parse cache, so large compiled bundles are not retained in memory.
10
+ * {@link collectReachableLocalImports} follows these edges so persisted build
11
+ * caches can check that the shared chunks and generated modules a cached module
12
+ * loads (for example `.server-collections`) still exist. Uses `parseSync`
13
+ * directly rather than the shared parse cache, so large compiled bundles are not
14
+ * retained in memory.
14
15
  */
15
16
  export function collectLocalImports(code, modulePath) {
16
17
  const { module } = parseSync(modulePath, code, { lang: 'js', sourceType: 'module' });
@@ -36,12 +37,19 @@ const defaultLocalImportFileAccess = {
36
37
  * Lists every local file reachable from `modulePath` through local imports.
37
38
  *
38
39
  * @remarks
39
- * Direct {@link collectLocalImports} misses shared chunks that a page output
40
- * only reaches through another chunk. Persisted caches walk this graph so reuse
41
- * fails when any reachable file is gone. `modulePath` itself is omitted; callers
42
- * already check that the compiled output exists.
40
+ * {@link collectLocalImports} alone misses shared chunks that a page output only
41
+ * reaches through another chunk. Persisted caches record this full set and are
42
+ * reused only while every file in it exists. `modulePath` itself is omitted,
43
+ * because callers already check that the compiled output exists.
44
+ *
45
+ * A missing file is listed but not followed, so a cache recorded against it
46
+ * never validates.
47
+ *
48
+ * Pass one `directImportsCache` to every walk of a single build so shared chunks
49
+ * are read and parsed once instead of once per output.
43
50
  */
44
- export function collectReachableLocalImports(modulePath, fileAccess = defaultLocalImportFileAccess) {
51
+ export function collectReachableLocalImports(modulePath, options = {}) {
52
+ const { fileAccess = defaultLocalImportFileAccess, directImportsCache = new Map() } = options;
45
53
  const reachable = new Set();
46
54
  const pending = [modulePath];
47
55
  const visited = new Set();
@@ -57,16 +65,15 @@ export function collectReachableLocalImports(modulePath, fileAccess = defaultLoc
57
65
  if (current !== modulePath && !fileAccess.exists(current)) {
58
66
  continue;
59
67
  }
60
- for (const imported of collectLocalImports(fileAccess.readFile(current), current)) {
61
- pending.push(imported);
68
+ let directImports = directImportsCache.get(current);
69
+ if (!directImports) {
70
+ directImports = collectLocalImports(fileAccess.readFile(current), current);
71
+ directImportsCache.set(current, directImports);
62
72
  }
73
+ pending.push(...directImports);
63
74
  }
64
75
  return [...reachable];
65
76
  }
66
- /** Reads a compiled module from disk and lists its local imports. */
67
- export function readLocalImports(modulePath) {
68
- return collectLocalImports(fileSystem.readFileSync(modulePath), modulePath);
69
- }
70
77
  function resolveLocalSpecifier(specifier, directory) {
71
78
  const bare = specifier.replace(/[?#].*$/, '');
72
79
  if (bare.startsWith('file:'))
@@ -6,6 +6,7 @@
6
6
  * registered on the app config.
7
7
  */
8
8
  import type { EcoPagesAppConfig } from '../../types/internal-types.js';
9
+ import { type RouteModuleDependencyHashes } from '../../services/module-loading/route-module-dependency-hasher.js';
9
10
  export declare const PAGES_UNIFIED_GRAPH_CACHE_DIR = ".server-pages-graph";
10
11
  export declare const PAGES_UNIFIED_GRAPH_CACHE_FILENAME = ".build-cache.json";
11
12
  export interface PagesUnifiedGraphCacheManifest {
@@ -19,6 +20,14 @@ export interface PagesUnifiedGraphCacheManifest {
19
20
  * shared chunks. The graph is reused only while all of them exist.
20
21
  */
21
22
  outputImports: string[];
23
+ /**
24
+ * Content hashes for every trackable source file in the graph.
25
+ *
26
+ * @remarks
27
+ * Compiled chunks can outlive a deleted layout or component. Reuse also
28
+ * requires these hashes so a source edit or deletion rebuilds the graph.
29
+ */
30
+ dependencyHashes: RouteModuleDependencyHashes;
22
31
  }
23
32
  export declare function isPagesUnifiedGraphEnabled(): boolean;
24
33
  /** True when the unified graph should build or serve prebuilt page modules. */
@@ -18,7 +18,7 @@ import { getCorePackageVersion } from './cache-keys.js';
18
18
  import { collectReachableLocalImports } from './output-imports.js';
19
19
  import { resolveInternalExecutionDir } from '../../utils/resolve-work-dir.js';
20
20
  import { getServerModuleBuildCacheOutdir, getSharedRouteModuleBuildCache, } from '../../services/module-loading/route-module-build-cache-registry.js';
21
- import { resolveRouteModuleDependencyPaths } from '../../services/module-loading/route-module-dependency-hasher.js';
21
+ import { RouteModuleDependencyHasher, resolveRouteModuleDependencyPaths, } from '../../services/module-loading/route-module-dependency-hasher.js';
22
22
  export const PAGES_UNIFIED_GRAPH_CACHE_DIR = '.server-pages-graph';
23
23
  export const PAGES_UNIFIED_GRAPH_CACHE_FILENAME = '.build-cache.json';
24
24
  export function isPagesUnifiedGraphEnabled() {
@@ -57,13 +57,24 @@ function createPagesUnifiedGraphBuildKey(appConfig, outdir) {
57
57
  'external-packages',
58
58
  ].join('::');
59
59
  }
60
+ /**
61
+ * @remarks
62
+ * Manifests without `outputImports` or `dependencyHashes` predate those
63
+ * checks, so they cannot prove their chunks and sources are still current.
64
+ */
60
65
  function readPagesUnifiedGraphManifest(appConfig) {
61
66
  const manifest = readProductionCacheManifest(getPagesUnifiedGraphCachePath(appConfig));
62
- if (!manifest?.outputs) {
67
+ if (!manifest?.outputs ||
68
+ !Array.isArray(manifest.outputImports) ||
69
+ !manifest.dependencyHashes ||
70
+ Object.keys(manifest.dependencyHashes).length === 0) {
63
71
  return undefined;
64
72
  }
65
73
  return manifest;
66
74
  }
75
+ function sourceDependenciesAreCurrent(manifest) {
76
+ return new RouteModuleDependencyHasher().matchesStoredHashes(manifest.dependencyHashes);
77
+ }
67
78
  function writePagesUnifiedGraphManifest(appConfig, manifest) {
68
79
  writeProductionCacheManifest(getPagesUnifiedGraphCachePath(appConfig), manifest);
69
80
  }
@@ -98,16 +109,24 @@ function resolveOutputForEntrypoint(entryPath, entryKey, buildResult) {
98
109
  }
99
110
  /**
100
111
  * Whether `manifest` was written by the current core version, build inputs and graph
101
- * setup, and every file its outputs import still exists.
112
+ * setup, every file its outputs import still exists, and source hashes still match.
102
113
  */
103
114
  function isGraphManifestCurrent(manifest, appConfig, outdir) {
104
115
  return (isProductionCacheManifestCurrent(manifest, getCorePackageVersion()) &&
105
116
  matchesProductionCacheFingerprint(manifest, createBuildInputsFingerprint(appConfig)) &&
106
117
  matchesProductionCacheBuildKey(manifest, createPagesUnifiedGraphBuildKey(appConfig, outdir)) &&
107
- manifest.outputImports?.every((filePath) => fileSystem.exists(filePath)) === true);
118
+ manifest.outputImports.every((filePath) => fileSystem.exists(filePath)) &&
119
+ sourceDependenciesAreCurrent(manifest));
108
120
  }
121
+ /**
122
+ * @remarks
123
+ * In addition to graph freshness and chunk existence on disk, the manifest must
124
+ * match the exact count of active template entries so removing or adding a page
125
+ * invalidates the graph.
126
+ */
109
127
  function isManifestValidForEntries(manifest, appConfig, outdir, entryPaths) {
110
128
  return (isGraphManifestCurrent(manifest, appConfig, outdir) &&
129
+ entryPaths.length === Object.keys(manifest.outputs).length &&
111
130
  entryPaths.every((entryPath) => {
112
131
  const outputPath = manifest.outputs[path.resolve(entryPath)];
113
132
  return outputPath ? fileSystem.exists(outputPath) : false;
@@ -137,9 +156,9 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
137
156
  if (!shouldBuildPagesUnifiedGraph()) {
138
157
  return undefined;
139
158
  }
140
- const eligibleEntryPaths = options.entryPaths
159
+ const eligibleEntryPaths = Array.from(new Set(options.entryPaths
141
160
  .map((entryPath) => path.resolve(entryPath))
142
- .filter((entryPath) => isPagesUnifiedGraphPage(entryPath, options.appConfig));
161
+ .filter((entryPath) => isPagesUnifiedGraphPage(entryPath, options.appConfig))));
143
162
  if (eligibleEntryPaths.length === 0) {
144
163
  return undefined;
145
164
  }
@@ -175,6 +194,9 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
175
194
  }
176
195
  const outputs = {};
177
196
  const outputImports = new Set();
197
+ const directImportsCache = new Map();
198
+ const dependencyHasher = new RouteModuleDependencyHasher();
199
+ const dependencyHashes = {};
178
200
  for (const entryPath of eligibleEntryPaths) {
179
201
  const fileHash = fileSystem.hash(entryPath);
180
202
  const entryKey = entryKeysByPath.get(entryPath);
@@ -183,16 +205,19 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
183
205
  throw new Error(`Pages unified graph build produced no output for ${entryPath}`);
184
206
  }
185
207
  outputs[entryPath] = compiledOutput;
186
- const compiledOutputImports = collectReachableLocalImports(compiledOutput);
208
+ const compiledOutputImports = collectReachableLocalImports(compiledOutput, { directImportsCache });
187
209
  for (const importPath of compiledOutputImports)
188
210
  outputImports.add(importPath);
211
+ const dependencyModulePaths = resolveRouteModuleDependencyPaths(buildResult, entryPath, options.appConfig.rootDir);
212
+ Object.assign(dependencyHashes, dependencyHasher.createDependencyHashes(dependencyModulePaths));
213
+ dependencyHashes[path.normalize(entryPath)] = fileHash;
189
214
  routeModuleBuildCache.recordBuild({
190
215
  filePath: entryPath,
191
216
  rootDir: options.appConfig.rootDir,
192
217
  outdir,
193
218
  fileHash,
194
219
  outputPath: compiledOutput,
195
- dependencyModulePaths: resolveRouteModuleDependencyPaths(buildResult, entryPath, options.appConfig.rootDir),
220
+ dependencyModulePaths,
196
221
  externalPackages: true,
197
222
  plugins,
198
223
  outputImports: compiledOutputImports,
@@ -205,6 +230,7 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
205
230
  builtAt: Date.now(),
206
231
  outputs,
207
232
  outputImports: [...outputImports],
233
+ dependencyHashes,
208
234
  };
209
235
  writePagesUnifiedGraphManifest(options.appConfig, manifest);
210
236
  appLogger.debug(`Built pages unified graph for ${eligibleEntryPaths.length} entries`);
@@ -24,11 +24,22 @@ export type QueuedForeignSubtreeResolutionContext = {
24
24
  queuedResolutions: QueuedForeignSubtreeResolution[];
25
25
  };
26
26
  type QueuedForeignSubtreeIntegrationContext = BaseIntegrationContext & Record<string, unknown>;
27
- type QueuedForeignSubtreeChildRenderResult = {
28
- assets: ProcessedAsset[];
27
+ /**
28
+ * Children of a queued foreign subtree after the host renderer has processed them.
29
+ *
30
+ * @remarks
31
+ * Set `html` when the host serialized the children, or `children` to pass them
32
+ * to the owning renderer unserialized. Leave both unset when there are no
33
+ * children. Assets are not returned here: the owning renderer reports the
34
+ * foreign component's assets, and host components' assets come from their
35
+ * declared dependencies.
36
+ */
37
+ export type QueuedForeignSubtreeChildRenderResult = {
29
38
  html?: string;
30
39
  children?: unknown;
31
40
  };
41
+ /** Renders the children of one queued foreign subtree inside the host renderer. */
42
+ export type RenderQueuedForeignSubtreeChildren<TContext extends QueuedForeignSubtreeResolutionContext> = (children: unknown, runtimeContext: TContext, queuedResolutionsByToken: Map<string, QueuedForeignSubtreeResolution>, resolveToken: (token: string) => Promise<string>) => Promise<QueuedForeignSubtreeChildRenderResult>;
32
43
  export interface ForeignSubtreeExecutionOwningRenderer {
33
44
  readonly name: string;
34
45
  renderComponentWithForeignChildren(input: ComponentRenderInput): Promise<ComponentRenderResult>;
@@ -56,38 +67,20 @@ export interface ForeignSubtreeQueuedRuntimeOptions<TContext extends QueuedForei
56
67
  tokenPrefix: string;
57
68
  createRuntimeContext?: (integrationContext: BaseIntegrationContext & Record<string, unknown>, rendererCache: Map<string, unknown>) => TContext;
58
69
  }
59
- export interface ForeignSubtreeStringQueuedHtmlOptions {
60
- currentIntegrationName: string;
61
- renderInput: ComponentRenderInput;
62
- html: string;
63
- runtimeContextKey: string;
64
- queueLabel: string;
65
- getOwningRenderer(integrationName: string, rendererCache: Map<string, ForeignSubtreeExecutionOwningRenderer>): Promise<ForeignSubtreeExecutionOwningRenderer>;
66
- applyAttributesToFirstElement(html: string, attributes: Record<string, string>): string;
67
- dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[];
68
- }
69
70
  export interface ForeignSubtreeQueuedHtmlOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
70
71
  currentIntegrationName: string;
71
72
  html: string;
72
73
  runtimeContext?: TContext;
73
- queueLabel: string;
74
- renderQueuedChildren(children: unknown, runtimeContext: TContext, queuedResolutionsByToken: Map<string, QueuedForeignSubtreeResolution>, resolveToken: (token: string) => Promise<string>): Promise<{
75
- assets: ProcessedAsset[];
76
- children?: unknown;
77
- html?: string;
78
- }>;
74
+ renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>;
79
75
  getOwningRenderer(integrationName: string, rendererCache: Map<string, ForeignSubtreeExecutionOwningRenderer>): Promise<ForeignSubtreeExecutionOwningRenderer>;
80
- applyAttributesToFirstElement(html: string, attributes: Record<string, string>): string;
81
- dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[];
82
76
  }
77
+ export type ForeignSubtreeStringQueuedHtmlOptions = Omit<ForeignSubtreeQueuedHtmlOptions<QueuedForeignSubtreeResolutionContext>, 'renderQueuedChildren'>;
83
78
  export interface ResolveQueuedForeignSubtreeTokensOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
84
79
  html: string;
85
80
  runtimeContext?: TContext;
86
81
  queueLabel: string;
87
- renderQueuedChildren: (children: unknown, runtimeContext: TContext, queuedResolutionsByToken: Map<string, QueuedForeignSubtreeResolution>, resolveToken: (token: string) => Promise<string>) => Promise<QueuedForeignSubtreeChildRenderResult>;
82
+ renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>;
88
83
  resolveForeignSubtree: (input: ComponentRenderInput, rendererCache: Map<string, unknown>) => Promise<ForeignSubtreeRenderPayload | undefined>;
89
- applyAttributesToFirstElement: (html: string, attributes: Record<string, string>) => string;
90
- dedupeProcessedAssets: (assets: ProcessedAsset[]) => ProcessedAsset[];
91
84
  }
92
85
  /**
93
86
  * Maps one component render result into the foreign-subtree payload shape used by
@@ -115,7 +108,15 @@ export declare class ForeignSubtreeExecutionService {
115
108
  createRuntimeContext?: (integrationContext: QueuedForeignSubtreeIntegrationContext, rendererCache: Map<string, unknown>) => TContext;
116
109
  }): ForeignChildRuntime;
117
110
  getRuntimeContext<TContext extends QueuedForeignSubtreeResolutionContext>(input: ComponentRenderInput, runtimeContextKey: string): TContext | undefined;
118
- resolveStringQueuedHtml<TContext extends QueuedForeignSubtreeResolutionContext>(options: ForeignSubtreeStringQueuedHtmlOptions): Promise<{
111
+ /**
112
+ * Resolves queued foreign subtrees for a renderer whose children are markup.
113
+ *
114
+ * @remarks
115
+ * String children and markup nodes are serialized and their nested tokens
116
+ * resolved. Structured children pass to the owning renderer unchanged; opaque
117
+ * objects are rejected.
118
+ */
119
+ resolveStringQueuedHtml(options: ForeignSubtreeStringQueuedHtmlOptions): Promise<{
119
120
  assets: ProcessedAsset[];
120
121
  html: string;
121
122
  }>;
@@ -1,5 +1,7 @@
1
+ import { applyAttributesToFirstElement } from '../../../services/html/html-transformer.service.js';
1
2
  import { getComponentRenderContext, runWithComponentRenderContext, } from './component-render-context.js';
2
3
  import { assertForeignChildrenNotOpaque, isMarkupNodeLike } from './foreign-child-output.utils.js';
4
+ import { dedupeProcessedAssets } from '../page-browser-graph/processed-asset-dedupe.js';
3
5
  /**
4
6
  * Maps one component render result into the foreign-subtree payload shape used by
5
7
  * queue resolution and integration tests.
@@ -106,34 +108,35 @@ export class ForeignSubtreeExecutionService {
106
108
  }
107
109
  return runtimeContext;
108
110
  }
111
+ /**
112
+ * Resolves queued foreign subtrees for a renderer whose children are markup.
113
+ *
114
+ * @remarks
115
+ * String children and markup nodes are serialized and their nested tokens
116
+ * resolved. Structured children pass to the owning renderer unchanged; opaque
117
+ * objects are rejected.
118
+ */
109
119
  async resolveStringQueuedHtml(options) {
110
- const runtimeContext = this.getQueuedRuntimeContext(options.renderInput, options.runtimeContextKey);
111
120
  return this.resolveQueuedHtml({
112
- currentIntegrationName: options.currentIntegrationName,
113
- html: options.html,
114
- runtimeContext,
115
- queueLabel: options.queueLabel,
121
+ ...options,
116
122
  renderQueuedChildren: async (children, _runtimeContext, queuedResolutionsByToken, resolveToken) => {
117
123
  if (children === undefined) {
118
- return { assets: [], html: undefined };
124
+ return {};
119
125
  }
120
126
  if (typeof children !== 'string' && !isMarkupNodeLike(children)) {
121
- assertForeignChildrenNotOpaque(children, options.queueLabel);
122
- return { assets: [], children };
127
+ assertForeignChildrenNotOpaque(children, options.currentIntegrationName);
128
+ return { children };
123
129
  }
124
130
  const html = await this.resolveQueuedTokens(typeof children === 'string' ? children : (children.outerHTML ?? ''), queuedResolutionsByToken, resolveToken);
125
- return { assets: [], html };
131
+ return { html };
126
132
  },
127
- getOwningRenderer: options.getOwningRenderer,
128
- applyAttributesToFirstElement: options.applyAttributesToFirstElement,
129
- dedupeProcessedAssets: options.dedupeProcessedAssets,
130
133
  });
131
134
  }
132
135
  async resolveQueuedHtml(options) {
133
136
  return this.resolveQueuedForeignSubtreeTokens({
134
137
  html: options.html,
135
138
  runtimeContext: options.runtimeContext,
136
- queueLabel: options.queueLabel,
139
+ queueLabel: options.currentIntegrationName,
137
140
  renderQueuedChildren: options.renderQueuedChildren,
138
141
  resolveForeignSubtree: (input, rendererCache) => this.resolveForeignSubtreeInOwningRenderer({
139
142
  currentIntegrationName: options.currentIntegrationName,
@@ -141,8 +144,6 @@ export class ForeignSubtreeExecutionService {
141
144
  rendererCache: rendererCache,
142
145
  getOwningRenderer: options.getOwningRenderer,
143
146
  }),
144
- applyAttributesToFirstElement: options.applyAttributesToFirstElement,
145
- dedupeProcessedAssets: options.dedupeProcessedAssets,
146
147
  });
147
148
  }
148
149
  async resolveQueuedForeignSubtreeTokens(options) {
@@ -178,9 +179,6 @@ export class ForeignSubtreeExecutionService {
178
179
  try {
179
180
  const renderedChildren = await options.renderQueuedChildren(resolution.props.children, runtimeContext, queuedResolutionsByToken, resolveToken);
180
181
  syncQueuedResolutions();
181
- if (renderedChildren.assets.length > 0) {
182
- collectedAssets.push(...renderedChildren.assets);
183
- }
184
182
  const foreignSubtreeRender = await options.resolveForeignSubtree({
185
183
  component: resolution.component,
186
184
  props: { ...resolution.props },
@@ -198,7 +196,7 @@ export class ForeignSubtreeExecutionService {
198
196
  }
199
197
  const resolvedHtml = foreignSubtreeRender.attachmentPolicy.kind === 'first-element' &&
200
198
  foreignSubtreeRender.rootAttributes
201
- ? options.applyAttributesToFirstElement(foreignSubtreeRender.html, foreignSubtreeRender.rootAttributes)
199
+ ? applyAttributesToFirstElement(foreignSubtreeRender.html, foreignSubtreeRender.rootAttributes)
202
200
  : foreignSubtreeRender.html;
203
201
  resolvedHtmlByToken.set(token, resolvedHtml);
204
202
  return resolvedHtml;
@@ -217,7 +215,7 @@ export class ForeignSubtreeExecutionService {
217
215
  resolvedHtml = resolvedHtml.split(resolution.token).join(await resolveToken(resolution.token));
218
216
  }
219
217
  return {
220
- assets: options.dedupeProcessedAssets(collectedAssets),
218
+ assets: dedupeProcessedAssets(collectedAssets),
221
219
  html: resolvedHtml,
222
220
  };
223
221
  }
@@ -15,7 +15,7 @@ import { RouteRenderOrchestrator, type RouteRenderOrchestratorAdapter, type Rout
15
15
  import { type ResolvedPageDependencies } from '../page-loading/resolved-page-dependencies.js';
16
16
  import { type GroupedGraphBuildPlan } from './page-browser-graph/grouped-graph-build-plan.js';
17
17
  import type { ForeignChildRuntime } from './foreign-child/component-render-context.js';
18
- import { ForeignSubtreeExecutionService } from './foreign-child/foreign-subtree-execution.service.js';
18
+ import { ForeignSubtreeExecutionService, type ForeignSubtreeExecutionOwningRenderer, type QueuedForeignSubtreeResolutionContext, type RenderQueuedForeignSubtreeChildren } from './foreign-child/foreign-subtree-execution.service.js';
19
19
  import { type DocumentShellLayoutInput } from './document-shell/document-shell-render.service.js';
20
20
  /**
21
21
  * Controls how one route module is loaded outside the normal render path.
@@ -353,6 +353,29 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
353
353
  * renderer's nested foreign-child handoff.
354
354
  */
355
355
  renderComponentWithForeignChildren(input: InternalComponentRenderInput): Promise<ComponentRenderResult>;
356
+ /**
357
+ * Returns the renderer that owns `integrationName`, reusing `rendererCache`
358
+ * for the current render.
359
+ */
360
+ protected resolveOwningRenderer(integrationName: string, rendererCache: Map<string, ForeignSubtreeExecutionOwningRenderer>): Promise<ForeignSubtreeExecutionOwningRenderer>;
361
+ /**
362
+ * Returns the queued foreign-subtree state this renderer keeps on `input`, or
363
+ * `undefined` when nothing was queued for it.
364
+ */
365
+ protected getQueuedForeignSubtreeContext<TContext extends QueuedForeignSubtreeResolutionContext = QueuedForeignSubtreeResolutionContext>(input: ComponentRenderInput): TContext | undefined;
366
+ /**
367
+ * Replaces the foreign-subtree tokens queued while rendering `html` with the
368
+ * HTML each owning renderer produces.
369
+ *
370
+ * @remarks
371
+ * `renderQueuedChildren` renders a subtree's children inside this renderer
372
+ * before the owning renderer renders the subtree around them. The returned
373
+ * assets are the owning renderers' assets, deduplicated.
374
+ */
375
+ protected resolveQueuedForeignSubtrees<TContext extends QueuedForeignSubtreeResolutionContext>(html: string, runtimeContext: TContext | undefined, renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>): Promise<{
376
+ assets: ProcessedAsset[];
377
+ html: string;
378
+ }>;
356
379
  protected finalizeIslandComponentRender(input: ComponentRenderInput, result: ComponentRenderResult): ComponentRenderResult;
357
380
  private normalizeComponentRenderOutput;
358
381
  protected normalizeUnresolvedMarkerArtifactHtml(html: string): string;
@@ -22,7 +22,7 @@ import { normalizeUnresolvedMarkerArtifactHtml } from './route-pipeline/marker-a
22
22
  import { isMarkupNodeLike } from './foreign-child/foreign-child-output.utils.js';
23
23
  import { getForeignSubtreeResolutionContextKey, getForeignSubtreeTokenPrefix, resolveOwningIntegrationRenderer, } from './foreign-child/owning-renderer-resolution.js';
24
24
  import { ensureIntegrationRuntimeReady } from '../../build/app-build-manifest-runtime.js';
25
- import { ForeignSubtreeExecutionService } from './foreign-child/foreign-subtree-execution.service.js';
25
+ import { ForeignSubtreeExecutionService, } from './foreign-child/foreign-subtree-execution.service.js';
26
26
  import { composeDocumentShell, finalizeDocumentShellHtml, renderPageDocumentShell, } from './document-shell/document-shell-render.service.js';
27
27
  import { resolveInnermostPageLayout, resolvePageLayoutComponents, } from './document-shell/layout-shell-props.service.js';
28
28
  import { finalizeIslandComponentRender } from '../../islands/island-host.js';
@@ -421,20 +421,9 @@ export class IntegrationRenderer {
421
421
  const componentRender = await this.renderStringComponentWithSerializedChildren(input, component);
422
422
  const queuedForeignSubtreeResolution = await this.foreignSubtreeExecutionService.resolveStringQueuedHtml({
423
423
  currentIntegrationName: this.name,
424
- renderInput: input,
425
424
  html: componentRender.html,
426
- runtimeContextKey: getForeignSubtreeResolutionContextKey(this.name),
427
- queueLabel: 'String',
428
- getOwningRenderer: (integrationName, rendererCache) => resolveOwningIntegrationRenderer({
429
- appConfig: this.appConfig,
430
- runtimeOrigin: this.runtimeOrigin,
431
- currentIntegrationName: this.name,
432
- currentRenderer: this,
433
- integrationName,
434
- cache: rendererCache,
435
- }),
436
- applyAttributesToFirstElement: (html, attributes) => this.htmlTransformer.applyAttributesToFirstElement(html, attributes),
437
- dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets),
425
+ runtimeContext: this.getQueuedForeignSubtreeContext(input),
426
+ getOwningRenderer: (integrationName, rendererCache) => this.resolveOwningRenderer(integrationName, rendererCache),
438
427
  });
439
428
  const mergedAssets = this.htmlTransformer.dedupeProcessedAssets([
440
429
  ...(componentRender.assets ?? []),
@@ -704,14 +693,46 @@ export class IntegrationRenderer {
704
693
  renderInput,
705
694
  rendererCache: rendererCache,
706
695
  }),
707
- getOwningRenderer: (integrationName, rendererCache) => resolveOwningIntegrationRenderer({
708
- appConfig: this.appConfig,
709
- runtimeOrigin: this.runtimeOrigin,
710
- currentIntegrationName: this.name,
711
- currentRenderer: this,
712
- integrationName,
713
- cache: rendererCache,
714
- }),
696
+ getOwningRenderer: (integrationName, rendererCache) => this.resolveOwningRenderer(integrationName, rendererCache),
697
+ });
698
+ }
699
+ /**
700
+ * Returns the renderer that owns `integrationName`, reusing `rendererCache`
701
+ * for the current render.
702
+ */
703
+ resolveOwningRenderer(integrationName, rendererCache) {
704
+ return resolveOwningIntegrationRenderer({
705
+ appConfig: this.appConfig,
706
+ runtimeOrigin: this.runtimeOrigin,
707
+ currentIntegrationName: this.name,
708
+ currentRenderer: this,
709
+ integrationName,
710
+ cache: rendererCache,
711
+ });
712
+ }
713
+ /**
714
+ * Returns the queued foreign-subtree state this renderer keeps on `input`, or
715
+ * `undefined` when nothing was queued for it.
716
+ */
717
+ getQueuedForeignSubtreeContext(input) {
718
+ return this.foreignSubtreeExecutionService.getQueuedRuntimeContext(input, getForeignSubtreeResolutionContextKey(this.name));
719
+ }
720
+ /**
721
+ * Replaces the foreign-subtree tokens queued while rendering `html` with the
722
+ * HTML each owning renderer produces.
723
+ *
724
+ * @remarks
725
+ * `renderQueuedChildren` renders a subtree's children inside this renderer
726
+ * before the owning renderer renders the subtree around them. The returned
727
+ * assets are the owning renderers' assets, deduplicated.
728
+ */
729
+ resolveQueuedForeignSubtrees(html, runtimeContext, renderQueuedChildren) {
730
+ return this.foreignSubtreeExecutionService.resolveQueuedHtml({
731
+ currentIntegrationName: this.name,
732
+ html,
733
+ runtimeContext,
734
+ renderQueuedChildren,
735
+ getOwningRenderer: (integrationName, rendererCache) => this.resolveOwningRenderer(integrationName, rendererCache),
715
736
  });
716
737
  }
717
738
  finalizeIslandComponentRender(input, result) {
@@ -40,14 +40,6 @@ export declare class HtmlTransformerService {
40
40
  * Nothing is stamped when text or a comment comes first (whitespace aside).
41
41
  */
42
42
  applyAttributesToFirstBodyElement(html: string, attributes: Record<string, string>): string;
43
- /**
44
- * Sets attributes on the element a fragment or document starts with.
45
- *
46
- * @remarks
47
- * Nothing is stamped when text or a comment comes first (whitespace aside),
48
- * so a Lit render that opens with `<!--lit-part-->` keeps its markup.
49
- */
50
- applyAttributesToFirstElement(html: string, attributes: Record<string, string>): string;
51
43
  /**
52
44
  * Removes duplicate processed assets while preserving first-seen order.
53
45
  *
@@ -81,3 +73,11 @@ export declare class HtmlTransformerService {
81
73
  private groupDependenciesByPosition;
82
74
  private resolvePagePackageHtmlDependencies;
83
75
  }
76
+ /**
77
+ * Sets attributes on the element a fragment or document starts with.
78
+ *
79
+ * @remarks
80
+ * Nothing is stamped when text or a comment comes first (whitespace aside),
81
+ * so a Lit render that opens with `<!--lit-part-->` keeps its markup.
82
+ */
83
+ export declare function applyAttributesToFirstElement(html: string, attributes: Record<string, string>): string;
@@ -78,16 +78,6 @@ export class HtmlTransformerService {
78
78
  return false;
79
79
  }, { leadingOnly: true });
80
80
  }
81
- /**
82
- * Sets attributes on the element a fragment or document starts with.
83
- *
84
- * @remarks
85
- * Nothing is stamped when text or a comment comes first (whitespace aside),
86
- * so a Lit render that opens with `<!--lit-part-->` keeps its markup.
87
- */
88
- applyAttributesToFirstElement(html, attributes) {
89
- return stampAttributes(html, attributes, () => true, { leadingOnly: true });
90
- }
91
81
  /**
92
82
  * Removes duplicate processed assets while preserving first-seen order.
93
83
  *
@@ -180,6 +170,16 @@ export class HtmlTransformerService {
180
170
  return dedupeProcessedAssets([...nonGraphHtmlAssets, ...entryHtmlAssets]);
181
171
  }
182
172
  }
173
+ /**
174
+ * Sets attributes on the element a fragment or document starts with.
175
+ *
176
+ * @remarks
177
+ * Nothing is stamped when text or a comment comes first (whitespace aside),
178
+ * so a Lit render that opens with `<!--lit-part-->` keeps its markup.
179
+ */
180
+ export function applyAttributesToFirstElement(html, attributes) {
181
+ return stampAttributes(html, attributes, () => true, { leadingOnly: true });
182
+ }
183
183
  /**
184
184
  * Sets `attributes` on the first element that `isTarget` accepts.
185
185
  *
@@ -30,8 +30,8 @@ Call site (route scan, renderer, SSG, API)
30
30
  ## Caching layers
31
31
 
32
32
  1. **In-memory promise cache** (`PageModuleImportService.importCache`) — keyed by runtime, file path, content-derived reuse identity (`createRouteModuleReuseIdentity`), and source hash. Cleared by `invalidateDevelopmentGraph()`.
33
- 2. **Disk transpile cache** (`.eco/.server-modules/.build-cache.json`) — production and stable development graphs when dependency hashes match. Manifest field `corePackageVersion` invalidates entries when the framework package changes. An entry is also reused only while every local file its compiled output imports still exists.
34
- 3. **Unified graph manifest** — production static export fast path only; see build layer docs.
33
+ 2. **Disk transpile cache** (`.eco/.server-modules/.build-cache.json`) — production and stable development graphs when dependency hashes match. Manifest field `corePackageVersion` invalidates entries when the framework package changes. An entry is also reused only while every local file its compiled output imports still exists. Rebuilding a route module (`recordBuild()`) drops `renderedOutputs` so incremental static generation re-renders HTML instead of serving stale output after dependency or template edits.
34
+ 3. **Unified graph manifest** — production static export fast path only; see build layer docs. Reuse also requires matching source-file hashes and an exact match against the active template route set, so a deleted or edited layout or component cannot keep serving its compiled chunk.
35
35
 
36
36
  Development import URLs use `sourceHash` plus a per-service import generation counter. Node uses that value in its `?update=` query. Bun also receives a generation-specific compiled output filename because it retains a previously imported file when only its query changes. Both paths advance after `invalidateDevelopmentGraph()` without a process-wide invalidation version in reuse keys.
37
37
 
@@ -39,16 +39,20 @@ Compiled collection server modules also include the app-owned server invalidatio
39
39
 
40
40
  ## Files
41
41
 
42
- | File | Role |
43
- | ----------------------------------------- | ---------------------------------------------------------------- |
44
- | `page-module-import.service.ts` | Core import/cache/build orchestration |
45
- | `route-module-build-manifest.ts` | Content-derived reuse identity and disk cache manifest |
46
- | `app-module-loader.service.ts` | App-facing loader interface |
47
- | `app-server-module-transpiler.service.ts` | Factory for app-scoped loader + transpiler |
48
- | `server-module-transpiler.service.ts` | Injectable transpiler boundary for tests and bootstrap |
49
- | `view-module-loader.ts` | Normalizes string/URL view registrations into transpiler loaders |
50
- | `host-module-loader-registry.ts` | Process-global host loader fallback for embedded runtimes |
51
- | `source-module-support.ts` | Extension allowlist for host direct loading |
42
+ | File | Role |
43
+ | ------------------------------------------- | ---------------------------------------------------------------- |
44
+ | `page-module-import.service.ts` | Core import/cache/build orchestration |
45
+ | `route-module-build-manifest.ts` | Content-derived reuse identity and disk cache manifest |
46
+ | `route-module-build-cache.store.ts` | Persisted route-module transpile and static-render cache store |
47
+ | `route-module-build-cache-registry.ts` | Shared cache instance registry per `(appConfig, outdir)` pair |
48
+ | `route-module-dependency-hasher.ts` | Dependency graph source file hashing and staleness validation |
49
+ | `collection-server-module-build.service.ts` | Compiles collection server modules with invalidation stamping |
50
+ | `app-module-loader.service.ts` | App-facing loader interface |
51
+ | `app-server-module-transpiler.service.ts` | Factory for app-scoped loader + transpiler |
52
+ | `server-module-transpiler.service.ts` | Injectable transpiler boundary for tests and bootstrap |
53
+ | `view-module-loader.ts` | Normalizes string/URL view registrations into transpiler loaders |
54
+ | `host-module-loader-registry.ts` | Process-global host loader fallback for embedded runtimes |
55
+ | `source-module-support.ts` | Extension allowlist for host direct loading |
52
56
 
53
57
  ## Development invalidation
54
58
 
@@ -23,6 +23,11 @@ export declare class RouteModuleBuildCache {
23
23
  lookup(options: PageModuleBuildImportOptions & {
24
24
  fileHash: string;
25
25
  }): RouteModuleBuildCacheLookup | undefined;
26
+ /**
27
+ * @remarks
28
+ * Replaces the transpile entry and drops `renderedOutputs`. Rebuilt modules
29
+ * must re-render HTML; otherwise a layout edit can keep the previous page.
30
+ */
26
31
  recordBuild(options: PageModuleBuildImportOptions & {
27
32
  fileHash: string;
28
33
  outputPath: string;
@@ -47,11 +47,16 @@ export class RouteModuleBuildCache {
47
47
  if (!this.dependencies.exists(outputPath)) {
48
48
  return undefined;
49
49
  }
50
- if (!entry.outputImports?.every((importPath) => this.dependencies.exists(importPath))) {
50
+ if (!entry.outputImports.every((importPath) => this.dependencies.exists(importPath))) {
51
51
  return undefined;
52
52
  }
53
53
  return { outputPath, entry };
54
54
  }
55
+ /**
56
+ * @remarks
57
+ * Replaces the transpile entry and drops `renderedOutputs`. Rebuilt modules
58
+ * must re-render HTML; otherwise a layout edit can keep the previous page.
59
+ */
55
60
  recordBuild(options) {
56
61
  if (!shouldPersistRouteModuleBuildCache(options)) {
57
62
  return;
@@ -64,7 +69,6 @@ export class RouteModuleBuildCache {
64
69
  dependencyHashes[cacheFilePath] = options.fileHash;
65
70
  const outputPath = resolveOutputPath(options.outputPath, options.outdir);
66
71
  const manifest = this.loadManifest();
67
- const existingEntry = manifest.entries[cacheFilePath];
68
72
  manifest.corePackageVersion = this.dependencies.getCorePackageVersion();
69
73
  manifest.entries[cacheFilePath] = {
70
74
  sourceHash: options.fileHash,
@@ -74,10 +78,11 @@ export class RouteModuleBuildCache {
74
78
  dependencyHashes,
75
79
  outputImports: options.outputImports ??
76
80
  collectReachableLocalImports(outputPath, {
77
- exists: (filePath) => this.dependencies.exists(filePath),
78
- readFile: (filePath) => this.dependencies.readFile(filePath),
81
+ fileAccess: {
82
+ exists: (filePath) => this.dependencies.exists(filePath),
83
+ readFile: (filePath) => this.dependencies.readFile(filePath),
84
+ },
79
85
  }),
80
- renderedOutputs: existingEntry?.renderedOutputs,
81
86
  };
82
87
  this.persistManifest(manifest);
83
88
  }
@@ -10,10 +10,11 @@ export interface RouteModuleBuildCacheEntry {
10
10
  buildKey: string;
11
11
  dependencyHashes?: RouteModuleDependencyHashes;
12
12
  /**
13
- * Local files the compiled output imports (shared chunks, collection modules).
14
- * The entry is reused only while all of them exist.
13
+ * Local files reachable from the compiled output through local imports,
14
+ * including shared chunks and collection modules. The entry is reused only
15
+ * while all of them exist.
15
16
  */
16
- outputImports?: string[];
17
+ outputImports: string[];
17
18
  renderedOutputs?: Record<string, RouteModuleStaticRenderCacheEntry>;
18
19
  }
19
20
  /** Metadata for one rendered static HTML artifact derived from a route module. */
@@ -58,5 +59,10 @@ export declare function resolvePageModuleOutputFileName(options: {
58
59
  /** Builds the cache key for persisted production route-module builds. */
59
60
  export declare function createPersistedRouteModuleBuildKey(options: PageModuleBuildImportOptions, sourceTransforms?: BuildOptions['sourceTransforms']): string;
60
61
  export declare function createEmptyRouteModuleBuildCacheManifest(): RouteModuleBuildCacheManifest;
62
+ /**
63
+ * @remarks
64
+ * Entries without `outputImports` predate import validation and cannot show that
65
+ * their chunks still exist, so they are dropped and rebuild on the next lookup.
66
+ */
61
67
  export declare function readRouteModuleBuildCacheManifest(manifestPath: string): RouteModuleBuildCacheManifest | undefined;
62
68
  export declare function writeRouteModuleBuildCacheManifest(manifestPath: string, manifest: RouteModuleBuildCacheManifest): void;
@@ -42,6 +42,11 @@ export function createEmptyRouteModuleBuildCacheManifest() {
42
42
  entries: {},
43
43
  };
44
44
  }
45
+ /**
46
+ * @remarks
47
+ * Entries without `outputImports` predate import validation and cannot show that
48
+ * their chunks still exist, so they are dropped and rebuild on the next lookup.
49
+ */
45
50
  export function readRouteModuleBuildCacheManifest(manifestPath) {
46
51
  const parsed = readProductionCacheManifest(manifestPath);
47
52
  if (!parsed || typeof parsed.entries !== 'object') {
@@ -51,7 +56,7 @@ export function readRouteModuleBuildCacheManifest(manifestPath) {
51
56
  corePackageVersion: parsed.corePackageVersion ?? '',
52
57
  configHash: parsed.configHash,
53
58
  buildInputsFingerprint: parsed.buildInputsFingerprint,
54
- entries: parsed.entries,
59
+ entries: Object.fromEntries(Object.entries(parsed.entries).filter(([, entry]) => Array.isArray(entry.outputImports))),
55
60
  };
56
61
  }
57
62
  export function writeRouteModuleBuildCacheManifest(manifestPath, manifest) {
@@ -30,13 +30,14 @@ Semantic error pages are excluded from ordinary page enumeration and emitted onc
30
30
 
31
31
  ## Files
32
32
 
33
- | File | Role |
34
- | ------------------------------ | ---------------------------------------------------------------------------- |
35
- | `static-site-generator.ts` | Route enumeration, HTML artifact writes, integration export hooks, sitemap |
36
- | `static-export-context.ts` | Hook context type for `beforeStaticExport` / `afterStaticExport` |
37
- | `sitemap.ts` | Pure sitemap.xml renderer |
38
- | `sitemap-routes.ts` | Sitemap location assembly (`exclude`, `extraUrls`, dedupe) |
39
- | `static-build-invalidation.ts` | `dist/` reset policy, production cache clearing, static-render cache context |
33
+ | File | Role |
34
+ | ------------------------------------------- | ---------------------------------------------------------------------------- |
35
+ | `static-site-generator.ts` | Route enumeration, HTML artifact writes, integration export hooks, sitemap |
36
+ | `static-export-context.ts` | Hook context type for `beforeStaticExport` / `afterStaticExport` |
37
+ | `sitemap.ts` | Pure sitemap.xml renderer |
38
+ | `sitemap-routes.ts` | Sitemap location assembly (`exclude`, `extraUrls`, dedupe) |
39
+ | `static-build-invalidation.ts` | `dist/` reset policy, production cache clearing, static-render cache context |
40
+ | `production-page-browser-graph-prebuild.ts` | Warms and prebuilds browser asset graphs before static export rendering |
40
41
 
41
42
  Build-input fingerprinting (`hashAppConfigFile`, `createBuildInputsFingerprint`) lives in `packages/core/src/build/cache/build-input-fingerprint.ts` and is shared with server-entry and unified-graph caches.
42
43
 
@@ -50,7 +51,7 @@ Build-input fingerprinting (`hashAppConfigFile`, `createBuildInputsFingerprint`)
50
51
 
51
52
  When `dist/` is preserved (`preserveExportDirectory: true`), `StaticSiteGenerator.run()` prunes HTML files no longer in the active route set.
52
53
 
53
- Rendered HTML reuse is tracked in `.eco/.server-modules/.build-cache.json` under each route module's `renderedOutputs`. `canReuseStaticRender()` skips re-rendering when the source file, dependency hashes, and output path are unchanged.
54
+ Rendered HTML reuse is tracked in `.eco/.server-modules/.build-cache.json` under each route module's `renderedOutputs`. `canReuseStaticRender()` skips re-rendering when the source file, dependency hashes, and output path are unchanged. Rebuilding a route module (`recordBuild()`) drops `renderedOutputs` so a layout or component edit cannot keep the previous HTML.
54
55
 
55
56
  `clearProductionBuildCaches()` runs on `force` builds and removes all persisted `.eco` build manifests (route modules, server entry, unified pages graph).
56
57