@ecopages/core 0.2.0-beta.1 → 0.2.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +107 -3
- package/src/adapters/abstract/application-adapter.d.ts +73 -1
- package/src/adapters/abstract/application-adapter.js +89 -0
- package/src/adapters/abstract/server-adapter.d.ts +3 -0
- package/src/adapters/abstract/ws-pattern-matcher.d.ts +60 -0
- package/src/adapters/abstract/ws-pattern-matcher.js +61 -0
- package/src/adapters/bun/client-bridge.d.ts +1 -0
- package/src/adapters/bun/client-bridge.js +3 -0
- package/src/adapters/bun/create-app.d.ts +5 -3
- package/src/adapters/bun/create-app.js +44 -39
- package/src/adapters/bun/hmr-manager.d.ts +2 -1
- package/src/adapters/bun/hmr-manager.js +2 -2
- package/src/adapters/bun/server-adapter.d.ts +81 -20
- package/src/adapters/bun/server-adapter.js +220 -78
- package/src/adapters/bun/static-preview-host.js +25 -20
- package/src/adapters/create-app.d.ts +13 -0
- package/src/adapters/create-app.js +10 -1
- package/src/adapters/node/create-app.d.ts +4 -0
- package/src/adapters/node/create-app.js +38 -9
- package/src/adapters/node/node-client-bridge.d.ts +1 -0
- package/src/adapters/node/node-client-bridge.js +3 -0
- package/src/adapters/node/node-hmr-manager.d.ts +2 -1
- package/src/adapters/node/node-hmr-manager.js +2 -2
- package/src/adapters/node/server-adapter-dependencies.js +2 -0
- package/src/adapters/node/server-adapter.d.ts +55 -19
- package/src/adapters/node/server-adapter.js +140 -132
- package/src/adapters/node/static-content-server.d.ts +1 -0
- package/src/adapters/node/static-content-server.js +10 -2
- package/src/adapters/node/static-preview-host.js +27 -12
- package/src/adapters/shared/bun-user-websocket-lifecycle.d.ts +22 -0
- package/src/adapters/shared/bun-user-websocket-lifecycle.js +96 -0
- package/src/adapters/shared/copy-runtime-public-dir.d.ts +6 -0
- package/src/adapters/shared/copy-runtime-public-dir.js +24 -0
- package/src/adapters/shared/hmr-html-response.d.ts +1 -1
- package/src/adapters/shared/hmr-html-response.js +4 -1
- package/src/adapters/shared/node-http-websocket-upgrades.d.ts +21 -0
- package/src/adapters/shared/node-http-websocket-upgrades.js +100 -0
- package/src/adapters/shared/port-manager.d.ts +116 -0
- package/src/adapters/shared/port-manager.js +196 -0
- package/src/adapters/shared/runtime-app-bootstrap.d.ts +2 -1
- package/src/adapters/shared/runtime-app-bootstrap.js +3 -6
- package/src/adapters/shared/runtime-server-lifecycle.d.ts +38 -0
- package/src/adapters/shared/runtime-server-lifecycle.js +39 -0
- package/src/adapters/shared/server-adapter.d.ts +2 -1
- package/src/adapters/shared/server-adapter.js +12 -4
- package/src/adapters/shared/server-route-handler.d.ts +4 -1
- package/src/adapters/shared/server-route-handler.js +5 -2
- package/src/adapters/shared/server-static-builder.d.ts +14 -29
- package/src/adapters/shared/server-static-builder.js +91 -70
- package/src/adapters/shared/shared-hmr-manager.d.ts +12 -0
- package/src/adapters/shared/shared-hmr-manager.js +64 -7
- package/src/adapters/shared/static-preview-host.d.ts +5 -0
- package/src/adapters/shared/websocket-lifecycle.d.ts +24 -0
- package/src/adapters/shared/websocket-lifecycle.js +55 -0
- package/src/build/README.md +77 -14
- package/src/build/app-build-manifest-runtime.d.ts +10 -0
- package/src/build/app-build-manifest-runtime.js +90 -0
- package/src/build/build-adapter.d.ts +17 -319
- package/src/build/build-adapter.js +28 -94
- package/src/build/build-contracts.d.ts +97 -0
- package/src/build/build-contracts.js +0 -0
- package/src/build/build-input-fingerprint.d.ts +28 -0
- package/src/build/build-input-fingerprint.js +31 -0
- package/src/build/build-profile-options.d.ts +7 -0
- package/src/build/build-profile-options.js +37 -0
- package/src/build/build-runtime.d.ts +24 -0
- package/src/build/build-runtime.js +65 -0
- package/src/build/deduping-build-executor.d.ts +28 -0
- package/src/build/deduping-build-executor.js +56 -0
- package/src/build/jsx-ownership-plugins.d.ts +24 -0
- package/src/build/jsx-ownership-plugins.js +41 -0
- package/src/build/pages-unified-graph-build.d.ts +31 -0
- package/src/build/pages-unified-graph-build.js +206 -0
- package/src/build/parallel-build-executor.d.ts +21 -0
- package/src/build/parallel-build-executor.js +52 -0
- package/src/build/production-build-cache.d.ts +20 -0
- package/src/build/production-build-cache.js +63 -0
- package/src/build/rolldown-adapter-helpers.d.ts +3 -6
- package/src/build/rolldown-adapter-helpers.js +71 -6
- package/src/build/rolldown-build-adapter.d.ts +2 -6
- package/src/build/rolldown-build-adapter.js +3 -3
- package/src/build/rolldown-build-invocation-metrics.d.ts +12 -0
- package/src/build/rolldown-build-invocation-metrics.js +43 -0
- package/src/build/rolldown-plugin-bridge.d.ts +15 -1
- package/src/build/rolldown-plugin-bridge.js +20 -5
- package/src/build/rolldown-source-transform-pass.d.ts +15 -0
- package/src/build/rolldown-source-transform-pass.js +58 -0
- package/src/build/runtime-build-executor.d.ts +8 -15
- package/src/build/runtime-build-executor.js +12 -15
- package/src/build/runtime-build-output-normalizer.d.ts +7 -0
- package/src/build/runtime-build-output-normalizer.js +94 -2
- package/src/build/server-entry-build-cache.d.ts +44 -0
- package/src/build/server-entry-build-cache.js +161 -0
- package/src/config/config-builder.d.ts +12 -7
- package/src/config/config-builder.js +12 -9
- package/src/dev/client-bridge-registry.d.ts +5 -0
- package/src/dev/client-bridge-registry.js +15 -0
- package/src/dev/dev-client-ownership.d.ts +7 -0
- package/src/dev/dev-client-ownership.js +6 -0
- package/src/dev/host-runtime.d.ts +3 -0
- package/src/dev/host-runtime.js +7 -0
- package/src/hmr/client/hmr-runtime.js +5 -2
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +17 -0
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +29 -0
- package/src/integrations/ghtml/ghtml-renderer.d.ts +2 -6
- package/src/integrations/ghtml/ghtml-renderer.js +2 -51
- package/src/integrations/ghtml/ghtml.plugin.d.ts +3 -16
- package/src/integrations/ghtml/ghtml.plugin.js +7 -14
- package/src/plugins/define-integration.d.ts +26 -0
- package/src/plugins/define-integration.js +19 -0
- package/src/plugins/eco-component-meta-plugin.js +5 -8
- package/src/plugins/foreign-jsx-override-plugin.js +4 -6
- package/src/plugins/integration-plugin.d.ts +19 -9
- package/src/plugins/integration-plugin.js +7 -4
- package/src/plugins/jsx-import-source.utils.d.ts +8 -0
- package/src/plugins/jsx-import-source.utils.js +26 -0
- package/src/plugins/processor.d.ts +19 -4
- package/src/plugins/processor.js +22 -4
- package/src/plugins/source-transform.d.ts +31 -0
- package/src/plugins/source-transform.js +23 -1
- package/src/route-renderer/GRAPH.md +8 -8
- package/src/route-renderer/README.md +30 -28
- package/src/route-renderer/orchestration/component-graph-collectors.d.ts +10 -0
- package/src/route-renderer/orchestration/component-graph-collectors.js +143 -0
- package/src/route-renderer/orchestration/component-graph.d.ts +36 -0
- package/src/route-renderer/orchestration/component-graph.js +90 -0
- package/src/route-renderer/orchestration/component-render-context.d.ts +3 -10
- package/src/route-renderer/orchestration/component-render-context.js +3 -1
- package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +1 -18
- package/src/route-renderer/orchestration/declared-ownership-graph.js +5 -31
- package/src/route-renderer/orchestration/document-shell-render.service.d.ts +54 -0
- package/src/route-renderer/orchestration/document-shell-render.service.js +54 -0
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts +59 -29
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +164 -35
- package/src/route-renderer/orchestration/global-injector-assets.service.d.ts +7 -0
- package/src/route-renderer/orchestration/global-injector-assets.service.js +32 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +18 -54
- package/src/route-renderer/orchestration/integration-renderer.js +108 -194
- package/src/route-renderer/orchestration/integration-route-render-adapter.d.ts +38 -0
- package/src/route-renderer/orchestration/integration-route-render-adapter.js +27 -0
- package/src/route-renderer/orchestration/ownership-validation.service.d.ts +4 -0
- package/src/route-renderer/orchestration/ownership-validation.service.js +11 -1
- package/src/route-renderer/orchestration/page-browser-graph-contribution.loader.d.ts +9 -0
- package/src/route-renderer/orchestration/page-browser-graph-contribution.loader.js +7 -0
- package/src/route-renderer/orchestration/page-browser-graph.service.d.ts +25 -0
- package/src/route-renderer/orchestration/page-browser-graph.service.js +174 -0
- package/src/route-renderer/orchestration/render-output.utils.d.ts +2 -0
- package/src/route-renderer/orchestration/render-output.utils.js +4 -0
- package/src/route-renderer/orchestration/route-html-finalization.service.d.ts +17 -0
- package/src/route-renderer/orchestration/route-html-finalization.service.js +26 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.d.ts +24 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.js +52 -0
- package/src/route-renderer/orchestration/route-prepared-options.utils.d.ts +4 -0
- package/src/route-renderer/orchestration/route-prepared-options.utils.js +33 -0
- package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +5 -38
- package/src/route-renderer/orchestration/route-render-orchestrator.js +51 -459
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +14 -0
- package/src/route-renderer/orchestration/string-markup-renderer.js +54 -0
- package/src/router/client/navigation-coordinator.d.ts +1 -1
- package/src/router/client/navigation-coordinator.js +12 -2
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +1 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +1 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +4 -2
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +27 -7
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +32 -14
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +17 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -31
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +2 -30
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +2 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +43 -0
- package/src/services/assets/browser-bundle.service.d.ts +3 -1
- package/src/services/assets/browser-bundle.service.js +17 -5
- package/src/services/html/html-transformer.service.d.ts +1 -1
- package/src/services/html/html-transformer.service.js +4 -4
- package/src/services/invalidation/development-invalidation.service.d.ts +10 -1
- package/src/services/invalidation/development-invalidation.service.js +31 -2
- package/src/services/module-loading/README.md +49 -0
- package/src/services/module-loading/app-server-module-transpiler.service.js +5 -17
- package/src/services/module-loading/page-module-import.service.d.ts +4 -1
- package/src/services/module-loading/page-module-import.service.js +61 -41
- package/src/services/module-loading/route-module-build-cache-registry.d.ts +24 -0
- package/src/services/module-loading/route-module-build-cache-registry.js +37 -0
- package/src/services/module-loading/route-module-build-cache.d.ts +4 -0
- package/src/services/module-loading/route-module-build-cache.js +38 -0
- package/src/services/module-loading/route-module-build-cache.store.d.ts +57 -0
- package/src/services/module-loading/route-module-build-cache.store.js +207 -0
- package/src/services/module-loading/route-module-build-manifest.d.ts +61 -0
- package/src/services/module-loading/route-module-build-manifest.js +116 -0
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +81 -0
- package/src/services/module-loading/route-module-dependency-hasher.js +121 -0
- package/src/services/module-loading/server-module-transpiler.service.js +1 -1
- package/src/static-site-generator/README.md +33 -0
- package/src/static-site-generator/static-build-invalidation.d.ts +10 -0
- package/src/static-site-generator/static-build-invalidation.js +59 -0
- package/src/static-site-generator/static-export-context.d.ts +22 -0
- package/src/static-site-generator/static-export-context.js +0 -0
- package/src/static-site-generator/static-site-generator.d.ts +17 -20
- package/src/static-site-generator/static-site-generator.js +188 -85
- package/src/types/internal-types.d.ts +12 -9
- package/src/types/public-types.d.ts +87 -22
- package/src/utils/parse-cli-args.d.ts +1 -0
- package/src/utils/parse-cli-args.js +3 -0
- package/src/watchers/project-watcher.d.ts +14 -2
- package/src/watchers/project-watcher.js +50 -20
- package/src/build/rolldown-dev-build-adapter.d.ts +0 -82
- package/src/build/rolldown-dev-build-adapter.js +0 -166
- package/src/hmr/hmr.postcss.test.e2e.d.ts +0 -1
- package/src/hmr/hmr.postcss.test.e2e.js +0 -31
- package/src/hmr/hmr.test.e2e.d.ts +0 -1
- package/src/hmr/hmr.test.e2e.js +0 -43
- package/src/route-renderer/orchestration/ownership-planning.service.d.ts +0 -24
- package/src/route-renderer/orchestration/ownership-planning.service.js +0 -63
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +0 -91
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +0 -170
|
@@ -2,13 +2,29 @@ import path from "node:path";
|
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import { fileSystem } from "@ecopages/file-system";
|
|
4
4
|
import { build } from "../../build/build-adapter.js";
|
|
5
|
+
import { resolveBuildProfileOptions } from "../../build/build-profile-options.js";
|
|
5
6
|
import { normalizeNodeRuntimeBuildOutputFile } from "../../build/runtime-build-output-normalizer.js";
|
|
7
|
+
import {
|
|
8
|
+
importPagesUnifiedGraphModule,
|
|
9
|
+
isPagesUnifiedGraphPage,
|
|
10
|
+
shouldBuildPagesUnifiedGraph
|
|
11
|
+
} from "../../build/pages-unified-graph-build.js";
|
|
12
|
+
import { recordPageModuleBuildInvocation } from "../../build/rolldown-build-invocation-metrics.js";
|
|
13
|
+
import {
|
|
14
|
+
resolvePageModuleOutputFileName,
|
|
15
|
+
createPluginCacheKey,
|
|
16
|
+
createJsxCacheKey
|
|
17
|
+
} from "./route-module-build-cache.js";
|
|
18
|
+
import { getSharedRouteModuleBuildCache } from "./route-module-build-cache-registry.js";
|
|
19
|
+
import { resolveRouteModuleDependencyPaths } from "./route-module-dependency-hasher.js";
|
|
6
20
|
import { supportsSourceModuleLoading } from "./source-module-support.js";
|
|
7
21
|
class PageModuleImportService {
|
|
22
|
+
appConfig;
|
|
8
23
|
dependencies;
|
|
9
24
|
importCache = /* @__PURE__ */ new Map();
|
|
10
25
|
developmentInvalidationVersion = 0;
|
|
11
|
-
constructor(dependencies) {
|
|
26
|
+
constructor(appConfig, dependencies) {
|
|
27
|
+
this.appConfig = appConfig;
|
|
12
28
|
this.dependencies = {
|
|
13
29
|
hashFile: dependencies?.hashFile ?? ((filePath) => fileSystem.hash(filePath)),
|
|
14
30
|
buildModule: dependencies?.buildModule ?? ((options, buildExecutor) => build(options, buildExecutor)),
|
|
@@ -70,6 +86,7 @@ class PageModuleImportService {
|
|
|
70
86
|
runtime,
|
|
71
87
|
filePath,
|
|
72
88
|
options.rootDir,
|
|
89
|
+
path.resolve(options.outdir),
|
|
73
90
|
splitting ?? "default",
|
|
74
91
|
externalPackages ?? "default",
|
|
75
92
|
options.cacheScope ?? "default",
|
|
@@ -104,39 +121,61 @@ class PageModuleImportService {
|
|
|
104
121
|
transpileErrorMessage = (details) => `Error transpiling page module: ${details}`,
|
|
105
122
|
noOutputMessage = (targetFilePath) => `No transpiled output generated for page module: ${targetFilePath}`
|
|
106
123
|
} = options;
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
124
|
+
const outputFileName = resolvePageModuleOutputFileName({
|
|
125
|
+
filePath,
|
|
126
|
+
fileHash,
|
|
127
|
+
cacheScope,
|
|
128
|
+
invalidationVersion
|
|
129
|
+
});
|
|
130
|
+
const outputNamingTemplate = outputFileName.replace(/\.mjs$/u, ".[ext]");
|
|
131
|
+
const preferredOutputPath = path.join(outdir, outputFileName);
|
|
132
|
+
const routeModuleBuildCache = this.getRouteModuleBuildCache(outdir);
|
|
133
|
+
const cachedBuild = routeModuleBuildCache.lookup({
|
|
134
|
+
...options,
|
|
135
|
+
fileHash
|
|
136
|
+
});
|
|
137
|
+
if (cachedBuild) {
|
|
138
|
+
return await import(
|
|
139
|
+
/* @vite-ignore */
|
|
140
|
+
pathToFileURL(cachedBuild.outputPath).href
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
if (!cacheScope && shouldBuildPagesUnifiedGraph() && this.appConfig && isPagesUnifiedGraphPage(filePath, this.appConfig)) {
|
|
144
|
+
const graphModule = await importPagesUnifiedGraphModule(this.appConfig, filePath);
|
|
145
|
+
if (graphModule !== void 0) {
|
|
146
|
+
return graphModule;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
recordPageModuleBuildInvocation();
|
|
150
|
+
const buildOptions = {
|
|
151
|
+
...resolveBuildProfileOptions("route-module", this.appConfig ?? { rootDir }, {
|
|
114
152
|
entrypoints: [filePath],
|
|
115
|
-
root: rootDir,
|
|
116
153
|
outdir,
|
|
117
|
-
target: "es2022",
|
|
118
|
-
format: "esm",
|
|
119
|
-
sourcemap: "none",
|
|
120
|
-
splitting: splitting ?? true,
|
|
121
|
-
minify: false,
|
|
122
154
|
naming: outputNamingTemplate,
|
|
123
|
-
|
|
155
|
+
splitting: splitting ?? true,
|
|
124
156
|
jsx: options.jsx,
|
|
125
157
|
plugins: options.plugins,
|
|
126
158
|
...externalPackages !== void 0 ? { externalPackages } : {}
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
|
|
159
|
+
}),
|
|
160
|
+
root: rootDir,
|
|
161
|
+
entrypoints: [filePath]
|
|
162
|
+
};
|
|
163
|
+
const buildResult = await this.dependencies.buildModule(buildOptions, options.buildExecutor);
|
|
130
164
|
if (!buildResult.success) {
|
|
131
165
|
const details = buildResult.logs.map((log) => log.message).join(" | ");
|
|
132
166
|
throw new Error(transpileErrorMessage(details));
|
|
133
167
|
}
|
|
134
|
-
const preferredOutputPath = path.join(outdir, outputFileName);
|
|
135
168
|
const compiledOutput = buildResult.outputs.find((output) => output.path === preferredOutputPath)?.path ?? buildResult.outputs.find((output) => /\.(?:[cm]?js)$/u.test(output.path))?.path;
|
|
136
169
|
if (!compiledOutput) {
|
|
137
170
|
throw new Error(noOutputMessage(filePath));
|
|
138
171
|
}
|
|
139
172
|
normalizeNodeRuntimeBuildOutputFile(compiledOutput, rootDir);
|
|
173
|
+
routeModuleBuildCache.recordBuild({
|
|
174
|
+
...options,
|
|
175
|
+
fileHash,
|
|
176
|
+
outputPath: compiledOutput,
|
|
177
|
+
dependencyModulePaths: resolveRouteModuleDependencyPaths(buildResult, filePath, rootDir)
|
|
178
|
+
});
|
|
140
179
|
const compiledOutputUrl = pathToFileURL(compiledOutput);
|
|
141
180
|
if (shouldAddRuntimeUpdateQuery(invalidationVersion, cacheScope)) {
|
|
142
181
|
compiledOutputUrl.searchParams.set(
|
|
@@ -149,6 +188,9 @@ class PageModuleImportService {
|
|
|
149
188
|
compiledOutputUrl.href
|
|
150
189
|
);
|
|
151
190
|
}
|
|
191
|
+
getRouteModuleBuildCache(outdir) {
|
|
192
|
+
return getSharedRouteModuleBuildCache(outdir, this.appConfig);
|
|
193
|
+
}
|
|
152
194
|
}
|
|
153
195
|
function createRuntimeModuleUrl(filePath, fileHash, invalidationVersion, cacheScope) {
|
|
154
196
|
const moduleUrl = pathToFileURL(filePath);
|
|
@@ -163,31 +205,9 @@ function createRuntimeModuleUrl(filePath, fileHash, invalidationVersion, cacheSc
|
|
|
163
205
|
function shouldAddRuntimeUpdateQuery(invalidationVersion, cacheScope) {
|
|
164
206
|
return process.env.NODE_ENV === "development" || invalidationVersion > 0 || !!cacheScope;
|
|
165
207
|
}
|
|
166
|
-
function shouldVersionBuildOutputPath(invalidationVersion) {
|
|
167
|
-
return typeof Bun !== "undefined" && invalidationVersion > 0;
|
|
168
|
-
}
|
|
169
208
|
function sanitizeCacheScope(cacheScope) {
|
|
170
209
|
return cacheScope.replace(/[^a-zA-Z0-9_-]+/g, "-");
|
|
171
210
|
}
|
|
172
|
-
function createJsxCacheKey(jsx) {
|
|
173
|
-
if (!jsx) {
|
|
174
|
-
return "jsx:default";
|
|
175
|
-
}
|
|
176
|
-
return JSON.stringify({
|
|
177
|
-
development: jsx.development ?? false,
|
|
178
|
-
factory: jsx.factory ?? null,
|
|
179
|
-
fragment: jsx.fragment ?? null,
|
|
180
|
-
importSource: jsx.importSource ?? null,
|
|
181
|
-
runtime: jsx.runtime ?? null,
|
|
182
|
-
sideEffects: jsx.sideEffects ?? null
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
function createPluginCacheKey(plugins) {
|
|
186
|
-
if (!plugins || plugins.length === 0) {
|
|
187
|
-
return "plugins:default";
|
|
188
|
-
}
|
|
189
|
-
return `plugins:${plugins.map((plugin) => plugin.name).join(",")}`;
|
|
190
|
-
}
|
|
191
211
|
export {
|
|
192
212
|
PageModuleImportService
|
|
193
213
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
2
|
+
import { RouteModuleBuildCache } from './route-module-build-cache.store.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the outdir whose transpile cache backs incremental static generation.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Static pages render through `.eco/.server-modules`. The manifest there carries
|
|
8
|
+
* import-graph hashes from transpile, so static-render reuse must read the same
|
|
9
|
+
* directory rather than `.server-route-modules`, which only serves route-registry
|
|
10
|
+
* scanning.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getServerModuleBuildCacheOutdir(appConfig: EcoPagesAppConfig): string;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use {@link getServerModuleBuildCacheOutdir}.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getRouteModuleBuildCacheOutdir: typeof getServerModuleBuildCacheOutdir;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the shared production build cache for one server-module outdir.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* One app-scoped instance prevents manifest drift between page imports and static
|
|
22
|
+
* generation during the same build process.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSharedRouteModuleBuildCache(outdir: string, appConfig?: EcoPagesAppConfig): RouteModuleBuildCache;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { resolveInternalExecutionDir } from "../../utils/resolve-work-dir.js";
|
|
3
|
+
import { RouteModuleBuildCache } from "./route-module-build-cache.store.js";
|
|
4
|
+
function getServerModuleBuildCacheOutdir(appConfig) {
|
|
5
|
+
return path.join(resolveInternalExecutionDir(appConfig), ".server-modules");
|
|
6
|
+
}
|
|
7
|
+
const getRouteModuleBuildCacheOutdir = getServerModuleBuildCacheOutdir;
|
|
8
|
+
function getRouteModuleBuildCacheMap(appConfig) {
|
|
9
|
+
const existing = appConfig.runtime?.routeModuleBuildCaches;
|
|
10
|
+
if (existing) {
|
|
11
|
+
return existing;
|
|
12
|
+
}
|
|
13
|
+
const routeModuleBuildCaches = /* @__PURE__ */ new Map();
|
|
14
|
+
appConfig.runtime = {
|
|
15
|
+
...appConfig.runtime ?? {},
|
|
16
|
+
routeModuleBuildCaches
|
|
17
|
+
};
|
|
18
|
+
return routeModuleBuildCaches;
|
|
19
|
+
}
|
|
20
|
+
function getSharedRouteModuleBuildCache(outdir, appConfig) {
|
|
21
|
+
if (!appConfig) {
|
|
22
|
+
return new RouteModuleBuildCache(outdir);
|
|
23
|
+
}
|
|
24
|
+
const caches = getRouteModuleBuildCacheMap(appConfig);
|
|
25
|
+
const existingCache = caches.get(outdir);
|
|
26
|
+
if (existingCache) {
|
|
27
|
+
return existingCache;
|
|
28
|
+
}
|
|
29
|
+
const routeModuleBuildCache = new RouteModuleBuildCache(outdir);
|
|
30
|
+
caches.set(outdir, routeModuleBuildCache);
|
|
31
|
+
return routeModuleBuildCache;
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
getRouteModuleBuildCacheOutdir,
|
|
35
|
+
getServerModuleBuildCacheOutdir,
|
|
36
|
+
getSharedRouteModuleBuildCache
|
|
37
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { RouteModuleDependencyHashes } from './route-module-dependency-hasher.js';
|
|
2
|
+
export { ROUTE_MODULE_BUILD_CACHE_FILENAME, createEmptyRouteModuleBuildCacheManifest, createPersistedRouteModuleBuildKey, createPluginCacheKey, createJsxCacheKey, hashPluginSetup, getCorePackageVersion, normalizeRouteModuleCachePath, readRouteModuleBuildCacheManifest, resolvePageModuleOutputFileName, shouldPersistRouteModuleBuildCache, writeRouteModuleBuildCacheManifest, type RouteModuleBuildCacheEntry, type RouteModuleBuildCacheLookup, type RouteModuleBuildCacheManifest, type RouteModuleStaticRenderCacheContext, type RouteModuleStaticRenderCacheEntry, } from './route-module-build-manifest.js';
|
|
3
|
+
export { RouteModuleBuildCache } from './route-module-build-cache.store.js';
|
|
4
|
+
export { getRouteModuleBuildCacheOutdir, getServerModuleBuildCacheOutdir, getSharedRouteModuleBuildCache, } from './route-module-build-cache-registry.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ROUTE_MODULE_BUILD_CACHE_FILENAME,
|
|
3
|
+
createEmptyRouteModuleBuildCacheManifest,
|
|
4
|
+
createPersistedRouteModuleBuildKey,
|
|
5
|
+
createPluginCacheKey,
|
|
6
|
+
createJsxCacheKey,
|
|
7
|
+
hashPluginSetup,
|
|
8
|
+
getCorePackageVersion,
|
|
9
|
+
normalizeRouteModuleCachePath,
|
|
10
|
+
readRouteModuleBuildCacheManifest,
|
|
11
|
+
resolvePageModuleOutputFileName,
|
|
12
|
+
shouldPersistRouteModuleBuildCache,
|
|
13
|
+
writeRouteModuleBuildCacheManifest
|
|
14
|
+
} from "./route-module-build-manifest.js";
|
|
15
|
+
import { RouteModuleBuildCache } from "./route-module-build-cache.store.js";
|
|
16
|
+
import {
|
|
17
|
+
getRouteModuleBuildCacheOutdir,
|
|
18
|
+
getServerModuleBuildCacheOutdir,
|
|
19
|
+
getSharedRouteModuleBuildCache
|
|
20
|
+
} from "./route-module-build-cache-registry.js";
|
|
21
|
+
export {
|
|
22
|
+
ROUTE_MODULE_BUILD_CACHE_FILENAME,
|
|
23
|
+
RouteModuleBuildCache,
|
|
24
|
+
createEmptyRouteModuleBuildCacheManifest,
|
|
25
|
+
createJsxCacheKey,
|
|
26
|
+
createPersistedRouteModuleBuildKey,
|
|
27
|
+
createPluginCacheKey,
|
|
28
|
+
getCorePackageVersion,
|
|
29
|
+
getRouteModuleBuildCacheOutdir,
|
|
30
|
+
getServerModuleBuildCacheOutdir,
|
|
31
|
+
getSharedRouteModuleBuildCache,
|
|
32
|
+
hashPluginSetup,
|
|
33
|
+
normalizeRouteModuleCachePath,
|
|
34
|
+
readRouteModuleBuildCacheManifest,
|
|
35
|
+
resolvePageModuleOutputFileName,
|
|
36
|
+
shouldPersistRouteModuleBuildCache,
|
|
37
|
+
writeRouteModuleBuildCacheManifest
|
|
38
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { PageModuleBuildImportOptions } from './page-module-import.service.js';
|
|
2
|
+
import { RouteModuleDependencyHasher, type RouteModuleDependencyHashes } from './route-module-dependency-hasher.js';
|
|
3
|
+
import { type RouteModuleBuildCacheLookup, type RouteModuleBuildCacheManifest, type RouteModuleStaticRenderCacheContext } from './route-module-build-manifest.js';
|
|
4
|
+
export type { RouteModuleDependencyHashes };
|
|
5
|
+
type RouteModuleBuildCacheDependencies = {
|
|
6
|
+
readManifest: (manifestPath: string) => RouteModuleBuildCacheManifest | undefined;
|
|
7
|
+
writeManifest: (manifestPath: string, manifest: RouteModuleBuildCacheManifest) => void;
|
|
8
|
+
exists: (filePath: string) => boolean;
|
|
9
|
+
getCorePackageVersion: () => string;
|
|
10
|
+
createDependencyHasher: () => RouteModuleDependencyHasher;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Persists route-module transpile and static-render metadata under one server outdir.
|
|
14
|
+
*/
|
|
15
|
+
export declare class RouteModuleBuildCache {
|
|
16
|
+
private readonly manifestPath;
|
|
17
|
+
private readonly dependencies;
|
|
18
|
+
private readonly dependencyHasher;
|
|
19
|
+
private manifest;
|
|
20
|
+
private manifestLoaded;
|
|
21
|
+
constructor(outdir: string, dependencies?: Partial<RouteModuleBuildCacheDependencies>);
|
|
22
|
+
lookup(options: PageModuleBuildImportOptions & {
|
|
23
|
+
fileHash: string;
|
|
24
|
+
}): RouteModuleBuildCacheLookup | undefined;
|
|
25
|
+
recordBuild(options: PageModuleBuildImportOptions & {
|
|
26
|
+
fileHash: string;
|
|
27
|
+
outputPath: string;
|
|
28
|
+
dependencyModulePaths?: readonly string[];
|
|
29
|
+
}): void;
|
|
30
|
+
isIncrementalStaticGenerationAvailable(context: RouteModuleStaticRenderCacheContext): boolean;
|
|
31
|
+
ensureIncrementalStaticGenerationContext(context: RouteModuleStaticRenderCacheContext): void;
|
|
32
|
+
canReuseStaticRender(options: {
|
|
33
|
+
sourceFile: string;
|
|
34
|
+
pathname: string;
|
|
35
|
+
renderedOutputPath: string;
|
|
36
|
+
context: RouteModuleStaticRenderCacheContext;
|
|
37
|
+
force?: boolean;
|
|
38
|
+
}): boolean;
|
|
39
|
+
lookupStaticRender(options: {
|
|
40
|
+
filePath: string;
|
|
41
|
+
pathname: string;
|
|
42
|
+
sourceHash: string;
|
|
43
|
+
renderedOutputPath: string;
|
|
44
|
+
context: RouteModuleStaticRenderCacheContext;
|
|
45
|
+
}): boolean;
|
|
46
|
+
recordStaticRender(options: {
|
|
47
|
+
filePath: string;
|
|
48
|
+
pathname: string;
|
|
49
|
+
sourceHash: string;
|
|
50
|
+
renderedOutputPath: string;
|
|
51
|
+
context: RouteModuleStaticRenderCacheContext;
|
|
52
|
+
}): void;
|
|
53
|
+
resetMemory(): void;
|
|
54
|
+
pruneStaleRenderedOutputs(activePathnames: ReadonlySet<string>): string[];
|
|
55
|
+
private loadManifest;
|
|
56
|
+
private persistManifest;
|
|
57
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileSystem } from "@ecopages/file-system";
|
|
3
|
+
import { RouteModuleDependencyHasher } from "./route-module-dependency-hasher.js";
|
|
4
|
+
import {
|
|
5
|
+
ROUTE_MODULE_BUILD_CACHE_FILENAME,
|
|
6
|
+
createEmptyRouteModuleBuildCacheManifest,
|
|
7
|
+
createPersistedRouteModuleBuildKey,
|
|
8
|
+
getCorePackageVersion,
|
|
9
|
+
normalizeRouteModuleCachePath,
|
|
10
|
+
readRouteModuleBuildCacheManifest,
|
|
11
|
+
shouldPersistRouteModuleBuildCache,
|
|
12
|
+
writeRouteModuleBuildCacheManifest
|
|
13
|
+
} from "./route-module-build-manifest.js";
|
|
14
|
+
import {
|
|
15
|
+
isProductionCacheManifestCurrent,
|
|
16
|
+
matchesProductionCacheFingerprint
|
|
17
|
+
} from "../../build/production-build-cache.js";
|
|
18
|
+
class RouteModuleBuildCache {
|
|
19
|
+
manifestPath;
|
|
20
|
+
dependencies;
|
|
21
|
+
dependencyHasher;
|
|
22
|
+
manifest;
|
|
23
|
+
manifestLoaded = false;
|
|
24
|
+
constructor(outdir, dependencies) {
|
|
25
|
+
this.manifestPath = path.join(outdir, ROUTE_MODULE_BUILD_CACHE_FILENAME);
|
|
26
|
+
this.dependencies = {
|
|
27
|
+
readManifest: dependencies?.readManifest ?? readRouteModuleBuildCacheManifest,
|
|
28
|
+
writeManifest: dependencies?.writeManifest ?? writeRouteModuleBuildCacheManifest,
|
|
29
|
+
exists: dependencies?.exists ?? ((filePath) => fileSystem.exists(filePath)),
|
|
30
|
+
getCorePackageVersion: dependencies?.getCorePackageVersion ?? getCorePackageVersion,
|
|
31
|
+
createDependencyHasher: dependencies?.createDependencyHasher ?? (() => new RouteModuleDependencyHasher())
|
|
32
|
+
};
|
|
33
|
+
this.dependencyHasher = this.dependencies.createDependencyHasher();
|
|
34
|
+
}
|
|
35
|
+
lookup(options) {
|
|
36
|
+
if (!shouldPersistRouteModuleBuildCache(options)) {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
const manifest = this.loadManifest();
|
|
40
|
+
if (manifest.invalidationVersion !== this.dependencies.getCorePackageVersion()) {
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
const buildKey = createPersistedRouteModuleBuildKey(options);
|
|
44
|
+
const cacheFilePath = normalizeRouteModuleCachePath(options.filePath);
|
|
45
|
+
const entry = manifest.entries[cacheFilePath];
|
|
46
|
+
if (!entry || entry.sourceHash !== options.fileHash || entry.buildKey !== buildKey) {
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
if (!this.dependencyHasher.matchesStoredHashes(entry.dependencyHashes, cacheFilePath, options.fileHash)) {
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
const outputPath = path.isAbsolute(entry.outputPath) ? entry.outputPath : path.join(options.outdir, entry.outputPath);
|
|
53
|
+
if (!this.dependencies.exists(outputPath)) {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
return { outputPath, entry };
|
|
57
|
+
}
|
|
58
|
+
recordBuild(options) {
|
|
59
|
+
if (!shouldPersistRouteModuleBuildCache(options)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const cacheFilePath = normalizeRouteModuleCachePath(options.filePath);
|
|
63
|
+
const dependencyModulePaths = options.dependencyModulePaths && options.dependencyModulePaths.length > 0 ? options.dependencyModulePaths : [cacheFilePath];
|
|
64
|
+
const dependencyHashes = this.dependencyHasher.createDependencyHashes(dependencyModulePaths);
|
|
65
|
+
dependencyHashes[cacheFilePath] = options.fileHash;
|
|
66
|
+
const manifest = this.loadManifest();
|
|
67
|
+
const existingEntry = manifest.entries[cacheFilePath];
|
|
68
|
+
manifest.invalidationVersion = this.dependencies.getCorePackageVersion();
|
|
69
|
+
manifest.entries[cacheFilePath] = {
|
|
70
|
+
sourceHash: options.fileHash,
|
|
71
|
+
outputPath: options.outputPath,
|
|
72
|
+
builtAt: Date.now(),
|
|
73
|
+
buildKey: createPersistedRouteModuleBuildKey(options),
|
|
74
|
+
dependencyHashes,
|
|
75
|
+
renderedOutputs: existingEntry?.renderedOutputs
|
|
76
|
+
};
|
|
77
|
+
this.persistManifest(manifest);
|
|
78
|
+
}
|
|
79
|
+
isIncrementalStaticGenerationAvailable(context) {
|
|
80
|
+
if (process.env.NODE_ENV !== "production") {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const manifest = this.loadManifest();
|
|
84
|
+
if (!isProductionCacheManifestCurrent(manifest, this.dependencies.getCorePackageVersion())) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return manifest.configHash === context.configHash && matchesProductionCacheFingerprint(manifest, context.buildInputsFingerprint);
|
|
88
|
+
}
|
|
89
|
+
ensureIncrementalStaticGenerationContext(context) {
|
|
90
|
+
if (process.env.NODE_ENV !== "production") {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const manifest = this.loadManifest();
|
|
94
|
+
manifest.invalidationVersion = this.dependencies.getCorePackageVersion();
|
|
95
|
+
manifest.configHash = context.configHash;
|
|
96
|
+
manifest.buildInputsFingerprint = context.buildInputsFingerprint;
|
|
97
|
+
this.persistManifest(manifest);
|
|
98
|
+
}
|
|
99
|
+
canReuseStaticRender(options) {
|
|
100
|
+
if (options.force) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
if (!fileSystem.exists(options.sourceFile)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
const sourceHash = fileSystem.hash(options.sourceFile);
|
|
107
|
+
return this.lookupStaticRender({
|
|
108
|
+
filePath: options.sourceFile,
|
|
109
|
+
pathname: options.pathname,
|
|
110
|
+
sourceHash,
|
|
111
|
+
renderedOutputPath: options.renderedOutputPath,
|
|
112
|
+
context: options.context
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
lookupStaticRender(options) {
|
|
116
|
+
if (!this.isIncrementalStaticGenerationAvailable(options.context)) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
const manifest = this.loadManifest();
|
|
120
|
+
const cacheFilePath = normalizeRouteModuleCachePath(options.filePath);
|
|
121
|
+
const entry = manifest.entries[cacheFilePath];
|
|
122
|
+
const renderedOutput = entry?.renderedOutputs?.[options.pathname];
|
|
123
|
+
if (!entry || !renderedOutput) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (entry.sourceHash !== options.sourceHash || renderedOutput.sourceHash !== options.sourceHash) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
if (!this.dependencyHasher.matchesStoredHashes(entry.dependencyHashes, cacheFilePath, options.sourceHash)) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
const cachedOutputPath = path.isAbsolute(renderedOutput.renderedOutputPath) ? renderedOutput.renderedOutputPath : path.resolve(renderedOutput.renderedOutputPath);
|
|
133
|
+
if (cachedOutputPath !== path.resolve(options.renderedOutputPath)) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return this.dependencies.exists(cachedOutputPath);
|
|
137
|
+
}
|
|
138
|
+
recordStaticRender(options) {
|
|
139
|
+
if (process.env.NODE_ENV !== "production") {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const cacheFilePath = normalizeRouteModuleCachePath(options.filePath);
|
|
143
|
+
const manifest = this.loadManifest();
|
|
144
|
+
const existingEntry = manifest.entries[cacheFilePath];
|
|
145
|
+
manifest.invalidationVersion = this.dependencies.getCorePackageVersion();
|
|
146
|
+
manifest.configHash = options.context.configHash;
|
|
147
|
+
manifest.buildInputsFingerprint = options.context.buildInputsFingerprint;
|
|
148
|
+
manifest.entries[cacheFilePath] = {
|
|
149
|
+
sourceHash: options.sourceHash,
|
|
150
|
+
outputPath: existingEntry?.outputPath ?? "",
|
|
151
|
+
builtAt: existingEntry?.builtAt ?? Date.now(),
|
|
152
|
+
buildKey: existingEntry?.buildKey ?? "",
|
|
153
|
+
dependencyHashes: existingEntry?.dependencyHashes,
|
|
154
|
+
renderedOutputs: {
|
|
155
|
+
...existingEntry?.renderedOutputs ?? {},
|
|
156
|
+
[options.pathname]: {
|
|
157
|
+
renderedOutputPath: options.renderedOutputPath,
|
|
158
|
+
renderedAt: Date.now(),
|
|
159
|
+
sourceHash: options.sourceHash
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
this.persistManifest(manifest);
|
|
164
|
+
}
|
|
165
|
+
resetMemory() {
|
|
166
|
+
this.manifest = void 0;
|
|
167
|
+
this.manifestLoaded = false;
|
|
168
|
+
}
|
|
169
|
+
pruneStaleRenderedOutputs(activePathnames) {
|
|
170
|
+
if (process.env.NODE_ENV !== "production") {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
const manifest = this.loadManifest();
|
|
174
|
+
const removedOutputPaths = [];
|
|
175
|
+
for (const entry of Object.values(manifest.entries)) {
|
|
176
|
+
if (!entry.renderedOutputs) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
for (const [pathname, renderedOutput] of Object.entries(entry.renderedOutputs)) {
|
|
180
|
+
if (activePathnames.has(pathname)) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
removedOutputPaths.push(renderedOutput.renderedOutputPath);
|
|
184
|
+
delete entry.renderedOutputs[pathname];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (removedOutputPaths.length > 0) {
|
|
188
|
+
this.persistManifest(manifest);
|
|
189
|
+
}
|
|
190
|
+
return removedOutputPaths;
|
|
191
|
+
}
|
|
192
|
+
loadManifest() {
|
|
193
|
+
if (this.manifestLoaded) {
|
|
194
|
+
return this.manifest ?? createEmptyRouteModuleBuildCacheManifest();
|
|
195
|
+
}
|
|
196
|
+
this.manifestLoaded = true;
|
|
197
|
+
this.manifest = this.dependencies.readManifest(this.manifestPath) ?? createEmptyRouteModuleBuildCacheManifest();
|
|
198
|
+
return this.manifest;
|
|
199
|
+
}
|
|
200
|
+
persistManifest(manifest) {
|
|
201
|
+
this.manifest = manifest;
|
|
202
|
+
this.dependencies.writeManifest(this.manifestPath, manifest);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
export {
|
|
206
|
+
RouteModuleBuildCache
|
|
207
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { EcoBuildPlugin } from '../../build/build-types.js';
|
|
2
|
+
import type { PageModuleBuildImportOptions } from './page-module-import.service.js';
|
|
3
|
+
import type { RouteModuleDependencyHashes } from './route-module-dependency-hasher.js';
|
|
4
|
+
/** Filename written beside transpiled server modules that stores incremental build metadata. */
|
|
5
|
+
export declare const ROUTE_MODULE_BUILD_CACHE_FILENAME = ".build-cache.json";
|
|
6
|
+
/** One persisted route-module build entry in {@link ROUTE_MODULE_BUILD_CACHE_FILENAME}. */
|
|
7
|
+
export interface RouteModuleBuildCacheEntry {
|
|
8
|
+
sourceHash: string;
|
|
9
|
+
outputPath: string;
|
|
10
|
+
builtAt: number;
|
|
11
|
+
buildKey: string;
|
|
12
|
+
dependencyHashes?: RouteModuleDependencyHashes;
|
|
13
|
+
renderedOutputs?: Record<string, RouteModuleStaticRenderCacheEntry>;
|
|
14
|
+
}
|
|
15
|
+
/** Metadata for one rendered static HTML artifact derived from a route module. */
|
|
16
|
+
export interface RouteModuleStaticRenderCacheEntry {
|
|
17
|
+
renderedOutputPath: string;
|
|
18
|
+
renderedAt: number;
|
|
19
|
+
sourceHash: string;
|
|
20
|
+
}
|
|
21
|
+
/** On-disk manifest describing all cached route-module builds for one server outdir. */
|
|
22
|
+
export interface RouteModuleBuildCacheManifest {
|
|
23
|
+
invalidationVersion: string;
|
|
24
|
+
configHash?: string;
|
|
25
|
+
buildInputsFingerprint?: string;
|
|
26
|
+
entries: Record<string, RouteModuleBuildCacheEntry>;
|
|
27
|
+
}
|
|
28
|
+
/** Successful route-module cache lookup result. */
|
|
29
|
+
export interface RouteModuleBuildCacheLookup {
|
|
30
|
+
outputPath: string;
|
|
31
|
+
entry: RouteModuleBuildCacheEntry;
|
|
32
|
+
}
|
|
33
|
+
/** Inputs that must remain stable for incremental static HTML generation. */
|
|
34
|
+
export interface RouteModuleStaticRenderCacheContext {
|
|
35
|
+
configHash: string;
|
|
36
|
+
buildInputsFingerprint: string;
|
|
37
|
+
}
|
|
38
|
+
export type RouteModuleBuildCacheManifestReader = (manifestPath: string) => RouteModuleBuildCacheManifest | undefined;
|
|
39
|
+
export type RouteModuleBuildCacheManifestWriter = (manifestPath: string, manifest: RouteModuleBuildCacheManifest) => void;
|
|
40
|
+
/** Returns the installed `@ecopages/core` package version used to invalidate persisted caches. */
|
|
41
|
+
export declare function getCorePackageVersion(): string;
|
|
42
|
+
/** Normalizes filesystem paths used as manifest keys and build-key inputs. */
|
|
43
|
+
export declare function normalizeRouteModuleCachePath(filePath: string): string;
|
|
44
|
+
/** Returns whether route-module disk caching should run for the current import. */
|
|
45
|
+
export declare function shouldPersistRouteModuleBuildCache(options: PageModuleBuildImportOptions): boolean;
|
|
46
|
+
/** Derives the deterministic on-disk filename for one transpiled route module. */
|
|
47
|
+
export declare function resolvePageModuleOutputFileName(options: {
|
|
48
|
+
filePath: string;
|
|
49
|
+
fileHash: string;
|
|
50
|
+
cacheScope?: string;
|
|
51
|
+
invalidationVersion?: number;
|
|
52
|
+
}): string;
|
|
53
|
+
/** Builds the cache key for persisted production route-module builds. */
|
|
54
|
+
export declare function createPersistedRouteModuleBuildKey(options: PageModuleBuildImportOptions): string;
|
|
55
|
+
export declare function createEmptyRouteModuleBuildCacheManifest(): RouteModuleBuildCacheManifest;
|
|
56
|
+
export declare function readRouteModuleBuildCacheManifest(manifestPath: string): RouteModuleBuildCacheManifest | undefined;
|
|
57
|
+
export declare function writeRouteModuleBuildCacheManifest(manifestPath: string, manifest: RouteModuleBuildCacheManifest): void;
|
|
58
|
+
export declare function createJsxCacheKey(jsx: PageModuleBuildImportOptions['jsx']): string;
|
|
59
|
+
export declare function createPluginCacheKey(plugins?: EcoBuildPlugin[]): string;
|
|
60
|
+
/** Exported for in-process import caches that must match persisted build keys. */
|
|
61
|
+
export declare function hashPluginSetup(setup: EcoBuildPlugin['setup']): string;
|