import { build, type BuildExecutor, type BuildOptions, type BuildResult } from '../../build/build-adapter.js'; import type { EcoBuildPlugin } from '../../build/contracts/build-types.js'; import type { EcoPagesAppConfig } from '../../types/internal-types.js'; import type { SourceModuleLoaderFactory } from './module-loading-types.js'; interface PageModuleImportBaseOptions { filePath: string; bypassCache?: boolean; } /** * Options for imports that must pass through the Ecopages build pipeline. * * @remarks * Callers should use build mode for framework-owned page modules and any other * source that relies on Ecopages build resolution before runtime execution. */ export interface PageModuleBuildImportOptions extends PageModuleImportBaseOptions { rootDir: string; outdir: string; buildExecutor?: BuildExecutor; splitting?: boolean; externalPackages?: boolean; sourceTransforms?: BuildOptions['sourceTransforms']; jsx?: { development?: boolean; factory?: string; fragment?: string; importSource?: string; runtime?: 'classic' | 'automatic'; sideEffects?: boolean; }; plugins?: EcoBuildPlugin[]; transpileErrorMessage?: (details: string) => string; noOutputMessage?: (filePath: string) => string; } /** * Minimal runtime dependencies required to load page modules. * * @remarks * This service owns cache and runtime import policy. Hashing and build * execution are injected so tests can provide explicit fakes without module * interception. */ export interface PageModuleImportDependencies { hashFile(filePath: string): string; buildModule(options: Parameters[0], buildExecutor?: BuildExecutor): Promise; canLoadSourceModuleFromHost(filePath: string): boolean; getHostModuleLoader: SourceModuleLoaderFactory; } /** * Loads page-like modules through the Ecopages build pipeline. * * This service centralizes the shared build-first import strategy used by route * scanning, page data loading, and request-time page inspection. In Node * development it can still delegate compatible source imports to the active * host loader, but the public contract remains one transpile-targeted module * loading path. * * Keeping this logic in one place prevents subtle drift in cache-busting, * transpilation settings, and error semantics across the different callers. */ export declare class PageModuleImportService { private readonly appConfig?; private readonly dependencies; private readonly dependencyHasher; private readonly importCache; private developmentImportGeneration; constructor(appConfig?: EcoPagesAppConfig, dependencies?: Partial); /** * Clears the shared import cache used by framework-owned page-module loads. */ clearImportCache(): void; /** * Clears in-memory import promises and dependency-hash memoization so the next * import revalidates against current source and transform identity. */ invalidateDevelopmentGraph(): void; /** * Imports a page-like module from source. * * The caller controls the output directory and error wording so different * subsystems can reuse the same loading mechanism while preserving their * current diagnostics. Module identities stay stable for unchanged files and * roll forward automatically when the source hash changes during watch mode. * * @typeParam T Expected module shape. * @param options Runtime-specific import settings. * @returns The loaded module. */ importModule(options: PageModuleBuildImportOptions): Promise; private loadModule; private getRouteModuleBuildCache; } export {};