@ecopages/core 0.2.0-beta.2 → 0.2.0-beta.21
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/README.md +1 -1
- package/package.json +163 -3
- package/src/adapters/abstract/application-adapter.d.ts +104 -5
- package/src/adapters/abstract/application-adapter.js +125 -1
- package/src/adapters/abstract/server-adapter.d.ts +6 -2
- 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 +6 -4
- package/src/adapters/bun/create-app.js +65 -43
- package/src/adapters/bun/server-adapter.d.ts +90 -22
- package/src/adapters/bun/server-adapter.js +266 -84
- package/src/adapters/bun/static-preview-host.js +25 -20
- package/src/adapters/create-app.d.ts +13 -11
- package/src/adapters/create-app.js +2 -51
- package/src/adapters/index.d.ts +1 -1
- package/src/adapters/index.js +1 -2
- package/src/adapters/node/create-app.d.ts +5 -1
- package/src/adapters/node/create-app.js +51 -12
- 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/server-adapter-dependencies.js +4 -0
- package/src/adapters/node/server-adapter.d.ts +62 -20
- package/src/adapters/node/server-adapter.js +160 -131
- 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/fs-server-response-matcher.d.ts +2 -0
- package/src/adapters/shared/fs-server-response-matcher.js +40 -18
- package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +21 -30
- package/src/adapters/shared/hmr-entrypoint-registrar.js +49 -54
- 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 +46 -0
- package/src/adapters/shared/runtime-server-lifecycle.js +50 -0
- package/src/adapters/shared/server-adapter.d.ts +2 -1
- package/src/adapters/shared/server-adapter.js +13 -6
- 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 +23 -32
- package/src/adapters/shared/server-static-builder.js +100 -73
- package/src/adapters/shared/shared-hmr-manager.d.ts +45 -11
- package/src/adapters/shared/shared-hmr-manager.js +204 -58
- 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 +9 -0
- package/src/build/app-build-manifest-runtime.js +87 -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/client/navigation-scripts/classification.d.ts +16 -0
- package/src/client/navigation-scripts/classification.js +41 -0
- package/src/client/navigation-scripts/index.d.ts +3 -0
- package/src/client/navigation-scripts/index.js +23 -0
- package/src/client/navigation-scripts/navigation-scripts.test.browser.js +65 -0
- package/src/client/navigation-scripts/registry.d.ts +11 -0
- package/src/client/navigation-scripts/registry.js +12 -0
- package/src/client/navigation-scripts/rerun-queue.d.ts +37 -0
- package/src/client/navigation-scripts/rerun-queue.js +73 -0
- package/src/client/scroll.d.ts +17 -0
- package/src/client/scroll.js +25 -0
- package/src/client/scroll.test.browser.js +37 -0
- package/src/client/view-transitions.d.ts +16 -0
- package/src/client/view-transitions.js +63 -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/hmr-manager-registry.d.ts +8 -0
- package/src/dev/hmr-manager-registry.js +15 -0
- package/src/dev/host-runtime.d.ts +3 -0
- package/src/dev/host-runtime.js +7 -0
- package/src/dev/runtime-server-started-message.d.ts +2 -0
- package/src/dev/runtime-server-started-message.js +6 -0
- package/src/eco/README.md +11 -0
- package/src/eco/eco-declared-component.d.ts +14 -0
- package/src/eco/eco-declared-component.js +16 -0
- package/src/eco/eco.browser.js +5 -6
- package/src/eco/eco.js +5 -6
- package/src/eco/eco.types.d.ts +2 -2
- package/src/eco/page-layout-normalization.d.ts +21 -0
- package/src/eco/page-layout-normalization.js +59 -0
- package/src/errors/index.d.ts +1 -0
- package/src/errors/index.js +7 -1
- package/src/errors/undeclared-component-dependency-error.d.ts +11 -0
- package/src/errors/undeclared-component-dependency-error.js +17 -0
- package/src/hmr/client/hmr-runtime.js +5 -2
- package/src/hmr/hmr-entrypoint-output.d.ts +43 -0
- package/src/hmr/hmr-entrypoint-output.js +53 -0
- package/src/hmr/hmr-strategy.d.ts +15 -0
- package/src/hmr/hmr-strategy.js +19 -0
- package/src/hmr/strategies/js-hmr-strategy.d.ts +3 -5
- package/src/hmr/strategies/js-hmr-strategy.js +67 -19
- 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 +98 -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 +90 -0
- package/src/route-renderer/orchestration/document-shell-render.service.js +120 -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 +113 -195
- 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/layout-shell-props.service.d.ts +20 -0
- package/src/route-renderer/orchestration/layout-shell-props.service.js +31 -0
- package/src/route-renderer/orchestration/ownership-validation.service.d.ts +5 -0
- package/src/route-renderer/orchestration/ownership-validation.service.js +29 -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 +26 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.js +54 -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 +8 -39
- package/src/route-renderer/orchestration/route-render-orchestrator.js +53 -461
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +14 -0
- package/src/route-renderer/orchestration/string-markup-renderer.js +55 -0
- package/src/route-renderer/page-loading/component-dependency-collection.js +5 -2
- package/src/router/client/link-intent.d.ts +11 -21
- package/src/router/client/link-intent.js +10 -0
- package/src/router/client/link-intent.test.browser.js +12 -1
- package/src/router/client/link-navigation-policy.d.ts +45 -0
- package/src/router/client/link-navigation-policy.js +101 -0
- package/src/router/client/link-navigation-policy.test.browser.d.ts +1 -0
- package/src/router/client/link-navigation-policy.test.browser.js +92 -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.d.ts +0 -1
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +18 -15
- 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 +20 -2
- package/src/services/invalidation/development-invalidation.service.js +56 -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 +5 -1
- package/src/services/module-loading/page-module-import.service.js +96 -45
- 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 +122 -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 +16 -9
- package/src/types/public-types.d.ts +144 -40
- package/src/utils/parse-cli-args.d.ts +2 -0
- package/src/utils/parse-cli-args.js +6 -0
- package/src/utils/server-utils.module.d.ts +3 -2
- package/src/utils/server-utils.module.js +5 -6
- package/src/utils/static-file-extensions.d.ts +12 -0
- package/src/utils/static-file-extensions.js +48 -0
- package/src/watchers/project-watcher-ignore.d.ts +11 -0
- package/src/watchers/project-watcher-ignore.js +16 -0
- package/src/watchers/project-watcher.d.ts +26 -3
- package/src/watchers/project-watcher.js +132 -30
- package/src/watchers/project-watcher.test-helpers.js +5 -5
- 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.js +0 -31
- 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
- /package/src/{hmr/hmr.postcss.test.e2e.d.ts → client/navigation-scripts/navigation-scripts.test.browser.d.ts} +0 -0
- /package/src/{hmr/hmr.test.e2e.d.ts → client/scroll.test.browser.d.ts} +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { EcoSourceTransform } from '../plugins/source-transform.js';
|
|
2
|
+
import type { EcoBuildPlugin } from './build-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Which backend owns the app's build pipeline.
|
|
5
|
+
*
|
|
6
|
+
* - `'rolldown'`: the default. Ecopages runs the build directly through
|
|
7
|
+
* its bundler-backed adapter.
|
|
8
|
+
* - `'vite-host'`: a host runtime owns the build. {@link ViteHostBuildAdapter}
|
|
9
|
+
* is exposed as a boundary marker; any direct call into it throws.
|
|
10
|
+
*/
|
|
11
|
+
export type BuildOwnership = 'vite-host' | 'rolldown';
|
|
12
|
+
/** A single message emitted by the build backend. */
|
|
13
|
+
export interface BuildLog {
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
/** A single artifact emitted by the build backend. */
|
|
17
|
+
export interface BuildOutput {
|
|
18
|
+
path: string;
|
|
19
|
+
}
|
|
20
|
+
/** Per-entrypoint dependency metadata surfaced alongside a build. */
|
|
21
|
+
export interface BuildDependencyGraph {
|
|
22
|
+
entrypoints: Record<string, string[]>;
|
|
23
|
+
}
|
|
24
|
+
/** The full result of one `BuildAdapter.build` call. */
|
|
25
|
+
export interface BuildResult {
|
|
26
|
+
success: boolean;
|
|
27
|
+
logs: BuildLog[];
|
|
28
|
+
outputs: BuildOutput[];
|
|
29
|
+
dependencyGraph?: BuildDependencyGraph;
|
|
30
|
+
entryOutputs?: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Options accepted by every `BuildAdapter.build` call.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* Fields that the adapter can forward are honored; fields that cannot
|
|
37
|
+
* (currently `splitting`, `bundle`, and `outbase`) are accepted so
|
|
38
|
+
* call-sites compile, but the adapter ignores them.
|
|
39
|
+
*/
|
|
40
|
+
export interface BuildOptions {
|
|
41
|
+
entrypoints: string[] | Record<string, string>;
|
|
42
|
+
outdir?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Base directory for `[dir]` placeholders in `naming`. Currently
|
|
45
|
+
* the bundled adapter derives the base from `root` directly and
|
|
46
|
+
* ignores this field.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated Accepted for call-site compatibility only. Use record-form
|
|
49
|
+
* `entrypoints` keys to preserve directory structure.
|
|
50
|
+
*/
|
|
51
|
+
outbase?: string;
|
|
52
|
+
naming?: string;
|
|
53
|
+
conditions?: string[];
|
|
54
|
+
define?: Record<string, string>;
|
|
55
|
+
minify?: boolean;
|
|
56
|
+
treeshaking?: boolean;
|
|
57
|
+
target?: string;
|
|
58
|
+
format?: string;
|
|
59
|
+
sourcemap?: string;
|
|
60
|
+
/** @deprecated Accepted for call-site compatibility only. */
|
|
61
|
+
splitting?: boolean;
|
|
62
|
+
root?: string;
|
|
63
|
+
/** @deprecated Accepted for call-site compatibility only. */
|
|
64
|
+
bundle?: boolean;
|
|
65
|
+
externalPackages?: boolean;
|
|
66
|
+
external?: string[];
|
|
67
|
+
jsx?: {
|
|
68
|
+
development?: boolean;
|
|
69
|
+
factory?: string;
|
|
70
|
+
fragment?: string;
|
|
71
|
+
importSource?: string;
|
|
72
|
+
runtime?: 'classic' | 'automatic';
|
|
73
|
+
sideEffects?: boolean;
|
|
74
|
+
};
|
|
75
|
+
plugins?: EcoBuildPlugin[];
|
|
76
|
+
sourceTransforms?: EcoSourceTransform[];
|
|
77
|
+
[key: string]: unknown;
|
|
78
|
+
}
|
|
79
|
+
/** Stable profile identifiers for `BuildAdapter.getTranspileOptions`. */
|
|
80
|
+
export type BuildTranspileProfile = 'browser-script' | 'hmr-runtime' | 'hmr-entrypoint';
|
|
81
|
+
/** Resolved transpile settings for a given profile. */
|
|
82
|
+
export interface BuildTranspileOptions {
|
|
83
|
+
target: string;
|
|
84
|
+
format: string;
|
|
85
|
+
sourcemap: string;
|
|
86
|
+
}
|
|
87
|
+
/** Low-level build backend contract. */
|
|
88
|
+
export interface BuildAdapter {
|
|
89
|
+
readonly ownership?: BuildOwnership;
|
|
90
|
+
build(options: BuildOptions): Promise<BuildResult>;
|
|
91
|
+
resolve(importPath: string, rootDir: string): string;
|
|
92
|
+
getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
|
|
93
|
+
}
|
|
94
|
+
/** Runtime-facing facade for issuing builds. */
|
|
95
|
+
export interface BuildExecutor {
|
|
96
|
+
build(options: BuildOptions): Promise<BuildResult>;
|
|
97
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IntegrationPlugin } from '../plugins/integration-plugin.js';
|
|
2
|
+
import type { Processor } from '../plugins/processor.js';
|
|
3
|
+
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Optional contributor surface for build-time cache invalidation.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Processors and integrations may override {@link didChange} to report that
|
|
9
|
+
* their build inputs changed independently of route source files.
|
|
10
|
+
*/
|
|
11
|
+
export interface BuildInputChangeContributor {
|
|
12
|
+
/**
|
|
13
|
+
* Returns `true` when this contributor's build inputs changed since the last
|
|
14
|
+
* persisted incremental build metadata was written.
|
|
15
|
+
*/
|
|
16
|
+
didChange?(): boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Returns whether a processor or integration signals changed build inputs. */
|
|
19
|
+
export declare function didBuildInputContributorChange(contributor: BuildInputChangeContributor): boolean;
|
|
20
|
+
/** Hashes the app's eco.config.ts file when present. */
|
|
21
|
+
export declare function hashAppConfigFile(appConfig: EcoPagesAppConfig): string;
|
|
22
|
+
/** Fingerprints processor/integration build-input state for cache invalidation. */
|
|
23
|
+
export declare function createBuildInputsFingerprint(appConfig: EcoPagesAppConfig): string;
|
|
24
|
+
/** Returns true when any processor or integration reports changed build inputs. */
|
|
25
|
+
export declare function haveBuildInputsChanged(appConfig: EcoPagesAppConfig): boolean;
|
|
26
|
+
/** Collects every processor and integration that can invalidate incremental builds. */
|
|
27
|
+
export declare function collectBuildInputContributors(appConfig: EcoPagesAppConfig): BuildInputChangeContributor[];
|
|
28
|
+
export type { Processor, IntegrationPlugin };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { fileSystem } from "@ecopages/file-system";
|
|
2
|
+
function didBuildInputContributorChange(contributor) {
|
|
3
|
+
return contributor.didChange?.() === true;
|
|
4
|
+
}
|
|
5
|
+
function hashAppConfigFile(appConfig) {
|
|
6
|
+
const configPath = appConfig.absolutePaths?.config;
|
|
7
|
+
if (!configPath || !fileSystem.exists(configPath)) {
|
|
8
|
+
return "missing";
|
|
9
|
+
}
|
|
10
|
+
return fileSystem.hash(configPath);
|
|
11
|
+
}
|
|
12
|
+
function createBuildInputsFingerprint(appConfig) {
|
|
13
|
+
const changedContributors = [
|
|
14
|
+
...Array.from(appConfig.processors?.values() ?? []).filter((processor) => didBuildInputContributorChange(processor)).map((processor) => `processor:${processor.getName()}`),
|
|
15
|
+
...(appConfig.integrations ?? []).filter((integration) => didBuildInputContributorChange(integration)).map((integration) => `integration:${integration.name}`)
|
|
16
|
+
];
|
|
17
|
+
return changedContributors.length > 0 ? changedContributors.sort().join("|") : "stable";
|
|
18
|
+
}
|
|
19
|
+
function haveBuildInputsChanged(appConfig) {
|
|
20
|
+
return createBuildInputsFingerprint(appConfig) !== "stable";
|
|
21
|
+
}
|
|
22
|
+
function collectBuildInputContributors(appConfig) {
|
|
23
|
+
return [...Array.from(appConfig.processors?.values() ?? []), ...appConfig.integrations ?? []];
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
collectBuildInputContributors,
|
|
27
|
+
createBuildInputsFingerprint,
|
|
28
|
+
didBuildInputContributorChange,
|
|
29
|
+
hashAppConfigFile,
|
|
30
|
+
haveBuildInputsChanged
|
|
31
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BuildOptions } from './build-adapter.js';
|
|
2
|
+
import type { BuildProfile } from './build-runtime.js';
|
|
3
|
+
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Resolves shared Rolldown options for a build profile.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveBuildProfileOptions(profile: BuildProfile, appConfig: EcoPagesAppConfig, overrides?: Partial<BuildOptions>): Partial<BuildOptions>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function resolveBuildProfileOptions(profile, appConfig, overrides = {}) {
|
|
2
|
+
const root = appConfig.rootDir;
|
|
3
|
+
switch (profile) {
|
|
4
|
+
case "server-entry":
|
|
5
|
+
return {
|
|
6
|
+
root,
|
|
7
|
+
target: "node",
|
|
8
|
+
format: "esm",
|
|
9
|
+
sourcemap: "none",
|
|
10
|
+
minify: false,
|
|
11
|
+
externalPackages: true,
|
|
12
|
+
...overrides
|
|
13
|
+
};
|
|
14
|
+
case "route-module":
|
|
15
|
+
return {
|
|
16
|
+
root,
|
|
17
|
+
target: "es2022",
|
|
18
|
+
format: "esm",
|
|
19
|
+
sourcemap: "none",
|
|
20
|
+
minify: false,
|
|
21
|
+
externalPackages: true,
|
|
22
|
+
...overrides
|
|
23
|
+
};
|
|
24
|
+
case "browser-hmr":
|
|
25
|
+
return {
|
|
26
|
+
root,
|
|
27
|
+
target: "browser",
|
|
28
|
+
format: "esm",
|
|
29
|
+
sourcemap: "none",
|
|
30
|
+
minify: false,
|
|
31
|
+
...overrides
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
resolveBuildProfileOptions
|
|
37
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
2
|
+
import { type BuildExecutor } from './build-adapter.js';
|
|
3
|
+
export type BuildProfile = 'server-entry' | 'route-module' | 'browser-hmr';
|
|
4
|
+
export interface BuildRuntime {
|
|
5
|
+
getProfile(profile: BuildProfile): BuildExecutor;
|
|
6
|
+
dispose(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare function getBuildRuntime(appConfig: EcoPagesAppConfig): BuildRuntime | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the installed build runtime, installing it when missing.
|
|
11
|
+
*/
|
|
12
|
+
export declare function requireBuildRuntime(appConfig: EcoPagesAppConfig): BuildRuntime;
|
|
13
|
+
/**
|
|
14
|
+
* Installs profile-based build executors for one app instance.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* All profiles use one-shot Rolldown. Server-entry stays serialized
|
|
18
|
+
* single-flight; route-module and browser-HMR run in parallel.
|
|
19
|
+
*/
|
|
20
|
+
export declare function installBuildRuntime(appConfig: EcoPagesAppConfig): BuildRuntime;
|
|
21
|
+
/**
|
|
22
|
+
* No-op retained for server teardown call sites.
|
|
23
|
+
*/
|
|
24
|
+
export declare function disposeAppBuildRuntime(appConfig: EcoPagesAppConfig): Promise<void>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { availableParallelism } from "node:os";
|
|
2
|
+
import {
|
|
3
|
+
getAppBrowserBuildPlugins,
|
|
4
|
+
getAppBuildAdapter,
|
|
5
|
+
getAppServerBuildPlugins,
|
|
6
|
+
withBuildExecutorPlugins
|
|
7
|
+
} from "./build-adapter.js";
|
|
8
|
+
import { ParallelBuildExecutor } from "./parallel-build-executor.js";
|
|
9
|
+
import { DedupingBuildExecutor } from "./deduping-build-executor.js";
|
|
10
|
+
import { SerializedBuildExecutor } from "./serialized-build-executor.js";
|
|
11
|
+
function resolveParallelismLimit() {
|
|
12
|
+
return Math.max(1, availableParallelism() - 1);
|
|
13
|
+
}
|
|
14
|
+
function patchAppRuntime(appConfig, patch) {
|
|
15
|
+
appConfig.runtime = {
|
|
16
|
+
...appConfig.runtime ?? {},
|
|
17
|
+
...patch
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
class AppBuildRuntime {
|
|
21
|
+
serverEntryExecutor;
|
|
22
|
+
routeModuleExecutor;
|
|
23
|
+
hmrExecutor;
|
|
24
|
+
constructor(appConfig) {
|
|
25
|
+
const adapter = getAppBuildAdapter(appConfig);
|
|
26
|
+
const serverPlugins = withBuildExecutorPlugins(adapter, () => getAppServerBuildPlugins(appConfig));
|
|
27
|
+
const browserPlugins = withBuildExecutorPlugins(adapter, () => getAppBrowserBuildPlugins(appConfig));
|
|
28
|
+
const limit = resolveParallelismLimit();
|
|
29
|
+
this.serverEntryExecutor = new SerializedBuildExecutor(serverPlugins);
|
|
30
|
+
this.routeModuleExecutor = new DedupingBuildExecutor(new ParallelBuildExecutor(serverPlugins, limit));
|
|
31
|
+
this.hmrExecutor = new DedupingBuildExecutor(new ParallelBuildExecutor(browserPlugins, Math.min(3, limit)));
|
|
32
|
+
}
|
|
33
|
+
getProfile(profile) {
|
|
34
|
+
switch (profile) {
|
|
35
|
+
case "server-entry":
|
|
36
|
+
return this.serverEntryExecutor;
|
|
37
|
+
case "route-module":
|
|
38
|
+
return this.routeModuleExecutor;
|
|
39
|
+
case "browser-hmr":
|
|
40
|
+
return this.hmrExecutor;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async dispose() {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function getBuildRuntime(appConfig) {
|
|
47
|
+
return appConfig.runtime?.buildRuntime;
|
|
48
|
+
}
|
|
49
|
+
function requireBuildRuntime(appConfig) {
|
|
50
|
+
return getBuildRuntime(appConfig) ?? installBuildRuntime(appConfig);
|
|
51
|
+
}
|
|
52
|
+
function installBuildRuntime(appConfig) {
|
|
53
|
+
const buildRuntime = new AppBuildRuntime(appConfig);
|
|
54
|
+
patchAppRuntime(appConfig, { buildRuntime });
|
|
55
|
+
return buildRuntime;
|
|
56
|
+
}
|
|
57
|
+
async function disposeAppBuildRuntime(appConfig) {
|
|
58
|
+
await getBuildRuntime(appConfig)?.dispose();
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
disposeAppBuildRuntime,
|
|
62
|
+
getBuildRuntime,
|
|
63
|
+
installBuildRuntime,
|
|
64
|
+
requireBuildRuntime
|
|
65
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BuildExecutor, BuildOptions, BuildResult } from './build-adapter.js';
|
|
2
|
+
/**
|
|
3
|
+
* Stable cache key for coalescing concurrent identical build requests.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Reuses the same material as route-module disk cache keys: normalized entrypoints,
|
|
7
|
+
* outdir, splitting, JSX, and plugin setup fingerprints.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createBuildOptionsDedupeKey(options: BuildOptions): string;
|
|
10
|
+
/**
|
|
11
|
+
* In-flight build coalescing wrapper.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* `ParallelBuildExecutor` allows concurrent builds but does not dedupe identical
|
|
15
|
+
* options. Multiple callers (route import, browser bundles, HMR) can hit the
|
|
16
|
+
* same Rolldown request before disk or import caches warm. This wrapper shares
|
|
17
|
+
* one inner `build()` promise per dedupe key until it settles.
|
|
18
|
+
*
|
|
19
|
+
* Wrap route-module and browser-hmr profiles only; server-entry stays serialized.
|
|
20
|
+
*/
|
|
21
|
+
export declare class DedupingBuildExecutor implements BuildExecutor {
|
|
22
|
+
private readonly inner;
|
|
23
|
+
private readonly inFlight;
|
|
24
|
+
constructor(inner: BuildExecutor);
|
|
25
|
+
build(options: BuildOptions): Promise<BuildResult>;
|
|
26
|
+
unwrap(): BuildExecutor;
|
|
27
|
+
getInFlightCountForTests(): number;
|
|
28
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { createJsxCacheKey, createPluginCacheKey } from "../services/module-loading/route-module-build-manifest.js";
|
|
3
|
+
function createBuildOptionsDedupeKey(options) {
|
|
4
|
+
return [
|
|
5
|
+
normalizeEntrypoints(options.entrypoints),
|
|
6
|
+
options.root ? path.resolve(options.root) : "root:default",
|
|
7
|
+
options.outdir ? path.resolve(options.outdir) : "outdir:default",
|
|
8
|
+
options.splitting ?? "splitting:default",
|
|
9
|
+
options.externalPackages ?? "externalPackages:default",
|
|
10
|
+
options.target ?? "target:default",
|
|
11
|
+
options.format ?? "format:default",
|
|
12
|
+
options.sourcemap ?? "sourcemap:default",
|
|
13
|
+
options.minify ?? "minify:default",
|
|
14
|
+
options.treeshaking ?? "treeshaking:default",
|
|
15
|
+
options.naming ?? "naming:default",
|
|
16
|
+
createJsxCacheKey(options.jsx),
|
|
17
|
+
createPluginCacheKey(options.plugins)
|
|
18
|
+
].join("::");
|
|
19
|
+
}
|
|
20
|
+
function normalizeEntrypoints(entrypoints) {
|
|
21
|
+
if (Array.isArray(entrypoints)) {
|
|
22
|
+
return entrypoints.map((entrypoint) => path.resolve(entrypoint)).sort().join("|");
|
|
23
|
+
}
|
|
24
|
+
return Object.entries(entrypoints).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${key}:${path.resolve(value)}`).join("|");
|
|
25
|
+
}
|
|
26
|
+
class DedupingBuildExecutor {
|
|
27
|
+
inner;
|
|
28
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
29
|
+
constructor(inner) {
|
|
30
|
+
this.inner = inner;
|
|
31
|
+
}
|
|
32
|
+
build(options) {
|
|
33
|
+
const key = createBuildOptionsDedupeKey(options);
|
|
34
|
+
const existing = this.inFlight.get(key);
|
|
35
|
+
if (existing) {
|
|
36
|
+
return existing;
|
|
37
|
+
}
|
|
38
|
+
const buildPromise = this.inner.build(options).finally(() => {
|
|
39
|
+
if (this.inFlight.get(key) === buildPromise) {
|
|
40
|
+
this.inFlight.delete(key);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
this.inFlight.set(key, buildPromise);
|
|
44
|
+
return buildPromise;
|
|
45
|
+
}
|
|
46
|
+
unwrap() {
|
|
47
|
+
return this.inner;
|
|
48
|
+
}
|
|
49
|
+
getInFlightCountForTests() {
|
|
50
|
+
return this.inFlight.size;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
DedupingBuildExecutor,
|
|
55
|
+
createBuildOptionsDedupeKey
|
|
56
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { EcoBuildPlugin } from './build-types.js';
|
|
2
|
+
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Foreign JSX override plugins for mixed-integration app builds.
|
|
5
|
+
*
|
|
6
|
+
* Each plugin rewrites files for one `(integration, extension)` pair with that
|
|
7
|
+
* integration's own `@jsxImportSource` so the bundler preserves the owning JSX
|
|
8
|
+
* runtime for native extension ownership.
|
|
9
|
+
*
|
|
10
|
+
* Extensions are sorted longest-first so `.page.react.tsx` wins over `.tsx`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getJsxOwnershipPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[];
|
|
13
|
+
/**
|
|
14
|
+
* Host-scoped JSX override plugins for one integration's client bundle graph.
|
|
15
|
+
*
|
|
16
|
+
* When a host integration (for example React) bundles foreign `.tsx` files, those
|
|
17
|
+
* files must compile with the host JSX runtime instead of the project default.
|
|
18
|
+
* Use this helper for host-owned client bundles. For app-wide transpilation that
|
|
19
|
+
* should preserve each integration's native JSX runtime, use
|
|
20
|
+
* {@link getJsxOwnershipPlugins} instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getHostScopedJsxOwnershipPlugins(appConfig: EcoPagesAppConfig, hostIntegrationName: string, options?: {
|
|
23
|
+
name?: string;
|
|
24
|
+
}): EcoBuildPlugin[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createForeignJsxOverridePlugin } from "../plugins/foreign-jsx-override-plugin.js";
|
|
2
|
+
import { collectJsxExtensions, filterJsxSourceExtensions } from "../plugins/jsx-import-source.utils.js";
|
|
3
|
+
function collectJsxExtensionEntries(appConfig) {
|
|
4
|
+
return (appConfig.integrations ?? []).filter((integration) => integration.jsxImportSource).flatMap(
|
|
5
|
+
(integration) => filterJsxSourceExtensions(integration.extensions).map((extension) => ({ integration, extension }))
|
|
6
|
+
).sort((left, right) => right.extension.length - left.extension.length);
|
|
7
|
+
}
|
|
8
|
+
function getJsxOwnershipPlugins(appConfig) {
|
|
9
|
+
const jsxExtensions = collectJsxExtensionEntries(appConfig);
|
|
10
|
+
return jsxExtensions.map(
|
|
11
|
+
({ integration, extension }) => createForeignJsxOverridePlugin({
|
|
12
|
+
hostJsxImportSource: integration.jsxImportSource,
|
|
13
|
+
foreignExtensions: [extension],
|
|
14
|
+
excludeExtensions: jsxExtensions.filter((candidate) => candidate.extension.length > extension.length).filter((candidate) => candidate.extension.endsWith(extension)).map((candidate) => candidate.extension),
|
|
15
|
+
name: `ecopages-jsx-ownership-${integration.name}-${extension.replace(/[^a-zA-Z0-9]+/g, "-")}`
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
function getHostScopedJsxOwnershipPlugins(appConfig, hostIntegrationName, options) {
|
|
20
|
+
const hostIntegration = (appConfig.integrations ?? []).find(
|
|
21
|
+
(integration) => integration.name === hostIntegrationName
|
|
22
|
+
);
|
|
23
|
+
const hostJsxImportSource = hostIntegration?.jsxImportSource;
|
|
24
|
+
if (!hostJsxImportSource) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const foreignExtensions = collectJsxExtensions(appConfig.integrations ?? [], {
|
|
28
|
+
excludeIntegrationName: hostIntegrationName
|
|
29
|
+
});
|
|
30
|
+
return [
|
|
31
|
+
createForeignJsxOverridePlugin({
|
|
32
|
+
name: options?.name ?? `ecopages-jsx-ownership-host-${hostIntegrationName}`,
|
|
33
|
+
hostJsxImportSource,
|
|
34
|
+
foreignExtensions
|
|
35
|
+
})
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
getHostScopedJsxOwnershipPlugins,
|
|
40
|
+
getJsxOwnershipPlugins
|
|
41
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified pages Rolldown graph (Phase A build + Phase C import).
|
|
3
|
+
*
|
|
4
|
+
* Enabled by default in production builds. Opt out with
|
|
5
|
+
* `ECOPAGES_UNIFIED_PAGES_GRAPH=0`. Covers all static page template extensions
|
|
6
|
+
* registered on the app config.
|
|
7
|
+
*/
|
|
8
|
+
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
9
|
+
export declare const PAGES_UNIFIED_GRAPH_CACHE_DIR = ".server-pages-graph";
|
|
10
|
+
export declare const PAGES_UNIFIED_GRAPH_CACHE_FILENAME = ".build-cache.json";
|
|
11
|
+
export interface PagesUnifiedGraphCacheManifest {
|
|
12
|
+
invalidationVersion: string;
|
|
13
|
+
buildInputsFingerprint: string;
|
|
14
|
+
buildKey: string;
|
|
15
|
+
builtAt: number;
|
|
16
|
+
outputs: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export declare function isPagesUnifiedGraphEnabled(): boolean;
|
|
19
|
+
/** True when the unified graph should build or serve prebuilt page modules. */
|
|
20
|
+
export declare function shouldBuildPagesUnifiedGraph(): boolean;
|
|
21
|
+
export declare function isPagesUnifiedGraphPage(filePath: string, appConfig: EcoPagesAppConfig): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Builds eligible static pages in one Rolldown invocation and seeds route-module disk cache.
|
|
24
|
+
*/
|
|
25
|
+
export declare function ensurePagesUnifiedGraphBuilt(options: {
|
|
26
|
+
appConfig: EcoPagesAppConfig;
|
|
27
|
+
entryPaths: readonly string[];
|
|
28
|
+
outdir: string;
|
|
29
|
+
force?: boolean;
|
|
30
|
+
}): Promise<PagesUnifiedGraphCacheManifest | undefined>;
|
|
31
|
+
export declare function importPagesUnifiedGraphModule<T>(appConfig: EcoPagesAppConfig, filePath: string): Promise<T | undefined>;
|