8000 refactor: patch NextServer#getMiddlewareManifest for Next >= 14 by vicb · Pull Request #892 · opennextjs/opennextjs-aws · GitHub
[go: up one dir, main page]

Skip to content

refactor: patch NextServer#getMiddlewareManifest for Next >= 14 #892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions packages/open-next/src/build/patch/patches/patchNextServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ rule:
inside:
kind: method_definition
any:
- has: {kind: property_identifier, field: name, regex: runEdgeFunction}
- has: {kind: property_identifier, field: name, regex: runMiddleware}
- has: {kind: property_identifier, field: name, regex: imageOptimizer}
- has: {kind: property_identifier, field: name, regex: ^runEdgeFunction$}
- has: {kind: property_identifier, field: name, regex: ^runM 8000 iddleware$}
- has: {kind: property_identifier, field: name, regex: ^imageOptimizer$}
- has:
kind: statement_block
has:
Expand All @@ -36,12 +36,12 @@ rule:
kind: statement_block
inside:
kind: if_statement
any:
- has:
any:
- has:
kind: member_expression
pattern: this.nextConfig.experimental.preloadEntriesOnStart
stopBy: end
- has:
- has:
kind: binary_expression
pattern: appDocumentPreloading === true
stopBy: end
Expand All @@ -57,7 +57,7 @@ rule:
kind: method_definition
has:
kind: property_identifier
regex: getMiddlewareManifest
regex: ^getMiddlewareManifest$
fix:
'{return null;}'
`;
Expand All @@ -69,7 +69,7 @@ export const patchNextServer: CodePatcher = {
{
versions: ">=15.0.0",
field: {
pathFilter: /next-server\.(js)$/,
pathFilter: /next-server\.js$/,
contentFilter: /process\.env\.NEXT_MINIMAL/,
patchCode: createPatchCode(minimalRule),
},
Expand All @@ -78,16 +78,17 @@ export const patchNextServer: CodePatcher = {
{
versions: ">=15.0.0",
field: {
pathFilter: /next-server\.(js)$/,
pathFilter: /next-server\.js$/,
contentFilter: /this\.nextConfig\.experimental\.preloadEntriesOnStart/,
patchCode: createPatchCode(disablePreloadingRule),
},
},
// Don't match edge functions in `NextServer`
{
versions: ">=15.0.0",
// Next 12 and some version of 13 use the bundled middleware/edge function
versions: ">=14.0.0",
field: {
pathFilter: /next-server\.(js)$/,
pathFilter: /next-server\.js$/,
contentFilter: /getMiddlewareManifest/,
patchCode: createPatchCode(removeMiddlewareManifestRule),
},
Expand Down
0