@ecopages/core 0.2.0-rc.1 → 0.2.0-rc.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/README.md +50 -32
- package/package.json +50 -4
- package/src/adapters/README.md +3 -1
- package/src/adapters/abstract/application-adapter.d.ts +28 -6
- package/src/adapters/abstract/application-adapter.js +58 -5
- 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/bun/create-app.d.ts +8 -4
- package/src/adapters/bun/create-app.js +64 -37
- package/src/adapters/bun/server-adapter.d.ts +6 -2
- package/src/adapters/bun/server-adapter.js +14 -1
- package/src/adapters/create-app.d.ts +62 -7
- package/src/adapters/create-app.js +61 -5
- package/src/adapters/node/create-app.d.ts +5 -5
- package/src/adapters/node/create-app.js +18 -5
- package/src/adapters/node/runtime-host.js +9 -4
- package/src/adapters/node/server-adapter.d.ts +5 -1
- package/src/adapters/node/server-adapter.js +16 -1
- package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
- package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -8
- package/src/adapters/shared/http/fs-server-response-factory.js +5 -30
- 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/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/server-adapter.d.ts +14 -5
- package/src/adapters/shared/runtime/server-adapter.js +22 -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/build/README.md +4 -0
- package/src/build/cache/server-entry-build-cache.d.ts +24 -1
- package/src/build/cache/server-entry-build-cache.js +125 -8
- 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/runtime/build-request-policy.js +1 -1
- package/src/build/server-bundle-publication.d.ts +14 -0
- package/src/build/server-bundle-publication.js +49 -0
- package/src/config/README.md +17 -2
- package/src/config/apply-user-config.d.ts +6 -0
- package/src/config/apply-user-config.js +67 -0
- package/src/config/config-builder.d.ts +10 -1
- package/src/config/config-builder.js +51 -10
- package/src/config/constants.d.ts +4 -0
- package/src/config/constants.js +4 -0
- 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 +100 -0
- package/src/config/resolve-eco-config-path.d.ts +23 -0
- package/src/config/resolve-eco-config-path.js +47 -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 +164 -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/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/strategies/js-hmr-strategy.d.ts +2 -0
- package/src/hmr/strategies/js-hmr-strategy.js +24 -16
- package/src/index.browser.d.ts +3 -0
- package/src/index.browser.js +3 -0
- package/src/index.d.ts +4 -1
- package/src/index.js +4 -1
- package/src/islands/README.md +5 -1
- 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 +118 -16
- 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 +2 -0
- 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 -5
- package/src/route-renderer/orchestration/integration-renderer.js +42 -29
- 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.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 +5 -0
- 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/error-pages/README.md +9 -0
- package/src/services/error-pages/default-error-pages.d.ts +44 -0
- package/src/services/error-pages/default-error-pages.js +207 -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/invalidation/development-invalidation.service.d.ts +7 -1
- package/src/services/invalidation/development-invalidation.service.js +35 -3
- package/src/services/module-loading/README.md +16 -13
- package/src/services/module-loading/app-server-module-transpiler.service.js +2 -0
- package/src/services/module-loading/collection-server-module-build.service.d.ts +1 -0
- package/src/services/module-loading/collection-server-module-build.service.js +5 -2
- 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-dependency-hasher.js +13 -1
- 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/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 -1
- package/src/types/public-types.d.ts +32 -22
- package/src/utils/parse-cli-args.js +29 -22
- package/src/watchers/project-watcher.d.ts +14 -1
- package/src/watchers/project-watcher.js +85 -34
- /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
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';
|
|
@@ -57,16 +57,125 @@ export function readServerEntryBuildCacheManifest(appConfig) {
|
|
|
57
57
|
function writeServerEntryBuildCacheManifest(appConfig, manifest) {
|
|
58
58
|
writeProductionCacheManifest(path.join(getServerEntryCacheDir(appConfig), SERVER_ENTRY_BUILD_CACHE_FILENAME), manifest);
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
function hashExistingFile(filePath) {
|
|
61
|
+
return filePath && fileSystem.exists(filePath) ? fileSystem.hash(filePath) : undefined;
|
|
62
|
+
}
|
|
63
|
+
export function writeServerBundleDeployManifest(appConfig, serverEntryPath, options) {
|
|
64
|
+
const { distDir, manifestPath: defaultManifestPath } = getServerBundleOutputPaths(appConfig);
|
|
65
|
+
const manifestPath = options?.outputDir
|
|
66
|
+
? path.join(options.outputDir, SERVER_BUNDLE_MANIFEST_FILENAME)
|
|
67
|
+
: defaultManifestPath;
|
|
62
68
|
fileSystem.ensureDir(path.dirname(manifestPath));
|
|
69
|
+
const sourceConfigPath = options?.sourceConfigPath ?? appConfig.absolutePaths?.config;
|
|
70
|
+
const emittedConfigPath = options?.emittedConfigModule
|
|
71
|
+
? path.resolve(path.dirname(manifestPath), options.emittedConfigModule)
|
|
72
|
+
: undefined;
|
|
63
73
|
const payload = {
|
|
64
74
|
serverEntry: path.relative(path.dirname(manifestPath), serverEntryPath) || SERVER_BUNDLE_FILENAME,
|
|
65
75
|
distDir,
|
|
66
76
|
builtAt: Date.now(),
|
|
77
|
+
sourceConfigPath,
|
|
78
|
+
sourceConfigRelativePath: sourceConfigPath ? path.relative(appConfig.rootDir, sourceConfigPath) : undefined,
|
|
79
|
+
emittedConfigModule: options?.emittedConfigModule,
|
|
80
|
+
configHash: hashExistingFile(sourceConfigPath),
|
|
81
|
+
emittedConfigHash: hashExistingFile(emittedConfigPath),
|
|
67
82
|
};
|
|
68
83
|
fileSystem.write(manifestPath, `${JSON.stringify(payload, null, '\t')}\n`);
|
|
69
84
|
}
|
|
85
|
+
export function readServerBundleDeployManifest(appConfig) {
|
|
86
|
+
const { manifestPath } = getServerBundleOutputPaths(appConfig);
|
|
87
|
+
if (!fileSystem.exists(manifestPath)) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
return JSON.parse(fileSystem.readFileSync(manifestPath).toString());
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function isEmittedConfigArtifact(manifest, manifestDir, requestedPath) {
|
|
98
|
+
if (!manifest.emittedConfigModule) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const emittedArtifactPath = path.resolve(manifestDir, manifest.emittedConfigModule);
|
|
102
|
+
if (path.resolve(requestedPath) !== emittedArtifactPath)
|
|
103
|
+
return false;
|
|
104
|
+
return (!manifest.emittedConfigHash ||
|
|
105
|
+
(fileSystem.exists(requestedPath) && fileSystem.hash(requestedPath) === manifest.emittedConfigHash));
|
|
106
|
+
}
|
|
107
|
+
function matchesBuiltConfigHash(manifest, requestedPath) {
|
|
108
|
+
if (!manifest.configHash || !fileSystem.exists(requestedPath)) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
return fileSystem.hash(requestedPath) === manifest.configHash;
|
|
112
|
+
}
|
|
113
|
+
function matchesBuiltConfigPath(manifest, cwd, requestedPath, isExplicitOverride) {
|
|
114
|
+
if (manifest.configHash)
|
|
115
|
+
return false;
|
|
116
|
+
if (!isExplicitOverride && manifest.sourceConfigRelativePath) {
|
|
117
|
+
if (path.relative(cwd, requestedPath) === manifest.sourceConfigRelativePath) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (manifest.sourceConfigPath && path.resolve(requestedPath) === path.resolve(manifest.sourceConfigPath)) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
function readDeployManifest(appConfigOrCwd) {
|
|
127
|
+
return typeof appConfigOrCwd === 'string'
|
|
128
|
+
? readServerBundleDeployManifestFromDir(appConfigOrCwd)
|
|
129
|
+
: readServerBundleDeployManifest(appConfigOrCwd);
|
|
130
|
+
}
|
|
131
|
+
function hasConfigIdentity(manifest) {
|
|
132
|
+
return Boolean(manifest.emittedConfigModule ||
|
|
133
|
+
manifest.configHash ||
|
|
134
|
+
manifest.sourceConfigPath ||
|
|
135
|
+
manifest.sourceConfigRelativePath);
|
|
136
|
+
}
|
|
137
|
+
function resolveDeployManifestDirectory(appConfigOrCwd) {
|
|
138
|
+
return typeof appConfigOrCwd === 'string'
|
|
139
|
+
? path.join(appConfigOrCwd, 'dist', SERVER_BUNDLE_DIR)
|
|
140
|
+
: getServerBundleOutputPaths(appConfigOrCwd).serverOutdir;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @remarks
|
|
144
|
+
* Production `start` must not load a different config than the one compiled into the bundle.
|
|
145
|
+
*/
|
|
146
|
+
export function assertProductionConfigIdentity(appConfigOrCwd, requestedConfigPath, options) {
|
|
147
|
+
if (!requestedConfigPath) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const manifest = readDeployManifest(appConfigOrCwd);
|
|
151
|
+
if (!manifest || !hasConfigIdentity(manifest))
|
|
152
|
+
return;
|
|
153
|
+
const manifestDir = resolveDeployManifestDirectory(appConfigOrCwd);
|
|
154
|
+
if (isEmittedConfigArtifact(manifest, manifestDir, requestedConfigPath)) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (matchesBuiltConfigHash(manifest, requestedConfigPath)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const cwd = typeof appConfigOrCwd === 'string' ? appConfigOrCwd : appConfigOrCwd.rootDir;
|
|
161
|
+
if (matchesBuiltConfigPath(manifest, cwd, requestedConfigPath, options?.isExplicitOverride)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const expected = manifest.sourceConfigRelativePath ?? manifest.sourceConfigPath ?? 'bundled config';
|
|
165
|
+
throw new Error(`Ecopages config mismatch: production bundle was built with ${expected}, but start requested ${requestedConfigPath}.`);
|
|
166
|
+
}
|
|
167
|
+
export function readServerBundleDeployManifestFromDir(cwd = process.cwd()) {
|
|
168
|
+
const manifestPath = path.join(cwd, 'dist', SERVER_BUNDLE_DIR, SERVER_BUNDLE_MANIFEST_FILENAME);
|
|
169
|
+
if (!fileSystem.exists(manifestPath)) {
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
return JSON.parse(fileSystem.readFileSync(manifestPath).toString());
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
70
179
|
export function lookupServerEntryBuildCache(options) {
|
|
71
180
|
if (options.force) {
|
|
72
181
|
return undefined;
|
|
@@ -76,6 +185,7 @@ export function lookupServerEntryBuildCache(options) {
|
|
|
76
185
|
}
|
|
77
186
|
const entryPath = path.resolve(options.entryPath);
|
|
78
187
|
const entryHash = fileSystem.hash(entryPath);
|
|
188
|
+
const configHash = hashAppConfigFile(options.appConfig);
|
|
79
189
|
const buildInputsFingerprint = createBuildInputsFingerprint(options.appConfig);
|
|
80
190
|
const buildKey = createServerEntryBuildKey(options.appConfig);
|
|
81
191
|
const manifest = readServerEntryBuildCacheManifest(options.appConfig);
|
|
@@ -87,6 +197,7 @@ export function lookupServerEntryBuildCache(options) {
|
|
|
87
197
|
}
|
|
88
198
|
if (manifest.entryPath !== entryPath ||
|
|
89
199
|
manifest.entryHash !== entryHash ||
|
|
200
|
+
manifest.configHash !== configHash ||
|
|
90
201
|
!matchesProductionCacheFingerprint(manifest, buildInputsFingerprint) ||
|
|
91
202
|
!matchesProductionCacheBuildKey(manifest, buildKey)) {
|
|
92
203
|
return undefined;
|
|
@@ -95,13 +206,13 @@ export function lookupServerEntryBuildCache(options) {
|
|
|
95
206
|
if (!hasher.matchesStoredHashes(manifest.dependencyHashes, entryPath, entryHash)) {
|
|
96
207
|
return undefined;
|
|
97
208
|
}
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
209
|
+
const allOutputsExist = manifest.outputPaths.length > 0 && manifest.outputPaths.every((outputPath) => fileSystem.exists(outputPath));
|
|
210
|
+
if (!allOutputsExist) {
|
|
100
211
|
return undefined;
|
|
101
212
|
}
|
|
102
213
|
return {
|
|
103
214
|
manifest,
|
|
104
|
-
outputPaths:
|
|
215
|
+
outputPaths: manifest.outputPaths,
|
|
105
216
|
};
|
|
106
217
|
}
|
|
107
218
|
export function recordServerEntryBuildCache(options) {
|
|
@@ -110,12 +221,18 @@ export function recordServerEntryBuildCache(options) {
|
|
|
110
221
|
}
|
|
111
222
|
const entryPath = path.resolve(options.entryPath);
|
|
112
223
|
const entryHash = fileSystem.hash(entryPath);
|
|
224
|
+
const configHash = hashAppConfigFile(options.appConfig);
|
|
113
225
|
const hasher = new RouteModuleDependencyHasher();
|
|
114
|
-
const
|
|
226
|
+
const appDependencyHashes = hashDependencyGraph(entryPath, options.buildResult.dependencyGraph, hasher, options.appConfig.rootDir);
|
|
227
|
+
const configDependencyHashes = options.appConfig.absolutePaths?.config && options.configBuildResult?.dependencyGraph
|
|
228
|
+
? hashDependencyGraph(options.appConfig.absolutePaths.config, options.configBuildResult.dependencyGraph, hasher, options.appConfig.rootDir)
|
|
229
|
+
: {};
|
|
230
|
+
const dependencyHashes = { ...appDependencyHashes, ...configDependencyHashes };
|
|
115
231
|
const manifest = {
|
|
116
232
|
invalidationVersion: getCorePackageVersion(),
|
|
117
233
|
entryPath,
|
|
118
234
|
entryHash,
|
|
235
|
+
configHash,
|
|
119
236
|
buildInputsFingerprint: createBuildInputsFingerprint(options.appConfig),
|
|
120
237
|
buildKey: createServerEntryBuildKey(options.appConfig),
|
|
121
238
|
outputPaths: options.outputPaths,
|
|
@@ -128,7 +245,7 @@ export function resolveProductionServerEntry(cwd = process.cwd()) {
|
|
|
128
245
|
const manifestPath = path.join(cwd, 'dist', SERVER_BUNDLE_DIR, SERVER_BUNDLE_MANIFEST_FILENAME);
|
|
129
246
|
if (fileSystem.exists(manifestPath)) {
|
|
130
247
|
try {
|
|
131
|
-
const parsed = JSON.parse(fileSystem.readFileSync(manifestPath));
|
|
248
|
+
const parsed = JSON.parse(fileSystem.readFileSync(manifestPath).toString());
|
|
132
249
|
if (parsed?.serverEntry) {
|
|
133
250
|
const fromManifest = path.isAbsolute(parsed.serverEntry)
|
|
134
251
|
? parsed.serverEntry
|
|
@@ -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',
|
|
@@ -298,14 +298,7 @@ export function toBuildLogs(error) {
|
|
|
298
298
|
}
|
|
299
299
|
return [{ message: 'Unknown build error' }];
|
|
300
300
|
}
|
|
301
|
-
|
|
302
|
-
* Translates a {@link BuildOptions} into Rolldown's `InputOptions` and
|
|
303
|
-
* `OutputOptions`. Always sets `experimental.nativeMagicString: true`
|
|
304
|
-
* and always consolidates eco plugins via the bridge.
|
|
305
|
-
*/
|
|
306
|
-
export function resolveRolldownOptions(options, contextRoot, outdir, appRootRequireCache) {
|
|
307
|
-
const rolldownPlatform = mapRolldownPlatform(options.target);
|
|
308
|
-
const external = createExternalMatcher(options, appRootRequireCache);
|
|
301
|
+
function buildRolldownTransformOptions(options) {
|
|
309
302
|
const transformOptions = {};
|
|
310
303
|
if (options.define) {
|
|
311
304
|
transformOptions.define = options.define;
|
|
@@ -316,21 +309,26 @@ export function resolveRolldownOptions(options, contextRoot, outdir, appRootRequ
|
|
|
316
309
|
if (options.target && /^(?:es|chrome|edge|firefox|safari|hermes|deno|ios)/.test(options.target)) {
|
|
317
310
|
transformOptions.target = options.target;
|
|
318
311
|
}
|
|
312
|
+
return Object.keys(transformOptions).length > 0 ? transformOptions : undefined;
|
|
313
|
+
}
|
|
314
|
+
function buildRolldownInputPlugins(options, contextRoot, rolldownPlatform) {
|
|
319
315
|
const bundlePlugins = options.plugins ?? [];
|
|
320
316
|
const sourceTransforms = options.sourceTransforms ?? [];
|
|
321
317
|
const appPlugins = createRolldownPluginBridge(bundlePlugins, contextRoot, sourceTransforms);
|
|
322
|
-
|
|
318
|
+
return [
|
|
323
319
|
...(rolldownPlatform === 'node' ? [createNodeBuiltinExternalPlugin()] : []),
|
|
324
320
|
...(rolldownPlatform === 'browser' ? [createBrowserNodeBuiltinGuardPlugin()] : []),
|
|
325
321
|
...(options.target !== 'browser' ? [createServerSideCssShimPlugin()] : []),
|
|
326
322
|
...appPlugins,
|
|
327
323
|
];
|
|
328
|
-
|
|
324
|
+
}
|
|
325
|
+
function buildRolldownInputOptions(options, contextRoot, external, rolldownPlatform) {
|
|
326
|
+
return {
|
|
329
327
|
input: options.entrypoints,
|
|
330
328
|
cwd: contextRoot,
|
|
331
329
|
external,
|
|
332
|
-
platform:
|
|
333
|
-
transform:
|
|
330
|
+
platform: rolldownPlatform,
|
|
331
|
+
transform: buildRolldownTransformOptions(options),
|
|
334
332
|
resolve: options.conditions ? { conditionNames: options.conditions } : undefined,
|
|
335
333
|
treeshake: typeof options.treeshaking === 'boolean' ? options.treeshaking : true,
|
|
336
334
|
...(process.env.ECOPAGES_PROFILE_BUILD === '1'
|
|
@@ -343,32 +341,50 @@ export function resolveRolldownOptions(options, contextRoot, outdir, appRootRequ
|
|
|
343
341
|
experimental: {
|
|
344
342
|
nativeMagicString: true,
|
|
345
343
|
},
|
|
346
|
-
plugins:
|
|
344
|
+
plugins: buildRolldownInputPlugins(options, contextRoot, rolldownPlatform),
|
|
347
345
|
};
|
|
346
|
+
}
|
|
347
|
+
function resolveRolldownEntryFileNames(options) {
|
|
348
348
|
const entryFileNames = toEntryFileNamesPattern(options.naming);
|
|
349
349
|
const jsExtension = getJavaScriptOutExtension(options, entryFileNames?.literal ?? false);
|
|
350
|
-
|
|
351
|
-
? jsExtension
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
350
|
+
if (entryFileNames) {
|
|
351
|
+
return jsExtension ? `${entryFileNames.pattern}${jsExtension}` : entryFileNames.pattern;
|
|
352
|
+
}
|
|
353
|
+
return jsExtension ? `[name]${jsExtension}` : '[name]';
|
|
354
|
+
}
|
|
355
|
+
function shouldDisableRolldownCodeSplitting(options) {
|
|
356
|
+
if (options.splitting !== false) {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
357
359
|
const entrypointCount = Array.isArray(options.entrypoints)
|
|
358
360
|
? options.entrypoints.length
|
|
359
361
|
: Object.keys(options.entrypoints).length;
|
|
360
|
-
|
|
361
|
-
|
|
362
|
+
return entrypointCount === 1;
|
|
363
|
+
}
|
|
364
|
+
function buildRolldownOutputOptions(options, outdir) {
|
|
365
|
+
return {
|
|
362
366
|
dir: outdir,
|
|
363
367
|
format: mapRolldownFormat(options.format),
|
|
364
368
|
minify: !!options.minify,
|
|
365
|
-
entryFileNames:
|
|
369
|
+
entryFileNames: resolveRolldownEntryFileNames(options),
|
|
366
370
|
chunkFileNames: '[name]-[hash].js',
|
|
367
371
|
assetFileNames: '[name]-[hash][extname]',
|
|
368
372
|
sourcemap: mapRolldownSourcemap(options.sourcemap),
|
|
369
|
-
...(
|
|
373
|
+
...(shouldDisableRolldownCodeSplitting(options) ? { codeSplitting: false } : {}),
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Translates a {@link BuildOptions} into Rolldown's `InputOptions` and
|
|
378
|
+
* `OutputOptions`. Always sets `experimental.nativeMagicString: true`
|
|
379
|
+
* and always consolidates eco plugins via the bridge.
|
|
380
|
+
*/
|
|
381
|
+
export function resolveRolldownOptions(options, contextRoot, outdir, appRootRequireCache) {
|
|
382
|
+
const rolldownPlatform = mapRolldownPlatform(options.target);
|
|
383
|
+
const external = createExternalMatcher(options, appRootRequireCache);
|
|
384
|
+
return {
|
|
385
|
+
inputOptions: buildRolldownInputOptions(options, contextRoot, external, rolldownPlatform),
|
|
386
|
+
outputOptions: buildRolldownOutputOptions(options, outdir),
|
|
370
387
|
};
|
|
371
|
-
return { inputOptions, outputOptions };
|
|
372
388
|
}
|
|
373
389
|
/**
|
|
374
390
|
* Rewrites manifest-owned runtime specifiers in emitted JS output
|
|
@@ -73,29 +73,33 @@ function inferRolldownModuleTypeFromPath(filePath) {
|
|
|
73
73
|
return 'js';
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
const DIRECT_ROLLDOWN_MODULE_LOADERS = new Set([
|
|
77
|
+
'js',
|
|
78
|
+
'jsx',
|
|
79
|
+
'ts',
|
|
80
|
+
'tsx',
|
|
81
|
+
'json',
|
|
82
|
+
'css',
|
|
83
|
+
'text',
|
|
84
|
+
'base64',
|
|
85
|
+
'dataurl',
|
|
86
|
+
'binary',
|
|
87
|
+
'empty',
|
|
88
|
+
]);
|
|
89
|
+
const ROLLDOWN_LOADER_ALIASES = {
|
|
90
|
+
'global-css': 'css',
|
|
91
|
+
'local-css': 'css',
|
|
92
|
+
file: 'asset',
|
|
93
|
+
copy: 'asset',
|
|
94
|
+
};
|
|
76
95
|
function normalizeRolldownModuleType(loader) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
case 'jsx':
|
|
80
|
-
case 'ts':
|
|
81
|
-
case 'tsx':
|
|
82
|
-
case 'json':
|
|
83
|
-
case 'css':
|
|
84
|
-
case 'text':
|
|
85
|
-
case 'base64':
|
|
86
|
-
case 'dataurl':
|
|
87
|
-
case 'binary':
|
|
88
|
-
case 'empty':
|
|
89
|
-
return loader;
|
|
90
|
-
case 'global-css':
|
|
91
|
-
case 'local-css':
|
|
92
|
-
return 'css';
|
|
93
|
-
case 'file':
|
|
94
|
-
case 'copy':
|
|
95
|
-
return 'asset';
|
|
96
|
-
default:
|
|
97
|
-
return undefined;
|
|
96
|
+
if (typeof loader === 'string' && DIRECT_ROLLDOWN_MODULE_LOADERS.has(loader)) {
|
|
97
|
+
return loader;
|
|
98
98
|
}
|
|
99
|
+
if (typeof loader === 'string' && Object.prototype.hasOwnProperty.call(ROLLDOWN_LOADER_ALIASES, loader)) {
|
|
100
|
+
return ROLLDOWN_LOADER_ALIASES[loader];
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
99
103
|
}
|
|
100
104
|
function convertLoadResultToModuleSource(result) {
|
|
101
105
|
if (result.loader === 'object' && result.exports && typeof result.exports === 'object') {
|
|
@@ -48,7 +48,7 @@ export function createServerBuildRequest(appConfig, input) {
|
|
|
48
48
|
...overrides,
|
|
49
49
|
entrypoints: input.entrypoints,
|
|
50
50
|
...(plugins.length > 0 ? { plugins } : {}),
|
|
51
|
-
sourceTransforms: getAppSourceTransforms(appConfig),
|
|
51
|
+
sourceTransforms: [...getAppSourceTransforms(appConfig), ...(input.sourceTransforms ?? [])],
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Creates a sibling staging directory so publication stays on one filesystem. */
|
|
2
|
+
export declare function createServerBundleStagingDirectory(serverOutdir: string): string;
|
|
3
|
+
/** Maps build outputs from the staging directory to their published locations. */
|
|
4
|
+
export declare function resolvePublishedServerBundlePaths(outputPaths: readonly string[], stagingDir: string, serverOutdir: string): string[];
|
|
5
|
+
/**
|
|
6
|
+
* Publishes a complete server bundle generation without exposing mixed artifacts.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* The previous directory is retained until the staged directory has been moved
|
|
10
|
+
* into place, allowing rollback if publication fails.
|
|
11
|
+
*/
|
|
12
|
+
export declare function publishServerBundleDirectory(stagingDir: string, serverOutdir: string): void;
|
|
13
|
+
/** Removes an unpublished staging generation after a failed build. */
|
|
14
|
+
export declare function removeServerBundleStagingDirectory(stagingDir: string): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { mkdtempSync, renameSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
5
|
+
/** Creates a sibling staging directory so publication stays on one filesystem. */
|
|
6
|
+
export function createServerBundleStagingDirectory(serverOutdir) {
|
|
7
|
+
const parentDir = path.dirname(serverOutdir);
|
|
8
|
+
fileSystem.ensureDir(parentDir);
|
|
9
|
+
return mkdtempSync(path.join(parentDir, `.${path.basename(serverOutdir)}.staging-`));
|
|
10
|
+
}
|
|
11
|
+
/** Maps build outputs from the staging directory to their published locations. */
|
|
12
|
+
export function resolvePublishedServerBundlePaths(outputPaths, stagingDir, serverOutdir) {
|
|
13
|
+
return outputPaths.map((outputPath) => {
|
|
14
|
+
const relativePath = path.relative(stagingDir, outputPath);
|
|
15
|
+
if (!relativePath || relativePath.startsWith('..') || path.isAbsolute(relativePath)) {
|
|
16
|
+
throw new Error(`Server bundle output escaped its staging directory: ${outputPath}`);
|
|
17
|
+
}
|
|
18
|
+
return path.join(serverOutdir, relativePath);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Publishes a complete server bundle generation without exposing mixed artifacts.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* The previous directory is retained until the staged directory has been moved
|
|
26
|
+
* into place, allowing rollback if publication fails.
|
|
27
|
+
*/
|
|
28
|
+
export function publishServerBundleDirectory(stagingDir, serverOutdir) {
|
|
29
|
+
const backupDir = path.join(path.dirname(serverOutdir), `.${path.basename(serverOutdir)}.previous-${randomUUID()}`);
|
|
30
|
+
const hadPublishedBundle = fileSystem.exists(serverOutdir);
|
|
31
|
+
try {
|
|
32
|
+
if (hadPublishedBundle)
|
|
33
|
+
renameSync(serverOutdir, backupDir);
|
|
34
|
+
renameSync(stagingDir, serverOutdir);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (hadPublishedBundle && !fileSystem.exists(serverOutdir) && fileSystem.exists(backupDir)) {
|
|
38
|
+
renameSync(backupDir, serverOutdir);
|
|
39
|
+
}
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
if (fileSystem.exists(backupDir))
|
|
43
|
+
fileSystem.remove(backupDir);
|
|
44
|
+
}
|
|
45
|
+
/** Removes an unpublished staging generation after a failed build. */
|
|
46
|
+
export function removeServerBundleStagingDirectory(stagingDir) {
|
|
47
|
+
if (fileSystem.exists(stagingDir))
|
|
48
|
+
fileSystem.remove(stagingDir);
|
|
49
|
+
}
|
package/src/config/README.md
CHANGED
|
@@ -18,14 +18,22 @@ It is responsible for:
|
|
|
18
18
|
|
|
19
19
|
## Main Files
|
|
20
20
|
|
|
21
|
-
- `config
|
|
22
|
-
- `config
|
|
21
|
+
- `define-config.ts`: synchronous `defineConfig()` identity for `eco.config.ts` authoring
|
|
22
|
+
- `load-eco-config.ts`: resolves the config module path, loads user config, and finalizes through `ConfigBuilder`
|
|
23
|
+
- `resolve-eco-config-path.ts`: `eco.config.ts` discovery (`configFile`, `ECOPAGES_CONFIG_FILE`, cwd default, and production `.server/eco.config.mjs`)
|
|
24
|
+
- `apply-user-config.ts`: maps declarative `EcoPagesUserConfig` fields onto `ConfigBuilder`
|
|
25
|
+
- `is-finalized-app-config.ts`: detects leftover `ConfigBuilder.build()` exports so `loadEcoPagesConfig()` can reuse them
|
|
26
|
+
- `user-config-types.ts`: TypeScript contracts for `EcoPagesUserConfig` and config loader options
|
|
27
|
+
- `config-builder.ts`: finalization boundary used by the loader and tests
|
|
28
|
+
- `server-config-bundle.ts`: emits `dist/.server/eco.config.mjs` for production server startup
|
|
29
|
+
- `config-builder.test.ts` / `load-eco-config.test.ts`: validation and loader coverage
|
|
23
30
|
|
|
24
31
|
## Ownership Rules
|
|
25
32
|
|
|
26
33
|
- Integrations and processors declare contributions.
|
|
27
34
|
- `ConfigBuilder.build()` decides ordering, validates compatibility, and seals build ownership for the finalized app config.
|
|
28
35
|
- Runtime startup reuses finalized config/build state; it should not recompute manifest ownership.
|
|
36
|
+
- Production startup loads the emitted config artifact recorded by the server build, even when the source config is still present.
|
|
29
37
|
|
|
30
38
|
App-owned is the default ownership path. Host-owned is explicit and should be selected during config construction when a host-driven compatibility flow must avoid silently falling back to app build execution.
|
|
31
39
|
|
|
@@ -34,3 +42,10 @@ App-owned is the default ownership path. Host-owned is explicit and should be se
|
|
|
34
42
|
The result of this layer is a built `EcoPagesAppConfig` with resolved absolute paths and app-owned runtime services attached under `appConfig.runtime`.
|
|
35
43
|
|
|
36
44
|
That built config is then consumed by server adapters, static generation, route rendering, and HMR.
|
|
45
|
+
|
|
46
|
+
## Tests and fixtures
|
|
47
|
+
|
|
48
|
+
- Production apps call `createApp()` (loads `eco.config.ts`) or pass `appConfig`, `userConfig`, or `configFile` explicitly.
|
|
49
|
+
- In development (`--dev`), adding, changing, or removing the resolved `eco.config` module or a supported project `.env` file triggers a supervised process restart (not in-process reload). The CLI re-merges dotenv files on respawn.
|
|
50
|
+
- `@ecopages/testing` `createTestAppConfig()` finalizes each in-memory user config independently through `finalizeEcoPagesConfig`; only module-backed `loadEcoPagesConfig()` calls are cached.
|
|
51
|
+
- Core fixture helpers live in `packages/core/__fixtures__/app/test-app-config.ts` (`createFixtureAppConfig`, `createFixtureApp`).
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ConfigBuilder } from './config-builder.js';
|
|
2
|
+
import type { EcoPagesUserConfig } from './user-config-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Applies author-owned config fields onto a {@link ConfigBuilder} instance.
|
|
5
|
+
*/
|
|
6
|
+
export declare function applyUserConfigToBuilder(builder: ConfigBuilder, userConfig: EcoPagesUserConfig): ConfigBuilder;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ConfigBuilder } from './config-builder.js';
|
|
2
|
+
function applyUserDirectoryConfig(builder, userConfig) {
|
|
3
|
+
if (userConfig.srcDir)
|
|
4
|
+
builder.setSrcDir(userConfig.srcDir);
|
|
5
|
+
if (userConfig.pagesDir)
|
|
6
|
+
builder.setPagesDir(userConfig.pagesDir);
|
|
7
|
+
if (userConfig.includesDir)
|
|
8
|
+
builder.setIncludesDir(userConfig.includesDir);
|
|
9
|
+
if (userConfig.componentsDir)
|
|
10
|
+
builder.setComponentsDir(userConfig.componentsDir);
|
|
11
|
+
if (userConfig.layoutsDir)
|
|
12
|
+
builder.setLayoutsDir(userConfig.layoutsDir);
|
|
13
|
+
if (userConfig.publicDir)
|
|
14
|
+
builder.setPublicDir(userConfig.publicDir);
|
|
15
|
+
if (userConfig.distDir)
|
|
16
|
+
builder.setDistDir(userConfig.distDir);
|
|
17
|
+
if (userConfig.workDir)
|
|
18
|
+
builder.setWorkDir(userConfig.workDir);
|
|
19
|
+
}
|
|
20
|
+
function applyUserPipelineConfig(builder, userConfig) {
|
|
21
|
+
if (userConfig.integrations)
|
|
22
|
+
builder.setIntegrations(userConfig.integrations);
|
|
23
|
+
if (userConfig.processors)
|
|
24
|
+
builder.setProcessors(userConfig.processors);
|
|
25
|
+
if (userConfig.loaders)
|
|
26
|
+
builder.setLoaders(userConfig.loaders);
|
|
27
|
+
if (userConfig.sourceTransforms)
|
|
28
|
+
builder.setSourceTransforms(userConfig.sourceTransforms);
|
|
29
|
+
if (userConfig.cache)
|
|
30
|
+
builder.setCacheConfig(userConfig.cache);
|
|
31
|
+
if (userConfig.buildOwnership)
|
|
32
|
+
builder.setBuildOwnership(userConfig.buildOwnership);
|
|
33
|
+
}
|
|
34
|
+
function applyUserMetadataConfig(builder, userConfig) {
|
|
35
|
+
if (userConfig.baseUrl !== undefined)
|
|
36
|
+
builder.setBaseUrl(userConfig.baseUrl);
|
|
37
|
+
if (userConfig.robotsTxt)
|
|
38
|
+
builder.setRobotsTxt(userConfig.robotsTxt);
|
|
39
|
+
if (userConfig.sitemap)
|
|
40
|
+
builder.setSitemap(userConfig.sitemap);
|
|
41
|
+
if (userConfig.defaultMetadata)
|
|
42
|
+
builder.setDefaultMetadata(userConfig.defaultMetadata);
|
|
43
|
+
}
|
|
44
|
+
function applyUserRuntimeConfig(builder, userConfig) {
|
|
45
|
+
if (userConfig.devToolbar)
|
|
46
|
+
builder.setDevToolbar(userConfig.devToolbar);
|
|
47
|
+
if (userConfig.additionalWatchPaths)
|
|
48
|
+
builder.setAdditionalWatchPaths(userConfig.additionalWatchPaths);
|
|
49
|
+
if (userConfig.devPrewarmPaths)
|
|
50
|
+
builder.setDevPrewarmPaths(userConfig.devPrewarmPaths);
|
|
51
|
+
if (userConfig.devPrewarmBeforeReadyPaths) {
|
|
52
|
+
builder.setDevPrewarmBeforeReadyPaths(userConfig.devPrewarmBeforeReadyPaths);
|
|
53
|
+
}
|
|
54
|
+
if (userConfig.experimental)
|
|
55
|
+
builder.setExperimental(userConfig.experimental);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Applies author-owned config fields onto a {@link ConfigBuilder} instance.
|
|
59
|
+
*/
|
|
60
|
+
export function applyUserConfigToBuilder(builder, userConfig) {
|
|
61
|
+
builder.setRootDir(userConfig.rootDir);
|
|
62
|
+
applyUserDirectoryConfig(builder, userConfig);
|
|
63
|
+
applyUserPipelineConfig(builder, userConfig);
|
|
64
|
+
applyUserMetadataConfig(builder, userConfig);
|
|
65
|
+
applyUserRuntimeConfig(builder, userConfig);
|
|
66
|
+
return builder;
|
|
67
|
+
}
|
|
@@ -16,7 +16,7 @@ export declare const CONFIG_BUILDER_ERRORS: {
|
|
|
16
16
|
readonly MIXED_JSX_ENGINES: "Both kitajs and react integrations are enabled. Use per-file JSX import source/pragma consistently (e.g. `/** @jsxImportSource react */` for React files and `/** @jsxImportSource @kitajs/html */` for Kita files).";
|
|
17
17
|
readonly duplicateProcessorName: (name: string) => string;
|
|
18
18
|
readonly duplicateLoaderName: (name: string) => string;
|
|
19
|
-
readonly duplicateSemanticTemplate: (kind:
|
|
19
|
+
readonly duplicateSemanticTemplate: (kind: string, matches: string[]) => string;
|
|
20
20
|
readonly incompatibleRuntimeCapability: (kind: "integration" | "processor", name: string, runtime: RuntimeKind, reason: string) => string;
|
|
21
21
|
readonly unsupportedRuntimeVersion: (kind: "integration" | "processor", name: string, runtime: RuntimeKind, current: string, min: string) => string;
|
|
22
22
|
readonly invalidRuntimeVersion: (kind: "integration" | "processor", name: string, version: string) => string;
|
|
@@ -45,6 +45,7 @@ type RuntimeKind = 'node' | 'bun';
|
|
|
45
45
|
*/
|
|
46
46
|
export declare class ConfigBuilder {
|
|
47
47
|
private buildOwnership;
|
|
48
|
+
private configModulePath?;
|
|
48
49
|
config: EcoPagesAppConfig;
|
|
49
50
|
/**
|
|
50
51
|
* Sets the base URL for the application.
|
|
@@ -80,6 +81,14 @@ export declare class ConfigBuilder {
|
|
|
80
81
|
* without an explicit ownership.
|
|
81
82
|
*/
|
|
82
83
|
setBuildOwnership(buildOwnership: BuildOwnership): this;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the canonical path of the Ecopages config module on disk.
|
|
86
|
+
*
|
|
87
|
+
* @remarks
|
|
88
|
+
* Used by the config loader so {@link EcoPagesAppConfig.absolutePaths.config}
|
|
89
|
+
* reflects `--config` overrides and production-emitted config modules.
|
|
90
|
+
*/
|
|
91
|
+
setConfigModulePath(configModulePath: string): this;
|
|
83
92
|
/**
|
|
84
93
|
* Sets the source directory relative to the root directory.
|
|
85
94
|
* This directory contains all the source files for the application.
|