@ecopages/core 0.2.0-rc.1 → 0.2.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -41
- package/package.json +50 -145
- package/src/adapters/README.md +11 -3
- package/src/adapters/abstract/application-adapter.d.ts +32 -36
- package/src/adapters/abstract/application-adapter.js +61 -47
- package/src/adapters/abstract/segment-path-matcher.js +56 -38
- package/src/adapters/abstract/server-adapter.d.ts +14 -0
- package/src/adapters/abstract/server-adapter.js +10 -0
- package/src/adapters/abstract/ws-pattern-matcher.d.ts +0 -5
- package/src/adapters/abstract/ws-pattern-matcher.js +0 -9
- package/src/adapters/bun/create-app.d.ts +15 -15
- package/src/adapters/bun/create-app.js +52 -67
- package/src/adapters/bun/hmr-manager.d.ts +0 -1
- package/src/adapters/bun/hmr-manager.js +2 -4
- package/src/adapters/bun/server-adapter.d.ts +15 -21
- package/src/adapters/bun/server-adapter.js +33 -67
- package/src/adapters/bun/static-preview-host.d.ts +1 -0
- package/src/adapters/bun/static-preview-host.js +1 -1
- package/src/adapters/create-app.d.ts +63 -8
- package/src/adapters/create-app.js +62 -5
- package/src/adapters/node/create-app.d.ts +8 -12
- package/src/adapters/node/create-app.js +22 -14
- package/src/adapters/node/runtime-host.d.ts +10 -10
- package/src/adapters/node/runtime-host.js +13 -8
- package/src/adapters/node/server-adapter-dependencies.d.ts +2 -10
- package/src/adapters/node/server-adapter-dependencies.js +8 -13
- package/src/adapters/node/server-adapter.d.ts +30 -32
- package/src/adapters/node/server-adapter.js +59 -65
- package/src/adapters/shared/hmr/shared-hmr-manager.d.ts +0 -4
- package/src/adapters/shared/hmr/shared-hmr-manager.js +0 -12
- package/src/adapters/shared/http/api-request-pipeline.d.ts +27 -1
- package/src/adapters/shared/http/api-request-pipeline.js +31 -16
- package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
- package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -9
- package/src/adapters/shared/http/fs-server-response-factory.js +5 -33
- package/src/adapters/shared/http/fs-server-response-matcher.d.ts +24 -24
- package/src/adapters/shared/http/fs-server-response-matcher.js +59 -83
- package/src/adapters/shared/runtime/application-adapter.d.ts +1 -0
- package/src/adapters/shared/runtime/application-adapter.js +12 -0
- package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
- package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
- package/src/adapters/shared/runtime/collect-dev-prewarm-plan.d.ts +1 -3
- package/src/adapters/shared/runtime/collect-dev-prewarm-plan.js +1 -4
- package/src/adapters/shared/runtime/port-manager-default-prompt.d.ts +6 -0
- package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
- package/src/adapters/shared/runtime/port-manager.d.ts +3 -3
- package/src/adapters/shared/runtime/port-manager.js +14 -45
- package/src/adapters/shared/runtime/runtime-app-bootstrap.d.ts +0 -10
- package/src/adapters/shared/runtime/runtime-app-bootstrap.js +0 -7
- package/src/adapters/shared/runtime/runtime-host.d.ts +5 -2
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +1 -1
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +1 -1
- package/src/adapters/shared/runtime/server-adapter.d.ts +27 -5
- package/src/adapters/shared/runtime/server-adapter.js +44 -30
- package/src/adapters/shared/runtime/server-route-handler.js +11 -3
- package/src/adapters/shared/runtime/server-static-builder.d.ts +9 -3
- package/src/adapters/shared/runtime/server-static-builder.js +59 -37
- package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +9 -1
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +8 -2
- package/src/build/README.md +9 -6
- package/src/build/cache/cache-constants.d.ts +0 -2
- package/src/build/cache/cache-constants.js +0 -2
- package/src/build/cache/cache-keys.d.ts +0 -2
- package/src/build/cache/cache-keys.js +0 -2
- package/src/build/cache/output-imports.d.ts +27 -0
- package/src/build/cache/output-imports.js +80 -0
- package/src/build/cache/pages-unified-graph-build.d.ts +6 -1
- package/src/build/cache/pages-unified-graph-build.js +42 -17
- package/src/build/cache/production-build-cache.d.ts +2 -2
- package/src/build/cache/production-build-cache.js +2 -2
- package/src/build/cache/server-entry-build-cache.d.ts +25 -3
- package/src/build/cache/server-entry-build-cache.js +129 -13
- package/src/build/contracts/build-contracts.d.ts +1 -13
- package/src/build/contracts/content-virtual-modules.d.ts +3 -1
- package/src/build/contracts/content-virtual-modules.js +8 -0
- package/src/build/rolldown/rolldown-adapter-helpers.js +41 -25
- package/src/build/rolldown/rolldown-plugin-bridge.js +25 -21
- package/src/build/rolldown/runtime-build-output-normalizer.js +3 -6
- package/src/build/runtime/build-request-identity.d.ts +2 -6
- package/src/build/runtime/build-request-identity.js +2 -8
- package/src/build/runtime/build-request-policy.js +1 -1
- package/src/build/runtime/deduping-build-executor.d.ts +0 -1
- package/src/build/runtime/deduping-build-executor.js +0 -1
- package/src/build/server-bundle-publication.d.ts +14 -0
- package/src/build/server-bundle-publication.js +49 -0
- package/src/cache/index.d.ts +1 -1
- package/src/cache/index.js +1 -1
- package/src/cache/module-parse-cache.d.ts +2 -29
- package/src/cache/module-parse-cache.js +6 -39
- package/src/config/README.md +17 -2
- package/src/config/apply-user-config.d.ts +8 -0
- package/src/config/apply-user-config.js +68 -0
- package/src/config/config-builder.d.ts +11 -1
- package/src/config/config-builder.js +53 -12
- package/src/config/constants.d.ts +4 -4
- package/src/config/constants.js +4 -4
- package/src/config/define-config.d.ts +9 -0
- package/src/config/define-config.js +10 -0
- package/src/config/index.d.ts +5 -0
- package/src/config/index.js +4 -0
- package/src/config/is-finalized-app-config.d.ts +6 -0
- package/src/config/is-finalized-app-config.js +11 -0
- package/src/config/load-eco-config.d.ts +21 -0
- package/src/config/load-eco-config.js +107 -0
- package/src/config/resolve-eco-config-path.d.ts +32 -0
- package/src/config/resolve-eco-config-path.js +58 -0
- package/src/config/server-config-bundle.d.ts +25 -0
- package/src/config/server-config-bundle.js +148 -0
- package/src/config/user-config-types.d.ts +170 -0
- package/src/config/user-config-types.js +1 -0
- package/src/css-imports.d.ts +4 -0
- package/src/declarations.d.ts +11 -5
- package/src/dev/README.md +6 -0
- package/src/dev/development-restart-watch-paths.d.ts +13 -0
- package/src/dev/development-restart-watch-paths.js +37 -0
- package/src/dev/development-restart.d.ts +13 -0
- package/src/dev/development-restart.js +21 -0
- package/src/dev/host-runtime.d.ts +0 -1
- package/src/dev/host-runtime.js +0 -3
- package/src/dev/sc-server.d.ts +4 -1
- package/src/dev/sc-server.js +11 -20
- package/src/dev/transform-server/dev-transform-import-rewriter.js +2 -2
- package/src/dev/transform-server/dev-transform-server.d.ts +6 -0
- package/src/dev/transform-server/dev-transform-server.js +16 -5
- package/src/eco/README.md +73 -5
- package/src/eco/component-identity.d.ts +3 -2
- package/src/eco/component-identity.js +5 -2
- package/src/eco/discovered-dependencies.d.ts +45 -0
- package/src/eco/discovered-dependencies.js +87 -0
- package/src/eco/eco.js +6 -0
- package/src/eco/eco.types.d.ts +18 -2
- package/src/eco/lazy-injector-map.js +57 -41
- package/src/eco/page-dependency-contributions.d.ts +19 -0
- package/src/eco/page-dependency-contributions.js +52 -0
- package/src/errors/http-error-page-contract.d.ts +77 -0
- package/src/errors/http-error-page-contract.js +106 -0
- package/src/hmr/hmr-file-change-prep.d.ts +0 -1
- package/src/hmr/hmr-file-change-prep.js +2 -5
- package/src/hmr/hmr-strategy.d.ts +3 -8
- package/src/hmr/hmr-strategy.js +3 -8
- package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -0
- package/src/hmr/strategies/js-hmr-strategy.js +24 -16
- package/src/index.browser.d.ts +2 -0
- package/src/index.browser.js +2 -0
- package/src/index.d.ts +5 -3
- package/src/index.js +5 -3
- package/src/islands/README.md +5 -1
- package/src/islands/island-host.d.ts +0 -9
- package/src/islands/island-host.js +1 -13
- package/src/plugins/README.md +8 -1
- package/src/plugins/component-import-discovery.d.ts +19 -0
- package/src/plugins/component-import-discovery.js +241 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +3 -1
- package/src/plugins/eco-component-meta-plugin.js +120 -18
- package/src/plugins/integration-plugin.d.ts +0 -1
- package/src/plugins/integration-plugin.js +0 -4
- package/src/plugins/processor.d.ts +10 -2
- package/src/plugins/processor.js +4 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
- package/src/plugins/tsconfig-import-resolver.js +4 -2
- package/src/route-renderer/GRAPH.md +1 -1
- package/src/route-renderer/README.md +15 -2
- package/src/{adapters/shared/http/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +3 -3
- package/src/route-renderer/orchestration/custom-element-scripts/README.md +9 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +16 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +34 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +80 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +190 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +17 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +41 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +10 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +46 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +7 -2
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +3 -4
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +11 -2
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +10 -2
- package/src/route-renderer/orchestration/integration-renderer.d.ts +9 -11
- package/src/route-renderer/orchestration/integration-renderer.js +43 -40
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +1 -1
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +2 -5
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +2 -68
- package/src/route-renderer/orchestration/ownership-graph/component-graph.js +55 -39
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -1
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -1
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +6 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +59 -36
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +8 -10
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +1 -1
- package/src/route-renderer/orchestration/string-markup-renderer.js +2 -1
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +6 -2
- package/src/route-renderer/page-loading/component-dependency-collection.js +113 -68
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +41 -28
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +10 -3
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +62 -25
- package/src/route-renderer/page-loading/page-dependency-bundling.js +14 -8
- package/src/route-renderer/page-loading/resolved-page-dependencies.d.ts +1 -2
- package/src/route-renderer/page-loading/resolved-page-dependencies.js +8 -7
- package/src/route-renderer/route-renderer.d.ts +9 -0
- package/src/route-renderer/route-renderer.js +18 -0
- package/src/router/README.md +7 -1
- package/src/router/server/route-registry.d.ts +13 -0
- package/src/router/server/route-registry.js +46 -32
- package/src/services/README.md +6 -1
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +36 -9
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.js +122 -37
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +2 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +13 -2
- package/src/services/assets/asset-processing-service/page-package.js +42 -39
- package/src/services/assets/browser-bundle.service.d.ts +1 -6
- package/src/services/error-pages/README.md +9 -0
- package/src/services/error-pages/default-error-pages.d.ts +39 -0
- package/src/services/error-pages/default-error-pages.js +199 -0
- package/src/services/error-pages/error-page-renderer.d.ts +58 -0
- package/src/services/error-pages/error-page-renderer.js +146 -0
- package/src/services/error-pages/semantic-error-page-exporter.d.ts +23 -0
- package/src/services/error-pages/semantic-error-page-exporter.js +35 -0
- package/src/services/html/html-rewriter.d.ts +77 -0
- package/src/services/html/html-rewriter.js +751 -0
- package/src/services/html/html-rewriter.parity.test.bun.d.ts +1 -0
- package/src/services/html/html-rewriter.parity.test.bun.js +74 -0
- package/src/services/html/html-transformer.service.d.ts +26 -39
- package/src/services/html/html-transformer.service.js +81 -153
- package/src/services/invalidation/development-invalidation.service.d.ts +9 -20
- package/src/services/invalidation/development-invalidation.service.js +35 -41
- package/src/services/module-loading/README.md +17 -14
- package/src/services/module-loading/app-module-loader.service.d.ts +0 -2
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +1 -1
- package/src/services/module-loading/app-server-module-transpiler.service.js +2 -10
- package/src/services/module-loading/collection-server-module-build.service.d.ts +1 -1
- package/src/services/module-loading/collection-server-module-build.service.js +5 -5
- package/src/services/module-loading/host-module-loader-registry.d.ts +0 -1
- package/src/services/module-loading/host-module-loader-registry.js +0 -3
- package/src/services/module-loading/page-module-import.service.d.ts +8 -0
- package/src/services/module-loading/page-module-import.service.js +62 -28
- package/src/services/module-loading/route-module-build-cache-registry.d.ts +0 -4
- package/src/services/module-loading/route-module-build-cache-registry.js +0 -4
- package/src/services/module-loading/route-module-build-cache.store.d.ts +3 -0
- package/src/services/module-loading/route-module-build-cache.store.js +18 -5
- package/src/services/module-loading/route-module-build-manifest.d.ts +6 -1
- package/src/services/module-loading/route-module-build-manifest.js +1 -2
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +3 -2
- package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
- package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -15
- package/src/services/module-loading/server-module-transpiler.service.js +0 -24
- package/src/services/module-loading/view-module-loader.d.ts +10 -0
- package/src/services/module-loading/view-module-loader.js +46 -0
- package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -12
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +4 -2
- package/src/services/runtime-state/server-invalidation-state.service.js +7 -14
- package/src/services/validation/schema-validation-service.d.ts +1 -0
- package/src/services/validation/schema-validation-service.js +23 -36
- package/src/static-site-generator/README.md +6 -1
- package/src/static-site-generator/static-site-generator.d.ts +7 -2
- package/src/static-site-generator/static-site-generator.js +90 -49
- package/src/types/internal-types.d.ts +6 -39
- package/src/types/public-types.d.ts +29 -131
- package/src/utils/parse-cli-args.js +29 -22
- package/src/watchers/project-watcher.d.ts +14 -16
- package/src/watchers/project-watcher.js +86 -61
- package/src/watchers/project-watcher.test-helpers.d.ts +10 -1
- package/src/watchers/project-watcher.test-helpers.js +12 -0
- package/src/adapters/abstract/router-adapter.d.ts +0 -26
- package/src/adapters/abstract/router-adapter.js +0 -13
- package/src/adapters/bun/index.d.ts +0 -2
- package/src/adapters/bun/index.js +0 -2
- package/src/adapters/index.d.ts +0 -2
- package/src/adapters/index.js +0 -2
- package/src/eco/eco.utils.d.ts +0 -1
- package/src/eco/eco.utils.js +0 -1
- package/src/services/cache/index.d.ts +0 -9
- package/src/services/cache/index.js +0 -8
- package/src/services/html/html-rewriter-provider.service.d.ts +0 -40
- package/src/services/html/html-rewriter-provider.service.js +0 -68
- package/src/services/module-loading/route-module-build-cache.d.ts +0 -4
- package/src/services/module-loading/route-module-build-cache.js +0 -3
- package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
- package/src/services/runtime-state/dev-graph.service.js +0 -170
- /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { isDevEnvFilePath } from '../../dev/development-restart-watch-paths.js';
|
|
2
3
|
import { getAppServerInvalidationState } from '../runtime-state/server-invalidation-state.service.js';
|
|
3
|
-
import { appLogger } from '../../global/app-logger.js';
|
|
4
4
|
import { clearAppDevelopmentRouteModuleBuildCaches } from '../module-loading/route-module-build-cache-registry.js';
|
|
5
|
+
import { clearCollectionServerBuildArtifacts } from '../module-loading/collection-server-module-build.service.js';
|
|
5
6
|
/**
|
|
6
7
|
* Framework-owned development invalidation service.
|
|
7
8
|
*
|
|
8
9
|
* @remarks
|
|
9
10
|
* This service centralizes two responsibilities:
|
|
10
11
|
* - file-change classification for watcher behavior
|
|
11
|
-
* - app-owned server-module invalidation
|
|
12
|
+
* - app-owned server-module invalidation
|
|
12
13
|
*
|
|
13
14
|
* Hosts and watchers should ask this service what a file change means instead
|
|
14
15
|
* of deciding invalidation semantics inline.
|
|
@@ -18,12 +19,6 @@ export class DevelopmentInvalidationService {
|
|
|
18
19
|
constructor(appConfig) {
|
|
19
20
|
this.appConfig = appConfig;
|
|
20
21
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Returns the current app-owned server-module invalidation version.
|
|
23
|
-
*/
|
|
24
|
-
getServerModuleInvalidationVersion() {
|
|
25
|
-
return getAppServerInvalidationState(this.appConfig).getServerInvalidationVersion();
|
|
26
|
-
}
|
|
27
22
|
/**
|
|
28
23
|
* Invalidates the app-owned server-module graph.
|
|
29
24
|
*/
|
|
@@ -31,42 +26,25 @@ export class DevelopmentInvalidationService {
|
|
|
31
26
|
getAppServerInvalidationState(this.appConfig).invalidateServerModules(changedFiles);
|
|
32
27
|
this.appConfig.runtime?.appModuleLoader?.invalidateDevelopmentGraph();
|
|
33
28
|
clearAppDevelopmentRouteModuleBuildCaches(this.appConfig);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*/
|
|
38
|
-
registerRegisteredScriptEntrypointChangeHandler(handler) {
|
|
39
|
-
const runtime = this.appConfig.runtime ?? {};
|
|
40
|
-
this.appConfig.runtime = runtime;
|
|
41
|
-
runtime.registeredScriptEntrypointChangeHandlers ??= [];
|
|
42
|
-
runtime.registeredScriptEntrypointChangeHandlers.push(handler);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Notifies integration handlers that a registered script entrypoint changed.
|
|
46
|
-
*/
|
|
47
|
-
async notifyRegisteredScriptEntrypointChange(filePath) {
|
|
48
|
-
const handlers = this.appConfig.runtime?.registeredScriptEntrypointChangeHandlers ?? [];
|
|
49
|
-
for (const handler of handlers) {
|
|
50
|
-
try {
|
|
51
|
-
await handler(filePath);
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
appLogger.error(`Failed to handle registered script entrypoint change for ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
55
|
-
}
|
|
29
|
+
clearCollectionServerBuildArtifacts(this.appConfig);
|
|
30
|
+
for (const processor of this.appConfig.processors.values()) {
|
|
31
|
+
processor.invalidateServerArtifacts?.();
|
|
56
32
|
}
|
|
57
33
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Resets runtime-owned graph state and invalidates server modules.
|
|
60
|
-
*/
|
|
61
|
-
resetRuntimeState(changedFiles) {
|
|
62
|
-
this.invalidateServerModules(changedFiles);
|
|
63
|
-
const serverInvalidationState = getAppServerInvalidationState(this.appConfig);
|
|
64
|
-
serverInvalidationState.reset();
|
|
65
|
-
}
|
|
66
34
|
/**
|
|
67
35
|
* Classifies one changed file into an explicit framework invalidation plan.
|
|
68
36
|
*/
|
|
69
37
|
planFileChange(filePath) {
|
|
38
|
+
if (this.isRuntimeRestartFile(filePath)) {
|
|
39
|
+
return {
|
|
40
|
+
category: 'runtime-restart',
|
|
41
|
+
invalidateServerModules: false,
|
|
42
|
+
refreshRoutes: false,
|
|
43
|
+
reloadBrowser: false,
|
|
44
|
+
delegateToHmr: false,
|
|
45
|
+
processorHandledAsset: false,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
70
48
|
if (this.isPublicDirFile(filePath)) {
|
|
71
49
|
return {
|
|
72
50
|
category: 'public-asset',
|
|
@@ -80,7 +58,7 @@ export class DevelopmentInvalidationService {
|
|
|
80
58
|
if (this.matchesAdditionalWatchPaths(filePath)) {
|
|
81
59
|
return {
|
|
82
60
|
category: 'additional-watch',
|
|
83
|
-
invalidateServerModules:
|
|
61
|
+
invalidateServerModules: true,
|
|
84
62
|
refreshRoutes: false,
|
|
85
63
|
reloadBrowser: true,
|
|
86
64
|
delegateToHmr: false,
|
|
@@ -146,6 +124,20 @@ export class DevelopmentInvalidationService {
|
|
|
146
124
|
processorHandledAsset: false,
|
|
147
125
|
};
|
|
148
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Returns whether a config or dotenv edit should restart the development process.
|
|
129
|
+
*/
|
|
130
|
+
isRuntimeRestartFile(filePath) {
|
|
131
|
+
return this.isConfigModuleFile(filePath) || isDevEnvFilePath(filePath, this.appConfig.rootDir);
|
|
132
|
+
}
|
|
133
|
+
/** Returns whether `filePath` is the resolved application config module. */
|
|
134
|
+
isConfigModuleFile(filePath) {
|
|
135
|
+
const resolvedPath = path.resolve(filePath);
|
|
136
|
+
const configPath = this.appConfig.absolutePaths?.config
|
|
137
|
+
? path.resolve(this.appConfig.absolutePaths.config)
|
|
138
|
+
: undefined;
|
|
139
|
+
return configPath !== undefined && resolvedPath === configPath;
|
|
140
|
+
}
|
|
149
141
|
/**
|
|
150
142
|
* Returns whether the file lives under the public directory.
|
|
151
143
|
*/
|
|
@@ -162,11 +154,13 @@ export class DevelopmentInvalidationService {
|
|
|
162
154
|
return false;
|
|
163
155
|
for (const pattern of patterns) {
|
|
164
156
|
if (pattern.includes('*')) {
|
|
165
|
-
const ext = pattern.replace(
|
|
157
|
+
const ext = pattern.replace(/\*\*?\/\*|\*+/g, '');
|
|
166
158
|
if (normalizedPath.endsWith(ext))
|
|
167
159
|
return true;
|
|
160
|
+
continue;
|
|
168
161
|
}
|
|
169
|
-
|
|
162
|
+
const resolvedPattern = path.isAbsolute(pattern) ? pattern : path.resolve(this.appConfig.rootDir, pattern);
|
|
163
|
+
if (normalizedPath === resolvedPattern || normalizedPath.startsWith(`${resolvedPattern}${path.sep}`)) {
|
|
170
164
|
return true;
|
|
171
165
|
}
|
|
172
166
|
}
|
|
@@ -20,32 +20,35 @@ Call site (route scan, renderer, SSG, API)
|
|
|
20
20
|
|
|
21
21
|
## Host vs app ownership
|
|
22
22
|
|
|
23
|
-
| Path | When
|
|
24
|
-
| ----------------------- |
|
|
25
|
-
| Host loader | `appConfig.runtime.hostModuleLoader` set (Vite host) and file supports direct source loading
|
|
26
|
-
| Ecopages build pipeline | Framework-owned template files under `pages/`, `includes/`,
|
|
23
|
+
| Path | When |
|
|
24
|
+
| ----------------------- | ----------------------------------------------------------------------------------------------- |
|
|
25
|
+
| Host loader | `appConfig.runtime.hostModuleLoader` set (Vite host) and file supports direct source loading |
|
|
26
|
+
| Ecopages build pipeline | Framework-owned template files under `pages/`, `includes/`, `layouts/`, `components/`, `views/` |
|
|
27
27
|
|
|
28
28
|
`shouldAppUseHostModuleLoader()` encodes the directory + extension rules. Bun always uses the build pipeline today.
|
|
29
29
|
|
|
30
30
|
## Caching layers
|
|
31
31
|
|
|
32
32
|
1. **In-memory promise cache** (`PageModuleImportService.importCache`) — keyed by runtime, file path, content-derived reuse identity (`createRouteModuleReuseIdentity`), and source hash. Cleared by `invalidateDevelopmentGraph()`.
|
|
33
|
-
2. **Disk transpile cache** (`.eco/.server-modules/.build-cache.json`) — production and stable development graphs when dependency hashes match. Manifest field `corePackageVersion` invalidates entries when the framework package changes.
|
|
33
|
+
2. **Disk transpile cache** (`.eco/.server-modules/.build-cache.json`) — production and stable development graphs when dependency hashes match. Manifest field `corePackageVersion` invalidates entries when the framework package changes. An entry is also reused only while every local file its compiled output imports still exists.
|
|
34
34
|
3. **Unified graph manifest** — production static export fast path only; see build layer docs.
|
|
35
35
|
|
|
36
36
|
Development import URLs use `sourceHash` plus a per-service import generation counter. Node uses that value in its `?update=` query. Bun also receives a generation-specific compiled output filename because it retains a previously imported file when only its query changes. Both paths advance after `invalidateDevelopmentGraph()` without a process-wide invalidation version in reuse keys.
|
|
37
37
|
|
|
38
|
+
Compiled collection server modules also include the app-owned server invalidation version in their output filename (`<collection>-<buildIdentity>-<invalidationVersion>.mjs`) so Node's ESM loader treats recompiled bundles as new modules after co-located helper files change.
|
|
39
|
+
|
|
38
40
|
## Files
|
|
39
41
|
|
|
40
|
-
| File | Role
|
|
41
|
-
| ----------------------------------------- |
|
|
42
|
-
| `page-module-import.service.ts` | Core import/cache/build orchestration
|
|
43
|
-
| `route-module-build-manifest.ts` | Content-derived reuse identity and disk cache manifest
|
|
44
|
-
| `app-module-loader.service.ts` | App-facing loader interface
|
|
45
|
-
| `app-server-module-transpiler.service.ts` | Factory for app-scoped loader + transpiler
|
|
46
|
-
| `server-module-transpiler.service.ts` | Injectable transpiler boundary for tests and bootstrap
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
42
|
+
| File | Role |
|
|
43
|
+
| ----------------------------------------- | ---------------------------------------------------------------- |
|
|
44
|
+
| `page-module-import.service.ts` | Core import/cache/build orchestration |
|
|
45
|
+
| `route-module-build-manifest.ts` | Content-derived reuse identity and disk cache manifest |
|
|
46
|
+
| `app-module-loader.service.ts` | App-facing loader interface |
|
|
47
|
+
| `app-server-module-transpiler.service.ts` | Factory for app-scoped loader + transpiler |
|
|
48
|
+
| `server-module-transpiler.service.ts` | Injectable transpiler boundary for tests and bootstrap |
|
|
49
|
+
| `view-module-loader.ts` | Normalizes string/URL view registrations into transpiler loaders |
|
|
50
|
+
| `host-module-loader-registry.ts` | Process-global host loader fallback for embedded runtimes |
|
|
51
|
+
| `source-module-support.ts` | Extension allowlist for host direct loading |
|
|
49
52
|
|
|
50
53
|
## Development invalidation
|
|
51
54
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { PageModuleBuildImportOptions } from './page-module-import.service.js';
|
|
2
|
-
export type AppModuleLoaderOwner = 'app' | 'host';
|
|
3
2
|
export interface AppModuleLoader {
|
|
4
|
-
readonly owner: AppModuleLoaderOwner;
|
|
5
3
|
importModule<T = unknown>(options: PageModuleBuildImportOptions): Promise<T>;
|
|
6
4
|
invalidateDevelopmentGraph(): void;
|
|
7
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { AppModuleLoader } from './app-module-loader.service.js';
|
|
3
3
|
import type { SourceModuleLoader } from './module-loading-types.js';
|
|
4
4
|
import { ServerModuleTranspiler } from './server-module-transpiler.service.js';
|
|
5
5
|
export declare function shouldAppUseHostModuleLoader(appConfig: EcoPagesAppConfig, filePath: string): boolean;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { requireBuildRuntime } from '../../build/runtime/build-runtime.js';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { DevelopmentInvalidationService } from '../invalidation/development-invalidation.service.js';
|
|
4
|
-
import {} from './app-module-loader.service.js';
|
|
5
3
|
import { PageModuleImportService } from './page-module-import.service.js';
|
|
6
4
|
import { supportsSourceModuleLoading } from './source-module-support.js';
|
|
7
5
|
import { ServerModuleTranspiler } from './server-module-transpiler.service.js';
|
|
@@ -10,11 +8,13 @@ export function shouldAppUseHostModuleLoader(appConfig, filePath) {
|
|
|
10
8
|
return supportsSourceModuleLoading(filePath);
|
|
11
9
|
}
|
|
12
10
|
const normalizedFilePath = path.normalize(filePath);
|
|
11
|
+
const viewsDir = path.join(appConfig.absolutePaths.srcDir, 'views');
|
|
13
12
|
const frameworkOwnedDirectories = [
|
|
14
13
|
appConfig.absolutePaths.pagesDir,
|
|
15
14
|
appConfig.absolutePaths.includesDir,
|
|
16
15
|
appConfig.absolutePaths.layoutsDir,
|
|
17
16
|
appConfig.absolutePaths.componentsDir,
|
|
17
|
+
viewsDir,
|
|
18
18
|
].map((directoryPath) => path.normalize(directoryPath));
|
|
19
19
|
const isFrameworkOwnedModule = frameworkOwnedDirectories.some((directoryPath) => {
|
|
20
20
|
return normalizedFilePath === directoryPath || normalizedFilePath.startsWith(`${directoryPath}${path.sep}`);
|
|
@@ -25,9 +25,6 @@ export function shouldAppUseHostModuleLoader(appConfig, filePath) {
|
|
|
25
25
|
export function getAppHostModuleLoader(appConfig) {
|
|
26
26
|
return appConfig.runtime?.hostModuleLoader;
|
|
27
27
|
}
|
|
28
|
-
function getAppModuleLoaderOwner(appConfig) {
|
|
29
|
-
return getAppHostModuleLoader(appConfig) ? 'host' : 'app';
|
|
30
|
-
}
|
|
31
28
|
export function setAppHostModuleLoader(appConfig, hostModuleLoader) {
|
|
32
29
|
appConfig.runtime = {
|
|
33
30
|
...(appConfig.runtime ?? {}),
|
|
@@ -48,9 +45,6 @@ export function createAppModuleLoader(appConfig) {
|
|
|
48
45
|
getHostModuleLoader: () => getAppHostModuleLoader(appConfig),
|
|
49
46
|
});
|
|
50
47
|
const appModuleLoader = {
|
|
51
|
-
get owner() {
|
|
52
|
-
return getAppModuleLoaderOwner(appConfig);
|
|
53
|
-
},
|
|
54
48
|
pageModuleImportService,
|
|
55
49
|
async importModule(options) {
|
|
56
50
|
return await pageModuleImportService.importModule({
|
|
@@ -84,10 +78,8 @@ export function setAppModuleLoader(appConfig, appModuleLoader) {
|
|
|
84
78
|
* instance.
|
|
85
79
|
*/
|
|
86
80
|
export function createAppServerModuleTranspiler(appConfig) {
|
|
87
|
-
const invalidationService = new DevelopmentInvalidationService(appConfig);
|
|
88
81
|
return new ServerModuleTranspiler({
|
|
89
82
|
rootDir: appConfig.rootDir,
|
|
90
|
-
invalidateModules: (changedFiles) => invalidationService.invalidateServerModules(changedFiles),
|
|
91
83
|
pageModuleImportService: getAppModuleLoader(appConfig),
|
|
92
84
|
});
|
|
93
85
|
}
|
|
@@ -5,8 +5,8 @@ export type CollectionServerBuildArtifact = {
|
|
|
5
5
|
outputUrl: string;
|
|
6
6
|
sourcePaths: string[];
|
|
7
7
|
buildIdentity: string;
|
|
8
|
+
invalidationVersion: number;
|
|
8
9
|
};
|
|
9
|
-
export declare function getCollectionServerBuildArtifact(appConfig: EcoPagesAppConfig, collectionName: string): CollectionServerBuildArtifact | undefined;
|
|
10
10
|
export declare function clearCollectionServerBuildArtifacts(appConfig: EcoPagesAppConfig): void;
|
|
11
11
|
/**
|
|
12
12
|
* Builds one generated collection server module as an independent server unit.
|
|
@@ -7,6 +7,7 @@ import { createServerBuildRequest } from '../../build/runtime/build-request-poli
|
|
|
7
7
|
import { recordCollectionBuild } from '../../diagnostics/request-pipeline-metrics.js';
|
|
8
8
|
import { resolveInternalExecutionDir } from '../../utils/resolve-work-dir.js';
|
|
9
9
|
import { fileSystem } from '@ecopages/file-system';
|
|
10
|
+
import { getAppServerInvalidationState } from '../runtime-state/server-invalidation-state.service.js';
|
|
10
11
|
const artifactsByCollection = new WeakMap();
|
|
11
12
|
function getArtifactMap(appConfig) {
|
|
12
13
|
let artifacts = artifactsByCollection.get(appConfig);
|
|
@@ -16,9 +17,6 @@ function getArtifactMap(appConfig) {
|
|
|
16
17
|
}
|
|
17
18
|
return artifacts;
|
|
18
19
|
}
|
|
19
|
-
export function getCollectionServerBuildArtifact(appConfig, collectionName) {
|
|
20
|
-
return getArtifactMap(appConfig).get(collectionName);
|
|
21
|
-
}
|
|
22
20
|
export function clearCollectionServerBuildArtifacts(appConfig) {
|
|
23
21
|
getArtifactMap(appConfig).clear();
|
|
24
22
|
}
|
|
@@ -51,13 +49,14 @@ export async function buildCollectionServerModule(input) {
|
|
|
51
49
|
splitting: false,
|
|
52
50
|
externalPackages: true,
|
|
53
51
|
});
|
|
52
|
+
const invalidationVersion = getAppServerInvalidationState(appConfig).getServerInvalidationVersion();
|
|
54
53
|
const buildIdentity = createCollectionBuildIdentity(createBuildRequestIdentity(buildRequest), sourceFilePath, ownedSourcePaths);
|
|
55
54
|
const artifacts = getArtifactMap(appConfig);
|
|
56
55
|
const existing = artifacts.get(collectionName);
|
|
57
|
-
if (existing?.buildIdentity === buildIdentity) {
|
|
56
|
+
if (existing?.buildIdentity === buildIdentity && existing?.invalidationVersion === invalidationVersion) {
|
|
58
57
|
return existing;
|
|
59
58
|
}
|
|
60
|
-
const outputFileName = `${collectionName}-${buildIdentity}.mjs`;
|
|
59
|
+
const outputFileName = `${collectionName}-${buildIdentity}-${invalidationVersion}.mjs`;
|
|
61
60
|
const buildOptions = { ...buildRequest, naming: outputFileName.replace(/\.mjs$/u, '.[ext]') };
|
|
62
61
|
recordCollectionBuild();
|
|
63
62
|
const buildResult = await build(buildOptions);
|
|
@@ -77,6 +76,7 @@ export async function buildCollectionServerModule(input) {
|
|
|
77
76
|
outputUrl: pathToFileURL(compiledOutput).href,
|
|
78
77
|
sourcePaths: [...ownedSourcePaths, sourceFilePath],
|
|
79
78
|
buildIdentity,
|
|
79
|
+
invalidationVersion,
|
|
80
80
|
};
|
|
81
81
|
artifacts.set(collectionName, artifact);
|
|
82
82
|
return artifact;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { SourceModuleLoader } from './module-loading-types.js';
|
|
2
2
|
export declare function setHostModuleLoader(loader: SourceModuleLoader): void;
|
|
3
3
|
export declare function getHostModuleLoader(): SourceModuleLoader | undefined;
|
|
4
|
-
export declare function clearHostModuleLoader(): void;
|
|
@@ -16,6 +16,8 @@ interface PageModuleImportBaseOptions {
|
|
|
16
16
|
export interface PageModuleBuildImportOptions extends PageModuleImportBaseOptions {
|
|
17
17
|
rootDir: string;
|
|
18
18
|
outdir: string;
|
|
19
|
+
/** Use the server build pipeline even when a development host can load source modules. */
|
|
20
|
+
forceBuild?: boolean;
|
|
19
21
|
buildExecutor?: BuildExecutor;
|
|
20
22
|
splitting?: boolean;
|
|
21
23
|
externalPackages?: boolean;
|
|
@@ -87,6 +89,12 @@ export declare class PageModuleImportService {
|
|
|
87
89
|
* @returns The loaded module.
|
|
88
90
|
*/
|
|
89
91
|
importModule<T = unknown>(options: PageModuleBuildImportOptions): Promise<T>;
|
|
92
|
+
private createRouteModuleBuildOptions;
|
|
93
|
+
private createRouteModuleCacheBuildOptions;
|
|
94
|
+
private tryLoadCachedRouteModuleBuild;
|
|
95
|
+
private tryLoadPagesUnifiedGraphModule;
|
|
96
|
+
private resolveCompiledRouteModuleOutput;
|
|
97
|
+
private importCompiledRouteModule;
|
|
90
98
|
private loadModule;
|
|
91
99
|
private getRouteModuleBuildCache;
|
|
92
100
|
}
|
|
@@ -72,7 +72,8 @@ export class PageModuleImportService {
|
|
|
72
72
|
async importModule(options) {
|
|
73
73
|
const { filePath } = options;
|
|
74
74
|
const fileHash = this.dependencies.hashFile(filePath);
|
|
75
|
-
const hostModuleLoader =
|
|
75
|
+
const hostModuleLoader = !options.forceBuild &&
|
|
76
|
+
typeof Bun === 'undefined' &&
|
|
76
77
|
process.env.NODE_ENV === 'development' &&
|
|
77
78
|
this.dependencies.canLoadSourceModuleFromHost(filePath)
|
|
78
79
|
? this.dependencies.getHostModuleLoader()
|
|
@@ -124,12 +125,8 @@ export class PageModuleImportService {
|
|
|
124
125
|
fileHash,
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
|
-
|
|
128
|
-
const { filePath,
|
|
129
|
-
const { rootDir, outdir, splitting, externalPackages, transpileErrorMessage = (details) => `Error transpiling page module: ${details}`, noOutputMessage = (targetFilePath) => `No transpiled output generated for page module: ${targetFilePath}`, } = options;
|
|
130
|
-
const outputFileName = createRuntimeBuildOutputFileName(resolvePageModuleOutputFileName({ filePath, fileHash }), this.developmentImportGeneration);
|
|
131
|
-
const outputNamingTemplate = outputFileName.replace(/\.mjs$/u, '.[ext]');
|
|
132
|
-
const preferredOutputPath = path.join(outdir, outputFileName);
|
|
128
|
+
createRouteModuleBuildOptions(options, outputNamingTemplate) {
|
|
129
|
+
const { filePath, rootDir, outdir, splitting, externalPackages } = options;
|
|
133
130
|
const buildOptions = this.appConfig
|
|
134
131
|
? createServerBuildRequest(this.appConfig, {
|
|
135
132
|
profile: 'route-module',
|
|
@@ -155,10 +152,17 @@ export class PageModuleImportService {
|
|
|
155
152
|
root: rootDir,
|
|
156
153
|
entrypoints: [filePath],
|
|
157
154
|
};
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
return {
|
|
156
|
+
buildOptions,
|
|
160
157
|
rootDir: buildOptions.root ?? rootDir,
|
|
161
158
|
outdir: buildOptions.outdir ?? outdir,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
createRouteModuleCacheBuildOptions(options, buildOptions, resolvedRootDir, resolvedOutdir, fileHash) {
|
|
162
|
+
return {
|
|
163
|
+
...options,
|
|
164
|
+
rootDir: resolvedRootDir,
|
|
165
|
+
outdir: resolvedOutdir,
|
|
162
166
|
splitting: buildOptions.splitting,
|
|
163
167
|
externalPackages: buildOptions.externalPackages,
|
|
164
168
|
jsx: buildOptions.jsx,
|
|
@@ -166,32 +170,36 @@ export class PageModuleImportService {
|
|
|
166
170
|
sourceTransforms: buildOptions.sourceTransforms,
|
|
167
171
|
fileHash,
|
|
168
172
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return loadedModule;
|
|
173
|
+
}
|
|
174
|
+
async tryLoadCachedRouteModuleBuild(cacheBuildOptions, outdir) {
|
|
175
|
+
const cachedBuild = this.getRouteModuleBuildCache(outdir).lookup(cacheBuildOptions);
|
|
176
|
+
if (!cachedBuild) {
|
|
177
|
+
return undefined;
|
|
175
178
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
const loadedModule = (await import(/* @vite-ignore */ pathToFileURL(cachedBuild.outputPath).href));
|
|
180
|
+
recordPageModuleLoad('disk-cache-hit');
|
|
181
|
+
return loadedModule;
|
|
182
|
+
}
|
|
183
|
+
async tryLoadPagesUnifiedGraphModule(filePath) {
|
|
184
|
+
if (!shouldBuildPagesUnifiedGraph() || !this.appConfig || !isPagesUnifiedGraphPage(filePath, this.appConfig)) {
|
|
185
|
+
return undefined;
|
|
182
186
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (!buildResult.success) {
|
|
187
|
-
const details = buildResult.logs.map((log) => log.message).join(' | ');
|
|
188
|
-
throw new Error(transpileErrorMessage(details));
|
|
187
|
+
const graphModule = await importPagesUnifiedGraphModule(this.appConfig, filePath);
|
|
188
|
+
if (graphModule === undefined) {
|
|
189
|
+
return undefined;
|
|
189
190
|
}
|
|
191
|
+
recordPageModuleLoad('unified-graph');
|
|
192
|
+
return graphModule;
|
|
193
|
+
}
|
|
194
|
+
resolveCompiledRouteModuleOutput(buildResult, preferredOutputPath, filePath, noOutputMessage) {
|
|
190
195
|
const compiledOutput = buildResult.outputs.find((output) => output.path === preferredOutputPath)?.path ??
|
|
191
196
|
buildResult.outputs.find((output) => /\.(?:[cm]?js)$/u.test(output.path))?.path;
|
|
192
197
|
if (!compiledOutput) {
|
|
193
198
|
throw new Error(noOutputMessage(filePath));
|
|
194
199
|
}
|
|
200
|
+
return compiledOutput;
|
|
201
|
+
}
|
|
202
|
+
async importCompiledRouteModule(compiledOutput, filePath, fileHash, rootDir, buildResult, importCacheKey, cacheBuildOptions, outdir) {
|
|
195
203
|
const dependencyModulePaths = resolveRouteModuleDependencyPaths(buildResult, filePath, rootDir);
|
|
196
204
|
const dependencyHashes = this.dependencyHasher.createDependencyHashes(dependencyModulePaths);
|
|
197
205
|
dependencyHashes[path.normalize(filePath)] = fileHash;
|
|
@@ -201,7 +209,7 @@ export class PageModuleImportService {
|
|
|
201
209
|
cacheEntry.dependencyHashes = dependencyHashes;
|
|
202
210
|
}
|
|
203
211
|
}
|
|
204
|
-
|
|
212
|
+
this.getRouteModuleBuildCache(outdir).recordBuild({
|
|
205
213
|
...cacheBuildOptions,
|
|
206
214
|
outputPath: compiledOutput,
|
|
207
215
|
dependencyModulePaths,
|
|
@@ -212,6 +220,32 @@ export class PageModuleImportService {
|
|
|
212
220
|
}
|
|
213
221
|
return (await import(/* @vite-ignore */ compiledOutputUrl.href));
|
|
214
222
|
}
|
|
223
|
+
async loadModule(options) {
|
|
224
|
+
const { filePath, fileHash, importCacheKey } = options;
|
|
225
|
+
const { outdir, transpileErrorMessage = (details) => `Error transpiling page module: ${details}`, noOutputMessage = (targetFilePath) => `No transpiled output generated for page module: ${targetFilePath}`, } = options;
|
|
226
|
+
const outputFileName = createRuntimeBuildOutputFileName(resolvePageModuleOutputFileName({ filePath, fileHash }), this.developmentImportGeneration);
|
|
227
|
+
const outputNamingTemplate = outputFileName.replace(/\.mjs$/u, '.[ext]');
|
|
228
|
+
const preferredOutputPath = path.join(outdir, outputFileName);
|
|
229
|
+
const { buildOptions, rootDir: resolvedRootDir, outdir: resolvedOutdir, } = this.createRouteModuleBuildOptions(options, outputNamingTemplate);
|
|
230
|
+
const cacheBuildOptions = this.createRouteModuleCacheBuildOptions(options, buildOptions, resolvedRootDir, resolvedOutdir, fileHash);
|
|
231
|
+
const cachedModule = await this.tryLoadCachedRouteModuleBuild(cacheBuildOptions, resolvedOutdir);
|
|
232
|
+
if (cachedModule !== undefined) {
|
|
233
|
+
return cachedModule;
|
|
234
|
+
}
|
|
235
|
+
const unifiedGraphModule = await this.tryLoadPagesUnifiedGraphModule(filePath);
|
|
236
|
+
if (unifiedGraphModule !== undefined) {
|
|
237
|
+
return unifiedGraphModule;
|
|
238
|
+
}
|
|
239
|
+
recordPageModuleBuildInvocation();
|
|
240
|
+
const buildResult = await this.dependencies.buildModule(buildOptions, options.buildExecutor);
|
|
241
|
+
recordPageModuleLoad('cold-build', buildResult.outputs.length);
|
|
242
|
+
if (!buildResult.success) {
|
|
243
|
+
const details = buildResult.logs.map((log) => log.message).join(' | ');
|
|
244
|
+
throw new Error(transpileErrorMessage(details));
|
|
245
|
+
}
|
|
246
|
+
const compiledOutput = this.resolveCompiledRouteModuleOutput(buildResult, preferredOutputPath, filePath, noOutputMessage);
|
|
247
|
+
return await this.importCompiledRouteModule(compiledOutput, filePath, fileHash, resolvedRootDir, buildResult, importCacheKey, cacheBuildOptions, resolvedOutdir);
|
|
248
|
+
}
|
|
215
249
|
getRouteModuleBuildCache(outdir) {
|
|
216
250
|
return getSharedRouteModuleBuildCache(outdir, this.appConfig);
|
|
217
251
|
}
|
|
@@ -10,10 +10,6 @@ import { RouteModuleBuildCache } from './route-module-build-cache.store.js';
|
|
|
10
10
|
* scanning.
|
|
11
11
|
*/
|
|
12
12
|
export declare function getServerModuleBuildCacheOutdir(appConfig: EcoPagesAppConfig): string;
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated Use {@link getServerModuleBuildCacheOutdir}.
|
|
15
|
-
*/
|
|
16
|
-
export declare const getRouteModuleBuildCacheOutdir: typeof getServerModuleBuildCacheOutdir;
|
|
17
13
|
/**
|
|
18
14
|
* Returns the shared production build cache for one server-module outdir.
|
|
19
15
|
*
|
|
@@ -13,10 +13,6 @@ import { RouteModuleBuildCache } from './route-module-build-cache.store.js';
|
|
|
13
13
|
export function getServerModuleBuildCacheOutdir(appConfig) {
|
|
14
14
|
return path.join(resolveInternalExecutionDir(appConfig), '.server-modules');
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use {@link getServerModuleBuildCacheOutdir}.
|
|
18
|
-
*/
|
|
19
|
-
export const getRouteModuleBuildCacheOutdir = getServerModuleBuildCacheOutdir;
|
|
20
16
|
function getRouteModuleBuildCacheMap(appConfig) {
|
|
21
17
|
const existing = appConfig.runtime?.routeModuleBuildCaches;
|
|
22
18
|
if (existing) {
|
|
@@ -6,6 +6,7 @@ type RouteModuleBuildCacheDependencies = {
|
|
|
6
6
|
readManifest: (manifestPath: string) => RouteModuleBuildCacheManifest | undefined;
|
|
7
7
|
writeManifest: (manifestPath: string, manifest: RouteModuleBuildCacheManifest) => void;
|
|
8
8
|
exists: (filePath: string) => boolean;
|
|
9
|
+
readFile: (filePath: string) => string;
|
|
9
10
|
getCorePackageVersion: () => string;
|
|
10
11
|
createDependencyHasher: () => RouteModuleDependencyHasher;
|
|
11
12
|
};
|
|
@@ -26,6 +27,8 @@ export declare class RouteModuleBuildCache {
|
|
|
26
27
|
fileHash: string;
|
|
27
28
|
outputPath: string;
|
|
28
29
|
dependencyModulePaths?: readonly string[];
|
|
30
|
+
/** Local imports of the output when the caller already collected them. */
|
|
31
|
+
outputImports?: string[];
|
|
29
32
|
}): void;
|
|
30
33
|
isIncrementalStaticGenerationAvailable(context: RouteModuleStaticRenderCacheContext): boolean;
|
|
31
34
|
ensureIncrementalStaticGenerationContext(context: RouteModuleStaticRenderCacheContext): void;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
|
+
import { collectReachableLocalImports } from '../../build/cache/output-imports.js';
|
|
3
4
|
import { RouteModuleDependencyHasher } from './route-module-dependency-hasher.js';
|
|
4
|
-
import { ROUTE_MODULE_BUILD_CACHE_FILENAME, createEmptyRouteModuleBuildCacheManifest, createPersistedRouteModuleBuildKey,
|
|
5
|
+
import { ROUTE_MODULE_BUILD_CACHE_FILENAME, createEmptyRouteModuleBuildCacheManifest, createPersistedRouteModuleBuildKey, normalizeRouteModuleCachePath, readRouteModuleBuildCacheManifest, shouldPersistRouteModuleBuildCache, writeRouteModuleBuildCacheManifest, } from './route-module-build-manifest.js';
|
|
6
|
+
import { getCorePackageVersion } from '../../build/cache/cache-keys.js';
|
|
5
7
|
import { isProductionCacheManifestCurrent, matchesProductionCacheFingerprint, } from '../../build/cache/production-build-cache.js';
|
|
6
8
|
/**
|
|
7
9
|
* Persists route-module transpile and static-render metadata under one server outdir.
|
|
@@ -18,6 +20,7 @@ export class RouteModuleBuildCache {
|
|
|
18
20
|
readManifest: dependencies?.readManifest ?? readRouteModuleBuildCacheManifest,
|
|
19
21
|
writeManifest: dependencies?.writeManifest ?? writeRouteModuleBuildCacheManifest,
|
|
20
22
|
exists: dependencies?.exists ?? ((filePath) => fileSystem.exists(filePath)),
|
|
23
|
+
readFile: dependencies?.readFile ?? ((filePath) => fileSystem.readFileSync(filePath)),
|
|
21
24
|
getCorePackageVersion: dependencies?.getCorePackageVersion ?? getCorePackageVersion,
|
|
22
25
|
createDependencyHasher: dependencies?.createDependencyHasher ?? (() => new RouteModuleDependencyHasher()),
|
|
23
26
|
};
|
|
@@ -40,12 +43,13 @@ export class RouteModuleBuildCache {
|
|
|
40
43
|
if (!this.dependencyHasher.matchesStoredHashes(entry.dependencyHashes, cacheFilePath, options.fileHash)) {
|
|
41
44
|
return undefined;
|
|
42
45
|
}
|
|
43
|
-
const outputPath =
|
|
44
|
-
? entry.outputPath
|
|
45
|
-
: path.join(options.outdir, entry.outputPath);
|
|
46
|
+
const outputPath = resolveOutputPath(entry.outputPath, options.outdir);
|
|
46
47
|
if (!this.dependencies.exists(outputPath)) {
|
|
47
48
|
return undefined;
|
|
48
49
|
}
|
|
50
|
+
if (!entry.outputImports?.every((importPath) => this.dependencies.exists(importPath))) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
49
53
|
return { outputPath, entry };
|
|
50
54
|
}
|
|
51
55
|
recordBuild(options) {
|
|
@@ -58,6 +62,7 @@ export class RouteModuleBuildCache {
|
|
|
58
62
|
: [cacheFilePath];
|
|
59
63
|
const dependencyHashes = this.dependencyHasher.createDependencyHashes(dependencyModulePaths);
|
|
60
64
|
dependencyHashes[cacheFilePath] = options.fileHash;
|
|
65
|
+
const outputPath = resolveOutputPath(options.outputPath, options.outdir);
|
|
61
66
|
const manifest = this.loadManifest();
|
|
62
67
|
const existingEntry = manifest.entries[cacheFilePath];
|
|
63
68
|
manifest.corePackageVersion = this.dependencies.getCorePackageVersion();
|
|
@@ -67,6 +72,11 @@ export class RouteModuleBuildCache {
|
|
|
67
72
|
builtAt: Date.now(),
|
|
68
73
|
buildKey: createPersistedRouteModuleBuildKey(options, options.sourceTransforms),
|
|
69
74
|
dependencyHashes,
|
|
75
|
+
outputImports: options.outputImports ??
|
|
76
|
+
collectReachableLocalImports(outputPath, {
|
|
77
|
+
exists: (filePath) => this.dependencies.exists(filePath),
|
|
78
|
+
readFile: (filePath) => this.dependencies.readFile(filePath),
|
|
79
|
+
}),
|
|
70
80
|
renderedOutputs: existingEntry?.renderedOutputs,
|
|
71
81
|
};
|
|
72
82
|
this.persistManifest(manifest);
|
|
@@ -144,11 +154,11 @@ export class RouteModuleBuildCache {
|
|
|
144
154
|
manifest.configHash = options.context.configHash;
|
|
145
155
|
manifest.buildInputsFingerprint = options.context.buildInputsFingerprint;
|
|
146
156
|
manifest.entries[cacheFilePath] = {
|
|
157
|
+
...existingEntry,
|
|
147
158
|
sourceHash: options.sourceHash,
|
|
148
159
|
outputPath: existingEntry?.outputPath ?? '',
|
|
149
160
|
builtAt: existingEntry?.builtAt ?? Date.now(),
|
|
150
161
|
buildKey: existingEntry?.buildKey ?? '',
|
|
151
|
-
dependencyHashes: existingEntry?.dependencyHashes,
|
|
152
162
|
renderedOutputs: {
|
|
153
163
|
...(existingEntry?.renderedOutputs ?? {}),
|
|
154
164
|
[options.pathname]: {
|
|
@@ -218,3 +228,6 @@ export class RouteModuleBuildCache {
|
|
|
218
228
|
this.dependencies.writeManifest(this.manifestPath, manifest);
|
|
219
229
|
}
|
|
220
230
|
}
|
|
231
|
+
function resolveOutputPath(outputPath, outdir) {
|
|
232
|
+
return path.isAbsolute(outputPath) ? outputPath : path.join(outdir, outputPath);
|
|
233
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { BuildOptions } from '../../build/contracts/build-contracts.js';
|
|
2
2
|
import type { PageModuleBuildImportOptions } from './page-module-import.service.js';
|
|
3
3
|
import type { RouteModuleDependencyHashes } from './route-module-dependency-hasher.js';
|
|
4
|
-
export { createJsxCacheKey, createPluginCacheKey, getCorePackageVersion, hashPluginSetup, } from '../../build/cache/cache-keys.js';
|
|
5
4
|
export { ROUTE_MODULE_BUILD_CACHE_FILENAME } from '../../build/cache/cache-constants.js';
|
|
6
5
|
/** One persisted route-module build entry in {@link ROUTE_MODULE_BUILD_CACHE_FILENAME}. */
|
|
7
6
|
export interface RouteModuleBuildCacheEntry {
|
|
@@ -10,6 +9,11 @@ export interface RouteModuleBuildCacheEntry {
|
|
|
10
9
|
builtAt: number;
|
|
11
10
|
buildKey: string;
|
|
12
11
|
dependencyHashes?: RouteModuleDependencyHashes;
|
|
12
|
+
/**
|
|
13
|
+
* Local files the compiled output imports (shared chunks, collection modules).
|
|
14
|
+
* The entry is reused only while all of them exist.
|
|
15
|
+
*/
|
|
16
|
+
outputImports?: string[];
|
|
13
17
|
renderedOutputs?: Record<string, RouteModuleStaticRenderCacheEntry>;
|
|
14
18
|
}
|
|
15
19
|
/** Metadata for one rendered static HTML artifact derived from a route module. */
|
|
@@ -20,6 +24,7 @@ export interface RouteModuleStaticRenderCacheEntry {
|
|
|
20
24
|
}
|
|
21
25
|
/** On-disk manifest describing all cached route-module builds for one server outdir. */
|
|
22
26
|
export interface RouteModuleBuildCacheManifest {
|
|
27
|
+
/** `getCorePackageVersion()` of the build that wrote the manifest. */
|
|
23
28
|
corePackageVersion: string;
|
|
24
29
|
configHash?: string;
|
|
25
30
|
buildInputsFingerprint?: string;
|