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

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 (179) hide show
  1. package/README.md +50 -32
  2. package/package.json +50 -4
  3. package/src/adapters/README.md +3 -1
  4. package/src/adapters/abstract/application-adapter.d.ts +28 -6
  5. package/src/adapters/abstract/application-adapter.js +58 -5
  6. package/src/adapters/abstract/segment-path-matcher.js +56 -38
  7. package/src/adapters/abstract/server-adapter.d.ts +14 -0
  8. package/src/adapters/abstract/server-adapter.js +10 -0
  9. package/src/adapters/bun/create-app.d.ts +8 -4
  10. package/src/adapters/bun/create-app.js +64 -37
  11. package/src/adapters/bun/server-adapter.d.ts +6 -2
  12. package/src/adapters/bun/server-adapter.js +14 -1
  13. package/src/adapters/create-app.d.ts +62 -7
  14. package/src/adapters/create-app.js +61 -5
  15. package/src/adapters/node/create-app.d.ts +5 -5
  16. package/src/adapters/node/create-app.js +18 -5
  17. package/src/adapters/node/runtime-host.js +9 -4
  18. package/src/adapters/node/server-adapter.d.ts +5 -1
  19. package/src/adapters/node/server-adapter.js +16 -1
  20. package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
  21. package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -8
  22. package/src/adapters/shared/http/fs-server-response-factory.js +5 -30
  23. package/src/adapters/shared/http/fs-server-response-matcher.d.ts +24 -24
  24. package/src/adapters/shared/http/fs-server-response-matcher.js +59 -83
  25. package/src/adapters/shared/runtime/application-adapter.d.ts +1 -0
  26. package/src/adapters/shared/runtime/application-adapter.js +12 -0
  27. package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
  28. package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
  29. package/src/adapters/shared/runtime/port-manager-default-prompt.d.ts +6 -0
  30. package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
  31. package/src/adapters/shared/runtime/port-manager.d.ts +3 -3
  32. package/src/adapters/shared/runtime/port-manager.js +14 -45
  33. package/src/adapters/shared/runtime/server-adapter.d.ts +14 -5
  34. package/src/adapters/shared/runtime/server-adapter.js +22 -30
  35. package/src/adapters/shared/runtime/server-route-handler.js +11 -3
  36. package/src/adapters/shared/runtime/server-static-builder.d.ts +9 -3
  37. package/src/adapters/shared/runtime/server-static-builder.js +59 -37
  38. package/src/build/README.md +4 -0
  39. package/src/build/cache/server-entry-build-cache.d.ts +24 -1
  40. package/src/build/cache/server-entry-build-cache.js +125 -8
  41. package/src/build/contracts/content-virtual-modules.d.ts +3 -1
  42. package/src/build/contracts/content-virtual-modules.js +8 -0
  43. package/src/build/rolldown/rolldown-adapter-helpers.js +41 -25
  44. package/src/build/rolldown/rolldown-plugin-bridge.js +25 -21
  45. package/src/build/runtime/build-request-policy.js +1 -1
  46. package/src/build/server-bundle-publication.d.ts +14 -0
  47. package/src/build/server-bundle-publication.js +49 -0
  48. package/src/config/README.md +17 -2
  49. package/src/config/apply-user-config.d.ts +6 -0
  50. package/src/config/apply-user-config.js +67 -0
  51. package/src/config/config-builder.d.ts +10 -1
  52. package/src/config/config-builder.js +51 -10
  53. package/src/config/constants.d.ts +4 -0
  54. package/src/config/constants.js +4 -0
  55. package/src/config/define-config.d.ts +9 -0
  56. package/src/config/define-config.js +10 -0
  57. package/src/config/index.d.ts +5 -0
  58. package/src/config/index.js +4 -0
  59. package/src/config/is-finalized-app-config.d.ts +6 -0
  60. package/src/config/is-finalized-app-config.js +11 -0
  61. package/src/config/load-eco-config.d.ts +21 -0
  62. package/src/config/load-eco-config.js +100 -0
  63. package/src/config/resolve-eco-config-path.d.ts +23 -0
  64. package/src/config/resolve-eco-config-path.js +47 -0
  65. package/src/config/server-config-bundle.d.ts +25 -0
  66. package/src/config/server-config-bundle.js +148 -0
  67. package/src/config/user-config-types.d.ts +164 -0
  68. package/src/config/user-config-types.js +1 -0
  69. package/src/css-imports.d.ts +4 -0
  70. package/src/declarations.d.ts +11 -5
  71. package/src/dev/README.md +6 -0
  72. package/src/dev/development-restart-watch-paths.d.ts +13 -0
  73. package/src/dev/development-restart-watch-paths.js +37 -0
  74. package/src/dev/development-restart.d.ts +13 -0
  75. package/src/dev/development-restart.js +21 -0
  76. package/src/dev/transform-server/dev-transform-server.d.ts +6 -0
  77. package/src/dev/transform-server/dev-transform-server.js +16 -5
  78. package/src/eco/README.md +73 -5
  79. package/src/eco/component-identity.d.ts +3 -2
  80. package/src/eco/component-identity.js +5 -2
  81. package/src/eco/discovered-dependencies.d.ts +45 -0
  82. package/src/eco/discovered-dependencies.js +87 -0
  83. package/src/eco/eco.js +6 -0
  84. package/src/eco/eco.types.d.ts +18 -2
  85. package/src/eco/lazy-injector-map.js +57 -41
  86. package/src/eco/page-dependency-contributions.d.ts +19 -0
  87. package/src/eco/page-dependency-contributions.js +52 -0
  88. package/src/errors/http-error-page-contract.d.ts +77 -0
  89. package/src/errors/http-error-page-contract.js +106 -0
  90. package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -0
  91. package/src/hmr/strategies/js-hmr-strategy.js +24 -16
  92. package/src/index.browser.d.ts +3 -0
  93. package/src/index.browser.js +3 -0
  94. package/src/index.d.ts +4 -1
  95. package/src/index.js +4 -1
  96. package/src/islands/README.md +5 -1
  97. package/src/plugins/README.md +8 -1
  98. package/src/plugins/component-import-discovery.d.ts +19 -0
  99. package/src/plugins/component-import-discovery.js +241 -0
  100. package/src/plugins/eco-component-meta-plugin.d.ts +3 -1
  101. package/src/plugins/eco-component-meta-plugin.js +118 -16
  102. package/src/plugins/processor.d.ts +10 -2
  103. package/src/plugins/processor.js +4 -0
  104. package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
  105. package/src/plugins/tsconfig-import-resolver.js +4 -2
  106. package/src/route-renderer/GRAPH.md +1 -1
  107. package/src/route-renderer/README.md +15 -2
  108. package/src/{adapters/shared/http/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +3 -3
  109. package/src/route-renderer/orchestration/custom-element-scripts/README.md +9 -0
  110. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +16 -0
  111. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +34 -0
  112. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +80 -0
  113. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +190 -0
  114. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +17 -0
  115. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +41 -0
  116. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +10 -0
  117. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +46 -0
  118. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +7 -2
  119. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +2 -0
  120. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +11 -2
  121. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +10 -2
  122. package/src/route-renderer/orchestration/integration-renderer.d.ts +9 -5
  123. package/src/route-renderer/orchestration/integration-renderer.js +42 -29
  124. package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +2 -5
  125. package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +2 -68
  126. package/src/route-renderer/orchestration/ownership-graph/component-graph.js +55 -39
  127. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +6 -0
  128. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +59 -36
  129. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +8 -10
  130. package/src/route-renderer/orchestration/string-markup-renderer.d.ts +1 -1
  131. package/src/route-renderer/orchestration/string-markup-renderer.js +2 -1
  132. package/src/route-renderer/page-loading/component-dependency-collection.d.ts +6 -2
  133. package/src/route-renderer/page-loading/component-dependency-collection.js +113 -68
  134. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +41 -28
  135. package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +10 -3
  136. package/src/route-renderer/page-loading/file-scoped-dependency-components.js +62 -25
  137. package/src/route-renderer/page-loading/page-dependency-bundling.js +14 -8
  138. package/src/route-renderer/page-loading/resolved-page-dependencies.d.ts +1 -2
  139. package/src/route-renderer/page-loading/resolved-page-dependencies.js +8 -7
  140. package/src/route-renderer/route-renderer.d.ts +9 -0
  141. package/src/route-renderer/route-renderer.js +18 -0
  142. package/src/router/README.md +7 -1
  143. package/src/router/server/route-registry.d.ts +13 -0
  144. package/src/router/server/route-registry.js +46 -32
  145. package/src/services/README.md +5 -0
  146. package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +36 -9
  147. package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.js +122 -37
  148. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +2 -0
  149. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +13 -2
  150. package/src/services/assets/asset-processing-service/page-package.js +42 -39
  151. package/src/services/error-pages/README.md +9 -0
  152. package/src/services/error-pages/default-error-pages.d.ts +44 -0
  153. package/src/services/error-pages/default-error-pages.js +207 -0
  154. package/src/services/error-pages/error-page-renderer.d.ts +58 -0
  155. package/src/services/error-pages/error-page-renderer.js +146 -0
  156. package/src/services/error-pages/semantic-error-page-exporter.d.ts +23 -0
  157. package/src/services/error-pages/semantic-error-page-exporter.js +35 -0
  158. package/src/services/invalidation/development-invalidation.service.d.ts +7 -1
  159. package/src/services/invalidation/development-invalidation.service.js +35 -3
  160. package/src/services/module-loading/README.md +16 -13
  161. package/src/services/module-loading/app-server-module-transpiler.service.js +2 -0
  162. package/src/services/module-loading/collection-server-module-build.service.d.ts +1 -0
  163. package/src/services/module-loading/collection-server-module-build.service.js +5 -2
  164. package/src/services/module-loading/page-module-import.service.d.ts +8 -0
  165. package/src/services/module-loading/page-module-import.service.js +62 -28
  166. package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
  167. package/src/services/module-loading/view-module-loader.d.ts +10 -0
  168. package/src/services/module-loading/view-module-loader.js +46 -0
  169. package/src/services/validation/schema-validation-service.d.ts +1 -0
  170. package/src/services/validation/schema-validation-service.js +23 -36
  171. package/src/static-site-generator/README.md +6 -1
  172. package/src/static-site-generator/static-site-generator.d.ts +7 -2
  173. package/src/static-site-generator/static-site-generator.js +90 -49
  174. package/src/types/internal-types.d.ts +6 -1
  175. package/src/types/public-types.d.ts +32 -22
  176. package/src/utils/parse-cli-args.js +29 -22
  177. package/src/watchers/project-watcher.d.ts +14 -1
  178. package/src/watchers/project-watcher.js +85 -34
  179. /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
@@ -20,7 +20,8 @@ These contracts are responsible for:
20
20
  - `processor.ts`: asset-transformation contract for processors, including generated `@types` package helpers for virtual modules
21
21
  - `runtime-capability.ts`: runtime compatibility declaration types
22
22
  - `source-transform.ts`: bundler-neutral source-transform primitive with Ecopages adapters plus app-level Vite plugin composition helpers
23
- - `eco-component-meta-plugin.ts`: component-identity attribution transform that uses a lexical `eco.` gate, then an Oxc `CallExpression` rewrite
23
+ - `component-import-discovery.ts`: resolves direct local factory exports, named `export { X } from` barrels (imported binding only), relative CSS imports, and aliased CSS imports; records successful named re-export hops as watch files; excludes `export *`, type imports, package imports, and ordinary helpers.
24
+ - `eco-component-meta-plugin.ts`: component-identity attribution transform for `eco.*()` factories and `attributeMdxComponentIdentity` for compiled MDX modules
24
25
 
25
26
  ## Ownership Rules
26
27
 
@@ -28,6 +29,7 @@ These contracts are responsible for:
28
29
  - Processors own asset semantics, cache ownership, and processor-specific watch behavior.
29
30
  - Core owns lifecycle ordering, startup orchestration, and manifest assembly.
30
31
  - The transform wraps native `eco.page()`, `eco.component()`, `eco.layout()`, and `eco.html()` factory options with `bindComponentIdentity()`. Factories retain the resulting `options.identity` on `config`, and runtime consumers read it through `getComponentIdentity()`. Browser, HMR, and server builds use the same source transform, so ownership and dependency diagnostics retain stable file attribution without a loader duplicate.
32
+ - MDX modules compiled by `@ecopages/mdx/core` use `attributeMdxComponentIdentity()` to strip bare CSS imports, attach live component accessors to `config.dependencies`, keep inferred stylesheets on identity, and assign `MDXContent.config = config`. The loader requires `projectRoot` from app config. Markdown code blocks and dynamic imports within functions are distinguished and left unaffected.
31
33
 
32
34
  ## Lifecycle Summary
33
35
 
@@ -35,3 +37,8 @@ These contracts are responsible for:
35
37
  2. Core seals the app-owned build manifest.
36
38
  3. Runtime startup calls runtime-only setup hooks.
37
39
  4. Request-time rendering and development invalidation reuse those finalized contracts.
40
+ 5. `DevelopmentInvalidationService.invalidateServerModules()` calls `Processor.invalidateServerArtifacts()` so processors can discard compiled server artifacts that are not part of the route-module graph.
41
+
42
+ ## Discovered dependency metadata
43
+
44
+ The identity transform passes a deferred Component accessor and resolved stylesheet paths to `bindComponentIdentity`. Factories attach the deferred Component accessor to `config.dependencies`; inferred stylesheets stay keyed by identity for the collector. Import bindings are read during graph traversal, after module initialization. Supported relative and aliased CSS imports are removed from all transformed outputs so the asset pipeline owns CSS delivery. Explicit styles override discovery. Discovery follows named `export { X } from` barrels for the imported binding only. Successful named re-export hops are recorded as watch files on the discovering identity so a barrel retarget invalidates HTML and Page Browser Graph caches without editing the importing Page. It does not follow `export *`, dynamic imports, namespace imports, package Components/CSS, CSS Modules, or custom import attributes. The transform uses the same discovery rules in Bun and Vite/Rolldown. Imported source changes are reparsed through the content-keyed parser cache.
@@ -0,0 +1,19 @@
1
+ export type DiscoveredImports = {
2
+ components: string[];
3
+ stylesheets: string[];
4
+ watchFiles: string[];
5
+ removals: Array<{
6
+ start: number;
7
+ end: number;
8
+ replacement: string;
9
+ }>;
10
+ };
11
+ /**
12
+ * Discovers local Eco Component imports and relative or aliased side-effect CSS.
13
+ *
14
+ * @remarks
15
+ * Named `export { X } from` barrels are followed for the imported binding only.
16
+ * Successful re-export hops are recorded in `watchFiles` so barrel edits invalidate caches.
17
+ * `export *`, dynamic imports, namespace imports, packages, and `.server` modules are not.
18
+ */
19
+ export declare function discoverComponentImports(program: unknown, ownerFile: string, projectRoot: string): DiscoveredImports;
@@ -0,0 +1,241 @@
1
+ import path from 'node:path';
2
+ import { existsSync, readFileSync, realpathSync } from 'node:fs';
3
+ import { cachedParseSync } from '../cache/module-parse-cache.js';
4
+ import { loadTsconfigPathPrefixes, matchesTsconfigPathPrefix, resolveProjectModulePath, } from './tsconfig-import-resolver.js';
5
+ function node(value) {
6
+ return typeof value === 'object' && value !== null ? value : undefined;
7
+ }
8
+ function nodes(value) {
9
+ return Array.isArray(value) ? value.map(node).filter((value) => value !== undefined) : [];
10
+ }
11
+ function identifierName(value) {
12
+ const named = node(value);
13
+ if (typeof named?.name === 'string')
14
+ return named.name;
15
+ if (typeof named?.value === 'string')
16
+ return named.value;
17
+ return undefined;
18
+ }
19
+ function isFactory(value) {
20
+ const call = node(value);
21
+ const callee = node(call?.callee);
22
+ return (call?.type === 'CallExpression' &&
23
+ callee?.type === 'MemberExpression' &&
24
+ node(callee.object)?.name === 'eco' &&
25
+ ['component', 'layout', 'html'].includes(String(node(callee.property)?.name)));
26
+ }
27
+ function isServerSpecifier(source) {
28
+ return /\.server(?:\.[cm]?[jt]sx?)?$/.test(source);
29
+ }
30
+ function collectDeclaredFactoryBindings(body) {
31
+ const declared = new Set();
32
+ const factories = new Set();
33
+ for (const statement of body) {
34
+ const declaration = statement.type === 'ExportNamedDeclaration' ? node(statement.declaration) : statement;
35
+ for (const variable of nodes(declaration?.declarations)) {
36
+ const name = identifierName(variable.id);
37
+ if (typeof name === 'string' && isFactory(variable.init)) {
38
+ declared.add(name);
39
+ if (statement.type === 'ExportNamedDeclaration')
40
+ factories.add(name);
41
+ }
42
+ }
43
+ if (statement.type === 'ExportDefaultDeclaration' && isFactory(statement.declaration))
44
+ factories.add('default');
45
+ }
46
+ return { declared, factories };
47
+ }
48
+ function indexReexportFromSource(from, specifiers, namedReexports) {
49
+ for (const specifier of specifiers) {
50
+ if (specifier.exportKind === 'type')
51
+ continue;
52
+ const exported = identifierName(specifier.exported);
53
+ const imported = identifierName(specifier.local) ?? exported;
54
+ if (exported && imported)
55
+ namedReexports.set(exported, { source: from, imported });
56
+ }
57
+ }
58
+ function indexLocalNamedExportSpecifiers(specifiers, declared, factories) {
59
+ for (const specifier of specifiers) {
60
+ if (specifier.exportKind !== 'type' && declared.has(String(identifierName(specifier.local)))) {
61
+ const exported = identifierName(specifier.exported);
62
+ if (exported)
63
+ factories.add(exported);
64
+ }
65
+ }
66
+ }
67
+ function indexNamedExportStatement(statement, declared, factories, namedReexports) {
68
+ if (statement.type === 'ExportDefaultDeclaration' && declared.has(String(identifierName(statement.declaration)))) {
69
+ factories.add('default');
70
+ }
71
+ if (statement.type !== 'ExportNamedDeclaration' || statement.exportKind === 'type') {
72
+ return;
73
+ }
74
+ const from = node(statement.source)?.value;
75
+ const specifiers = nodes(statement.specifiers);
76
+ if (typeof from === 'string') {
77
+ indexReexportFromSource(from, specifiers, namedReexports);
78
+ return;
79
+ }
80
+ indexLocalNamedExportSpecifiers(specifiers, declared, factories);
81
+ }
82
+ /**
83
+ * Indexes local `eco.*()` factory exports and named `export { X } from` re-exports.
84
+ *
85
+ * @remarks
86
+ * `export *` is ignored so a barrel cannot pull an entire kit into the graph.
87
+ */
88
+ function indexModuleExports(file, cache) {
89
+ const cached = cache.get(file);
90
+ if (cached)
91
+ return cached;
92
+ const source = readFileSync(file, 'utf8');
93
+ const parsed = cachedParseSync(file, source, { sourceType: 'module' });
94
+ const body = nodes(parsed.program.body);
95
+ const { declared, factories } = collectDeclaredFactoryBindings(body);
96
+ const namedReexports = new Map();
97
+ for (const statement of body) {
98
+ indexNamedExportStatement(statement, declared, factories, namedReexports);
99
+ }
100
+ const indexed = { factories, namedReexports };
101
+ cache.set(file, indexed);
102
+ return indexed;
103
+ }
104
+ /**
105
+ * True when `exportName` is an `eco.*()` factory, including through named barrel re-exports.
106
+ *
107
+ * @remarks
108
+ * Completed answers are memoized on `resolved`. `path` is only the current walk, so a
109
+ * second alias of the same Component is not treated as a cycle miss.
110
+ */
111
+ function isFactoryExport(file, exportName, projectRoot, pathPrefixes, state) {
112
+ const visitKey = `${file}\0${exportName}`;
113
+ const known = state.resolved.get(visitKey);
114
+ if (known !== undefined)
115
+ return known;
116
+ if (state.path.has(visitKey))
117
+ return false;
118
+ state.path.add(visitKey);
119
+ let result = false;
120
+ if (!file.includes(`${path.sep}node_modules${path.sep}`) && !isServerSpecifier(file)) {
121
+ const { factories, namedReexports } = indexModuleExports(file, state.moduleIndex);
122
+ if (factories.has(exportName)) {
123
+ result = true;
124
+ }
125
+ else {
126
+ const reexport = namedReexports.get(exportName);
127
+ if (reexport &&
128
+ !isServerSpecifier(reexport.source) &&
129
+ (reexport.source.startsWith('.') || matchesTsconfigPathPrefix(reexport.source, pathPrefixes))) {
130
+ const resolved = resolveProjectModulePath(projectRoot, file, reexport.source, { preserveBarrel: true });
131
+ if (!resolved) {
132
+ throw new Error(`[ecopages] Cannot resolve import ${JSON.stringify(reexport.source)} from ${file}`);
133
+ }
134
+ if (/\.[jt]sx?$/.test(resolved) && !resolved.includes(`${path.sep}node_modules${path.sep}`)) {
135
+ result = isFactoryExport(resolved, reexport.imported, projectRoot, pathPrefixes, state);
136
+ if (result)
137
+ state.watchFiles.add(file);
138
+ }
139
+ }
140
+ }
141
+ }
142
+ state.path.delete(visitKey);
143
+ state.resolved.set(visitKey, result);
144
+ return result;
145
+ }
146
+ function isCssImport(source) {
147
+ return source.endsWith('.css') && !source.endsWith('.module.css');
148
+ }
149
+ function resolveStylesheetImportPath(source, ownerFile, projectRoot, pathPrefixes) {
150
+ const isRelative = source.startsWith('.');
151
+ const isAlias = matchesTsconfigPathPrefix(source, pathPrefixes);
152
+ if (!isRelative && !isAlias) {
153
+ return undefined;
154
+ }
155
+ if (isRelative) {
156
+ const candidate = path.resolve(path.dirname(ownerFile), source);
157
+ return existsSync(candidate) ? realpathSync(candidate) : undefined;
158
+ }
159
+ return resolveProjectModulePath(projectRoot, ownerFile, source, { preserveBarrel: true });
160
+ }
161
+ function tryRecordSideEffectStylesheetImport(statement, source, ownerFile, projectRoot, pathPrefixes, result) {
162
+ const specifiers = nodes(statement.specifiers);
163
+ if (!isCssImport(source) || specifiers.length > 0) {
164
+ return false;
165
+ }
166
+ const resolved = resolveStylesheetImportPath(source, ownerFile, projectRoot, pathPrefixes);
167
+ if (!resolved) {
168
+ if (source.startsWith('.') || matchesTsconfigPathPrefix(source, pathPrefixes)) {
169
+ throw new Error(`[ecopages] Cannot resolve stylesheet import ${JSON.stringify(source)} from ${ownerFile}`);
170
+ }
171
+ return false;
172
+ }
173
+ if (!existsSync(resolved)) {
174
+ throw new Error(`[ecopages] Cannot resolve stylesheet import ${JSON.stringify(source)} from ${ownerFile}`);
175
+ }
176
+ result.stylesheets.push(resolved);
177
+ result.removals.push({ start: statement.start, end: statement.end, replacement: '' });
178
+ return true;
179
+ }
180
+ function collectFactoryComponentsFromImport(statement, source, ownerFile, projectRoot, pathPrefixes, factoryState, result) {
181
+ const specifiers = nodes(statement.specifiers);
182
+ const values = specifiers.filter((entry) => entry.importKind !== 'type' &&
183
+ (entry.type === 'ImportSpecifier' || entry.type === 'ImportDefaultSpecifier'));
184
+ if (!values.length || (!source.startsWith('.') && !matchesTsconfigPathPrefix(source, pathPrefixes))) {
185
+ return;
186
+ }
187
+ if (isServerSpecifier(source)) {
188
+ return;
189
+ }
190
+ const resolved = resolveProjectModulePath(projectRoot, ownerFile, source, { preserveBarrel: true });
191
+ if (!resolved)
192
+ throw new Error(`[ecopages] Cannot resolve import ${JSON.stringify(source)} from ${ownerFile}`);
193
+ if (!/\.[jt]sx?$/.test(resolved) || resolved.includes(`${path.sep}node_modules${path.sep}`)) {
194
+ return;
195
+ }
196
+ for (const specifier of values) {
197
+ const imported = specifier.type === 'ImportDefaultSpecifier' ? 'default' : identifierName(specifier.imported);
198
+ const local = identifierName(specifier.local);
199
+ if (typeof local === 'string' &&
200
+ imported &&
201
+ isFactoryExport(resolved, imported, projectRoot, pathPrefixes, {
202
+ ...factoryState,
203
+ path: new Set(),
204
+ })) {
205
+ result.components.push(local);
206
+ }
207
+ }
208
+ }
209
+ /**
210
+ * Discovers local Eco Component imports and relative or aliased side-effect CSS.
211
+ *
212
+ * @remarks
213
+ * Named `export { X } from` barrels are followed for the imported binding only.
214
+ * Successful re-export hops are recorded in `watchFiles` so barrel edits invalidate caches.
215
+ * `export *`, dynamic imports, namespace imports, packages, and `.server` modules are not.
216
+ */
217
+ export function discoverComponentImports(program, ownerFile, projectRoot) {
218
+ const result = { components: [], stylesheets: [], watchFiles: [], removals: [] };
219
+ const pathPrefixes = loadTsconfigPathPrefixes(projectRoot);
220
+ const factoryState = {
221
+ moduleIndex: new Map(),
222
+ resolved: new Map(),
223
+ watchFiles: new Set(),
224
+ path: new Set(),
225
+ };
226
+ for (const statement of nodes(node(program)?.body)) {
227
+ if (statement.type !== 'ImportDeclaration' || statement.importKind === 'type')
228
+ continue;
229
+ if (nodes(statement.attributes).length || nodes(statement.assertions).length)
230
+ continue;
231
+ const source = node(statement.source)?.value;
232
+ if (typeof source !== 'string')
233
+ continue;
234
+ if (tryRecordSideEffectStylesheetImport(statement, source, ownerFile, projectRoot, pathPrefixes, result)) {
235
+ continue;
236
+ }
237
+ collectFactoryComponentsFromImport(statement, source, ownerFile, projectRoot, pathPrefixes, factoryState, result);
238
+ }
239
+ result.watchFiles.push(...factoryState.watchFiles);
240
+ return result;
241
+ }
@@ -5,7 +5,9 @@ export interface EcoComponentDirPluginOptions {
5
5
  config: EcoPagesAppConfig;
6
6
  }
7
7
  /** Attributes real `eco.*()` factory calls with canonical component identity. */
8
- export declare function attributeComponentIdentity(contents: string, filePath: string, integration: string): string;
8
+ export declare function attributeComponentIdentity(contents: string, filePath: string, integration: string, projectRoot?: string): string;
9
+ /** Attributes compiled MDX module with canonical component identity and discovered dependencies. */
10
+ export declare function attributeMdxComponentIdentity(contents: string, filePath: string, integration: string, projectRoot: string): string;
9
11
  export declare function createEcoComponentMetaTransform(options: EcoComponentDirPluginOptions): EcoSourceTransform;
10
12
  export declare function createEcoComponentMetaVitePlugin(options: EcoComponentDirPluginOptions): EcoViteCompatiblePlugin;
11
13
  export declare function createEcoComponentMetaPlugin(options: EcoComponentDirPluginOptions): EcoBuildPlugin;
@@ -2,6 +2,7 @@ import { prependJsxImportSourceIfMissing } from './jsx-import-source.utils.js';
2
2
  import { createEcoBuildPluginFromSourceTransform, createVitePluginFromSourceTransform } from './source-transform.js';
3
3
  import { cachedParseSync } from '../cache/module-parse-cache.js';
4
4
  import { rapidhash } from '../utils/hash.js';
5
+ import { discoverComponentImports } from './component-import-discovery.js';
5
6
  function integrationForFile(filePath, config) {
6
7
  const candidates = config.integrations
7
8
  .flatMap((integration) => integration.extensions.map((extension) => [extension, integration]))
@@ -12,6 +13,12 @@ function integrationForFile(filePath, config) {
12
13
  function isAstNode(value) {
13
14
  return typeof value === 'object' && value !== null;
14
15
  }
16
+ function node(value) {
17
+ return typeof value === 'object' && value !== null ? value : undefined;
18
+ }
19
+ function nodes(value) {
20
+ return Array.isArray(value) ? value.map(node).filter((value) => value !== undefined) : [];
21
+ }
15
22
  function isEcoFactoryCall(node) {
16
23
  if (node.type !== 'CallExpression' || !isAstNode(node.callee))
17
24
  return false;
@@ -41,36 +48,52 @@ function walkAst(node, visit) {
41
48
  for (const value of Object.values(node))
42
49
  walkAst(value, visit);
43
50
  }
44
- function addIdentityBindingImport(contents, program) {
51
+ function addNamedImport(contents, program, sourceModule, importedName) {
52
+ const importedNames = typeof importedName === 'string' ? [importedName] : [...importedName];
45
53
  const imports = program.body.filter((node) => isAstNode(node) &&
46
54
  node.type === 'ImportDeclaration' &&
47
55
  isAstNode(node.source) &&
48
- node.source.value === '@ecopages/core');
56
+ node.source.value === sourceModule);
49
57
  const valueImport = imports.find((node) => node.importKind !== 'type');
50
58
  if (!valueImport)
51
- return `import { bindComponentIdentity } from '@ecopages/core';\n${contents}`;
59
+ return `import { ${importedNames.join(', ')} } from '${sourceModule}';\n${contents}`;
52
60
  const specifiers = Array.isArray(valueImport.specifiers) ? valueImport.specifiers.filter(isAstNode) : [];
53
- if (specifiers.some((specifier) => specifier.type === 'ImportSpecifier' &&
54
- isAstNode(specifier.imported) &&
55
- specifier.imported.name === 'bindComponentIdentity')) {
61
+ const existingNames = new Set(specifiers.flatMap((specifier) => {
62
+ if (specifier.type !== 'ImportSpecifier' || !isAstNode(specifier.imported))
63
+ return [];
64
+ const name = specifier.imported.name ?? specifier.imported.value;
65
+ return typeof name === 'string' ? [name] : [];
66
+ }));
67
+ const missing = importedNames.filter((name) => !existingNames.has(name));
68
+ if (missing.length === 0) {
56
69
  return contents;
57
70
  }
58
71
  const namedSpecifiers = specifiers.filter((specifier) => specifier.type === 'ImportSpecifier');
59
72
  if (namedSpecifiers.length > 0) {
60
73
  const lastSpecifier = namedSpecifiers[namedSpecifiers.length - 1];
61
- return `${contents.slice(0, lastSpecifier.end)}, bindComponentIdentity${contents.slice(lastSpecifier.end)}`;
74
+ return `${contents.slice(0, lastSpecifier.end)}, ${missing.join(', ')}${contents.slice(lastSpecifier.end)}`;
62
75
  }
63
76
  if (specifiers.some((specifier) => specifier.type === 'ImportNamespaceSpecifier')) {
64
- return `import { bindComponentIdentity } from '@ecopages/core';\n${contents}`;
77
+ return `import { ${missing.join(', ')} } from '${sourceModule}';\n${contents}`;
65
78
  }
66
79
  const defaultSpecifier = specifiers.find((specifier) => specifier.type === 'ImportDefaultSpecifier');
67
80
  if (defaultSpecifier) {
68
- return `${contents.slice(0, defaultSpecifier.end)}, { bindComponentIdentity }${contents.slice(defaultSpecifier.end)}`;
81
+ return `${contents.slice(0, defaultSpecifier.end)}, { ${missing.join(', ')} }${contents.slice(defaultSpecifier.end)}`;
69
82
  }
70
- return `import { bindComponentIdentity } from '@ecopages/core';\n${contents}`;
83
+ return `import { ${missing.join(', ')} } from '${sourceModule}';\n${contents}`;
84
+ }
85
+ function addIdentityBindingImport(contents, program) {
86
+ return addNamedImport(contents, program, '@ecopages/core', 'bindComponentIdentity');
87
+ }
88
+ function serializeDiscoveryArgument(discovered) {
89
+ if (!discovered || (discovered.components.length === 0 && discovered.stylesheets.length === 0)) {
90
+ return '';
91
+ }
92
+ const watchFiles = discovered.watchFiles.length > 0 ? `, watchFiles: ${JSON.stringify(discovered.watchFiles)}` : '';
93
+ return `, { components: () => [${discovered.components.join(', ')}], stylesheets: ${JSON.stringify(discovered.stylesheets)}${watchFiles} }`;
71
94
  }
72
95
  /** Attributes real `eco.*()` factory calls with canonical component identity. */
73
- export function attributeComponentIdentity(contents, filePath, integration) {
96
+ export function attributeComponentIdentity(contents, filePath, integration, projectRoot) {
74
97
  if (!contents.includes('eco.'))
75
98
  return contents;
76
99
  let program;
@@ -82,6 +105,13 @@ export function attributeComponentIdentity(contents, filePath, integration) {
82
105
  }
83
106
  const identityLiteral = `{ id: ${JSON.stringify(rapidhash(filePath).toString(36))}, file: ${JSON.stringify(filePath)}, integration: ${JSON.stringify(integration)} }`;
84
107
  const edits = [];
108
+ let hasFactory = false;
109
+ walkAst(program, (node) => {
110
+ if (isEcoFactoryCall(node))
111
+ hasFactory = true;
112
+ });
113
+ const discovered = hasFactory && projectRoot ? discoverComponentImports(program, filePath, projectRoot) : undefined;
114
+ const discoveryArgument = serializeDiscoveryArgument(discovered);
85
115
  walkAst(program, (node) => {
86
116
  if (!isEcoFactoryCall(node) || !Array.isArray(node.arguments))
87
117
  return;
@@ -93,16 +123,90 @@ export function attributeComponentIdentity(contents, filePath, integration) {
93
123
  edits.push({
94
124
  start: firstArgument.start,
95
125
  end: firstArgument.end,
96
- replacement: `bindComponentIdentity(${identityLiteral}, ${contents.slice(firstArgument.start, firstArgument.end)})`,
126
+ replacement: `bindComponentIdentity(${identityLiteral}, ${contents.slice(firstArgument.start, firstArgument.end)}${discoveryArgument})`,
97
127
  });
98
128
  });
99
129
  if (edits.length === 0)
100
130
  return contents;
131
+ edits.push(...(discovered?.removals ?? []));
132
+ let transformed = contents;
133
+ for (const edit of edits.sort((left, right) => right.start - left.start)) {
134
+ transformed = `${transformed.slice(0, edit.start)}${edit.replacement}${transformed.slice(edit.end)}`;
135
+ }
136
+ return addIdentityBindingImport(transformed, cachedParseSync(filePath, transformed, { sourceType: 'module' }).program);
137
+ }
138
+ function findMdxConfigDeclarator(program) {
139
+ for (const statement of nodes(program?.body)) {
140
+ if (statement.type !== 'ExportNamedDeclaration' || !statement.declaration) {
141
+ continue;
142
+ }
143
+ const decl = node(statement.declaration);
144
+ if (decl?.type !== 'VariableDeclaration') {
145
+ continue;
146
+ }
147
+ for (const declarator of nodes(decl.declarations)) {
148
+ if (node(declarator.id)?.name === 'config') {
149
+ return declarator;
150
+ }
151
+ }
152
+ }
153
+ return undefined;
154
+ }
155
+ function buildMdxConfigIdentityEdits(options) {
156
+ const edits = [...options.removals];
157
+ const init = options.configDeclarator ? node(options.configDeclarator.init) : undefined;
158
+ if (!init || typeof init.start !== 'number' || typeof init.end !== 'number') {
159
+ return edits;
160
+ }
161
+ edits.push({
162
+ start: init.start,
163
+ end: init.end,
164
+ replacement: `bindComponentIdentity(${options.identityLiteral}, ${options.contents.slice(init.start, init.end)}${options.discoveryArgument})`,
165
+ });
166
+ return edits;
167
+ }
168
+ function buildMdxIdentityAppend(options) {
169
+ let appended = '';
170
+ if (!options.configDeclarator) {
171
+ appended += `\nexport const config = bindComponentIdentity(${options.identityLiteral}, {}${options.discoveryArgument});\n`;
172
+ }
173
+ appended += `attachDiscoveredDependencies(config);\nif (typeof MDXContent === 'function') MDXContent.config = config;\n`;
174
+ return appended;
175
+ }
176
+ /** Attributes compiled MDX module with canonical component identity and discovered dependencies. */
177
+ export function attributeMdxComponentIdentity(contents, filePath, integration, projectRoot) {
178
+ if (!projectRoot) {
179
+ throw new Error(`[ecopages] Cannot process MDX dependencies for "${filePath}": projectRoot is required.`);
180
+ }
181
+ let program;
182
+ try {
183
+ program = cachedParseSync(filePath, contents, { lang: 'jsx', sourceType: 'module' })
184
+ .program;
185
+ }
186
+ catch {
187
+ return contents;
188
+ }
189
+ const configDeclarator = findMdxConfigDeclarator(program);
190
+ if (configDeclarator && isIdentityBinding(configDeclarator.init)) {
191
+ return contents;
192
+ }
193
+ const discovered = discoverComponentImports(program, filePath, projectRoot);
194
+ const identityLiteral = `{ id: ${JSON.stringify(rapidhash(filePath).toString(36))}, file: ${JSON.stringify(filePath)}, integration: ${JSON.stringify(integration)} }`;
195
+ const discoveryArgument = serializeDiscoveryArgument(discovered);
196
+ const edits = buildMdxConfigIdentityEdits({
197
+ contents,
198
+ configDeclarator,
199
+ identityLiteral,
200
+ discoveryArgument,
201
+ removals: discovered.removals,
202
+ });
203
+ const appended = buildMdxIdentityAppend({ configDeclarator, identityLiteral, discoveryArgument });
101
204
  let transformed = contents;
102
205
  for (const edit of edits.sort((left, right) => right.start - left.start)) {
103
206
  transformed = `${transformed.slice(0, edit.start)}${edit.replacement}${transformed.slice(edit.end)}`;
104
207
  }
105
- return addIdentityBindingImport(transformed, program);
208
+ transformed = `${transformed}\n${appended}`;
209
+ return addNamedImport(transformed, cachedParseSync(filePath, transformed, { lang: 'jsx', sourceType: 'module' }).program, '@ecopages/core', ['bindComponentIdentity', 'attachDiscoveredDependencies']);
106
210
  }
107
211
  export function createEcoComponentMetaTransform(options) {
108
212
  const extensions = options.config.integrations
@@ -115,14 +219,12 @@ export function createEcoComponentMetaTransform(options) {
115
219
  enforce: 'pre',
116
220
  filter,
117
221
  transform(code, id) {
118
- if (id.endsWith('.mdx'))
119
- return { code };
120
222
  const integration = integrationForFile(id, options.config);
121
223
  if (!integration) {
122
224
  return { code };
123
225
  }
124
226
  return {
125
- code: prependJsxImportSourceIfMissing(attributeComponentIdentity(code, id, integration.name), integration.jsxImportSource),
227
+ code: prependJsxImportSourceIfMissing(attributeComponentIdentity(code, id, integration.name, options.config.rootDir), integration.jsxImportSource),
126
228
  };
127
229
  },
128
230
  };
@@ -62,7 +62,7 @@ export interface ProcessorAssetCapability {
62
62
  */
63
63
  extensions?: ProcessorExtensionPattern[];
64
64
  }
65
- export interface ProcessorConfig<TOptions = Record<string, unknown>> {
65
+ export interface ProcessorConfig<TOptions = unknown> {
66
66
  name: string;
67
67
  description?: string;
68
68
  options?: TOptions;
@@ -77,6 +77,10 @@ export interface ProcessorContext {
77
77
  distDir: string;
78
78
  cache?: string;
79
79
  }
80
+ /**
81
+ * Unconstrained processor type for heterogeneous processor collections.
82
+ */
83
+ export type AnyProcessor = Processor<unknown>;
80
84
  /**
81
85
  * Base class for content and asset processors that contribute build plugins.
82
86
  *
@@ -90,7 +94,7 @@ export interface ProcessorContext {
90
94
  * Virtual modules that must resolve during route-module transpile belong in
91
95
  * `plugins`. Browser-only bundler hooks belong in `buildPlugins`.
92
96
  */
93
- export declare abstract class Processor<TOptions = Record<string, unknown>> {
97
+ export declare abstract class Processor<TOptions = unknown> {
94
98
  readonly name: string;
95
99
  protected context?: ProcessorContext;
96
100
  protected options?: TOptions;
@@ -147,6 +151,10 @@ export declare abstract class Processor<TOptions = Record<string, unknown>> {
147
151
  didChange(): boolean;
148
152
  abstract setup(): Promise<void>;
149
153
  abstract process(input: unknown, filePath?: string): Promise<unknown>;
154
+ /**
155
+ * Discards cached server build artifacts when server modules are invalidated.
156
+ */
157
+ invalidateServerArtifacts(): void;
150
158
  /**
151
159
  * Releases runtime resources owned by the processor.
152
160
  *
@@ -108,6 +108,10 @@ export class Processor {
108
108
  didChange() {
109
109
  return false;
110
110
  }
111
+ /**
112
+ * Discards cached server build artifacts when server modules are invalidated.
113
+ */
114
+ invalidateServerArtifacts() { }
111
115
  /**
112
116
  * Releases runtime resources owned by the processor.
113
117
  *
@@ -30,7 +30,9 @@ export declare function resolveRelativeModulePath(fromFile: string, specifier: s
30
30
  /**
31
31
  * Resolves a relative or tsconfig path alias import (via oxc-resolver).
32
32
  */
33
- export declare function resolveProjectModulePath(projectRoot: string, fromFile: string, specifier: string): string | undefined;
33
+ export declare function resolveProjectModulePath(projectRoot: string, fromFile: string, specifier: string, options?: {
34
+ preserveBarrel?: boolean;
35
+ }): string | undefined;
34
36
  /**
35
37
  * Resolves a TS path alias import using the app's tsconfig `paths` (via oxc-resolver).
36
38
  */
@@ -232,7 +232,7 @@ export function resolveRelativeModulePath(fromFile, specifier) {
232
232
  /**
233
233
  * Resolves a relative or tsconfig path alias import (via oxc-resolver).
234
234
  */
235
- export function resolveProjectModulePath(projectRoot, fromFile, specifier) {
235
+ export function resolveProjectModulePath(projectRoot, fromFile, specifier, options) {
236
236
  const prefixes = loadTsconfigPathPrefixes(projectRoot);
237
237
  const isRelative = specifier.startsWith('.');
238
238
  const isPathAlias = matchesTsconfigPathPrefix(specifier, prefixes);
@@ -243,7 +243,9 @@ export function resolveProjectModulePath(projectRoot, fromFile, specifier) {
243
243
  if (resolver) {
244
244
  const result = resolver.sync(path.dirname(fromFile), specifier);
245
245
  if (result.path) {
246
- return resolveAliasedBarrelTarget(realpathSync(result.path));
246
+ return options?.preserveBarrel
247
+ ? realpathSync(result.path)
248
+ : resolveAliasedBarrelTarget(realpathSync(result.path));
247
249
  }
248
250
  }
249
251
  if (isRelative) {
@@ -43,7 +43,7 @@ flowchart TD
43
43
  D --> E[resolvePageData]
44
44
  E --> F[ownershipValidationService.validate + throwIfOwnershipInvalid]
45
45
  F --> G[resolveDependencies + buildPageBrowserGraph]
46
- G --> H[collect injector and eager SSR lazy assets]
46
+ G --> H[collect lazy injector assets]
47
47
  H --> I[build pagePackage and prepared render options]
48
48
  I --> J[IntegrationRenderer.render via document shell]
49
49
  J --> K[capture rendered body as html]
@@ -52,6 +52,10 @@ See [`../build/README.md`](../build/README.md) for the JSX ownership helper spli
52
52
  - `RouteRendererFactory` chooses integration renderers from route files
53
53
  - `RouteRenderer` delegates execution to the selected renderer
54
54
 
55
+ ### `explicit-view-render-preparation.ts`
56
+
57
+ Resolves the integration renderer and static props for one `eco.page()` view. Explicit static routes, static export, and registered error pages share this helper so view rendering does not fork per caller.
58
+
55
59
  ### `orchestration/`
56
60
 
57
61
  Root renderer classes:
@@ -66,6 +70,7 @@ Domain folders:
66
70
  - `document-shell/`: shared page/layout/html shell composition, layout prop resolution, and attribute stamping helpers
67
71
  - `route-pipeline/`: route preparation, final HTML capture, marker-artifact enforcement
68
72
  - `page-browser-graph/`: browser asset graph build, session cache, and injector assets
73
+ - `custom-element-scripts/`: shared `ssr: true` script collection and server preload for custom-element registration
69
74
 
70
75
  **Page Browser Graph session behavior:**
71
76
 
@@ -95,17 +100,19 @@ Important:
95
100
 
96
101
  - route-level fallback resolution is gone; unresolved artifacts are now a hard failure
97
102
  - ownership is declared from canonical component identity, not inferred from final HTML
98
- - declared page dependencies are resolved from final render inputs and carried to the owning integration; integrations may use them for renderer-specific lifecycle work such as HMR ownership
103
+ - declared page dependencies are resolved from final render inputs and carried as dependency roots to the owning integration; those roots participate in asset, integration, ownership, and renderer-specific lifecycle collection
99
104
  - same-integration children stay renderer-local and do not need to pass through a universal transport
100
105
 
101
106
  ## Declared Foreign Child Contract
102
107
 
103
- Mixed-integration component configs must declare every possible foreign child in `config.dependencies.components`.
108
+ Static mixed-integration component configs must declare every possible foreign child in `config.dependencies.components`. Page dependency resolvers can additionally provide request-time component roots when a route loads a component dynamically.
104
109
 
105
110
  `OwnershipValidationService` surfaces missing metadata or unknown integrations during `prepareRenderOptions()` and throws before render execution starts.
106
111
 
107
112
  At runtime, renderers still discover actual foreign children through the active component render context.
108
113
 
114
+ Component renders always execute under a render context that names the rendering integration (`executeComponentRender` installs one when none is active). This lets ownership guards such as the content-processor's `getComponent()` detect a foreign render lane even when no foreign-child runtime is installed.
115
+
109
116
  ## Foreign Subtree Contract
110
117
 
111
118
  `renderComponentWithForeignChildren()` is the renderer entrypoint for mixed-integration trees. It is responsible for:
@@ -137,3 +144,9 @@ Not every integration needs queue-based handoff.
137
144
 
138
145
  - Different integrations still own different foreign-child runtime strategies, which is intentional where child transport or hydration behavior differs.
139
146
  - `integration-renderer.ts` remains the largest integration hook surface even after document-shell extraction.
147
+
148
+ ## Discovered Dependencies and loading policy
149
+
150
+ Dependency collection reads declared `config.dependencies` plus identity-keyed inferred stylesheets, including deferred direct-import Component references. Traversal visits each config once; multiple Components in one file remain distinct. It collects explicit styles before inferred styles across the graph, suppressing inferred duplicates by resolved path. Page dependency results may include multiple file-owned contributions so relative assets keep the file that declared them. Source watch paths include discovered Components, their stylesheet files, and named barrel hops recorded during discovery.
151
+
152
+ Lit preloads scripts marked `ssr: true` before server rendering, while the existing lazy-trigger manifest controls browser loading. The route pipeline does not emit a second eager script for these entries. Integration renderers refresh their resolved global assets after runtime activation so late setup cannot omit hydration support.