diff --git a/.changeset/wild-readers-remain.md b/.changeset/wild-readers-remain.md new file mode 100644 index 000000000..667c95d22 --- /dev/null +++ b/.changeset/wild-readers-remain.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/cloudflare": patch +--- + +Drop the patch for NextServer#getMiddlewareManifest (taken care of by was) diff --git a/packages/cloudflare/src/cli/build/patches/plugins/next-server.spec.ts b/packages/cloudflare/src/cli/build/patches/plugins/next-server.spec.ts index 898bf798f..745b1973e 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/next-server.spec.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/next-server.spec.ts @@ -1,12 +1,7 @@ import { describe, expect, test } from "vitest"; import { computePatchDiff } from "../../utils/test-patch.js"; -import { - buildIdRule, - createCacheHandlerRule, - createComposableCacheHandlersRule, - createMiddlewareManifestRule, -} from "./next-server.js"; +import { buildIdRule, createCacheHandlerRule, createComposableCacheHandlersRule } from "./next-server.js"; describe("Next Server", () => { const nextServerCode = ` @@ -130,38 +125,6 @@ class NextNodeServer extends _baseserver.default { `); }); - test("middleware manifest", () => { - expect(computePatchDiff("next-server.js", nextServerCode, createMiddlewareManifestRule("manifest"))) - .toMatchInlineSnapshot(` - "Index: next-server.js - =================================================================== - --- next-server.js - +++ next-server.js - @@ -1,5 +1,4 @@ - - - class NextNodeServer extends _baseserver.default { - constructor(options){ - // Initialize super class - super(options); - @@ -30,12 +29,10 @@ - throw err; - } - } - getMiddlewareManifest() { - - if (this.minimalMode) return null; - - const manifest = require(this.middlewareManifestPath); - - return manifest; - - } - + return "manifest"; - +} - async loadCustomCacheHandlers() { - const { cacheHandlers } = this.nextConfig.experimental; - if (!cacheHandlers) return; - // If we've already initialized the cache handlers interface, don't do it - " - `); - }); - test("cache handler", () => { expect(computePatchDiff("next-server.js", nextServerCode, createCacheHandlerRule("manifest"))) .toMatchInlineSnapshot(` diff --git a/packages/cloudflare/src/cli/build/patches/plugins/next-server.ts b/packages/cloudflare/src/cli/build/patches/plugins/next-server.ts index 0f52ccff4..3d5e6a291 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/next-server.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/next-server.ts @@ -4,11 +4,9 @@ * Note: we will probably need to revisit the patches when the Next adapter API lands * * - Inline `getBuildId` as it relies on `readFileSync` that is not supported by workerd - * - Inline the middleware manifest * - Override the cache and composable cache handlers */ -import { existsSync, readFileSync } from "node:fs"; import path from "node:path"; import { type BuildOptions, getPackagePath } from "@opennextjs/aws/build/helper.js"; @@ -31,19 +29,6 @@ export function patchNextServer(updater: ContentUpdater, buildOpts: BuildOptions contents = patchCode(contents, buildIdRule); - const manifestPath = path.join( - outputDir, - "server-functions/default", - getPackagePath(buildOpts), - ".next/server/middleware-manifest.json" - ); - - const manifest = existsSync(manifestPath) - ? JSON.parse(await readFileSync(manifestPath, "utf-8")) - : {}; - - contents = patchCode(contents, createMiddlewareManifestRule(manifest)); - const outputPath = path.join(outputDir, "server-functions/default"); const cacheHandler = path.join(outputPath, getPackagePath(buildOpts), "cache.cjs"); contents = patchCode(contents, createCacheHandlerRule(cacheHandler)); @@ -72,19 +57,6 @@ fix: |- } `; -export function createMiddlewareManifestRule(manifest: unknown) { - return ` -rule: - pattern: - selector: method_definition - context: "class { getMiddlewareManifest($$$PARAMS) { $$$_ } }" -fix: |- - getMiddlewareManifest($$$PARAMS) { - return ${JSON.stringify(manifest)}; - } -`; -} - /** * The cache handler used by Next.js is normally defined in the config file as a path. At runtime, * Next.js would then do a dynamic require on a transformed version of the path to retrieve the