@ecopages/core 0.2.0-beta.1 → 0.2.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +107 -3
- package/src/adapters/abstract/application-adapter.d.ts +73 -1
- package/src/adapters/abstract/application-adapter.js +89 -0
- package/src/adapters/abstract/server-adapter.d.ts +3 -0
- package/src/adapters/abstract/ws-pattern-matcher.d.ts +60 -0
- package/src/adapters/abstract/ws-pattern-matcher.js +61 -0
- package/src/adapters/bun/client-bridge.d.ts +1 -0
- package/src/adapters/bun/client-bridge.js +3 -0
- package/src/adapters/bun/create-app.d.ts +5 -3
- package/src/adapters/bun/create-app.js +44 -39
- package/src/adapters/bun/hmr-manager.d.ts +2 -1
- package/src/adapters/bun/hmr-manager.js +2 -2
- package/src/adapters/bun/server-adapter.d.ts +81 -20
- package/src/adapters/bun/server-adapter.js +220 -78
- package/src/adapters/bun/static-preview-host.js +25 -20
- package/src/adapters/create-app.d.ts +13 -0
- package/src/adapters/create-app.js +10 -1
- package/src/adapters/node/create-app.d.ts +4 -0
- package/src/adapters/node/create-app.js +38 -9
- package/src/adapters/node/node-client-bridge.d.ts +1 -0
- package/src/adapters/node/node-client-bridge.js +3 -0
- package/src/adapters/node/node-hmr-manager.d.ts +2 -1
- package/src/adapters/node/node-hmr-manager.js +2 -2
- package/src/adapters/node/server-adapter-dependencies.js +2 -0
- package/src/adapters/node/server-adapter.d.ts +55 -19
- package/src/adapters/node/server-adapter.js +140 -132
- package/src/adapters/node/static-content-server.d.ts +1 -0
- package/src/adapters/node/static-content-server.js +10 -2
- package/src/adapters/node/static-preview-host.js +27 -12
- package/src/adapters/shared/bun-user-websocket-lifecycle.d.ts +22 -0
- package/src/adapters/shared/bun-user-websocket-lifecycle.js +96 -0
- package/src/adapters/shared/copy-runtime-public-dir.d.ts +6 -0
- package/src/adapters/shared/copy-runtime-public-dir.js +24 -0
- package/src/adapters/shared/hmr-html-response.d.ts +1 -1
- package/src/adapters/shared/hmr-html-response.js +4 -1
- package/src/adapters/shared/node-http-websocket-upgrades.d.ts +21 -0
- package/src/adapters/shared/node-http-websocket-upgrades.js +100 -0
- package/src/adapters/shared/port-manager.d.ts +116 -0
- package/src/adapters/shared/port-manager.js +196 -0
- package/src/adapters/shared/runtime-app-bootstrap.d.ts +2 -1
- package/src/adapters/shared/runtime-app-bootstrap.js +3 -6
- package/src/adapters/shared/runtime-server-lifecycle.d.ts +38 -0
- package/src/adapters/shared/runtime-server-lifecycle.js +39 -0
- package/src/adapters/shared/server-adapter.d.ts +2 -1
- package/src/adapters/shared/server-adapter.js +12 -4
- package/src/adapters/shared/server-route-handler.d.ts +4 -1
- package/src/adapters/shared/server-route-handler.js +5 -2
- package/src/adapters/shared/server-static-builder.d.ts +14 -29
- package/src/adapters/shared/server-static-builder.js +91 -70
- package/src/adapters/shared/shared-hmr-manager.d.ts +12 -0
- package/src/adapters/shared/shared-hmr-manager.js +64 -7
- package/src/adapters/shared/static-preview-host.d.ts +5 -0
- package/src/adapters/shared/websocket-lifecycle.d.ts +24 -0
- package/src/adapters/shared/websocket-lifecycle.js +55 -0
- package/src/build/README.md +77 -14
- package/src/build/app-build-manifest-runtime.d.ts +10 -0
- package/src/build/app-build-manifest-runtime.js +90 -0
- package/src/build/build-adapter.d.ts +17 -319
- package/src/build/build-adapter.js +28 -94
- package/src/build/build-contracts.d.ts +97 -0
- package/src/build/build-contracts.js +0 -0
- package/src/build/build-input-fingerprint.d.ts +28 -0
- package/src/build/build-input-fingerprint.js +31 -0
- package/src/build/build-profile-options.d.ts +7 -0
- package/src/build/build-profile-options.js +37 -0
- package/src/build/build-runtime.d.ts +24 -0
- package/src/build/build-runtime.js +65 -0
- package/src/build/deduping-build-executor.d.ts +28 -0
- package/src/build/deduping-build-executor.js +56 -0
- package/src/build/jsx-ownership-plugins.d.ts +24 -0
- package/src/build/jsx-ownership-plugins.js +41 -0
- package/src/build/pages-unified-graph-build.d.ts +31 -0
- package/src/build/pages-unified-graph-build.js +206 -0
- package/src/build/parallel-build-executor.d.ts +21 -0
- package/src/build/parallel-build-executor.js +52 -0
- package/src/build/production-build-cache.d.ts +20 -0
- package/src/build/production-build-cache.js +63 -0
- package/src/build/rolldown-adapter-helpers.d.ts +3 -6
- package/src/build/rolldown-adapter-helpers.js +71 -6
- package/src/build/rolldown-build-adapter.d.ts +2 -6
- package/src/build/rolldown-build-adapter.js +3 -3
- package/src/build/rolldown-build-invocation-metrics.d.ts +12 -0
- package/src/build/rolldown-build-invocation-metrics.js +43 -0
- package/src/build/rolldown-plugin-bridge.d.ts +15 -1
- package/src/build/rolldown-plugin-bridge.js +20 -5
- package/src/build/rolldown-source-transform-pass.d.ts +15 -0
- package/src/build/rolldown-source-transform-pass.js +58 -0
- package/src/build/runtime-build-executor.d.ts +8 -15
- package/src/build/runtime-build-executor.js +12 -15
- package/src/build/runtime-build-output-normalizer.d.ts +7 -0
- package/src/build/runtime-build-output-normalizer.js +94 -2
- package/src/build/server-entry-build-cache.d.ts +44 -0
- package/src/build/server-entry-build-cache.js +161 -0
- package/src/config/config-builder.d.ts +12 -7
- package/src/config/config-builder.js +12 -9
- package/src/dev/client-bridge-registry.d.ts +5 -0
- package/src/dev/client-bridge-registry.js +15 -0
- package/src/dev/dev-client-ownership.d.ts +7 -0
- package/src/dev/dev-client-ownership.js +6 -0
- package/src/dev/host-runtime.d.ts +3 -0
- package/src/dev/host-runtime.js +7 -0
- package/src/hmr/client/hmr-runtime.js +5 -2
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +17 -0
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +29 -0
- package/src/integrations/ghtml/ghtml-renderer.d.ts +2 -6
- package/src/integrations/ghtml/ghtml-renderer.js +2 -51
- package/src/integrations/ghtml/ghtml.plugin.d.ts +3 -16
- package/src/integrations/ghtml/ghtml.plugin.js +7 -14
- package/src/plugins/define-integration.d.ts +26 -0
- package/src/plugins/define-integration.js +19 -0
- package/src/plugins/eco-component-meta-plugin.js +5 -8
- package/src/plugins/foreign-jsx-override-plugin.js +4 -6
- package/src/plugins/integration-plugin.d.ts +19 -9
- package/src/plugins/integration-plugin.js +7 -4
- package/src/plugins/jsx-import-source.utils.d.ts +8 -0
- package/src/plugins/jsx-import-source.utils.js +26 -0
- package/src/plugins/processor.d.ts +19 -4
- package/src/plugins/processor.js +22 -4
- package/src/plugins/source-transform.d.ts +31 -0
- package/src/plugins/source-transform.js +23 -1
- package/src/route-renderer/GRAPH.md +8 -8
- package/src/route-renderer/README.md +30 -28
- package/src/route-renderer/orchestration/component-graph-collectors.d.ts +10 -0
- package/src/route-renderer/orchestration/component-graph-collectors.js +143 -0
- package/src/route-renderer/orchestration/component-graph.d.ts +36 -0
- package/src/route-renderer/orchestration/component-graph.js +90 -0
- package/src/route-renderer/orchestration/component-render-context.d.ts +3 -10
- package/src/route-renderer/orchestration/component-render-context.js +3 -1
- package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +1 -18
- package/src/route-renderer/orchestration/declared-ownership-graph.js +5 -31
- package/src/route-renderer/orchestration/document-shell-render.service.d.ts +54 -0
- package/src/route-renderer/orchestration/document-shell-render.service.js +54 -0
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts +59 -29
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +164 -35
- package/src/route-renderer/orchestration/global-injector-assets.service.d.ts +7 -0
- package/src/route-renderer/orchestration/global-injector-assets.service.js +32 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +18 -54
- package/src/route-renderer/orchestration/integration-renderer.js +108 -194
- package/src/route-renderer/orchestration/integration-route-render-adapter.d.ts +38 -0
- package/src/route-renderer/orchestration/integration-route-render-adapter.js +27 -0
- package/src/route-renderer/orchestration/ownership-validation.service.d.ts +4 -0
- package/src/route-renderer/orchestration/ownership-validation.service.js +11 -1
- package/src/route-renderer/orchestration/page-browser-graph-contribution.loader.d.ts +9 -0
- package/src/route-renderer/orchestration/page-browser-graph-contribution.loader.js +7 -0
- package/src/route-renderer/orchestration/page-browser-graph.service.d.ts +25 -0
- package/src/route-renderer/orchestration/page-browser-graph.service.js +174 -0
- package/src/route-renderer/orchestration/render-output.utils.d.ts +2 -0
- package/src/route-renderer/orchestration/render-output.utils.js +4 -0
- package/src/route-renderer/orchestration/route-html-finalization.service.d.ts +17 -0
- package/src/route-renderer/orchestration/route-html-finalization.service.js +26 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.d.ts +24 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.js +52 -0
- package/src/route-renderer/orchestration/route-prepared-options.utils.d.ts +4 -0
- package/src/route-renderer/orchestration/route-prepared-options.utils.js +33 -0
- package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +5 -38
- package/src/route-renderer/orchestration/route-render-orchestrator.js +51 -459
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +14 -0
- package/src/route-renderer/orchestration/string-markup-renderer.js +54 -0
- package/src/router/client/navigation-coordinator.d.ts +1 -1
- package/src/router/client/navigation-coordinator.js +12 -2
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +1 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +1 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +4 -2
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +27 -7
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +32 -14
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +17 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -31
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +2 -30
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +2 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +43 -0
- package/src/services/assets/browser-bundle.service.d.ts +3 -1
- package/src/services/assets/browser-bundle.service.js +17 -5
- package/src/services/html/html-transformer.service.d.ts +1 -1
- package/src/services/html/html-transformer.service.js +4 -4
- package/src/services/invalidation/development-invalidation.service.d.ts +10 -1
- package/src/services/invalidation/development-invalidation.service.js +31 -2
- package/src/services/module-loading/README.md +49 -0
- package/src/services/module-loading/app-server-module-transpiler.service.js +5 -17
- package/src/services/module-loading/page-module-import.service.d.ts +4 -1
- package/src/services/module-loading/page-module-import.service.js +61 -41
- package/src/services/module-loading/route-module-build-cache-registry.d.ts +24 -0
- package/src/services/module-loading/route-module-build-cache-registry.js +37 -0
- package/src/services/module-loading/route-module-build-cache.d.ts +4 -0
- package/src/services/module-loading/route-module-build-cache.js +38 -0
- package/src/services/module-loading/route-module-build-cache.store.d.ts +57 -0
- package/src/services/module-loading/route-module-build-cache.store.js +207 -0
- package/src/services/module-loading/route-module-build-manifest.d.ts +61 -0
- package/src/services/module-loading/route-module-build-manifest.js +116 -0
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +81 -0
- package/src/services/module-loading/route-module-dependency-hasher.js +121 -0
- package/src/services/module-loading/server-module-transpiler.service.js +1 -1
- package/src/static-site-generator/README.md +33 -0
- package/src/static-site-generator/static-build-invalidation.d.ts +10 -0
- package/src/static-site-generator/static-build-invalidation.js +59 -0
- package/src/static-site-generator/static-export-context.d.ts +22 -0
- package/src/static-site-generator/static-export-context.js +0 -0
- package/src/static-site-generator/static-site-generator.d.ts +17 -20
- package/src/static-site-generator/static-site-generator.js +188 -85
- package/src/types/internal-types.d.ts +12 -9
- package/src/types/public-types.d.ts +87 -22
- package/src/utils/parse-cli-args.d.ts +1 -0
- package/src/utils/parse-cli-args.js +3 -0
- package/src/watchers/project-watcher.d.ts +14 -2
- package/src/watchers/project-watcher.js +50 -20
- package/src/build/rolldown-dev-build-adapter.d.ts +0 -82
- package/src/build/rolldown-dev-build-adapter.js +0 -166
- package/src/hmr/hmr.postcss.test.e2e.d.ts +0 -1
- package/src/hmr/hmr.postcss.test.e2e.js +0 -31
- package/src/hmr/hmr.test.e2e.d.ts +0 -1
- package/src/hmr/hmr.test.e2e.js +0 -43
- package/src/route-renderer/orchestration/ownership-planning.service.d.ts +0 -24
- package/src/route-renderer/orchestration/ownership-planning.service.js +0 -63
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +0 -91
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +0 -170
|
@@ -7,4 +7,9 @@ export interface StaticPreviewHostStartOptions {
|
|
|
7
7
|
appConfig: EcoPagesAppConfig;
|
|
8
8
|
hostname: string;
|
|
9
9
|
port: number;
|
|
10
|
+
/**
|
|
11
|
+
* When true, bind to the next available port if the preferred one is busy.
|
|
12
|
+
* Should remain false when the port was explicitly configured.
|
|
13
|
+
*/
|
|
14
|
+
allowPortFallback?: boolean;
|
|
10
15
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { EcopagesSocket, WebSocketCloseInfo } from '../../types/public-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @remarks
|
|
4
|
+
* Bun and Node expose different raw socket types but share the same
|
|
5
|
+
* {@link OutgoingWebSocketMessage} contract. Adapters supply only `send`/`close`;
|
|
6
|
+
* {@link createEcopagesSocket} owns message normalization and stream forwarding.
|
|
7
|
+
*/
|
|
8
|
+
export interface WebSocketSendTransport {
|
|
9
|
+
send(data: string | Uint8Array): void;
|
|
10
|
+
close(code?: number, reason?: string): void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @remarks
|
|
14
|
+
* Bun and Node adapters previously duplicated outgoing-message dispatch and
|
|
15
|
+
* stream forwarding; this is the shared implementation both transports delegate to.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createEcopagesSocket<TContext, TParams extends Record<string, string>>(transport: WebSocketSendTransport, meta: {
|
|
18
|
+
kind: string;
|
|
19
|
+
params: TParams;
|
|
20
|
+
search: Record<string, string>;
|
|
21
|
+
context: TContext;
|
|
22
|
+
}): EcopagesSocket<TContext, TParams>;
|
|
23
|
+
export declare function toWebSocketCloseInfo(code: number, reason: string): WebSocketCloseInfo;
|
|
24
|
+
export declare function invokeWebSocketHandlerHook(kind: string, hookName: string, result: void | Promise<void>): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { appLogger } from "../../global/app-logger.js";
|
|
2
|
+
function sendOutgoingMessage(transport, message) {
|
|
3
|
+
if (typeof message === "string") {
|
|
4
|
+
transport.send(message);
|
|
5
|
+
} else if (message instanceof Blob) {
|
|
6
|
+
void message.arrayBuffer().then((buffer) => transport.send(new Uint8Array(buffer)));
|
|
7
|
+
} else if (message instanceof ArrayBuffer) {
|
|
8
|
+
transport.send(new Uint8Array(message));
|
|
9
|
+
} else if (ArrayBuffer.isView(message)) {
|
|
10
|
+
transport.send(new Uint8Array(message.buffer, message.byteOffset, message.byteLength));
|
|
11
|
+
} else {
|
|
12
|
+
transport.send(message);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function createEcopagesSocket(transport, meta) {
|
|
16
|
+
return {
|
|
17
|
+
kind: meta.kind,
|
|
18
|
+
params: meta.params,
|
|
19
|
+
search: meta.search,
|
|
20
|
+
context: meta.context,
|
|
21
|
+
send: (message) => sendOutgoingMessage(transport, message),
|
|
22
|
+
sendStream: async (stream) => {
|
|
23
|
+
const reader = stream.getReader();
|
|
24
|
+
try {
|
|
25
|
+
while (true) {
|
|
26
|
+
const { value, done } = await reader.read();
|
|
27
|
+
if (done) break;
|
|
28
|
+
if (value) transport.send(value);
|
|
29
|
+
}
|
|
30
|
+
} finally {
|
|
31
|
+
reader.releaseLock();
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
close: (code, reason) => transport.close(code, reason)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function toWebSocketCloseInfo(code, reason) {
|
|
38
|
+
return {
|
|
39
|
+
code,
|
|
40
|
+
reason,
|
|
41
|
+
wasClean: code === 1e3 || code === 1001
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function invokeWebSocketHandlerHook(kind, hookName, result) {
|
|
45
|
+
if (result instanceof Promise) {
|
|
46
|
+
result.catch((error) => {
|
|
47
|
+
appLogger.error(`[WS:${kind}] ${hookName} failed:`, error);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
createEcopagesSocket,
|
|
53
|
+
invokeWebSocketHandlerHook,
|
|
54
|
+
toWebSocketCloseInfo
|
|
55
|
+
};
|
package/src/build/README.md
CHANGED
|
@@ -4,13 +4,15 @@ The build layer is the bundler contract for Ecopages. One bundled adapter is the
|
|
|
4
4
|
|
|
5
5
|
## Mental Model
|
|
6
6
|
|
|
7
|
-
Three concentric shapes, plus
|
|
7
|
+
Three concentric shapes, plus profile executors and a plugin injector:
|
|
8
8
|
|
|
9
9
|
| Shape | Lives in | Purpose |
|
|
10
10
|
| -------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
11
11
|
| `BuildAdapter` | `build-adapter.ts` | Low-level backend. Two implementations: the bundled adapter (the real bundler) and `ViteHostBuildAdapter` (a host-owned boundary marker that throws on direct use). |
|
|
12
|
-
| `
|
|
13
|
-
| `
|
|
12
|
+
| `BuildRuntime` | `build-runtime.ts` | Profile-based executor registry. Single entry point on `appConfig.runtime.buildRuntime`. |
|
|
13
|
+
| `BuildExecutor` | `build-contracts.ts` | Narrower runtime facade. Only `build` is exposed. Retrieved via `buildRuntime.getProfile(...)`. |
|
|
14
|
+
| `SerializedBuildExecutor` | `serialized-build-executor.ts` | FIFO queue around any `BuildExecutor`. Used for server-entry single-flight ordering. |
|
|
15
|
+
| `ParallelBuildExecutor` | `parallel-build-executor.ts` | Concurrency-limited wrapper for independent route-module and HMR browser builds. |
|
|
14
16
|
| `withBuildExecutorPlugins` | `build-adapter.ts` | Merges app-owned plugins into every `build` call. The single point of plugin injection. |
|
|
15
17
|
|
|
16
18
|
Plus one translation bridge:
|
|
@@ -20,29 +22,31 @@ Plus one translation bridge:
|
|
|
20
22
|
## Files
|
|
21
23
|
|
|
22
24
|
- `build-adapter.ts`: types, factories, app-owned helpers, `withBuildExecutorPlugins`.
|
|
25
|
+
- `build-runtime.ts`: profile-based executor installation (`server-entry`, `route-module`, `browser-hmr`).
|
|
23
26
|
- `build-types.ts`: the `EcoBuildPlugin` contract used by integrations and processors.
|
|
24
27
|
- `rolldown-build-adapter.ts`: the production `BuildAdapter`. Wraps the bundler and exposes a normalized `BuildResult` (outputs, dependency graph, logs).
|
|
25
28
|
- `rolldown-plugin-bridge.ts`: `EcoBuildPlugin[]` → bundler-plugin translation.
|
|
26
29
|
- `serialized-build-executor.ts`: FIFO queue primitive.
|
|
27
|
-
- `runtime-build-executor.ts`:
|
|
30
|
+
- `runtime-build-executor.ts`: server-adapter entrypoint that installs `BuildRuntime` via `installAppRuntimeBuildExecutor()`.
|
|
31
|
+
- `server-entry-build-cache.ts`: production server-entry bundle cache (`.eco/.server-entry/.build-cache.json` + `dist/.server/manifest.json`).
|
|
28
32
|
- `*.test.ts`: regression coverage.
|
|
29
33
|
|
|
30
34
|
## Default Flow
|
|
31
35
|
|
|
32
|
-
`ConfigBuilder.build()` creates one app-owned adapter
|
|
33
|
-
|
|
34
|
-
When a server adapter initializes, it calls `installAppRuntimeBuildExecutor(appConfig)`. That function reads the existing executor (or falls back to the app-owned adapter) and stores a fresh wrapper:
|
|
36
|
+
`ConfigBuilder.build()` creates one app-owned adapter and manifest. When a server adapter initializes, it calls `installAppRuntimeBuildExecutor(appConfig)`, which installs `BuildRuntime`:
|
|
35
37
|
|
|
36
38
|
```
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
BuildRuntime.getProfile(...)
|
|
40
|
+
├─ server-entry → SerializedBuildExecutor → withBuildExecutorPlugins → RolldownBuildAdapter
|
|
41
|
+
├─ route-module → ParallelBuildExecutor → withBuildExecutorPlugins → RolldownBuildAdapter
|
|
42
|
+
└─ browser-hmr → ParallelBuildExecutor → withBuildExecutorPlugins → RolldownBuildAdapter
|
|
41
43
|
```
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
All profiles use one-shot Rolldown in both dev and production. Route-module and browser-HMR builds run in parallel; server-entry stays serialized single-flight.
|
|
46
|
+
|
|
47
|
+
Runtime code should call `requireBuildRuntime(appConfig).getProfile('route-module' | 'browser-hmr' | 'server-entry')` instead of reading legacy executor slots.
|
|
44
48
|
|
|
45
|
-
The exported `defaultBuildAdapter` and the top-level `build()` / `getTranspileOptions()` helpers are non-app-aware escape hatches. New runtime code should prefer `getAppBuildAdapter()`, `
|
|
49
|
+
The exported `defaultBuildAdapter` and the top-level `build()` / `getTranspileOptions()` helpers are non-app-aware escape hatches. New runtime code should prefer `getAppBuildAdapter()`, `requireBuildRuntime()`, and `getAppTranspileOptions()`.
|
|
46
50
|
|
|
47
51
|
## Vite-Host Boundary
|
|
48
52
|
|
|
@@ -81,11 +85,70 @@ Plugin ordering: the bundler's `resolveId` and `load` are "first" hooks. The bri
|
|
|
81
85
|
|
|
82
86
|
These fields are kept in the type so existing call-sites compile. The proper fix is a more focused `BuildOptions` schema in a follow-up.
|
|
83
87
|
|
|
88
|
+
## Dev / watch path
|
|
89
|
+
|
|
90
|
+
`installBuildRuntime` (via `installAppRuntimeBuildExecutor`) installs profile-based executors:
|
|
91
|
+
|
|
92
|
+
| Profile | Backend | Concurrency |
|
|
93
|
+
| -------------- | ----------------- | -------------------- |
|
|
94
|
+
| `server-entry` | Rolldown one-shot | Serialized |
|
|
95
|
+
| `route-module` | Rolldown one-shot | Parallel |
|
|
96
|
+
| `browser-hmr` | Rolldown one-shot | Parallel (limit ≤ 3) |
|
|
97
|
+
|
|
98
|
+
`hmr-entrypoint` rebuilds use the `browser-hmr` profile. Other browser builds (`browser-script`, `hmr-runtime`) use `route-module`.
|
|
99
|
+
|
|
100
|
+
`ProjectWatcher` deduplicates watch roots, ignores `.eco/` and `dist/`, and coalesces duplicate chokidar events within 150ms.
|
|
101
|
+
|
|
102
|
+
## Metrics
|
|
103
|
+
|
|
104
|
+
Set `ECOPAGES_ROLLDOWN_BUILD_METRICS=1` to log Rolldown invocation counts during dev and production builds. Compare kitchen-sink dev navigation and `static-build-bench` before/after runtime changes.
|
|
105
|
+
|
|
106
|
+
## Production build caches
|
|
107
|
+
|
|
108
|
+
Two persisted cache layers accelerate production builds. Both use `.build-cache.json` manifests keyed by dependency hashes and a build-inputs fingerprint.
|
|
109
|
+
|
|
110
|
+
| Cache | On-disk location | Module |
|
|
111
|
+
| -------------------------------------- | --------------------------------------------------- | ----------------------------------- |
|
|
112
|
+
| Server-entry bundle | `.eco/.server-entry/.build-cache.json` | `server-entry-build-cache.ts` |
|
|
113
|
+
| Route-module transpile + static render | `<server-outdir>/.server-modules/.build-cache.json` | `route-module-build-cache.store.ts` |
|
|
114
|
+
|
|
115
|
+
`getInstalledServerEntryBuildExecutor()` returns the `server-entry` profile from `BuildRuntime`. `clearProductionBuildCaches()` wipes both manifest trees, resets in-memory route-module state, and clears `buildRuntime`.
|
|
116
|
+
|
|
117
|
+
The route-module registry (`route-module-build-cache-registry.ts`) shares one `RouteModuleBuildCache` per `(app, outdir)` pair. Legacy `.server-route-modules` outdirs are still read for migration but new writes go to `.server-modules`.
|
|
118
|
+
|
|
119
|
+
## Unified pages graph
|
|
120
|
+
|
|
121
|
+
Production static exports compile all template pages in one Rolldown invocation when `shouldBuildPagesUnifiedGraph()` is true (default in production; opt out with `ECOPAGES_UNIFIED_PAGES_GRAPH=0`).
|
|
122
|
+
|
|
123
|
+
| Artifact | Location |
|
|
124
|
+
| -------------- | ----------------------------------------------------- |
|
|
125
|
+
| Graph manifest | `.eco/.server-pages-graph/.build-cache.json` |
|
|
126
|
+
| Chunk outputs | `.eco/.server-modules/` (shared with per-route cache) |
|
|
127
|
+
|
|
128
|
+
`StaticSiteGenerator` calls `ensurePagesUnifiedGraphBuilt()` before the export loop. `PageModuleImportService` imports prebuilt chunks via `importPagesUnifiedGraphModule()` and falls back to per-page Rolldown on miss.
|
|
129
|
+
|
|
130
|
+
`ECOPAGES_ROLLDOWN_BUILD_METRICS=1` enables `rolldown-build-invocation-metrics.ts` counters used by bench and parity tests.
|
|
131
|
+
|
|
132
|
+
Build-input fingerprinting lives in `build-input-fingerprint.ts` and is shared with server-entry cache, unified pages graph, and static-render invalidation.
|
|
133
|
+
|
|
134
|
+
## JSX Ownership Plugins
|
|
135
|
+
|
|
136
|
+
Mixed-integration apps need explicit `@jsxImportSource` handling in two different shapes:
|
|
137
|
+
|
|
138
|
+
| Helper | Use when | Behavior |
|
|
139
|
+
| ------------------------------------ | ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
140
|
+
| `getJsxOwnershipPlugins()` | App-wide server/transpile builds | Each JSX integration extension gets its **own** `jsxImportSource` so native files keep their owning runtime. |
|
|
141
|
+
| `getHostScopedJsxOwnershipPlugins()` | One integration's **client** bundle graph | Foreign `.tsx`/`.jsx` files compile with the **host** integration JSX runtime (for example React bundling `.kita.tsx`). |
|
|
142
|
+
| `eco-component-meta-plugin` | Component metadata injection | Prepends the **owning** integration pragma only when injecting `__eco` metadata into native files. |
|
|
143
|
+
|
|
144
|
+
`foreign-jsx-override-plugin.ts` is the shared implementation. Prefer the helpers above instead of calling it directly from integrations.
|
|
145
|
+
|
|
84
146
|
## Testing Strategy
|
|
85
147
|
|
|
86
148
|
- `rolldown-build-adapter.test.ts` covers the adapter's `build`, `resolve`, `getTranspileOptions`, and dependency-graph extraction end-to-end.
|
|
87
149
|
- `rolldown-plugin-bridge.test.ts` covers the `EcoBuildPlugin[]` → plugin translation in isolation.
|
|
88
150
|
- `build-adapter.test.ts` covers the app-owned helpers, the `BuildOwnership` routing, the `withBuildExecutorPlugins` injection, and the default-fallback behaviour.
|
|
89
|
-
- `
|
|
151
|
+
- `build-runtime.test.ts` covers profile executor installation and parallelism.
|
|
152
|
+
- `runtime-build-executor.test.ts` covers the runtime wrapper: plugin injection and the Vite-host rejection path.
|
|
90
153
|
|
|
91
154
|
If you change option mapping or plugin-bridge semantics, update the adapter and bridge tests first. If you change the app-owned helper contracts, update `build-adapter.test.ts` first.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EcoBuildPlugin } from './build-types.js';
|
|
2
|
+
import type { AppBuildManifest } from './build-manifest.js';
|
|
3
|
+
import type { EcoPagesAppConfig, IHmrManager } from '../types/internal-types.js';
|
|
4
|
+
export declare function collectConfiguredAppBuildManifestContributions(appConfig: EcoPagesAppConfig): Promise<Pick<AppBuildManifest, 'runtimePlugins' | 'browserBundlePlugins' | 'browserRuntimeManifest'>>;
|
|
5
|
+
export declare function setupAppRuntimePlugins(options: {
|
|
6
|
+
appConfig: EcoPagesAppConfig;
|
|
7
|
+
runtimeOrigin: string;
|
|
8
|
+
hmrManager?: IHmrManager;
|
|
9
|
+
onRuntimePlugin?: (plugin: EcoBuildPlugin) => void;
|
|
10
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { mergeBrowserRuntimeManifests } from "./browser-runtime-manifest.js";
|
|
2
|
+
import { appLogger } from "../global/app-logger.js";
|
|
3
|
+
function patchAppRuntime(appConfig, patch) {
|
|
4
|
+
appConfig.runtime = {
|
|
5
|
+
...appConfig.runtime ?? {},
|
|
6
|
+
...patch
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function registerRuntimePlugins(appConfig, onRuntimePlugin) {
|
|
10
|
+
for (const loader of appConfig.loaders.values()) {
|
|
11
|
+
onRuntimePlugin?.(loader);
|
|
12
|
+
}
|
|
13
|
+
for (const processor of appConfig.processors.values()) {
|
|
14
|
+
if (processor.plugins) {
|
|
15
|
+
for (const plugin of processor.plugins) {
|
|
16
|
+
onRuntimePlugin?.(plugin);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (const integration of appConfig.integrations) {
|
|
21
|
+
for (const plugin of integration.plugins) {
|
|
22
|
+
onRuntimePlugin?.(plugin);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function collectConfiguredAppBuildManifestContributions(appConfig) {
|
|
27
|
+
const runtimePlugins = [];
|
|
28
|
+
const browserBundlePlugins = [];
|
|
29
|
+
const browserRuntimeManifests = [];
|
|
30
|
+
for (const processor of appConfig.processors.values()) {
|
|
31
|
+
await processor.prepareBuildContributions();
|
|
32
|
+
if (processor.plugins) {
|
|
33
|
+
runtimePlugins.push(...processor.plugins);
|
|
34
|
+
}
|
|
35
|
+
if (processor.buildPlugins) {
|
|
36
|
+
browserBundlePlugins.push(...processor.buildPlugins);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const integration of appConfig.integrations) {
|
|
40
|
+
integration.setConfig(appConfig);
|
|
41
|
+
await integration.prepareBuildContributions();
|
|
42
|
+
runtimePlugins.push(...integration.plugins ?? []);
|
|
43
|
+
browserBundlePlugins.push(...integration.browserBuildPlugins ?? []);
|
|
44
|
+
browserRuntimeManifests.push(integration.browserRuntimeManifest);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
runtimePlugins,
|
|
48
|
+
browserBundlePlugins,
|
|
49
|
+
browserRuntimeManifest: mergeBrowserRuntimeManifests(...browserRuntimeManifests)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async function setupAppRuntimePlugins(options) {
|
|
53
|
+
if (options.appConfig.runtime?.runtimeAssetsPrepared) {
|
|
54
|
+
appLogger.debug("Skipped setupAppRuntimePlugins: runtime assets already prepared");
|
|
55
|
+
registerRuntimePlugins(options.appConfig, options.onRuntimePlugin);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
appLogger.debugTime("setupAppRuntimePlugins");
|
|
59
|
+
try {
|
|
60
|
+
for (const loader of options.appConfig.loaders.values()) {
|
|
61
|
+
options.onRuntimePlugin?.(loader);
|
|
62
|
+
}
|
|
63
|
+
for (const processor of options.appConfig.processors.values()) {
|
|
64
|
+
await processor.setup();
|
|
65
|
+
if (processor.plugins) {
|
|
66
|
+
for (const plugin of processor.plugins) {
|
|
67
|
+
options.onRuntimePlugin?.(plugin);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const integration of options.appConfig.integrations) {
|
|
72
|
+
integration.setConfig(options.appConfig);
|
|
73
|
+
integration.setRuntimeOrigin(options.runtimeOrigin);
|
|
74
|
+
if (options.hmrManager) {
|
|
75
|
+
integration.setHmrManager(options.hmrManager);
|
|
76
|
+
}
|
|
77
|
+
await integration.setup();
|
|
78
|
+
for (const plugin of integration.plugins) {
|
|
79
|
+
options.onRuntimePlugin?.(plugin);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
patchAppRuntime(options.appConfig, { runtimeAssetsPrepared: true });
|
|
83
|
+
} finally {
|
|
84
|
+
appLogger.debugTimeEnd("setupAppRuntimePlugins");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
collectConfiguredAppBuildManifestContributions,
|
|
89
|
+
setupAppRuntimePlugins
|
|
90
|
+
};
|