/** * Bundler for Cloudflare Workers. * * Uses wrangler (which internally uses esbuild + Turbopack-aware resolution) * to bundle the generated worker entry into CF Workers-compatible output. * * This works with both webpack and Turbopack output — wrangler handles * the custom chunk format that plain esbuild cannot follow. */ /** * Content-dedup the wasm siblings wrangler emitted into the server output. * * The pre-bundle `dedupeWasmByContent` (build.ts) only sees wasm that flows * through the adapter's `wasmFiles` map. But an identical payload can reach the * bundle by a SECOND, independent path: Next's wasm worker-loader emits a * dynamic `import("./-query_compiler_fast_bg.wasm")` while our staged * CompiledWasm arrives as a static `import __wasm from * "./-query_compiler_fast_bg.sqlite.wasm"`. wrangler content-hashes both, * so they land as two 3.5MB files that share the same `-` prefix but * differ in basename — the B11 duplicate a real Prisma-on-D1 app ships (a * fixture that only exercises the map-path never reproduces it). * * wrangler's prefix IS a content hash, so a shared prefix means identical * bytes; we still byte-compare before deleting. Keep one file per payload, * rewrite every reference to the dropped basename (static or dynamic import, * in worker.js and any chunk) to the kept one, and delete the extra. Prefer to * keep a file that a static `import … from` targets — that's the CompiledWasm * form workerd is happiest with; the dynamic-import site just repoints to it. * * Best-effort and content-safe: never merges files whose bytes differ, and * applied write-before-delete so a mid-way failure leaves a valid output — at * worst not-fully-deduped (a redundant wasm still present), never a JS import * pointing at a deleted file. Returns the number of files dropped. Exported for * tests. */ export declare function dedupeEmittedWasm(outputDir: string): Promise; /** * Resolve wrangler's CLI entry script through Node module resolution. * * Never guess `/node_modules/.bin/wrangler`: npm hoists * wrangler to the top of the install tree (under the Creek CLI's lazy * install that's `.creek/node_modules/.bin`), so the nested path only * exists when hoisting is defeated by a version conflict. Resolving * `wrangler/package.json` and reading its `bin` field finds the real * entry under npm hoisting, pnpm's virtual store, and link installs * alike — and running it with process.execPath sidesteps `.bin` shell * shims entirely (which also don't exist as POSIX scripts on Windows). * * Exported for tests. */ export declare function resolveWranglerEntry(requireFn: Pick): Promise; /** * Minify the final worker.js in place with a standalone esbuild pass. * * ON BY DEFAULT — opt out with CREEK_ADAPTER_MINIFY=0. * * History, so the default is never flipped on bad evidence again: 0.2.13 * shipped this ON, users hit "PrismaD1 is not a constructor" on every * D1-backed page, and 0.2.14 turned it off blaming a minify/`__toESM` * interop. That attribution was WRONG — the 0.2.17 root-cause analysis * (commit 0dfa03e, verified by pulling the deployed worker and A/B * reproduction) showed the breakage was Next externalizing * `@prisma/adapter-d1` to an empty module, present since 0.2.10 and * identical with minify off ("minify was a red herring — 0.2.16 unminified * broke identically", creek repo packages/cli/src/utils/nextjs.ts). The * e2e/prisma-d1 gate has run the minify-ON leg green in CI since 0.2.15. * * Two invariants keep this safe: * - ORDER: minify runs AFTER the post-bundle regex patch chain. The patches * match identifiers in unminified output; minifying first silently no-ops * them (measured: split-mode POC 500s on the fast-set-immediate patch). * Do NOT move this to bundle-time (`wrangler deploy --minify` / * esbuild `minify: true` during bundling) without making every patch * minify-agnostic. * - The e2e/prisma-d1 CI matrix runs {minify off, minify on}; a real interop * break blocks release. * * esbuild is not a direct dependency — it is resolved from the copy wrangler * ships. Any failure (esbuild unresolvable, parse error) ships the * unminified worker rather than failing the build. * * Exported for tests. */ export declare function minifyWorker(workerPath: string, requireFn: Pick): Promise<{ minified: boolean; reason?: string; disabled?: boolean; }>; export interface BundleOptions { workerSource: string; outputDir: string; serverAssets: Map; wasmFiles: Map; distDir: string; repoRoot: string; standaloneDir: string; } export declare function patchUseCachePrerenderDanglingPromiseBailout(workerCode: string): string; export declare function patchNullFallbackPartialShellBlocking(workerCode: string): string; export declare function patchAppPageRevalidationPostponedState(workerCode: string): string; export declare function bundleForWorkers(opts: BundleOptions): Promise; //# sourceMappingURL=bundler.d.ts.map