/** * Worker entry source code generator. * * Generates a CF Workers entry that statically imports all Next.js * page/route handlers. With --webpack, .next/server/app/*.js are * standard CJS modules that esbuild can bundle. */ import type { NextAdapter } from "next"; type BuildContext = Parameters>[0]; export interface WorkerEntryOptions { buildId: string; routing: BuildContext["routing"]; outputs: BuildContext["outputs"]; basePath: string; assetPrefix: string; i18n: unknown; /** * Subset of \`next.config\` that the worker runtime needs — \`ROUTING\` * doesn't expose these fields directly (trailingSlash is implemented * as regex rules in \`beforeMiddleware\`). Carry them separately so * code that needs the boolean flag can consult it without reverse- * engineering the routing table. */ config: { trailingSlash?: boolean; }; /** Embedded manifests: absolute path → file content */ manifests: Record; /** * User-side text files (data.json, fixtures, i18n messages, etc.) keyed by * path relative to outputFileTracingRoot. Read by the fs shim at runtime when * route handlers call fs.readFileSync. See build.ts:collectUserFiles(). */ userFiles: Record; /** Path to Turbopack runtime file (for static import to trigger chunk bundling) */ turbopackRuntimePath?: string; /** Prerender entries for ISR cache seeding */ prerenderEntries: Array<{ pathname: string; html: string; postponedState?: string; allowsFallbackShellResume?: boolean; initialRevalidate?: number | false; initialStatus?: number; initialHeaders?: Record; pprHeaders?: Record; lastModified?: number; segmentPaths?: string[]; metaHeaders?: Record; }>; /** * Composable cache (`'use cache'`) entries extracted from build-time * prerenders, keyed by bracket-form shell pathname. Applied request-scoped * at runtime so only requests matching a shell see its seeds. */ composableCacheSeedsByShell?: Array<[ string, Array<{ key: string; value: string; tags: string[]; stale: number; timestamp: number; expire: number; revalidate: number; }> ]>; /** Path to edge registration chunk (contains _ENTRIES setup) */ edgeRegistrationChunkPath?: string; /** Turbopack runtime module IDs for edge middleware evaluation */ edgeRuntimeModuleIds?: number[]; /** Paths to edge otherChunks that need explicit import */ edgeOtherChunkPaths?: string[]; /** * Path to `.next/server/edge-runtime-webpack.js` when the user built with * `next build --webpack`. This tiny IIFE installs the chunk-push hook on * `self.webpackChunk_N_E`; it must evaluate BEFORE `middleware.js` so the * push that registers chunk 149 triggers entry evaluation and populates * `_ENTRIES["middleware_middleware"]`. Turbopack builds don't emit this * file — its absence is the signal to fall through to the Turbopack path. */ webpackEdgeRuntimePath?: string; /** * Path to a tiny generated bootstrap file that predeclares * `globalThis._ENTRIES`. Imported BEFORE the webpack runtime so that * middleware.js's strict-mode bare `_ENTRIES = {}` has a global to resolve * against (otherwise: ReferenceError at module evaluation). */ webpackEdgeBootstrapPath?: string; /** * [xxh3_128_hex, wasm_filename_with_ext] pairs. Turbopack edge bundles * access the compiled WebAssembly.Module via \`globalThis.wasm_\`. * Import each wasm (wrangler declares \`.wasm\` as CompiledWasm) and * assign onto globalThis before edge modules evaluate. */ wasmHashToFilename?: Array<[string, string]>; /** * [byteLength, wasm_filename] pairs. Registered in * \`globalThis.__CREEK_WASM_BY_LENGTH\` so the runtime * \`WebAssembly.instantiate\` patch can swap byte-based calls for the * pre-compiled Module workerd already has in memory. */ wasmLengthToFilename?: Array<[number, string]>; /** * Module specifiers that Turbopack marked as externals but that the * user's code references at runtime via dynamic import. \`id\` is the * exact runtime specifier passed to Turbopack's externalImport helper; * \`importSpecifier\` is the concrete module path we ask wrangler to * bundle for that id. */ externalModules?: Array<{ id: string; importSpecifier: string; }>; /** * Absolute path to the user's \`.next/server/instrumentation.js\` when the * project actually provides one (not our \`module.exports = {}\` placeholder). * We static-import it from the worker entry so wrangler bundles the full * module graph, then hand it to Next.js's \`getInstrumentationModule\` * lookup — otherwise the dynamic \`__require\` falls back to undefined on * workerd and \`instrumentation.register()\` is never called. * Fixes e2e/opentelemetry/client-trace-metadata (5 tests) and any other * test that depends on user instrumentation side effects. */ userInstrumentationPath?: string; } /** * Generate the worker entry source code. * All handler modules are statically imported so esbuild bundles them. */ export declare function generateWorkerEntry(opts: WorkerEntryOptions): string; export {}; //# sourceMappingURL=worker-entry.d.ts.map