Skip to content

Commit a690ff5

Browse files
committed
Drop the patch for NextServer#getMiddlewareManifest
fixup! remove ref to the dropBabel patch (merged into patchNextServer in aws) fixup! aws@896 fixup! 3.6.6
1 parent 7a2fc7d commit a690ff5

File tree

4 files changed

+7
-68
lines changed

4 files changed

+7
-68
lines changed

.changeset/wild-readers-remain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
Drop the patch for NextServer#getMiddlewareManifest

packages/cloudflare/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@
8383
"peerDependencies": {
8484
"wrangler": "catalog:"
8585
}
86-
}
86+
}

packages/cloudflare/src/cli/build/patches/plugins/next-server.spec.ts

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { describe, expect, test } from "vitest";
22

3-
import { computePatchDiff } from "../../utils/test-patch.js";
4-
import {
5-
buildIdRule,
6-
createCacheHandlerRule,
7-
createComposableCacheHandlersRule,
8-
createMiddlewareManifestRule,
9-
} from "./next-server.js";
3+
import { buildIdRule, createCacheHandlerRule, createComposableCacheHandlersRule } from "./next-server.js";
104

115
describe("Next Server", () => {
126
const nextServerCode = `
@@ -130,38 +124,6 @@ class NextNodeServer extends _baseserver.default {
130124
`);
131125
});
132126

133-
test("middleware manifest", () => {
134-
expect(computePatchDiff("next-server.js", nextServerCode, createMiddlewareManifestRule("manifest")))
135-
.toMatchInlineSnapshot(`
136-
"Index: next-server.js
137-
===================================================================
138-
--- next-server.js
139-
+++ next-server.js
140-
@@ -1,5 +1,4 @@
141-
-
142-
class NextNodeServer extends _baseserver.default {
143-
constructor(options){
144-
// Initialize super class
145-
super(options);
146-
@@ -30,12 +29,10 @@
147-
throw err;
148-
}
149-
}
150-
getMiddlewareManifest() {
151-
- if (this.minimalMode) return null;
152-
- const manifest = require(this.middlewareManifestPath);
153-
- return manifest;
154-
- }
155-
+ return "manifest";
156-
+}
157-
async loadCustomCacheHandlers() {
158-
const { cacheHandlers } = this.nextConfig.experimental;
159-
if (!cacheHandlers) return;
160-
// If we've already initialized the cache handlers interface, don't do it
161-
"
162-
`);
163-
});
164-
165127
test("cache handler", () => {
166128
expect(computePatchDiff("next-server.js", nextServerCode, createCacheHandlerRule("manifest")))
167129
.toMatchInlineSnapshot(`

packages/cloudflare/src/cli/build/patches/plugins/next-server.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
* Note: we will probably need to revisit the patches when the Next adapter API lands
55
*
66
* - Inline `getBuildId` as it relies on `readFileSync` that is not supported by workerd
7-
* - Inline the middleware manifest
87
* - Override the cache and composable cache handlers
98
*/
109

11-
import { existsSync, readFileSync } from "node:fs";
1210
import path from "node:path";
1311

1412
import { type BuildOptions, getPackagePath } from "@opennextjs/aws/build/helper.js";
@@ -31,19 +29,6 @@ export function patchNextServer(updater: ContentUpdater, buildOpts: BuildOptions
3129

3230
contents = patchCode(contents, buildIdRule);
3331

34-
const manifestPath = path.join(
35-
outputDir,
36-
"server-functions/default",
37-
getPackagePath(buildOpts),
38-
".next/server/middleware-manifest.json"
39-
);
40-
41-
const manifest = existsSync(manifestPath)
42-
? JSON.parse(await readFileSync(manifestPath, "utf-8"))
43-
: {};
44-
45-
contents = patchCode(contents, createMiddlewareManifestRule(manifest));
46-
4732
const outputPath = path.join(outputDir, "server-functions/default");
4833
const cacheHandler = path.join(outputPath, getPackagePath(buildOpts), "cache.cjs");
4934
contents = patchCode(contents, createCacheHandlerRule(cacheHandler));
@@ -72,19 +57,6 @@ fix: |-
7257
}
7358
`;
7459

75-
export function createMiddlewareManifestRule(manifest: unknown) {
76-
return `
77-
rule:
78-
pattern:
79-
selector: method_definition
80-
context: "class { getMiddlewareManifest($$$PARAMS) { $$$_ } }"
81-
fix: |-
82-
getMiddlewareManifest($$$PARAMS) {
83-
return ${JSON.stringify(manifest)};
84-
}
85-
`;
86-
}
87-
8860
/**
8961
* The cache handler used by Next.js is normally defined in the config file as a path. At runtime,
9062
* Next.js would then do a dynamic require on a transformed version of the path to retrieve the

0 commit comments

Comments
 (0)