Skip to content

Commit 9b25f18

Browse files
committed
Fix proxy renaming
1 parent 648e476 commit 9b25f18

File tree

3 files changed

+12
-41
lines changed

3 files changed

+12
-41
lines changed

packages/next/src/build/entries.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import {
2020
APP_DIR_ALIAS,
2121
WEBPACK_LAYERS,
2222
INSTRUMENTATION_HOOK_FILENAME,
23-
PROXY_FILENAME,
24-
MIDDLEWARE_FILENAME,
2523
} from '../lib/constants'
2624
import { isAPIRoute } from '../lib/is-api-route'
2725
import { isEdgeRuntime } from '../lib/is-edge-runtime'
@@ -574,7 +572,7 @@ export interface CreateEntrypointsParams {
574572
buildId: string
575573
config: NextConfigComplete
576574
envFiles: LoadedEnvFiles
577-
isDev?: boolean
575+
isDev: boolean
578576
pages: MappedPages
579577
pagesDir?: string
580578
previewMode: __ApiPreviewProps
@@ -643,6 +641,7 @@ export function getEdgeServerEntry(opts: {
643641
return {
644642
import: `next-middleware-loader?${stringify(loaderParams)}!`,
645643
layer: WEBPACK_LAYERS.middleware,
644+
filename: 'middleware.js',
646645
}
647646
}
648647

@@ -770,7 +769,7 @@ export function runDependingOnPageType<T>(params: {
770769
return
771770
}
772771

773-
if (isMiddlewareFile(params.page) && !isProxyFile(params.page)) {
772+
if (isMiddlewareFile(params.page)) {
774773
if (params.pageRuntime === 'nodejs') {
775774
params.onServer()
776775
return
@@ -953,13 +952,7 @@ export async function createEntrypoints(
953952
isDev: false,
954953
})
955954
} else if (isMiddlewareFile(page)) {
956-
server[
957-
serverBundlePath
958-
// proxy.js still uses middleware.js for bundle path for now.
959-
// TODO: Revisit when we remove middleware.js.
960-
.replace(PROXY_FILENAME, MIDDLEWARE_FILENAME)
961-
.replace('src/', '')
962-
] = getEdgeServerEntry({
955+
server[serverBundlePath.replace('src/', '')] = getEdgeServerEntry({
963956
...params,
964957
rootDir,
965958
absolutePagePath: absolutePagePath,
@@ -1034,12 +1027,7 @@ export async function createEntrypoints(
10341027
: undefined,
10351028
}).import
10361029
}
1037-
const edgeServerBundlePath = isMiddlewareFile(page)
1038-
? serverBundlePath
1039-
.replace(PROXY_FILENAME, MIDDLEWARE_FILENAME)
1040-
.replace('src/', '')
1041-
: serverBundlePath
1042-
edgeServer[edgeServerBundlePath] = getEdgeServerEntry({
1030+
edgeServer[serverBundlePath] = getEdgeServerEntry({
10431031
...params,
10441032
rootDir,
10451033
absolutePagePath: absolutePagePath,

packages/next/src/build/get-static-info-including-layouts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function getStaticInfoIncludingLayouts({
2929
pageFilePath: string
3030
appDir: string | undefined
3131
config: NextConfigComplete
32-
isDev: boolean | undefined
32+
isDev: boolean
3333
page: string
3434
}): Promise<PageStaticInfo> {
3535
// TODO: sync types for pages: PAGE_TYPES, ROUTER_TYPE, 'app' | 'pages', etc.

packages/next/src/server/next-server.ts

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,30 +1578,13 @@ export default class NextNodeServer extends BaseServer<
15781578
// of mapping proxy to middleware as the entry, just fallback
15791579
// to proxy.
15801580
// TODO: Remove this once we handle as the single entrypoint.
1581-
try {
1582-
return require(
1583-
join(
1584-
/* turbopackIgnore: true */ this.distDir,
1585-
'server',
1586-
'middleware.js'
1587-
)
1581+
return require(
1582+
join(
1583+
/* turbopackIgnore: true */ this.distDir,
1584+
'server',
1585+
'middleware.js'
15881586
)
1589-
} catch (middlewareErr) {
1590-
if (
1591-
isError(middlewareErr) &&
1592-
(middlewareErr.code === 'ENOENT' ||
1593-
middlewareErr.code === 'MODULE_NOT_FOUND')
1594-
) {
1595-
return require(
1596-
join(
1597-
/* turbopackIgnore: true */ this.distDir,
1598-
'server',
1599-
'proxy.js'
1600-
)
1601-
)
1602-
}
1603-
throw middlewareErr
1604-
}
1587+
)
16051588
}
16061589
} catch (err) {
16071590
if (

0 commit comments

Comments
 (0)