@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
|
@@ -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') {
|
|
@@ -2,6 +2,7 @@ import { createRequire } from 'node:module';
|
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { appLogger } from '../../global/app-logger.js';
|
|
5
6
|
import { isBarePackageImportSpecifier } from '../../plugins/tsconfig-import-resolver.js';
|
|
6
7
|
const corePackageRequire = createRequire(new URL('../../../package.json', import.meta.url));
|
|
7
8
|
const appDeclaredPackageCache = new Map();
|
|
@@ -201,9 +202,7 @@ function rewriteRuntimeBuildOutputImports(code, rootDir) {
|
|
|
201
202
|
});
|
|
202
203
|
}
|
|
203
204
|
export function normalizeNodeRuntimeBuildOutputFile(filePath, rootDir) {
|
|
204
|
-
|
|
205
|
-
console.log(`[normalizeNodeRuntimeBuildOutputFile] Checking ${filePath}`);
|
|
206
|
-
}
|
|
205
|
+
appLogger.debug(`[normalizeNodeRuntimeBuildOutputFile] Checking ${filePath}`);
|
|
207
206
|
if (!/\.(?:[cm]?js)$/u.test(filePath)) {
|
|
208
207
|
return;
|
|
209
208
|
}
|
|
@@ -214,9 +213,7 @@ export function normalizeNodeRuntimeBuildOutputFile(filePath, rootDir) {
|
|
|
214
213
|
const code = fileSystem.readFileSync(filePath, 'utf-8');
|
|
215
214
|
const rewritten = rewriteRuntimeBuildOutputImports(code, rootDir);
|
|
216
215
|
if (rewritten !== code) {
|
|
217
|
-
|
|
218
|
-
console.log(`[normalizeNodeRuntimeBuildOutputFile] Rewriting ${filePath}`);
|
|
219
|
-
}
|
|
216
|
+
appLogger.debug(`[normalizeNodeRuntimeBuildOutputFile] Rewriting ${filePath}`);
|
|
220
217
|
fileSystem.writeFileSync(filePath, rewritten);
|
|
221
218
|
}
|
|
222
219
|
}
|
|
@@ -7,11 +7,7 @@ import type { BuildOptions } from '../contracts/build-contracts.js';
|
|
|
7
7
|
* are sorted. Plugin, `conditions`, and source-transform order is preserved because
|
|
8
8
|
* Rolldown hook and `conditionNames` precedence depend on it.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* coalesce. Empty `conditions` / `define` / `external` normalize to the same
|
|
13
|
-
* sentinel as `undefined`.
|
|
10
|
+
* Empty `conditions` / `define` / `external` normalize to the same sentinel as
|
|
11
|
+
* `undefined`.
|
|
14
12
|
*/
|
|
15
13
|
export declare function createBuildRequestIdentity(options: BuildOptions): string;
|
|
16
|
-
/** @deprecated Use {@link createBuildRequestIdentity}. */
|
|
17
|
-
export declare const createBuildOptionsDedupeKey: typeof createBuildRequestIdentity;
|
|
@@ -47,19 +47,15 @@ function normalizeDefine(define) {
|
|
|
47
47
|
* are sorted. Plugin, `conditions`, and source-transform order is preserved because
|
|
48
48
|
* Rolldown hook and `conditionNames` precedence depend on it.
|
|
49
49
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* coalesce. Empty `conditions` / `define` / `external` normalize to the same
|
|
53
|
-
* sentinel as `undefined`.
|
|
50
|
+
* Empty `conditions` / `define` / `external` normalize to the same sentinel as
|
|
51
|
+
* `undefined`.
|
|
54
52
|
*/
|
|
55
53
|
export function createBuildRequestIdentity(options) {
|
|
56
54
|
return [
|
|
57
55
|
normalizeEntrypoints(options.entrypoints),
|
|
58
56
|
options.root ? path.resolve(options.root) : 'root:default',
|
|
59
57
|
options.outdir ? path.resolve(options.outdir) : 'outdir:default',
|
|
60
|
-
options.outbase ? path.resolve(options.outbase) : 'outbase:default',
|
|
61
58
|
options.splitting ?? 'splitting:default',
|
|
62
|
-
options.bundle ?? 'bundle:default',
|
|
63
59
|
options.externalPackages ?? 'externalPackages:default',
|
|
64
60
|
options.target ?? 'target:default',
|
|
65
61
|
options.format ?? 'format:default',
|
|
@@ -75,5 +71,3 @@ export function createBuildRequestIdentity(options) {
|
|
|
75
71
|
createSourceTransformCacheKey(options.sourceTransforms),
|
|
76
72
|
].join('::');
|
|
77
73
|
}
|
|
78
|
-
/** @deprecated Use {@link createBuildRequestIdentity}. */
|
|
79
|
-
export const createBuildOptionsDedupeKey = createBuildRequestIdentity;
|
|
@@ -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/cache/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module @ecopages/core/cache
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
6
|
+
export { parseModuleSource, type ModuleParseOptions } from './module-parse-cache.js';
|
|
7
7
|
export { recordModuleTransformProfile } from './module-transform-profiler.js';
|
package/src/cache/index.js
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module @ecopages/core/cache
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
6
|
+
export { parseModuleSource } from './module-parse-cache.js';
|
|
7
7
|
export { recordModuleTransformProfile } from './module-transform-profiler.js';
|
|
@@ -22,22 +22,17 @@ export type ModuleParseOptions = ParserOptions & {
|
|
|
22
22
|
*/
|
|
23
23
|
lang?: ParserOptions['lang'];
|
|
24
24
|
};
|
|
25
|
-
export type ParserLanguage = 'js' | 'jsx' | 'ts' | 'tsx';
|
|
26
|
-
/** Resolves the Oxc dialect for a source module from its file extension. */
|
|
27
|
-
export declare function parserLanguageForFile(filePath: string): ParserLanguage;
|
|
28
25
|
/** Parses an ECMAScript module with the shared, normalized cache contract. */
|
|
29
26
|
export declare function parseModuleSource(filePath: string, source: string, options?: ModuleParseOptions): ParseResult;
|
|
30
27
|
/**
|
|
31
28
|
* LRU-bounded module parse cache.
|
|
32
29
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
30
|
+
* One instance is shared across the process; call {@link parseModuleSource}
|
|
31
|
+
* to use it.
|
|
35
32
|
*/
|
|
36
33
|
export declare class ModuleParseCache {
|
|
37
34
|
private readonly entries;
|
|
38
35
|
private readonly maxEntries;
|
|
39
|
-
private hits;
|
|
40
|
-
private misses;
|
|
41
36
|
constructor(maxEntries?: number);
|
|
42
37
|
/**
|
|
43
38
|
* Parse `source` for `filePath`, memoizing by (filePath, source, options).
|
|
@@ -45,26 +40,4 @@ export declare class ModuleParseCache {
|
|
|
45
40
|
* @returns the {@link ParseResult} from `oxc-parser.parseSync`.
|
|
46
41
|
*/
|
|
47
42
|
getOrParse(filePath: string, source: string, options?: ModuleParseOptions): ParseResult;
|
|
48
|
-
/** Clear all cached entries. Useful in tests and on full-rebuild signals. */
|
|
49
|
-
clear(): void;
|
|
50
|
-
/** Current cache size (for observability). */
|
|
51
|
-
get size(): number;
|
|
52
|
-
/** Cumulative hit/miss counters (for observability). */
|
|
53
|
-
stats(): {
|
|
54
|
-
hits: number;
|
|
55
|
-
misses: number;
|
|
56
|
-
size: number;
|
|
57
|
-
hitRate: number;
|
|
58
|
-
};
|
|
59
43
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Default shared cache. Use this from plugin code so the cache is
|
|
62
|
-
* amortized across plugins and build invocations.
|
|
63
|
-
*/
|
|
64
|
-
export declare const moduleParseCache: ModuleParseCache;
|
|
65
|
-
/**
|
|
66
|
-
* Drop-in replacement for `oxc-parser.parseSync` that uses the shared
|
|
67
|
-
* {@link moduleParseCache}. Use everywhere we currently call `parseSync`
|
|
68
|
-
* on user/source files during a build.
|
|
69
|
-
*/
|
|
70
|
-
export declare function cachedParseSync(filePath: string, source: string, options?: ModuleParseOptions): ParseResult;
|
|
@@ -18,7 +18,7 @@ import { parseSync } from 'oxc-parser';
|
|
|
18
18
|
import { rapidhash } from '../utils/hash.js';
|
|
19
19
|
const DEFAULT_MAX_ENTRIES = 10_000;
|
|
20
20
|
/** Resolves the Oxc dialect for a source module from its file extension. */
|
|
21
|
-
|
|
21
|
+
function parserLanguageForFile(filePath) {
|
|
22
22
|
const extension = extname(filePath).toLowerCase();
|
|
23
23
|
if (extension === '.tsx')
|
|
24
24
|
return 'tsx';
|
|
@@ -30,19 +30,17 @@ export function parserLanguageForFile(filePath) {
|
|
|
30
30
|
}
|
|
31
31
|
/** Parses an ECMAScript module with the shared, normalized cache contract. */
|
|
32
32
|
export function parseModuleSource(filePath, source, options = {}) {
|
|
33
|
-
return moduleParseCache.getOrParse(filePath, source,
|
|
33
|
+
return moduleParseCache.getOrParse(filePath, source, options);
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* LRU-bounded module parse cache.
|
|
37
37
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* One instance is shared across the process; call {@link parseModuleSource}
|
|
39
|
+
* to use it.
|
|
40
40
|
*/
|
|
41
41
|
export class ModuleParseCache {
|
|
42
42
|
entries = new Map();
|
|
43
43
|
maxEntries;
|
|
44
|
-
hits = 0;
|
|
45
|
-
misses = 0;
|
|
46
44
|
constructor(maxEntries = DEFAULT_MAX_ENTRIES) {
|
|
47
45
|
if (maxEntries <= 0) {
|
|
48
46
|
throw new Error(`ModuleParseCache: maxEntries must be > 0, got ${maxEntries}`);
|
|
@@ -60,13 +58,11 @@ export class ModuleParseCache {
|
|
|
60
58
|
const key = makeKey(filePath, hash, normalizedOptions);
|
|
61
59
|
const existing = this.entries.get(key);
|
|
62
60
|
if (existing && existing.hash === hash) {
|
|
63
|
-
this.hits += 1;
|
|
64
61
|
// Refresh LRU position.
|
|
65
62
|
this.entries.delete(key);
|
|
66
63
|
this.entries.set(key, existing);
|
|
67
64
|
return existing.result;
|
|
68
65
|
}
|
|
69
|
-
this.misses += 1;
|
|
70
66
|
const result = parseSync(filePath, source, normalizedOptions);
|
|
71
67
|
this.entries.set(key, { hash, result });
|
|
72
68
|
if (this.entries.size > this.maxEntries) {
|
|
@@ -80,40 +76,11 @@ export class ModuleParseCache {
|
|
|
80
76
|
}
|
|
81
77
|
return result;
|
|
82
78
|
}
|
|
83
|
-
/** Clear all cached entries. Useful in tests and on full-rebuild signals. */
|
|
84
|
-
clear() {
|
|
85
|
-
this.entries.clear();
|
|
86
|
-
this.hits = 0;
|
|
87
|
-
this.misses = 0;
|
|
88
|
-
}
|
|
89
|
-
/** Current cache size (for observability). */
|
|
90
|
-
get size() {
|
|
91
|
-
return this.entries.size;
|
|
92
|
-
}
|
|
93
|
-
/** Cumulative hit/miss counters (for observability). */
|
|
94
|
-
stats() {
|
|
95
|
-
const total = this.hits + this.misses;
|
|
96
|
-
return {
|
|
97
|
-
hits: this.hits,
|
|
98
|
-
misses: this.misses,
|
|
99
|
-
size: this.entries.size,
|
|
100
|
-
hitRate: total === 0 ? 0 : this.hits / total,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
79
|
}
|
|
104
80
|
/**
|
|
105
|
-
* Default shared cache
|
|
106
|
-
* amortized across plugins and build invocations.
|
|
81
|
+
* Default shared cache, amortized across plugins and build invocations.
|
|
107
82
|
*/
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Drop-in replacement for `oxc-parser.parseSync` that uses the shared
|
|
111
|
-
* {@link moduleParseCache}. Use everywhere we currently call `parseSync`
|
|
112
|
-
* on user/source files during a build.
|
|
113
|
-
*/
|
|
114
|
-
export function cachedParseSync(filePath, source, options = {}) {
|
|
115
|
-
return parseModuleSource(filePath, source, options);
|
|
116
|
-
}
|
|
83
|
+
const moduleParseCache = new ModuleParseCache();
|
|
117
84
|
function normalizeModuleParseOptions(filePath, options) {
|
|
118
85
|
return {
|
|
119
86
|
...options,
|
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` (omitted `rootDir` defaults to `cwd`; `baseUrl` defaults during `ConfigBuilder.build()`)
|
|
23
|
+
- `resolve-eco-config-path.ts`: `eco.config.ts` discovery (`configFile`, `ECOPAGES_CONFIG_FILE`, cwd default, and production `.server/eco.config.mjs`) and `resolveUserConfigRootDir()`
|
|
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 (by config path, build ownership, and cwd).
|
|
51
|
+
- Core fixture helpers live in `packages/core/__fixtures__/app/test-app-config.ts` (`createFixtureAppConfig`, `createFixtureApp`).
|
|
@@ -0,0 +1,8 @@
|
|
|
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, options?: {
|
|
7
|
+
cwd?: string;
|
|
8
|
+
}): ConfigBuilder;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ConfigBuilder } from './config-builder.js';
|
|
2
|
+
import { resolveUserConfigRootDir } from './resolve-eco-config-path.js';
|
|
3
|
+
function applyUserDirectoryConfig(builder, userConfig) {
|
|
4
|
+
if (userConfig.srcDir)
|
|
5
|
+
builder.setSrcDir(userConfig.srcDir);
|
|
6
|
+
if (userConfig.pagesDir)
|
|
7
|
+
builder.setPagesDir(userConfig.pagesDir);
|
|
8
|
+
if (userConfig.includesDir)
|
|
9
|
+
builder.setIncludesDir(userConfig.includesDir);
|
|
10
|
+
if (userConfig.componentsDir)
|
|
11
|
+
builder.setComponentsDir(userConfig.componentsDir);
|
|
12
|
+
if (userConfig.layoutsDir)
|
|
13
|
+
builder.setLayoutsDir(userConfig.layoutsDir);
|
|
14
|
+
if (userConfig.publicDir)
|
|
15
|
+
builder.setPublicDir(userConfig.publicDir);
|
|
16
|
+
if (userConfig.distDir)
|
|
17
|
+
builder.setDistDir(userConfig.distDir);
|
|
18
|
+
if (userConfig.workDir)
|
|
19
|
+
builder.setWorkDir(userConfig.workDir);
|
|
20
|
+
}
|
|
21
|
+
function applyUserPipelineConfig(builder, userConfig) {
|
|
22
|
+
if (userConfig.integrations)
|
|
23
|
+
builder.setIntegrations(userConfig.integrations);
|
|
24
|
+
if (userConfig.processors)
|
|
25
|
+
builder.setProcessors(userConfig.processors);
|
|
26
|
+
if (userConfig.loaders)
|
|
27
|
+
builder.setLoaders(userConfig.loaders);
|
|
28
|
+
if (userConfig.sourceTransforms)
|
|
29
|
+
builder.setSourceTransforms(userConfig.sourceTransforms);
|
|
30
|
+
if (userConfig.cache)
|
|
31
|
+
builder.setCacheConfig(userConfig.cache);
|
|
32
|
+
if (userConfig.buildOwnership)
|
|
33
|
+
builder.setBuildOwnership(userConfig.buildOwnership);
|
|
34
|
+
}
|
|
35
|
+
function applyUserMetadataConfig(builder, userConfig) {
|
|
36
|
+
if (userConfig.baseUrl !== undefined)
|
|
37
|
+
builder.setBaseUrl(userConfig.baseUrl);
|
|
38
|
+
if (userConfig.robotsTxt)
|
|
39
|
+
builder.setRobotsTxt(userConfig.robotsTxt);
|
|
40
|
+
if (userConfig.sitemap)
|
|
41
|
+
builder.setSitemap(userConfig.sitemap);
|
|
42
|
+
if (userConfig.defaultMetadata)
|
|
43
|
+
builder.setDefaultMetadata(userConfig.defaultMetadata);
|
|
44
|
+
}
|
|
45
|
+
function applyUserRuntimeConfig(builder, userConfig) {
|
|
46
|
+
if (userConfig.devToolbar)
|
|
47
|
+
builder.setDevToolbar(userConfig.devToolbar);
|
|
48
|
+
if (userConfig.additionalWatchPaths)
|
|
49
|
+
builder.setAdditionalWatchPaths(userConfig.additionalWatchPaths);
|
|
50
|
+
if (userConfig.devPrewarmPaths)
|
|
51
|
+
builder.setDevPrewarmPaths(userConfig.devPrewarmPaths);
|
|
52
|
+
if (userConfig.devPrewarmBeforeReadyPaths) {
|
|
53
|
+
builder.setDevPrewarmBeforeReadyPaths(userConfig.devPrewarmBeforeReadyPaths);
|
|
54
|
+
}
|
|
55
|
+
if (userConfig.experimental)
|
|
56
|
+
builder.setExperimental(userConfig.experimental);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Applies author-owned config fields onto a {@link ConfigBuilder} instance.
|
|
60
|
+
*/
|
|
61
|
+
export function applyUserConfigToBuilder(builder, userConfig, options = {}) {
|
|
62
|
+
builder.setRootDir(resolveUserConfigRootDir(userConfig.rootDir, options.cwd));
|
|
63
|
+
applyUserDirectoryConfig(builder, userConfig);
|
|
64
|
+
applyUserPipelineConfig(builder, userConfig);
|
|
65
|
+
applyUserMetadataConfig(builder, userConfig);
|
|
66
|
+
applyUserRuntimeConfig(builder, userConfig);
|
|
67
|
+
return builder;
|
|
68
|
+
}
|
|
@@ -16,7 +16,8 @@ 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
|
|
19
|
+
readonly duplicateSourceTransformName: (name: string) => string;
|
|
20
|
+
readonly duplicateSemanticTemplate: (kind: string, matches: string[]) => string;
|
|
20
21
|
readonly incompatibleRuntimeCapability: (kind: "integration" | "processor", name: string, runtime: RuntimeKind, reason: string) => string;
|
|
21
22
|
readonly unsupportedRuntimeVersion: (kind: "integration" | "processor", name: string, runtime: RuntimeKind, current: string, min: string) => string;
|
|
22
23
|
readonly invalidRuntimeVersion: (kind: "integration" | "processor", name: string, version: string) => string;
|
|
@@ -45,6 +46,7 @@ type RuntimeKind = 'node' | 'bun';
|
|
|
45
46
|
*/
|
|
46
47
|
export declare class ConfigBuilder {
|
|
47
48
|
private buildOwnership;
|
|
49
|
+
private configModulePath?;
|
|
48
50
|
config: EcoPagesAppConfig;
|
|
49
51
|
/**
|
|
50
52
|
* Sets the base URL for the application.
|
|
@@ -80,6 +82,14 @@ export declare class ConfigBuilder {
|
|
|
80
82
|
* without an explicit ownership.
|
|
81
83
|
*/
|
|
82
84
|
setBuildOwnership(buildOwnership: BuildOwnership): this;
|
|
85
|
+
/**
|
|
86
|
+
* Sets the canonical path of the Ecopages config module on disk.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* Used by the config loader so {@link EcoPagesAppConfig.absolutePaths.config}
|
|
90
|
+
* reflects `--config` overrides and production-emitted config modules.
|
|
91
|
+
*/
|
|
92
|
+
setConfigModulePath(configModulePath: string): this;
|
|
83
93
|
/**
|
|
84
94
|
* Sets the source directory relative to the root directory.
|
|
85
95
|
* This directory contains all the source files for the application.
|