Skip to content

Commit ea95c2c

Browse files
committed
refactor: patch NextServer#getMiddlewareManifest regardless of Next version
1 parent de77cff commit ea95c2c

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

packages/open-next/src/build/patch/patches/patchNextServer.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ rule:
1818
inside:
1919
kind: method_definition
2020
any:
21-
- has: {kind: property_identifier, field: name, regex: runEdgeFunction}
22-
- has: {kind: property_identifier, field: name, regex: runMiddleware}
23-
- has: {kind: property_identifier, field: name, regex: imageOptimizer}
21+
- has: {kind: property_identifier, field: name, regex: ^runEdgeFunction$}
22+
- has: {kind: property_identifier, field: name, regex: ^runMiddleware$}
23+
- has: {kind: property_identifier, field: name, regex: ^imageOptimizer$}
2424
- has:
2525
kind: statement_block
2626
has:
@@ -36,12 +36,12 @@ rule:
3636
kind: statement_block
3737
inside:
3838
kind: if_statement
39-
any:
40-
- has:
39+
any:
40+
- has:
4141
kind: member_expression
4242
pattern: this.nextConfig.experimental.preloadEntriesOnStart
4343
stopBy: end
44-
- has:
44+
- has:
4545
kind: binary_expression
4646
pattern: appDocumentPreloading === true
4747
stopBy: end
@@ -57,7 +57,7 @@ rule:
5757
kind: method_definition
5858
has:
5959
kind: property_identifier
60-
regex: getMiddlewareManifest
60+
regex: ^getMiddlewareManifest$
6161
fix:
6262
'{return null;}'
6363
`;
@@ -69,7 +69,7 @@ export const patchNextServer: CodePatcher = {
6969
{
7070
versions: ">=15.0.0",
7171
field: {
72-
pathFilter: /next-server\.(js)$/,
72+
pathFilter: /next-server\.js$/,
7373
contentFilter: /process\.env\.NEXT_MINIMAL/,
7474
patchCode: createPatchCode(minimalRule),
7575
},
@@ -78,16 +78,15 @@ export const patchNextServer: CodePatcher = {
7878
{
7979
versions: ">=15.0.0",
8080
field: {
81-
pathFilter: /next-server\.(js)$/,
81+
pathFilter: /next-server\.js$/,
8282
contentFilter: /this\.nextConfig\.experimental\.preloadEntriesOnStart/,
8383
patchCode: createPatchCode(disablePreloadingRule),
8484
},
8585
},
8686
// Don't match edge functions in `NextServer`
8787
{
88-
versions: ">=15.0.0",
8988
field: {
90-
pathFilter: /next-server\.(js)$/,
89+
pathFilter: /next-server\.js$/,
9190
contentFilter: /getMiddlewareManifest/,
9291
patchCode: createPatchCode(removeMiddlewareManifestRule),
9392
},

0 commit comments

Comments
 (0)