@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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
4
|
+
import { parseSync } from 'oxc-parser';
|
|
5
|
+
/**
|
|
6
|
+
* Lists the local files a compiled module imports: relative, absolute and
|
|
7
|
+
* `file:` specifiers in static imports, re-exports and literal dynamic imports.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Persisted build caches record these so a cached module is reused only while
|
|
11
|
+
* the shared chunks and generated modules it loads (for example
|
|
12
|
+
* `.server-collections`) still exist. Uses `parseSync` directly rather than the
|
|
13
|
+
* shared parse cache, so large compiled bundles are not retained in memory.
|
|
14
|
+
*/
|
|
15
|
+
export function collectLocalImports(code, modulePath) {
|
|
16
|
+
const { module } = parseSync(modulePath, code, { lang: 'js', sourceType: 'module' });
|
|
17
|
+
const specifiers = [
|
|
18
|
+
...module.staticImports.map((entry) => entry.moduleRequest.value),
|
|
19
|
+
...module.staticExports.flatMap((entry) => entry.entries.map((exportEntry) => exportEntry.moduleRequest?.value)),
|
|
20
|
+
...module.dynamicImports.map((entry) => readStringLiteral(code.slice(entry.moduleRequest.start, entry.moduleRequest.end))),
|
|
21
|
+
];
|
|
22
|
+
const directory = path.dirname(modulePath);
|
|
23
|
+
const localImports = new Set();
|
|
24
|
+
for (const specifier of specifiers) {
|
|
25
|
+
const resolved = specifier ? resolveLocalSpecifier(specifier, directory) : undefined;
|
|
26
|
+
if (resolved)
|
|
27
|
+
localImports.add(resolved);
|
|
28
|
+
}
|
|
29
|
+
return [...localImports];
|
|
30
|
+
}
|
|
31
|
+
const defaultLocalImportFileAccess = {
|
|
32
|
+
exists: (filePath) => fileSystem.exists(filePath),
|
|
33
|
+
readFile: (filePath) => fileSystem.readFileSync(filePath),
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Lists every local file reachable from `modulePath` through local imports.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Direct {@link collectLocalImports} misses shared chunks that a page output
|
|
40
|
+
* only reaches through another chunk. Persisted caches walk this graph so reuse
|
|
41
|
+
* fails when any reachable file is gone. `modulePath` itself is omitted; callers
|
|
42
|
+
* already check that the compiled output exists.
|
|
43
|
+
*/
|
|
44
|
+
export function collectReachableLocalImports(modulePath, fileAccess = defaultLocalImportFileAccess) {
|
|
45
|
+
const reachable = new Set();
|
|
46
|
+
const pending = [modulePath];
|
|
47
|
+
const visited = new Set();
|
|
48
|
+
while (pending.length > 0) {
|
|
49
|
+
const current = pending.pop();
|
|
50
|
+
if (!current || visited.has(current)) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
visited.add(current);
|
|
54
|
+
if (current !== modulePath) {
|
|
55
|
+
reachable.add(current);
|
|
56
|
+
}
|
|
57
|
+
if (current !== modulePath && !fileAccess.exists(current)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
for (const imported of collectLocalImports(fileAccess.readFile(current), current)) {
|
|
61
|
+
pending.push(imported);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return [...reachable];
|
|
65
|
+
}
|
|
66
|
+
/** Reads a compiled module from disk and lists its local imports. */
|
|
67
|
+
export function readLocalImports(modulePath) {
|
|
68
|
+
return collectLocalImports(fileSystem.readFileSync(modulePath), modulePath);
|
|
69
|
+
}
|
|
70
|
+
function resolveLocalSpecifier(specifier, directory) {
|
|
71
|
+
const bare = specifier.replace(/[?#].*$/, '');
|
|
72
|
+
if (bare.startsWith('file:'))
|
|
73
|
+
return fileURLToPath(bare);
|
|
74
|
+
if (bare.startsWith('.'))
|
|
75
|
+
return path.resolve(directory, bare);
|
|
76
|
+
return path.isAbsolute(bare) ? bare : undefined;
|
|
77
|
+
}
|
|
78
|
+
function readStringLiteral(source) {
|
|
79
|
+
return /^(['"`])([^'"`$]*)\1$/.exec(source.trim())?.[2];
|
|
80
|
+
}
|
|
@@ -9,11 +9,16 @@ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
|
9
9
|
export declare const PAGES_UNIFIED_GRAPH_CACHE_DIR = ".server-pages-graph";
|
|
10
10
|
export declare const PAGES_UNIFIED_GRAPH_CACHE_FILENAME = ".build-cache.json";
|
|
11
11
|
export interface PagesUnifiedGraphCacheManifest {
|
|
12
|
-
|
|
12
|
+
corePackageVersion: string;
|
|
13
13
|
buildInputsFingerprint: string;
|
|
14
14
|
buildKey: string;
|
|
15
15
|
builtAt: number;
|
|
16
16
|
outputs: Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Local files reachable from the outputs through local imports, including
|
|
19
|
+
* shared chunks. The graph is reused only while all of them exist.
|
|
20
|
+
*/
|
|
21
|
+
outputImports: string[];
|
|
17
22
|
}
|
|
18
23
|
export declare function isPagesUnifiedGraphEnabled(): boolean;
|
|
19
24
|
/** True when the unified graph should build or serve prebuilt page modules. */
|
|
@@ -15,8 +15,9 @@ import { createServerBuildRequest, resolveServerAppBuildPlugins } from '../runti
|
|
|
15
15
|
import { createBuildInputsFingerprint, hashAppConfigFile } from './build-input-fingerprint.js';
|
|
16
16
|
import { isProductionCacheManifestCurrent, matchesProductionCacheBuildKey, matchesProductionCacheFingerprint, readProductionCacheManifest, writeProductionCacheManifest, } from './production-build-cache.js';
|
|
17
17
|
import { getCorePackageVersion } from './cache-keys.js';
|
|
18
|
+
import { collectReachableLocalImports } from './output-imports.js';
|
|
18
19
|
import { resolveInternalExecutionDir } from '../../utils/resolve-work-dir.js';
|
|
19
|
-
import { getSharedRouteModuleBuildCache } from '../../services/module-loading/route-module-build-cache-registry.js';
|
|
20
|
+
import { getServerModuleBuildCacheOutdir, getSharedRouteModuleBuildCache, } from '../../services/module-loading/route-module-build-cache-registry.js';
|
|
20
21
|
import { resolveRouteModuleDependencyPaths } from '../../services/module-loading/route-module-dependency-hasher.js';
|
|
21
22
|
export const PAGES_UNIFIED_GRAPH_CACHE_DIR = '.server-pages-graph';
|
|
22
23
|
export const PAGES_UNIFIED_GRAPH_CACHE_FILENAME = '.build-cache.json';
|
|
@@ -95,21 +96,39 @@ function resolveOutputForEntrypoint(entryPath, entryKey, buildResult) {
|
|
|
95
96
|
}
|
|
96
97
|
return undefined;
|
|
97
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Whether `manifest` was written by the current core version, build inputs and graph
|
|
101
|
+
* setup, and every file its outputs import still exists.
|
|
102
|
+
*/
|
|
103
|
+
function isGraphManifestCurrent(manifest, appConfig, outdir) {
|
|
104
|
+
return (isProductionCacheManifestCurrent(manifest, getCorePackageVersion()) &&
|
|
105
|
+
matchesProductionCacheFingerprint(manifest, createBuildInputsFingerprint(appConfig)) &&
|
|
106
|
+
matchesProductionCacheBuildKey(manifest, createPagesUnifiedGraphBuildKey(appConfig, outdir)) &&
|
|
107
|
+
manifest.outputImports?.every((filePath) => fileSystem.exists(filePath)) === true);
|
|
108
|
+
}
|
|
98
109
|
function isManifestValidForEntries(manifest, appConfig, outdir, entryPaths) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
return (isGraphManifestCurrent(manifest, appConfig, outdir) &&
|
|
111
|
+
entryPaths.every((entryPath) => {
|
|
112
|
+
const outputPath = manifest.outputs[path.resolve(entryPath)];
|
|
113
|
+
return outputPath ? fileSystem.exists(outputPath) : false;
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
const importableGraphs = new WeakMap();
|
|
117
|
+
/**
|
|
118
|
+
* {@link isGraphManifestCurrent} for page imports, memoized per manifest write.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
* Page modules can be imported before the static site generator calls
|
|
122
|
+
* {@link ensurePagesUnifiedGraphBuilt} (for example while collecting static
|
|
123
|
+
* paths), so the import path must not trust a manifest left by an older build.
|
|
124
|
+
*/
|
|
125
|
+
function isGraphImportable(manifest, appConfig) {
|
|
126
|
+
const known = importableGraphs.get(appConfig);
|
|
127
|
+
if (known?.builtAt === manifest.builtAt)
|
|
128
|
+
return known.current;
|
|
129
|
+
const current = isGraphManifestCurrent(manifest, appConfig, getServerModuleBuildCacheOutdir(appConfig));
|
|
130
|
+
importableGraphs.set(appConfig, { builtAt: manifest.builtAt, current });
|
|
131
|
+
return current;
|
|
113
132
|
}
|
|
114
133
|
/**
|
|
115
134
|
* Builds eligible static pages in one Rolldown invocation and seeds route-module disk cache.
|
|
@@ -155,6 +174,7 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
|
|
|
155
174
|
throw new Error(`Pages unified graph build failed: ${details}`);
|
|
156
175
|
}
|
|
157
176
|
const outputs = {};
|
|
177
|
+
const outputImports = new Set();
|
|
158
178
|
for (const entryPath of eligibleEntryPaths) {
|
|
159
179
|
const fileHash = fileSystem.hash(entryPath);
|
|
160
180
|
const entryKey = entryKeysByPath.get(entryPath);
|
|
@@ -163,6 +183,9 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
|
|
|
163
183
|
throw new Error(`Pages unified graph build produced no output for ${entryPath}`);
|
|
164
184
|
}
|
|
165
185
|
outputs[entryPath] = compiledOutput;
|
|
186
|
+
const compiledOutputImports = collectReachableLocalImports(compiledOutput);
|
|
187
|
+
for (const importPath of compiledOutputImports)
|
|
188
|
+
outputImports.add(importPath);
|
|
166
189
|
routeModuleBuildCache.recordBuild({
|
|
167
190
|
filePath: entryPath,
|
|
168
191
|
rootDir: options.appConfig.rootDir,
|
|
@@ -172,14 +195,16 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
|
|
|
172
195
|
dependencyModulePaths: resolveRouteModuleDependencyPaths(buildResult, entryPath, options.appConfig.rootDir),
|
|
173
196
|
externalPackages: true,
|
|
174
197
|
plugins,
|
|
198
|
+
outputImports: compiledOutputImports,
|
|
175
199
|
});
|
|
176
200
|
}
|
|
177
201
|
const manifest = {
|
|
178
|
-
|
|
202
|
+
corePackageVersion: getCorePackageVersion(),
|
|
179
203
|
buildInputsFingerprint: createBuildInputsFingerprint(options.appConfig),
|
|
180
204
|
buildKey: createPagesUnifiedGraphBuildKey(options.appConfig, outdir),
|
|
181
205
|
builtAt: Date.now(),
|
|
182
206
|
outputs,
|
|
207
|
+
outputImports: [...outputImports],
|
|
183
208
|
};
|
|
184
209
|
writePagesUnifiedGraphManifest(options.appConfig, manifest);
|
|
185
210
|
appLogger.debug(`Built pages unified graph for ${eligibleEntryPaths.length} entries`);
|
|
@@ -187,7 +212,7 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
|
|
|
187
212
|
}
|
|
188
213
|
export async function importPagesUnifiedGraphModule(appConfig, filePath) {
|
|
189
214
|
const manifest = readPagesUnifiedGraphManifest(appConfig);
|
|
190
|
-
if (!manifest) {
|
|
215
|
+
if (!manifest || !isGraphImportable(manifest, appConfig)) {
|
|
191
216
|
return undefined;
|
|
192
217
|
}
|
|
193
218
|
const resolvedFilePath = path.resolve(filePath);
|
|
@@ -3,7 +3,7 @@ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
|
3
3
|
* Shared manifest fields for persisted production build caches.
|
|
4
4
|
*/
|
|
5
5
|
export interface ProductionCacheManifestBase {
|
|
6
|
-
|
|
6
|
+
/** `getCorePackageVersion()` of the build that wrote the manifest. */
|
|
7
7
|
corePackageVersion?: string;
|
|
8
8
|
buildInputsFingerprint?: string;
|
|
9
9
|
buildKey?: string;
|
|
@@ -16,6 +16,6 @@ export declare function getProductionBuildCacheManifestPaths(appConfig: EcoPages
|
|
|
16
16
|
export declare function clearPersistedProductionBuildCacheManifests(appConfig: EcoPagesAppConfig): void;
|
|
17
17
|
export declare function readProductionCacheManifest<T extends ProductionCacheManifestBase>(manifestPath: string): T | undefined;
|
|
18
18
|
export declare function writeProductionCacheManifest(manifestPath: string, manifest: unknown): void;
|
|
19
|
-
export declare function isProductionCacheManifestCurrent(manifest: ProductionCacheManifestBase | undefined,
|
|
19
|
+
export declare function isProductionCacheManifestCurrent(manifest: ProductionCacheManifestBase | undefined, corePackageVersion: string): boolean;
|
|
20
20
|
export declare function matchesProductionCacheFingerprint(manifest: ProductionCacheManifestBase | undefined, buildInputsFingerprint: string): boolean;
|
|
21
21
|
export declare function matchesProductionCacheBuildKey(manifest: ProductionCacheManifestBase | undefined, buildKey: string): boolean;
|
|
@@ -45,8 +45,8 @@ export function writeProductionCacheManifest(manifestPath, manifest) {
|
|
|
45
45
|
fileSystem.ensureDir(path.dirname(manifestPath));
|
|
46
46
|
fileSystem.write(manifestPath, `${JSON.stringify(manifest, null, '\t')}\n`);
|
|
47
47
|
}
|
|
48
|
-
export function isProductionCacheManifestCurrent(manifest,
|
|
49
|
-
return
|
|
48
|
+
export function isProductionCacheManifestCurrent(manifest, corePackageVersion) {
|
|
49
|
+
return manifest?.corePackageVersion === corePackageVersion;
|
|
50
50
|
}
|
|
51
51
|
export function matchesProductionCacheFingerprint(manifest, buildInputsFingerprint) {
|
|
52
52
|
return manifest?.buildInputsFingerprint === buildInputsFingerprint;
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import type { BuildResult } from '../build-adapter.js';
|
|
2
2
|
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
3
|
-
export { SERVER_ENTRY_BUILD_CACHE_FILENAME } from './cache-constants.js';
|
|
4
3
|
export declare const SERVER_BUNDLE_MANIFEST_FILENAME = "manifest.json";
|
|
5
4
|
export interface ServerBundleDeployManifest {
|
|
6
5
|
serverEntry: string;
|
|
7
6
|
distDir: string;
|
|
8
7
|
builtAt: number;
|
|
8
|
+
/** Canonical source config path compiled into the server bundle. */
|
|
9
|
+
sourceConfigPath?: string;
|
|
10
|
+
/** Relative source config path from project root. */
|
|
11
|
+
sourceConfigRelativePath?: string;
|
|
12
|
+
/** Deployed config module path relative to the server bundle directory. */
|
|
13
|
+
emittedConfigModule?: string;
|
|
14
|
+
/** Content hash of the source config file when built. */
|
|
15
|
+
configHash?: string;
|
|
16
|
+
/** Content hash of the emitted production config artifact. */
|
|
17
|
+
emittedConfigHash?: string;
|
|
9
18
|
}
|
|
10
19
|
export interface ServerEntryBuildCacheManifest {
|
|
11
|
-
|
|
20
|
+
corePackageVersion: string;
|
|
12
21
|
entryPath: string;
|
|
13
22
|
entryHash: string;
|
|
23
|
+
configHash: string;
|
|
14
24
|
buildInputsFingerprint: string;
|
|
15
25
|
buildKey: string;
|
|
16
26
|
outputPaths: string[];
|
|
@@ -28,7 +38,18 @@ export declare function getServerBundleOutputPaths(appConfig: EcoPagesAppConfig)
|
|
|
28
38
|
manifestPath: string;
|
|
29
39
|
};
|
|
30
40
|
export declare function readServerEntryBuildCacheManifest(appConfig: EcoPagesAppConfig): ServerEntryBuildCacheManifest | undefined;
|
|
31
|
-
export declare function writeServerBundleDeployManifest(appConfig: EcoPagesAppConfig, serverEntryPath: string
|
|
41
|
+
export declare function writeServerBundleDeployManifest(appConfig: EcoPagesAppConfig, serverEntryPath: string, options?: Pick<ServerBundleDeployManifest, 'sourceConfigPath' | 'emittedConfigModule'> & {
|
|
42
|
+
outputDir?: string;
|
|
43
|
+
}): void;
|
|
44
|
+
export declare function readServerBundleDeployManifest(appConfig: EcoPagesAppConfig): ServerBundleDeployManifest | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* @remarks
|
|
47
|
+
* Production `start` must not load a different config than the one compiled into the bundle.
|
|
48
|
+
*/
|
|
49
|
+
export declare function assertProductionConfigIdentity(appConfigOrCwd: EcoPagesAppConfig | string, requestedConfigPath: string | undefined, options?: {
|
|
50
|
+
isExplicitOverride?: boolean;
|
|
51
|
+
}): void;
|
|
52
|
+
export declare function readServerBundleDeployManifestFromDir(cwd?: string): ServerBundleDeployManifest | undefined;
|
|
32
53
|
export declare function lookupServerEntryBuildCache(options: {
|
|
33
54
|
appConfig: EcoPagesAppConfig;
|
|
34
55
|
entryPath: string;
|
|
@@ -38,6 +59,7 @@ export declare function recordServerEntryBuildCache(options: {
|
|
|
38
59
|
appConfig: EcoPagesAppConfig;
|
|
39
60
|
entryPath: string;
|
|
40
61
|
buildResult: BuildResult;
|
|
62
|
+
configBuildResult?: BuildResult;
|
|
41
63
|
outputPaths: string[];
|
|
42
64
|
}): void;
|
|
43
65
|
export declare function resolveProductionServerEntry(cwd?: string): string | undefined;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { resolveServerAppBuildPlugins } from '../runtime/build-request-policy.js';
|
|
4
|
-
import { createBuildInputsFingerprint } from './build-input-fingerprint.js';
|
|
4
|
+
import { createBuildInputsFingerprint, hashAppConfigFile } from './build-input-fingerprint.js';
|
|
5
5
|
import { isProductionCacheManifestCurrent, matchesProductionCacheBuildKey, matchesProductionCacheFingerprint, readProductionCacheManifest, writeProductionCacheManifest, } from './production-build-cache.js';
|
|
6
6
|
import { createPluginCacheKey, getCorePackageVersion } from './cache-keys.js';
|
|
7
7
|
import { RouteModuleDependencyHasher, createRouteModuleDependencyHashes, } from '../../services/module-loading/route-module-dependency-hasher.js';
|
|
8
8
|
import { resolveInternalExecutionDir } from '../../utils/resolve-work-dir.js';
|
|
9
9
|
import { SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME } from '../../utils/resolve-entry-file.js';
|
|
10
|
-
import {
|
|
11
|
-
export { SERVER_ENTRY_BUILD_CACHE_FILENAME } from './cache-constants.js';
|
|
10
|
+
import { ROUTE_MODULE_BUILD_CACHE_FILENAME } from './cache-constants.js';
|
|
12
11
|
export const SERVER_BUNDLE_MANIFEST_FILENAME = 'manifest.json';
|
|
13
12
|
function getServerEntryCacheDir(appConfig) {
|
|
14
13
|
return path.join(resolveInternalExecutionDir(appConfig), '.server-entry');
|
|
15
14
|
}
|
|
16
15
|
function getServerEntryCacheManifestPath(appConfig) {
|
|
17
|
-
return path.join(getServerEntryCacheDir(appConfig),
|
|
16
|
+
return path.join(getServerEntryCacheDir(appConfig), ROUTE_MODULE_BUILD_CACHE_FILENAME);
|
|
18
17
|
}
|
|
19
18
|
function hashDependencyGraph(entryPath, dependencyGraph, hasher, rootDir) {
|
|
20
19
|
if (!dependencyGraph) {
|
|
@@ -55,18 +54,127 @@ export function readServerEntryBuildCacheManifest(appConfig) {
|
|
|
55
54
|
return readProductionCacheManifest(getServerEntryCacheManifestPath(appConfig));
|
|
56
55
|
}
|
|
57
56
|
function writeServerEntryBuildCacheManifest(appConfig, manifest) {
|
|
58
|
-
writeProductionCacheManifest(path.join(getServerEntryCacheDir(appConfig),
|
|
57
|
+
writeProductionCacheManifest(path.join(getServerEntryCacheDir(appConfig), ROUTE_MODULE_BUILD_CACHE_FILENAME), manifest);
|
|
59
58
|
}
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
function hashExistingFile(filePath) {
|
|
60
|
+
return filePath && fileSystem.exists(filePath) ? fileSystem.hash(filePath) : undefined;
|
|
61
|
+
}
|
|
62
|
+
export function writeServerBundleDeployManifest(appConfig, serverEntryPath, options) {
|
|
63
|
+
const { distDir, manifestPath: defaultManifestPath } = getServerBundleOutputPaths(appConfig);
|
|
64
|
+
const manifestPath = options?.outputDir
|
|
65
|
+
? path.join(options.outputDir, SERVER_BUNDLE_MANIFEST_FILENAME)
|
|
66
|
+
: defaultManifestPath;
|
|
62
67
|
fileSystem.ensureDir(path.dirname(manifestPath));
|
|
68
|
+
const sourceConfigPath = options?.sourceConfigPath ?? appConfig.absolutePaths?.config;
|
|
69
|
+
const emittedConfigPath = options?.emittedConfigModule
|
|
70
|
+
? path.resolve(path.dirname(manifestPath), options.emittedConfigModule)
|
|
71
|
+
: undefined;
|
|
63
72
|
const payload = {
|
|
64
73
|
serverEntry: path.relative(path.dirname(manifestPath), serverEntryPath) || SERVER_BUNDLE_FILENAME,
|
|
65
74
|
distDir,
|
|
66
75
|
builtAt: Date.now(),
|
|
76
|
+
sourceConfigPath,
|
|
77
|
+
sourceConfigRelativePath: sourceConfigPath ? path.relative(appConfig.rootDir, sourceConfigPath) : undefined,
|
|
78
|
+
emittedConfigModule: options?.emittedConfigModule,
|
|
79
|
+
configHash: hashExistingFile(sourceConfigPath),
|
|
80
|
+
emittedConfigHash: hashExistingFile(emittedConfigPath),
|
|
67
81
|
};
|
|
68
82
|
fileSystem.write(manifestPath, `${JSON.stringify(payload, null, '\t')}\n`);
|
|
69
83
|
}
|
|
84
|
+
export function readServerBundleDeployManifest(appConfig) {
|
|
85
|
+
const { manifestPath } = getServerBundleOutputPaths(appConfig);
|
|
86
|
+
if (!fileSystem.exists(manifestPath)) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
return JSON.parse(fileSystem.readFileSync(manifestPath).toString());
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function isEmittedConfigArtifact(manifest, manifestDir, requestedPath) {
|
|
97
|
+
if (!manifest.emittedConfigModule) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
const emittedArtifactPath = path.resolve(manifestDir, manifest.emittedConfigModule);
|
|
101
|
+
if (path.resolve(requestedPath) !== emittedArtifactPath)
|
|
102
|
+
return false;
|
|
103
|
+
return (!manifest.emittedConfigHash ||
|
|
104
|
+
(fileSystem.exists(requestedPath) && fileSystem.hash(requestedPath) === manifest.emittedConfigHash));
|
|
105
|
+
}
|
|
106
|
+
function matchesBuiltConfigHash(manifest, requestedPath) {
|
|
107
|
+
if (!manifest.configHash || !fileSystem.exists(requestedPath)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return fileSystem.hash(requestedPath) === manifest.configHash;
|
|
111
|
+
}
|
|
112
|
+
function matchesBuiltConfigPath(manifest, cwd, requestedPath, isExplicitOverride) {
|
|
113
|
+
if (manifest.configHash)
|
|
114
|
+
return false;
|
|
115
|
+
if (!isExplicitOverride && manifest.sourceConfigRelativePath) {
|
|
116
|
+
if (path.relative(cwd, requestedPath) === manifest.sourceConfigRelativePath) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (manifest.sourceConfigPath && path.resolve(requestedPath) === path.resolve(manifest.sourceConfigPath)) {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
function readDeployManifest(appConfigOrCwd) {
|
|
126
|
+
return typeof appConfigOrCwd === 'string'
|
|
127
|
+
? readServerBundleDeployManifestFromDir(appConfigOrCwd)
|
|
128
|
+
: readServerBundleDeployManifest(appConfigOrCwd);
|
|
129
|
+
}
|
|
130
|
+
function hasConfigIdentity(manifest) {
|
|
131
|
+
return Boolean(manifest.emittedConfigModule ||
|
|
132
|
+
manifest.configHash ||
|
|
133
|
+
manifest.sourceConfigPath ||
|
|
134
|
+
manifest.sourceConfigRelativePath);
|
|
135
|
+
}
|
|
136
|
+
function resolveDeployManifestDirectory(appConfigOrCwd) {
|
|
137
|
+
return typeof appConfigOrCwd === 'string'
|
|
138
|
+
? path.join(appConfigOrCwd, 'dist', SERVER_BUNDLE_DIR)
|
|
139
|
+
: getServerBundleOutputPaths(appConfigOrCwd).serverOutdir;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @remarks
|
|
143
|
+
* Production `start` must not load a different config than the one compiled into the bundle.
|
|
144
|
+
*/
|
|
145
|
+
export function assertProductionConfigIdentity(appConfigOrCwd, requestedConfigPath, options) {
|
|
146
|
+
if (!requestedConfigPath) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const manifest = readDeployManifest(appConfigOrCwd);
|
|
150
|
+
if (!manifest || !hasConfigIdentity(manifest))
|
|
151
|
+
return;
|
|
152
|
+
const manifestDir = resolveDeployManifestDirectory(appConfigOrCwd);
|
|
153
|
+
if (isEmittedConfigArtifact(manifest, manifestDir, requestedConfigPath)) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (matchesBuiltConfigHash(manifest, requestedConfigPath)) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const cwd = typeof appConfigOrCwd === 'string' ? appConfigOrCwd : appConfigOrCwd.rootDir;
|
|
160
|
+
if (matchesBuiltConfigPath(manifest, cwd, requestedConfigPath, options?.isExplicitOverride)) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const expected = manifest.sourceConfigRelativePath ?? manifest.sourceConfigPath ?? 'bundled config';
|
|
164
|
+
throw new Error(`Ecopages config mismatch: production bundle was built with ${expected}, but start requested ${requestedConfigPath}.`);
|
|
165
|
+
}
|
|
166
|
+
export function readServerBundleDeployManifestFromDir(cwd = process.cwd()) {
|
|
167
|
+
const manifestPath = path.join(cwd, 'dist', SERVER_BUNDLE_DIR, SERVER_BUNDLE_MANIFEST_FILENAME);
|
|
168
|
+
if (!fileSystem.exists(manifestPath)) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
return JSON.parse(fileSystem.readFileSync(manifestPath).toString());
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
70
178
|
export function lookupServerEntryBuildCache(options) {
|
|
71
179
|
if (options.force) {
|
|
72
180
|
return undefined;
|
|
@@ -76,6 +184,7 @@ export function lookupServerEntryBuildCache(options) {
|
|
|
76
184
|
}
|
|
77
185
|
const entryPath = path.resolve(options.entryPath);
|
|
78
186
|
const entryHash = fileSystem.hash(entryPath);
|
|
187
|
+
const configHash = hashAppConfigFile(options.appConfig);
|
|
79
188
|
const buildInputsFingerprint = createBuildInputsFingerprint(options.appConfig);
|
|
80
189
|
const buildKey = createServerEntryBuildKey(options.appConfig);
|
|
81
190
|
const manifest = readServerEntryBuildCacheManifest(options.appConfig);
|
|
@@ -87,6 +196,7 @@ export function lookupServerEntryBuildCache(options) {
|
|
|
87
196
|
}
|
|
88
197
|
if (manifest.entryPath !== entryPath ||
|
|
89
198
|
manifest.entryHash !== entryHash ||
|
|
199
|
+
manifest.configHash !== configHash ||
|
|
90
200
|
!matchesProductionCacheFingerprint(manifest, buildInputsFingerprint) ||
|
|
91
201
|
!matchesProductionCacheBuildKey(manifest, buildKey)) {
|
|
92
202
|
return undefined;
|
|
@@ -95,13 +205,13 @@ export function lookupServerEntryBuildCache(options) {
|
|
|
95
205
|
if (!hasher.matchesStoredHashes(manifest.dependencyHashes, entryPath, entryHash)) {
|
|
96
206
|
return undefined;
|
|
97
207
|
}
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
208
|
+
const allOutputsExist = manifest.outputPaths.length > 0 && manifest.outputPaths.every((outputPath) => fileSystem.exists(outputPath));
|
|
209
|
+
if (!allOutputsExist) {
|
|
100
210
|
return undefined;
|
|
101
211
|
}
|
|
102
212
|
return {
|
|
103
213
|
manifest,
|
|
104
|
-
outputPaths:
|
|
214
|
+
outputPaths: manifest.outputPaths,
|
|
105
215
|
};
|
|
106
216
|
}
|
|
107
217
|
export function recordServerEntryBuildCache(options) {
|
|
@@ -110,12 +220,18 @@ export function recordServerEntryBuildCache(options) {
|
|
|
110
220
|
}
|
|
111
221
|
const entryPath = path.resolve(options.entryPath);
|
|
112
222
|
const entryHash = fileSystem.hash(entryPath);
|
|
223
|
+
const configHash = hashAppConfigFile(options.appConfig);
|
|
113
224
|
const hasher = new RouteModuleDependencyHasher();
|
|
114
|
-
const
|
|
225
|
+
const appDependencyHashes = hashDependencyGraph(entryPath, options.buildResult.dependencyGraph, hasher, options.appConfig.rootDir);
|
|
226
|
+
const configDependencyHashes = options.appConfig.absolutePaths?.config && options.configBuildResult?.dependencyGraph
|
|
227
|
+
? hashDependencyGraph(options.appConfig.absolutePaths.config, options.configBuildResult.dependencyGraph, hasher, options.appConfig.rootDir)
|
|
228
|
+
: {};
|
|
229
|
+
const dependencyHashes = { ...appDependencyHashes, ...configDependencyHashes };
|
|
115
230
|
const manifest = {
|
|
116
|
-
|
|
231
|
+
corePackageVersion: getCorePackageVersion(),
|
|
117
232
|
entryPath,
|
|
118
233
|
entryHash,
|
|
234
|
+
configHash,
|
|
119
235
|
buildInputsFingerprint: createBuildInputsFingerprint(options.appConfig),
|
|
120
236
|
buildKey: createServerEntryBuildKey(options.appConfig),
|
|
121
237
|
outputPaths: options.outputPaths,
|
|
@@ -128,7 +244,7 @@ export function resolveProductionServerEntry(cwd = process.cwd()) {
|
|
|
128
244
|
const manifestPath = path.join(cwd, 'dist', SERVER_BUNDLE_DIR, SERVER_BUNDLE_MANIFEST_FILENAME);
|
|
129
245
|
if (fileSystem.exists(manifestPath)) {
|
|
130
246
|
try {
|
|
131
|
-
const parsed = JSON.parse(fileSystem.readFileSync(manifestPath));
|
|
247
|
+
const parsed = JSON.parse(fileSystem.readFileSync(manifestPath).toString());
|
|
132
248
|
if (parsed?.serverEntry) {
|
|
133
249
|
const fromManifest = path.isAbsolute(parsed.serverEntry)
|
|
134
250
|
? parsed.serverEntry
|
|
@@ -34,21 +34,11 @@ export interface BuildResult {
|
|
|
34
34
|
*
|
|
35
35
|
* @remarks
|
|
36
36
|
* Fields that the adapter can forward are honored. `splitting: false` disables
|
|
37
|
-
* Rolldown code splitting for single-entrypoint builds.
|
|
38
|
-
* are accepted for call-site compatibility but ignored.
|
|
37
|
+
* Rolldown code splitting for single-entrypoint builds.
|
|
39
38
|
*/
|
|
40
39
|
export interface BuildOptions {
|
|
41
40
|
entrypoints: string[] | Record<string, string>;
|
|
42
41
|
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
42
|
naming?: string;
|
|
53
43
|
conditions?: string[];
|
|
54
44
|
define?: Record<string, string>;
|
|
@@ -60,8 +50,6 @@ export interface BuildOptions {
|
|
|
60
50
|
/** When `false` with a single entrypoint, inlines dynamic imports into one output file. */
|
|
61
51
|
splitting?: boolean;
|
|
62
52
|
root?: string;
|
|
63
|
-
/** @deprecated Accepted for call-site compatibility only. */
|
|
64
|
-
bundle?: boolean;
|
|
65
53
|
externalPackages?: boolean;
|
|
66
54
|
external?: string[];
|
|
67
55
|
jsx?: {
|
|
@@ -4,9 +4,11 @@ export declare const CONTENT_VIRTUAL_MODULE_PREFIX = "ecopages:content";
|
|
|
4
4
|
export declare const CONTENT_VIRTUAL_MODULE_PATTERN: RegExp;
|
|
5
5
|
/** Matches `ecopages:content/<collection>/server` component resolver specifiers. */
|
|
6
6
|
export declare const CONTENT_SERVER_VIRTUAL_MODULE_PATTERN: RegExp;
|
|
7
|
+
/** Matches browser-only `ecopages:content/<collection>/browser` component loader specifiers. */
|
|
8
|
+
export declare const CONTENT_BROWSER_VIRTUAL_MODULE_PATTERN: RegExp;
|
|
7
9
|
export type ParsedCollectionSpecifier = {
|
|
8
10
|
collectionName: string;
|
|
9
|
-
variant: 'entries' | 'server';
|
|
11
|
+
variant: 'entries' | 'server' | 'browser';
|
|
10
12
|
};
|
|
11
13
|
export declare function parseCollectionSpecifier(specifier: string): ParsedCollectionSpecifier | null;
|
|
12
14
|
export declare function isContentServerVirtualModule(specifier: string): boolean;
|
|
@@ -4,6 +4,8 @@ export const CONTENT_VIRTUAL_MODULE_PREFIX = 'ecopages:content';
|
|
|
4
4
|
export const CONTENT_VIRTUAL_MODULE_PATTERN = /^ecopages:content\/[a-z][a-z0-9-]*$/;
|
|
5
5
|
/** Matches `ecopages:content/<collection>/server` component resolver specifiers. */
|
|
6
6
|
export const CONTENT_SERVER_VIRTUAL_MODULE_PATTERN = /^ecopages:content\/[a-z][a-z0-9-]+\/server$/;
|
|
7
|
+
/** Matches browser-only `ecopages:content/<collection>/browser` component loader specifiers. */
|
|
8
|
+
export const CONTENT_BROWSER_VIRTUAL_MODULE_PATTERN = /^ecopages:content\/[a-z][a-z0-9-]+\/browser$/;
|
|
7
9
|
export function parseCollectionSpecifier(specifier) {
|
|
8
10
|
const normalized = specifier.startsWith(`${CONTENT_VIRTUAL_MODULE_PREFIX}/`)
|
|
9
11
|
? specifier.slice(`${CONTENT_VIRTUAL_MODULE_PREFIX}/`.length)
|
|
@@ -19,6 +21,12 @@ export function parseCollectionSpecifier(specifier) {
|
|
|
19
21
|
variant: 'server',
|
|
20
22
|
};
|
|
21
23
|
}
|
|
24
|
+
if (normalized.endsWith('/browser')) {
|
|
25
|
+
return {
|
|
26
|
+
collectionName: normalized.slice(0, -'/browser'.length),
|
|
27
|
+
variant: 'browser',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
22
30
|
return {
|
|
23
31
|
collectionName: normalized,
|
|
24
32
|
variant: 'entries',
|