@ecopages/core 0.2.0-rc.1 → 0.2.0-rc.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/README.md +50 -41
- package/package.json +50 -145
- package/src/adapters/README.md +11 -3
- package/src/adapters/abstract/application-adapter.d.ts +32 -36
- package/src/adapters/abstract/application-adapter.js +61 -47
- package/src/adapters/abstract/segment-path-matcher.js +56 -38
- package/src/adapters/abstract/server-adapter.d.ts +14 -0
- package/src/adapters/abstract/server-adapter.js +10 -0
- package/src/adapters/abstract/ws-pattern-matcher.d.ts +0 -5
- package/src/adapters/abstract/ws-pattern-matcher.js +0 -9
- package/src/adapters/bun/create-app.d.ts +15 -15
- package/src/adapters/bun/create-app.js +52 -67
- package/src/adapters/bun/hmr-manager.d.ts +0 -1
- package/src/adapters/bun/hmr-manager.js +2 -4
- package/src/adapters/bun/server-adapter.d.ts +15 -21
- package/src/adapters/bun/server-adapter.js +33 -67
- package/src/adapters/bun/static-preview-host.d.ts +1 -0
- package/src/adapters/bun/static-preview-host.js +1 -1
- package/src/adapters/create-app.d.ts +63 -8
- package/src/adapters/create-app.js +62 -5
- package/src/adapters/node/create-app.d.ts +8 -12
- package/src/adapters/node/create-app.js +22 -14
- package/src/adapters/node/runtime-host.d.ts +10 -10
- package/src/adapters/node/runtime-host.js +13 -8
- package/src/adapters/node/server-adapter-dependencies.d.ts +2 -10
- package/src/adapters/node/server-adapter-dependencies.js +8 -13
- package/src/adapters/node/server-adapter.d.ts +30 -32
- package/src/adapters/node/server-adapter.js +59 -65
- package/src/adapters/shared/hmr/shared-hmr-manager.d.ts +0 -4
- package/src/adapters/shared/hmr/shared-hmr-manager.js +0 -12
- package/src/adapters/shared/http/api-request-pipeline.d.ts +27 -1
- package/src/adapters/shared/http/api-request-pipeline.js +31 -16
- package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
- package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -9
- package/src/adapters/shared/http/fs-server-response-factory.js +5 -33
- package/src/adapters/shared/http/fs-server-response-matcher.d.ts +24 -24
- package/src/adapters/shared/http/fs-server-response-matcher.js +59 -83
- package/src/adapters/shared/runtime/application-adapter.d.ts +1 -0
- package/src/adapters/shared/runtime/application-adapter.js +12 -0
- package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
- package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
- package/src/adapters/shared/runtime/collect-dev-prewarm-plan.d.ts +1 -3
- package/src/adapters/shared/runtime/collect-dev-prewarm-plan.js +1 -4
- package/src/adapters/shared/runtime/port-manager-default-prompt.d.ts +6 -0
- package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
- package/src/adapters/shared/runtime/port-manager.d.ts +3 -3
- package/src/adapters/shared/runtime/port-manager.js +14 -45
- package/src/adapters/shared/runtime/runtime-app-bootstrap.d.ts +0 -10
- package/src/adapters/shared/runtime/runtime-app-bootstrap.js +0 -7
- package/src/adapters/shared/runtime/runtime-host.d.ts +5 -2
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +1 -1
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +1 -1
- package/src/adapters/shared/runtime/server-adapter.d.ts +27 -5
- package/src/adapters/shared/runtime/server-adapter.js +44 -30
- package/src/adapters/shared/runtime/server-route-handler.js +11 -3
- package/src/adapters/shared/runtime/server-static-builder.d.ts +9 -3
- package/src/adapters/shared/runtime/server-static-builder.js +59 -37
- package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +9 -1
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +8 -2
- package/src/build/README.md +9 -6
- package/src/build/cache/cache-constants.d.ts +0 -2
- package/src/build/cache/cache-constants.js +0 -2
- package/src/build/cache/cache-keys.d.ts +0 -2
- package/src/build/cache/cache-keys.js +0 -2
- package/src/build/cache/output-imports.d.ts +27 -0
- package/src/build/cache/output-imports.js +80 -0
- package/src/build/cache/pages-unified-graph-build.d.ts +6 -1
- package/src/build/cache/pages-unified-graph-build.js +42 -17
- package/src/build/cache/production-build-cache.d.ts +2 -2
- package/src/build/cache/production-build-cache.js +2 -2
- package/src/build/cache/server-entry-build-cache.d.ts +25 -3
- package/src/build/cache/server-entry-build-cache.js +129 -13
- package/src/build/contracts/build-contracts.d.ts +1 -13
- package/src/build/contracts/content-virtual-modules.d.ts +3 -1
- package/src/build/contracts/content-virtual-modules.js +8 -0
- package/src/build/rolldown/rolldown-adapter-helpers.js +41 -25
- package/src/build/rolldown/rolldown-plugin-bridge.js +25 -21
- package/src/build/rolldown/runtime-build-output-normalizer.js +3 -6
- package/src/build/runtime/build-request-identity.d.ts +2 -6
- package/src/build/runtime/build-request-identity.js +2 -8
- package/src/build/runtime/build-request-policy.js +1 -1
- package/src/build/runtime/deduping-build-executor.d.ts +0 -1
- package/src/build/runtime/deduping-build-executor.js +0 -1
- package/src/build/server-bundle-publication.d.ts +14 -0
- package/src/build/server-bundle-publication.js +49 -0
- package/src/cache/index.d.ts +1 -1
- package/src/cache/index.js +1 -1
- package/src/cache/module-parse-cache.d.ts +2 -29
- package/src/cache/module-parse-cache.js +6 -39
- package/src/config/README.md +17 -2
- package/src/config/apply-user-config.d.ts +8 -0
- package/src/config/apply-user-config.js +68 -0
- package/src/config/config-builder.d.ts +11 -1
- package/src/config/config-builder.js +53 -12
- package/src/config/constants.d.ts +4 -4
- package/src/config/constants.js +4 -4
- package/src/config/define-config.d.ts +9 -0
- package/src/config/define-config.js +10 -0
- package/src/config/index.d.ts +5 -0
- package/src/config/index.js +4 -0
- package/src/config/is-finalized-app-config.d.ts +6 -0
- package/src/config/is-finalized-app-config.js +11 -0
- package/src/config/load-eco-config.d.ts +21 -0
- package/src/config/load-eco-config.js +107 -0
- package/src/config/resolve-eco-config-path.d.ts +32 -0
- package/src/config/resolve-eco-config-path.js +58 -0
- package/src/config/server-config-bundle.d.ts +25 -0
- package/src/config/server-config-bundle.js +148 -0
- package/src/config/user-config-types.d.ts +170 -0
- package/src/config/user-config-types.js +1 -0
- package/src/css-imports.d.ts +4 -0
- package/src/declarations.d.ts +11 -5
- package/src/dev/README.md +6 -0
- package/src/dev/development-restart-watch-paths.d.ts +13 -0
- package/src/dev/development-restart-watch-paths.js +37 -0
- package/src/dev/development-restart.d.ts +13 -0
- package/src/dev/development-restart.js +21 -0
- package/src/dev/host-runtime.d.ts +0 -1
- package/src/dev/host-runtime.js +0 -3
- package/src/dev/sc-server.d.ts +4 -1
- package/src/dev/sc-server.js +11 -20
- package/src/dev/transform-server/dev-transform-import-rewriter.js +2 -2
- package/src/dev/transform-server/dev-transform-server.d.ts +6 -0
- package/src/dev/transform-server/dev-transform-server.js +16 -5
- package/src/eco/README.md +73 -5
- package/src/eco/component-identity.d.ts +3 -2
- package/src/eco/component-identity.js +5 -2
- package/src/eco/discovered-dependencies.d.ts +45 -0
- package/src/eco/discovered-dependencies.js +87 -0
- package/src/eco/eco.js +6 -0
- package/src/eco/eco.types.d.ts +18 -2
- package/src/eco/lazy-injector-map.js +57 -41
- package/src/eco/page-dependency-contributions.d.ts +19 -0
- package/src/eco/page-dependency-contributions.js +52 -0
- package/src/errors/http-error-page-contract.d.ts +77 -0
- package/src/errors/http-error-page-contract.js +106 -0
- package/src/hmr/hmr-file-change-prep.d.ts +0 -1
- package/src/hmr/hmr-file-change-prep.js +2 -5
- package/src/hmr/hmr-strategy.d.ts +3 -8
- package/src/hmr/hmr-strategy.js +3 -8
- package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -0
- package/src/hmr/strategies/js-hmr-strategy.js +24 -16
- package/src/index.browser.d.ts +2 -0
- package/src/index.browser.js +2 -0
- package/src/index.d.ts +5 -3
- package/src/index.js +5 -3
- package/src/islands/README.md +5 -1
- package/src/islands/island-host.d.ts +0 -9
- package/src/islands/island-host.js +1 -13
- package/src/plugins/README.md +8 -1
- package/src/plugins/component-import-discovery.d.ts +19 -0
- package/src/plugins/component-import-discovery.js +241 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +3 -1
- package/src/plugins/eco-component-meta-plugin.js +120 -18
- package/src/plugins/integration-plugin.d.ts +0 -1
- package/src/plugins/integration-plugin.js +0 -4
- package/src/plugins/processor.d.ts +10 -2
- package/src/plugins/processor.js +4 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
- package/src/plugins/tsconfig-import-resolver.js +4 -2
- package/src/route-renderer/GRAPH.md +1 -1
- package/src/route-renderer/README.md +15 -2
- package/src/{adapters/shared/http/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +3 -3
- package/src/route-renderer/orchestration/custom-element-scripts/README.md +9 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +16 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +34 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +80 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +190 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +17 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +41 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +10 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +46 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +7 -2
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +3 -4
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +11 -2
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +10 -2
- package/src/route-renderer/orchestration/integration-renderer.d.ts +9 -11
- package/src/route-renderer/orchestration/integration-renderer.js +43 -40
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +1 -1
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +2 -5
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +2 -68
- package/src/route-renderer/orchestration/ownership-graph/component-graph.js +55 -39
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -1
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -1
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +6 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +59 -36
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +8 -10
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +1 -1
- package/src/route-renderer/orchestration/string-markup-renderer.js +2 -1
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +6 -2
- package/src/route-renderer/page-loading/component-dependency-collection.js +113 -68
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +41 -28
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +10 -3
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +62 -25
- package/src/route-renderer/page-loading/page-dependency-bundling.js +14 -8
- package/src/route-renderer/page-loading/resolved-page-dependencies.d.ts +1 -2
- package/src/route-renderer/page-loading/resolved-page-dependencies.js +8 -7
- package/src/route-renderer/route-renderer.d.ts +9 -0
- package/src/route-renderer/route-renderer.js +18 -0
- package/src/router/README.md +7 -1
- package/src/router/server/route-registry.d.ts +13 -0
- package/src/router/server/route-registry.js +46 -32
- package/src/services/README.md +6 -1
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +36 -9
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.js +122 -37
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +2 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +13 -2
- package/src/services/assets/asset-processing-service/page-package.js +42 -39
- package/src/services/assets/browser-bundle.service.d.ts +1 -6
- package/src/services/error-pages/README.md +9 -0
- package/src/services/error-pages/default-error-pages.d.ts +39 -0
- package/src/services/error-pages/default-error-pages.js +199 -0
- package/src/services/error-pages/error-page-renderer.d.ts +58 -0
- package/src/services/error-pages/error-page-renderer.js +146 -0
- package/src/services/error-pages/semantic-error-page-exporter.d.ts +23 -0
- package/src/services/error-pages/semantic-error-page-exporter.js +35 -0
- package/src/services/html/html-rewriter.d.ts +77 -0
- package/src/services/html/html-rewriter.js +751 -0
- package/src/services/html/html-rewriter.parity.test.bun.d.ts +1 -0
- package/src/services/html/html-rewriter.parity.test.bun.js +74 -0
- package/src/services/html/html-transformer.service.d.ts +26 -39
- package/src/services/html/html-transformer.service.js +81 -153
- package/src/services/invalidation/development-invalidation.service.d.ts +9 -20
- package/src/services/invalidation/development-invalidation.service.js +35 -41
- package/src/services/module-loading/README.md +17 -14
- package/src/services/module-loading/app-module-loader.service.d.ts +0 -2
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +1 -1
- package/src/services/module-loading/app-server-module-transpiler.service.js +2 -10
- package/src/services/module-loading/collection-server-module-build.service.d.ts +1 -1
- package/src/services/module-loading/collection-server-module-build.service.js +5 -5
- package/src/services/module-loading/host-module-loader-registry.d.ts +0 -1
- package/src/services/module-loading/host-module-loader-registry.js +0 -3
- package/src/services/module-loading/page-module-import.service.d.ts +8 -0
- package/src/services/module-loading/page-module-import.service.js +62 -28
- package/src/services/module-loading/route-module-build-cache-registry.d.ts +0 -4
- package/src/services/module-loading/route-module-build-cache-registry.js +0 -4
- package/src/services/module-loading/route-module-build-cache.store.d.ts +3 -0
- package/src/services/module-loading/route-module-build-cache.store.js +18 -5
- package/src/services/module-loading/route-module-build-manifest.d.ts +6 -1
- package/src/services/module-loading/route-module-build-manifest.js +1 -2
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +3 -2
- package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
- package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -15
- package/src/services/module-loading/server-module-transpiler.service.js +0 -24
- package/src/services/module-loading/view-module-loader.d.ts +10 -0
- package/src/services/module-loading/view-module-loader.js +46 -0
- package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -12
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +4 -2
- package/src/services/runtime-state/server-invalidation-state.service.js +7 -14
- package/src/services/validation/schema-validation-service.d.ts +1 -0
- package/src/services/validation/schema-validation-service.js +23 -36
- package/src/static-site-generator/README.md +6 -1
- package/src/static-site-generator/static-site-generator.d.ts +7 -2
- package/src/static-site-generator/static-site-generator.js +90 -49
- package/src/types/internal-types.d.ts +6 -39
- package/src/types/public-types.d.ts +29 -131
- package/src/utils/parse-cli-args.js +29 -22
- package/src/watchers/project-watcher.d.ts +14 -16
- package/src/watchers/project-watcher.js +86 -61
- package/src/watchers/project-watcher.test-helpers.d.ts +10 -1
- package/src/watchers/project-watcher.test-helpers.js +12 -0
- package/src/adapters/abstract/router-adapter.d.ts +0 -26
- package/src/adapters/abstract/router-adapter.js +0 -13
- package/src/adapters/bun/index.d.ts +0 -2
- package/src/adapters/bun/index.js +0 -2
- package/src/adapters/index.d.ts +0 -2
- package/src/adapters/index.js +0 -2
- package/src/eco/eco.utils.d.ts +0 -1
- package/src/eco/eco.utils.js +0 -1
- package/src/services/cache/index.d.ts +0 -9
- package/src/services/cache/index.js +0 -8
- package/src/services/html/html-rewriter-provider.service.d.ts +0 -40
- package/src/services/html/html-rewriter-provider.service.js +0 -68
- package/src/services/module-loading/route-module-build-cache.d.ts +0 -4
- package/src/services/module-loading/route-module-build-cache.js +0 -3
- package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
- package/src/services/runtime-state/dev-graph.service.js +0 -170
- /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { readProductionCacheManifest, writeProductionCacheManifest } from '../../build/cache/production-build-cache.js';
|
|
3
3
|
import { createJsxCacheKey, createPluginCacheKey, createSourceTransformCacheKey, getCorePackageVersion, } from '../../build/cache/cache-keys.js';
|
|
4
|
-
export { createJsxCacheKey, createPluginCacheKey, getCorePackageVersion, hashPluginSetup, } from '../../build/cache/cache-keys.js';
|
|
5
4
|
export { ROUTE_MODULE_BUILD_CACHE_FILENAME } from '../../build/cache/cache-constants.js';
|
|
6
5
|
/** Normalizes filesystem paths used as manifest keys and build-key inputs. */
|
|
7
6
|
export function normalizeRouteModuleCachePath(filePath) {
|
|
@@ -49,7 +48,7 @@ export function readRouteModuleBuildCacheManifest(manifestPath) {
|
|
|
49
48
|
return undefined;
|
|
50
49
|
}
|
|
51
50
|
return {
|
|
52
|
-
corePackageVersion: parsed.corePackageVersion ??
|
|
51
|
+
corePackageVersion: parsed.corePackageVersion ?? '',
|
|
53
52
|
configHash: parsed.configHash,
|
|
54
53
|
buildInputsFingerprint: parsed.buildInputsFingerprint,
|
|
55
54
|
entries: parsed.entries,
|
|
@@ -5,8 +5,9 @@ import type { BuildResult } from '../../build/build-adapter.js';
|
|
|
5
5
|
* @remarks
|
|
6
6
|
* Keys are normalized absolute filesystem paths. Values are opaque content hashes
|
|
7
7
|
* produced by the active {@link FileSystem} implementation. Only app-owned source
|
|
8
|
-
* files are tracked; `node:` builtins and `node_modules` paths are excluded
|
|
9
|
-
*
|
|
8
|
+
* files are tracked; `node:` builtins and `node_modules` paths are excluded.
|
|
9
|
+
* Installed packages stay external to route modules, and framework code changes
|
|
10
|
+
* with a release, which the core package version covers.
|
|
10
11
|
*/
|
|
11
12
|
export type RouteModuleDependencyHashes = Record<string, string>;
|
|
12
13
|
type HashFileFn = (filePath: string) => string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
4
|
/**
|
|
@@ -129,10 +130,21 @@ export function resolveRouteModuleDependencyPaths(buildResult, entrypointPath, r
|
|
|
129
130
|
const normalizedEntrypoint = path.isAbsolute(entrypointPath)
|
|
130
131
|
? path.normalize(entrypointPath)
|
|
131
132
|
: path.normalize(path.resolve(rootDir, entrypointPath));
|
|
133
|
+
let realEntrypoint;
|
|
134
|
+
try {
|
|
135
|
+
realEntrypoint = fileSystem.exists(normalizedEntrypoint) ? fs.realpathSync(normalizedEntrypoint) : undefined;
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// fall back
|
|
139
|
+
}
|
|
132
140
|
const graphEntrypoints = buildResult.dependencyGraph?.entrypoints ?? {};
|
|
133
141
|
const dependencyPaths = graphEntrypoints[normalizedEntrypoint] ??
|
|
142
|
+
(realEntrypoint ? graphEntrypoints[realEntrypoint] : undefined) ??
|
|
134
143
|
graphEntrypoints[entrypointPath] ??
|
|
135
|
-
Object.entries(graphEntrypoints).find(([candidate]) =>
|
|
144
|
+
Object.entries(graphEntrypoints).find(([candidate]) => {
|
|
145
|
+
const norm = path.normalize(candidate);
|
|
146
|
+
return norm === normalizedEntrypoint || (realEntrypoint !== undefined && norm === realEntrypoint);
|
|
147
|
+
})?.[1];
|
|
136
148
|
if (!dependencyPaths || dependencyPaths.length === 0) {
|
|
137
149
|
return [normalizedEntrypoint];
|
|
138
150
|
}
|
|
@@ -4,7 +4,7 @@ import type { AppModuleLoader } from './app-module-loader.service.js';
|
|
|
4
4
|
import { type PageModuleBuildImportOptions } from './page-module-import.service.js';
|
|
5
5
|
import type { SourceModuleLoaderFactory } from './module-loading-types.js';
|
|
6
6
|
export type ServerModuleTranspilerOptions = Omit<PageModuleBuildImportOptions, 'rootDir' | 'buildExecutor'>;
|
|
7
|
-
export type ServerModuleImportDependency = Pick<AppModuleLoader, 'importModule'
|
|
7
|
+
export type ServerModuleImportDependency = Pick<AppModuleLoader, 'importModule'>;
|
|
8
8
|
/**
|
|
9
9
|
* Immutable execution context for one server-transpiler instance.
|
|
10
10
|
*
|
|
@@ -18,7 +18,6 @@ export type ServerModuleTranspilerBootstrapArgs = {
|
|
|
18
18
|
getBuildExecutor?: () => BuildExecutor | undefined;
|
|
19
19
|
canLoadSourceModuleFromHost?: (filePath: string) => boolean;
|
|
20
20
|
getHostModuleLoader?: SourceModuleLoaderFactory;
|
|
21
|
-
invalidateModules?: (changedFiles?: string[]) => void;
|
|
22
21
|
pageModuleImportService?: ServerModuleImportDependency;
|
|
23
22
|
/** Factory evaluated on each importModule call to produce plugins applied to every load. */
|
|
24
23
|
getDefaultPlugins?: () => EcoBuildPlugin[];
|
|
@@ -34,7 +33,6 @@ export declare class ServerModuleTranspiler {
|
|
|
34
33
|
private readonly pageModuleImportService;
|
|
35
34
|
private readonly getRootDir;
|
|
36
35
|
private readonly getBuildExecutor;
|
|
37
|
-
private readonly invalidateModules;
|
|
38
36
|
private readonly getDefaultPlugins;
|
|
39
37
|
/**
|
|
40
38
|
* Creates one explicit server-transpiler boundary for a given execution
|
|
@@ -46,16 +44,4 @@ export declare class ServerModuleTranspiler {
|
|
|
46
44
|
* context.
|
|
47
45
|
*/
|
|
48
46
|
importModule<T = unknown>(options: ServerModuleTranspilerOptions): Promise<T>;
|
|
49
|
-
/**
|
|
50
|
-
* Invalidates cached module state for development reloads.
|
|
51
|
-
*/
|
|
52
|
-
invalidate(changedFiles?: string[]): void;
|
|
53
|
-
/**
|
|
54
|
-
* Releases transpiler-owned resources.
|
|
55
|
-
*
|
|
56
|
-
* @remarks
|
|
57
|
-
* The current implementation delegates cache ownership to lower-level module
|
|
58
|
-
* loading services, so disposal is intentionally a no-op for now.
|
|
59
|
-
*/
|
|
60
|
-
dispose(): Promise<void>;
|
|
61
47
|
}
|
|
@@ -10,7 +10,6 @@ export class ServerModuleTranspiler {
|
|
|
10
10
|
pageModuleImportService;
|
|
11
11
|
getRootDir;
|
|
12
12
|
getBuildExecutor;
|
|
13
|
-
invalidateModules;
|
|
14
13
|
getDefaultPlugins;
|
|
15
14
|
/**
|
|
16
15
|
* Creates one explicit server-transpiler boundary for a given execution
|
|
@@ -26,13 +25,6 @@ export class ServerModuleTranspiler {
|
|
|
26
25
|
this.getRootDir = () => args.rootDir;
|
|
27
26
|
this.getBuildExecutor = args.getBuildExecutor ?? (() => undefined);
|
|
28
27
|
this.getDefaultPlugins = args.getDefaultPlugins ?? (() => []);
|
|
29
|
-
this.invalidateModules = (changedFiles) => {
|
|
30
|
-
if (args.invalidateModules) {
|
|
31
|
-
args.invalidateModules(changedFiles);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
this.pageModuleImportService.invalidateDevelopmentGraph();
|
|
35
|
-
};
|
|
36
28
|
}
|
|
37
29
|
/**
|
|
38
30
|
* Loads a server-side source module through the caller-owned transpile
|
|
@@ -48,20 +40,4 @@ export class ServerModuleTranspiler {
|
|
|
48
40
|
buildExecutor: this.getBuildExecutor(),
|
|
49
41
|
});
|
|
50
42
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Invalidates cached module state for development reloads.
|
|
53
|
-
*/
|
|
54
|
-
invalidate(changedFiles) {
|
|
55
|
-
this.invalidateModules(changedFiles);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Releases transpiler-owned resources.
|
|
59
|
-
*
|
|
60
|
-
* @remarks
|
|
61
|
-
* The current implementation delegates cache ownership to lower-level module
|
|
62
|
-
* loading services, so disposal is intentionally a no-op for now.
|
|
63
|
-
*/
|
|
64
|
-
async dispose() {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
43
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
2
|
+
import type { ViewLoader } from '../../types/public-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a view loader that imports through the app server-module transpiler.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Use this for `app.static()` and HTML error-page registrations instead of
|
|
8
|
+
* raw dynamic `import()` so Node applies Ecopages build transforms (component identity).
|
|
9
|
+
*/
|
|
10
|
+
export declare function createViewModuleLoader<P = Record<string, unknown>>(appConfig: EcoPagesAppConfig, modulePath: string | URL): ViewLoader<P>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
4
|
+
import { resolveInternalExecutionDir } from '../../utils/resolve-work-dir.js';
|
|
5
|
+
import { getAppServerModuleTranspiler } from './app-server-module-transpiler.service.js';
|
|
6
|
+
function resolveViewModuleOnDisk(filePath, templatesExt) {
|
|
7
|
+
if (fileSystem.exists(filePath)) {
|
|
8
|
+
return filePath;
|
|
9
|
+
}
|
|
10
|
+
for (const extension of templatesExt) {
|
|
11
|
+
const withExtension = `${filePath}${extension}`;
|
|
12
|
+
if (fileSystem.exists(withExtension)) {
|
|
13
|
+
return withExtension;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const pathWithoutTerminalExtension = filePath.replace(/\.[^./]+$/, '');
|
|
17
|
+
for (const extension of templatesExt) {
|
|
18
|
+
const candidate = `${pathWithoutTerminalExtension}${extension}`;
|
|
19
|
+
if (fileSystem.exists(candidate)) {
|
|
20
|
+
return candidate;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return filePath;
|
|
24
|
+
}
|
|
25
|
+
function resolveViewModuleFilePath(appConfig, modulePath) {
|
|
26
|
+
const filePath = modulePath instanceof URL ? fileURLToPath(modulePath) : modulePath;
|
|
27
|
+
const rootedPath = path.isAbsolute(filePath)
|
|
28
|
+
? filePath
|
|
29
|
+
: path.join(appConfig.rootDir, filePath.replace(/^\.\//, ''));
|
|
30
|
+
return resolveViewModuleOnDisk(rootedPath, appConfig.templatesExt);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a view loader that imports through the app server-module transpiler.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* Use this for `app.static()` and HTML error-page registrations instead of
|
|
37
|
+
* raw dynamic `import()` so Node applies Ecopages build transforms (component identity).
|
|
38
|
+
*/
|
|
39
|
+
export function createViewModuleLoader(appConfig, modulePath) {
|
|
40
|
+
const filePath = resolveViewModuleFilePath(appConfig, modulePath);
|
|
41
|
+
return async () => await getAppServerModuleTranspiler(appConfig).importModule({
|
|
42
|
+
filePath,
|
|
43
|
+
outdir: path.join(resolveInternalExecutionDir(appConfig), '.server-modules'),
|
|
44
|
+
externalPackages: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -62,15 +62,6 @@ export class InMemoryEntrypointDependencyGraph {
|
|
|
62
62
|
this.entrypointDependencies.clear();
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
function isLegacyEntrypointDependencyGraph(value) {
|
|
66
|
-
return (Boolean(value) &&
|
|
67
|
-
typeof value === 'object' &&
|
|
68
|
-
typeof value.supportsSelectiveInvalidation === 'function' &&
|
|
69
|
-
typeof value.getDependencyEntrypoints === 'function' &&
|
|
70
|
-
typeof value.setEntrypointDependencies === 'function' &&
|
|
71
|
-
typeof value.clearEntrypointDependencies === 'function' &&
|
|
72
|
-
typeof value.reset === 'function');
|
|
73
|
-
}
|
|
74
65
|
/**
|
|
75
66
|
* Returns the app-owned entrypoint dependency graph.
|
|
76
67
|
*/
|
|
@@ -78,9 +69,6 @@ export function getAppEntrypointDependencyGraph(appConfig) {
|
|
|
78
69
|
if (appConfig.runtime?.entrypointDependencyGraph) {
|
|
79
70
|
return appConfig.runtime.entrypointDependencyGraph;
|
|
80
71
|
}
|
|
81
|
-
if (isLegacyEntrypointDependencyGraph(appConfig.runtime?.devGraphService)) {
|
|
82
|
-
return appConfig.runtime.devGraphService;
|
|
83
|
-
}
|
|
84
72
|
return new NoopEntrypointDependencyGraph();
|
|
85
73
|
}
|
|
86
74
|
/**
|
|
@@ -5,7 +5,6 @@ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
|
5
5
|
export interface ServerInvalidationState {
|
|
6
6
|
getServerInvalidationVersion(): number;
|
|
7
7
|
invalidateServerModules(changedFiles?: string[]): void;
|
|
8
|
-
reset(): void;
|
|
9
8
|
}
|
|
10
9
|
/**
|
|
11
10
|
* Minimal app-local invalidation state backed by a single generation counter.
|
|
@@ -14,10 +13,13 @@ export declare class CounterServerInvalidationState implements ServerInvalidatio
|
|
|
14
13
|
private serverInvalidationVersion;
|
|
15
14
|
getServerInvalidationVersion(): number;
|
|
16
15
|
invalidateServerModules(_changedFiles?: string[]): void;
|
|
17
|
-
reset(): void;
|
|
18
16
|
}
|
|
19
17
|
/**
|
|
20
18
|
* Returns the app-owned server invalidation state.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* When nothing is installed yet, a counter is installed on first read so later
|
|
22
|
+
* reads share its version instead of each starting from zero.
|
|
21
23
|
*/
|
|
22
24
|
export declare function getAppServerInvalidationState(appConfig: EcoPagesAppConfig): ServerInvalidationState;
|
|
23
25
|
/**
|
|
@@ -9,28 +9,21 @@ export class CounterServerInvalidationState {
|
|
|
9
9
|
invalidateServerModules(_changedFiles) {
|
|
10
10
|
this.serverInvalidationVersion += 1;
|
|
11
11
|
}
|
|
12
|
-
reset() {
|
|
13
|
-
this.serverInvalidationVersion += 1;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function isLegacyServerInvalidationState(value) {
|
|
17
|
-
return (Boolean(value) &&
|
|
18
|
-
typeof value === 'object' &&
|
|
19
|
-
typeof value.getServerInvalidationVersion === 'function' &&
|
|
20
|
-
typeof value.invalidateServerModules === 'function' &&
|
|
21
|
-
typeof value.reset === 'function');
|
|
22
12
|
}
|
|
23
13
|
/**
|
|
24
14
|
* Returns the app-owned server invalidation state.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* When nothing is installed yet, a counter is installed on first read so later
|
|
18
|
+
* reads share its version instead of each starting from zero.
|
|
25
19
|
*/
|
|
26
20
|
export function getAppServerInvalidationState(appConfig) {
|
|
27
21
|
if (appConfig.runtime?.serverInvalidationState) {
|
|
28
22
|
return appConfig.runtime.serverInvalidationState;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return new CounterServerInvalidationState();
|
|
24
|
+
const serverInvalidationState = new CounterServerInvalidationState();
|
|
25
|
+
setAppServerInvalidationState(appConfig, serverInvalidationState);
|
|
26
|
+
return serverInvalidationState;
|
|
34
27
|
}
|
|
35
28
|
/**
|
|
36
29
|
* Installs the invalidation state used by one app instance.
|
|
@@ -110,6 +110,7 @@ export declare class SchemaValidationService {
|
|
|
110
110
|
* }
|
|
111
111
|
* ```
|
|
112
112
|
*/
|
|
113
|
+
private validateRequestPart;
|
|
113
114
|
validateRequest(source: ValidationSource, schemas: ValidationSchemas): Promise<ValidationResult<ValidatedData>>;
|
|
114
115
|
/**
|
|
115
116
|
* Validates a single value against a Standard Schema.
|
|
@@ -84,45 +84,32 @@ export class SchemaValidationService {
|
|
|
84
84
|
* }
|
|
85
85
|
* ```
|
|
86
86
|
*/
|
|
87
|
+
async validateRequestPart(schema, value, assign, allErrors, shouldValidate) {
|
|
88
|
+
if (!schema || !shouldValidate) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const result = await this.validateWithSchema(schema, value);
|
|
92
|
+
if (!result.success) {
|
|
93
|
+
allErrors.push(...(result.errors || []));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
assign(result.data);
|
|
97
|
+
}
|
|
87
98
|
async validateRequest(source, schemas) {
|
|
88
99
|
const validated = {};
|
|
89
100
|
const allErrors = [];
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
allErrors.push(...(result.errors || []));
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
validated.query = result.data;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (schemas.headers && source.headers) {
|
|
109
|
-
const result = await this.validateWithSchema(schemas.headers, source.headers);
|
|
110
|
-
if (!result.success) {
|
|
111
|
-
allErrors.push(...(result.errors || []));
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
validated.headers = result.data;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (schemas.params && source.params) {
|
|
118
|
-
const result = await this.validateWithSchema(schemas.params, source.params);
|
|
119
|
-
if (!result.success) {
|
|
120
|
-
allErrors.push(...(result.errors || []));
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
validated.params = result.data;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
101
|
+
await this.validateRequestPart(schemas.body, source.body, (data) => {
|
|
102
|
+
validated.body = data;
|
|
103
|
+
}, allErrors, schemas.body !== undefined && source.body !== undefined);
|
|
104
|
+
await this.validateRequestPart(schemas.query, source.query, (data) => {
|
|
105
|
+
validated.query = data;
|
|
106
|
+
}, allErrors, !!schemas.query && !!source.query);
|
|
107
|
+
await this.validateRequestPart(schemas.headers, source.headers, (data) => {
|
|
108
|
+
validated.headers = data;
|
|
109
|
+
}, allErrors, !!schemas.headers && !!source.headers);
|
|
110
|
+
await this.validateRequestPart(schemas.params, source.params, (data) => {
|
|
111
|
+
validated.params = data;
|
|
112
|
+
}, allErrors, !!schemas.params && !!source.params);
|
|
126
113
|
if (allErrors.length > 0) {
|
|
127
114
|
return { success: false, errors: allErrors };
|
|
128
115
|
}
|
|
@@ -11,6 +11,7 @@ It is responsible for:
|
|
|
11
11
|
- enumerating renderable routes
|
|
12
12
|
- rendering static outputs through the normal rendering pipeline
|
|
13
13
|
- respecting route-level constraints such as cache policy and unsupported dynamic server-only paths
|
|
14
|
+
- emitting semantic 404/500 artifacts through the shared error-page renderer
|
|
14
15
|
|
|
15
16
|
## Design Rule
|
|
16
17
|
|
|
@@ -25,6 +26,8 @@ That means it should reuse:
|
|
|
25
26
|
|
|
26
27
|
It should not invent a parallel rendering stack just for build mode.
|
|
27
28
|
|
|
29
|
+
Semantic error pages are excluded from ordinary page enumeration and emitted once by `services/error-pages/semantic-error-page-exporter.ts`, so runtime and static output share source precedence and rendering behavior.
|
|
30
|
+
|
|
28
31
|
## Files
|
|
29
32
|
|
|
30
33
|
| File | Role |
|
|
@@ -58,10 +61,12 @@ Integrations may implement:
|
|
|
58
61
|
- `beforeStaticExport(context)` — runs after unified-graph prebuild, before page rendering
|
|
59
62
|
- `afterStaticExport(context)` — runs in a `finally` block after generation completes
|
|
60
63
|
|
|
61
|
-
When `appConfig.sitemap.enabled` is true, `sitemap.xml` is written **after** `afterStaticExport` so integration-generated URLs can be listed via `extraUrls`.
|
|
64
|
+
When `appConfig.sitemap.enabled` is true, `sitemap.xml` is written **after** `afterStaticExport` so integration-generated URLs can be listed via `extraUrls`. Development (`ecopages dev`) does not emit this file.
|
|
62
65
|
|
|
63
66
|
Sitemap eligibility is decided during successful page export (`activeStaticPathnames` plus `robots.index !== false`, fail-closed on metadata errors). `resolveSitemapLocations` then applies `exclude` and appends `extraUrls`.
|
|
64
67
|
|
|
65
68
|
`StaticExportContext.routes` is the unfiltered static-generation route list. Sitemap filtering is applied separately.
|
|
66
69
|
|
|
67
70
|
See `StaticExportContext` in `static-export-context.ts`.
|
|
71
|
+
|
|
72
|
+
User-facing guide: [Sitemap](https://github.com/ecopages/ecopages/blob/main/apps/docs/src/content/docs/core/sitemap.mdx) in the docs app.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
2
|
-
import type { SitemapConfig, StaticRoute } from '../types/public-types.js';
|
|
2
|
+
import type { SitemapConfig, StaticRoute, ErrorPageLoaders } from '../types/public-types.js';
|
|
3
3
|
import type { PageRendererResolver, StaticGenerationRendererResolver } from '../route-renderer/route-renderer.js';
|
|
4
4
|
import type { StaticGenerationRoute } from '../router/server/route-registry.js';
|
|
5
5
|
import type { RouteModuleBuildCache } from '../services/module-loading/route-module-build-cache.store.js';
|
|
@@ -92,14 +92,19 @@ export declare class StaticSiteGenerator {
|
|
|
92
92
|
}): Promise<void>;
|
|
93
93
|
private createStaticExportContext;
|
|
94
94
|
private invokeStaticExportHook;
|
|
95
|
+
private resetStaticGenerationState;
|
|
96
|
+
private ensureUnifiedGraphForStaticGeneration;
|
|
97
|
+
private executeStaticGenerationBody;
|
|
98
|
+
private finalizeStaticGenerationRun;
|
|
95
99
|
/**
|
|
96
100
|
* Executes the full static-generation workflow for one app run.
|
|
97
101
|
*/
|
|
98
|
-
run({ router, baseUrl, routeRendererFactory, staticRoutes, force, preserveExportDirectory, }: {
|
|
102
|
+
run({ router, baseUrl, routeRendererFactory, staticRoutes, errorPageLoaders, force, preserveExportDirectory, }: {
|
|
99
103
|
router: StaticGenerationRouteSource;
|
|
100
104
|
baseUrl: string;
|
|
101
105
|
routeRendererFactory?: StaticGenerationRendererFactory;
|
|
102
106
|
staticRoutes?: StaticRoute[];
|
|
107
|
+
errorPageLoaders?: ErrorPageLoaders;
|
|
103
108
|
force?: boolean;
|
|
104
109
|
preserveExportDirectory?: boolean;
|
|
105
110
|
}): Promise<void>;
|
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { availableParallelism } from 'node:os';
|
|
3
3
|
import { appLogger } from '../global/app-logger.js';
|
|
4
4
|
import { fileSystem } from '@ecopages/file-system';
|
|
5
|
-
import { prepareExplicitStaticRender } from '../
|
|
5
|
+
import { prepareExplicitStaticRender } from '../route-renderer/explicit-view-render-preparation.js';
|
|
6
6
|
import { createRouteModuleStaticRenderCacheContext } from './static-build-invalidation.js';
|
|
7
7
|
import { getServerModuleBuildCacheOutdir, getSharedRouteModuleBuildCache, } from '../services/module-loading/route-module-build-cache-registry.js';
|
|
8
8
|
import { ensurePagesUnifiedGraphBuilt, shouldBuildPagesUnifiedGraph, } from '../build/cache/pages-unified-graph-build.js';
|
|
@@ -12,6 +12,8 @@ import { renderSitemap } from './sitemap.js';
|
|
|
12
12
|
import { resolveSitemapLocations } from './sitemap-routes.js';
|
|
13
13
|
import { toEcopagesRouteInfo } from '../utils/ecopages-route-info.js';
|
|
14
14
|
import { normalizePathname } from '../utils/path-pattern.js';
|
|
15
|
+
import { ErrorPageRenderer } from '../services/error-pages/error-page-renderer.js';
|
|
16
|
+
import { SemanticErrorPageExporter, SEMANTIC_ERROR_PAGE_PATHNAMES, } from '../services/error-pages/semantic-error-page-exporter.js';
|
|
15
17
|
export const STATIC_SITE_GENERATOR_ERRORS = {
|
|
16
18
|
ROUTE_RENDERER_FACTORY_REQUIRED: 'RouteRendererFactory is required for render strategy',
|
|
17
19
|
unsupportedBodyType: (bodyType) => `Unsupported body type for static generation: ${bodyType}`,
|
|
@@ -319,13 +321,7 @@ export class StaticSiteGenerator {
|
|
|
319
321
|
}
|
|
320
322
|
}
|
|
321
323
|
}
|
|
322
|
-
|
|
323
|
-
* Executes the full static-generation workflow for one app run.
|
|
324
|
-
*/
|
|
325
|
-
async run({ router, baseUrl, routeRendererFactory, staticRoutes, force = false, preserveExportDirectory = false, }) {
|
|
326
|
-
const skippedDynamicPages = [];
|
|
327
|
-
const activeStaticPathnames = new Set();
|
|
328
|
-
const sitemapEligiblePathnames = this.appConfig.sitemap?.enabled ? new Set() : undefined;
|
|
324
|
+
resetStaticGenerationState(force) {
|
|
329
325
|
this.forceFullStaticGeneration = force;
|
|
330
326
|
this.staticRenderCacheContext = createRouteModuleStaticRenderCacheContext(this.appConfig);
|
|
331
327
|
this.pageModuleLoader = undefined;
|
|
@@ -335,16 +331,83 @@ export class StaticSiteGenerator {
|
|
|
335
331
|
if (shouldPrebuildProductionPageBrowserGraphs() && force) {
|
|
336
332
|
clearProductionPageBrowserGraphSession(this.appConfig);
|
|
337
333
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (shouldBuildPagesUnifiedGraph()) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
334
|
+
}
|
|
335
|
+
async ensureUnifiedGraphForStaticGeneration(routes, force) {
|
|
336
|
+
if (!shouldBuildPagesUnifiedGraph()) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
await ensurePagesUnifiedGraphBuilt({
|
|
340
|
+
appConfig: this.appConfig,
|
|
341
|
+
entryPaths: routes.map((route) => route.templateRoute.filePath),
|
|
342
|
+
outdir: getServerModuleBuildCacheOutdir(this.appConfig),
|
|
343
|
+
force,
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
async executeStaticGenerationBody(input) {
|
|
347
|
+
if (shouldPrebuildProductionPageBrowserGraphs() && input.routeRendererFactory) {
|
|
348
|
+
await prebuildProductionPageBrowserGraphs(input.routes.map((route) => ({
|
|
349
|
+
routeFile: route.templateRoute.filePath,
|
|
350
|
+
params: route.params,
|
|
351
|
+
})), input.routeRendererFactory);
|
|
352
|
+
}
|
|
353
|
+
this.generateRobotsTxt();
|
|
354
|
+
const semanticErrorPathnames = new Set(SEMANTIC_ERROR_PAGE_PATHNAMES);
|
|
355
|
+
const pageRoutes = input.routes.filter((route) => !semanticErrorPathnames.has(route.pathname));
|
|
356
|
+
await this.generateStaticPages({
|
|
357
|
+
router: input.router,
|
|
358
|
+
baseUrl: input.baseUrl,
|
|
359
|
+
routeRendererFactory: input.routeRendererFactory,
|
|
360
|
+
skipped: input.skippedDynamicPages,
|
|
361
|
+
activeStaticPathnames: input.activeStaticPathnames,
|
|
362
|
+
preloadedRoutes: pageRoutes,
|
|
363
|
+
sitemapEligiblePathnames: input.sitemapEligiblePathnames,
|
|
364
|
+
});
|
|
365
|
+
if (input.staticRoutes && input.staticRoutes.length > 0 && input.routeRendererFactory) {
|
|
366
|
+
await this.generateExplicitStaticPages({
|
|
367
|
+
staticRoutes: input.staticRoutes,
|
|
368
|
+
routeRendererFactory: input.routeRendererFactory,
|
|
369
|
+
skipped: input.skippedDynamicPages,
|
|
370
|
+
activeStaticPathnames: input.activeStaticPathnames,
|
|
371
|
+
sitemapEligiblePathnames: input.sitemapEligiblePathnames,
|
|
346
372
|
});
|
|
347
373
|
}
|
|
374
|
+
const errorPageRenderer = new ErrorPageRenderer({
|
|
375
|
+
appConfig: this.appConfig,
|
|
376
|
+
routeRendererFactory: input.routeRendererFactory,
|
|
377
|
+
errorPageLoaders: input.errorPageLoaders,
|
|
378
|
+
});
|
|
379
|
+
await new SemanticErrorPageExporter({
|
|
380
|
+
errorPageRenderer,
|
|
381
|
+
writeArtifact: async (artifact) => await this.writeStaticPageArtifact(artifact),
|
|
382
|
+
}).export(input.activeStaticPathnames);
|
|
383
|
+
if (input.preserveExportDirectory) {
|
|
384
|
+
this.pruneStaleStaticOutputs(input.activeStaticPathnames);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
finalizeStaticGenerationRun(input) {
|
|
388
|
+
if (this.appConfig.sitemap?.enabled && input.sitemapEligiblePathnames) {
|
|
389
|
+
const locations = resolveSitemapLocations({
|
|
390
|
+
eligiblePathnames: [...input.sitemapEligiblePathnames],
|
|
391
|
+
sitemap: this.appConfig.sitemap,
|
|
392
|
+
baseUrl: input.baseUrl,
|
|
393
|
+
});
|
|
394
|
+
this.generateSitemap(locations, this.appConfig.sitemap);
|
|
395
|
+
}
|
|
396
|
+
if (input.skippedDynamicPages.length > 0) {
|
|
397
|
+
appLogger.debug(`Skipped ${input.skippedDynamicPages.length} page(s) with cache: 'dynamic' (not supported in static generation)`, input.skippedDynamicPages);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Executes the full static-generation workflow for one app run.
|
|
402
|
+
*/
|
|
403
|
+
async run({ router, baseUrl, routeRendererFactory, staticRoutes, errorPageLoaders, force = false, preserveExportDirectory = false, }) {
|
|
404
|
+
const skippedDynamicPages = [];
|
|
405
|
+
const activeStaticPathnames = new Set();
|
|
406
|
+
const sitemapEligiblePathnames = this.appConfig.sitemap?.enabled ? new Set() : undefined;
|
|
407
|
+
this.resetStaticGenerationState(force);
|
|
408
|
+
const routes = await router.listStaticGenerationRoutes({ runtimeOrigin: baseUrl });
|
|
409
|
+
const exportRoutes = routes.map((route) => toEcopagesRouteInfo(route));
|
|
410
|
+
await this.ensureUnifiedGraphForStaticGeneration(routes, force);
|
|
348
411
|
const staticExportContext = this.createStaticExportContext({
|
|
349
412
|
router,
|
|
350
413
|
baseUrl,
|
|
@@ -356,34 +419,18 @@ export class StaticSiteGenerator {
|
|
|
356
419
|
});
|
|
357
420
|
await this.invokeStaticExportHook('beforeStaticExport', staticExportContext);
|
|
358
421
|
try {
|
|
359
|
-
|
|
360
|
-
await prebuildProductionPageBrowserGraphs(routes.map((route) => ({
|
|
361
|
-
routeFile: route.templateRoute.filePath,
|
|
362
|
-
params: route.params,
|
|
363
|
-
})), routeRendererFactory);
|
|
364
|
-
}
|
|
365
|
-
this.generateRobotsTxt();
|
|
366
|
-
await this.generateStaticPages({
|
|
422
|
+
await this.executeStaticGenerationBody({
|
|
367
423
|
router,
|
|
368
424
|
baseUrl,
|
|
369
425
|
routeRendererFactory,
|
|
370
|
-
|
|
426
|
+
staticRoutes,
|
|
427
|
+
errorPageLoaders,
|
|
428
|
+
preserveExportDirectory,
|
|
429
|
+
routes,
|
|
430
|
+
skippedDynamicPages,
|
|
371
431
|
activeStaticPathnames,
|
|
372
|
-
preloadedRoutes: routes,
|
|
373
432
|
sitemapEligiblePathnames,
|
|
374
433
|
});
|
|
375
|
-
if (staticRoutes && staticRoutes.length > 0 && routeRendererFactory) {
|
|
376
|
-
await this.generateExplicitStaticPages({
|
|
377
|
-
staticRoutes,
|
|
378
|
-
routeRendererFactory,
|
|
379
|
-
skipped: skippedDynamicPages,
|
|
380
|
-
activeStaticPathnames,
|
|
381
|
-
sitemapEligiblePathnames,
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
if (preserveExportDirectory) {
|
|
385
|
-
this.pruneStaleStaticOutputs(activeStaticPathnames);
|
|
386
|
-
}
|
|
387
434
|
}
|
|
388
435
|
catch (error) {
|
|
389
436
|
if (shouldPrebuildProductionPageBrowserGraphs()) {
|
|
@@ -394,17 +441,11 @@ export class StaticSiteGenerator {
|
|
|
394
441
|
finally {
|
|
395
442
|
await this.invokeStaticExportHook('afterStaticExport', staticExportContext);
|
|
396
443
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
});
|
|
403
|
-
this.generateSitemap(locations, this.appConfig.sitemap);
|
|
404
|
-
}
|
|
405
|
-
if (skippedDynamicPages.length > 0) {
|
|
406
|
-
appLogger.debug(`Skipped ${skippedDynamicPages.length} page(s) with cache: 'dynamic' (not supported in static generation)`, skippedDynamicPages);
|
|
407
|
-
}
|
|
444
|
+
this.finalizeStaticGenerationRun({
|
|
445
|
+
baseUrl,
|
|
446
|
+
skippedDynamicPages,
|
|
447
|
+
sitemapEligiblePathnames,
|
|
448
|
+
});
|
|
408
449
|
}
|
|
409
450
|
async generateExplicitStaticPages(input) {
|
|
410
451
|
appLogger.debug('Generating explicit static routes', input.staticRoutes.map((r) => r.path));
|