Skip to content

Commit ca42ea7

Browse files
committed
Refactor: create server module map only once
Small follow-up to #86591. We don't need to recreate the server module map proxy every time we set the manifests singleton. Instead, we can just update the underlying server actions manifest, and the server module map can read the current manifest from the singleton.
1 parent 7cdb4d0 commit ca42ea7

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

packages/next/src/server/app-render/action-utils.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { ActionManifest } from '../../build/webpack/plugins/flight-client-entry-plugin'
21
import { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'
32
import { pathHasPrefix } from '../../shared/lib/router/utils/path-has-prefix'
43
import { removePathPrefix } from '../../shared/lib/router/utils/remove-path-prefix'
@@ -18,17 +17,13 @@ export interface ServerModuleMap {
1817
// Server Reference Manifest similar to our client module map.
1918
// This is because our manifest contains a lot of internal Next.js data that
2019
// are relevant to the runtime, workers, etc. that React doesn't need to know.
21-
export function createServerModuleMap({
22-
serverActionsManifest,
23-
}: {
24-
serverActionsManifest: ActionManifest
25-
}): ServerModuleMap {
20+
export function createServerModuleMap(): ServerModuleMap {
2621
return new Proxy(
2722
{},
2823
{
2924
get: (_, id: string) => {
3025
const workers =
31-
serverActionsManifest[
26+
getServerActionsManifest()[
3227
process.env.NEXT_RUNTIME === 'edge' ? 'edge' : 'node'
3328
]?.[id]?.workers
3429

packages/next/src/server/app-render/manifests-singleton.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ export function setManifestsSingleton({
180180
)
181181

182182
existingSingleton.serverActionsManifest = serverActionsManifest
183-
184-
existingSingleton.serverModuleMap = createServerModuleMap({
185-
serverActionsManifest,
186-
})
187183
} else {
188184
const clientReferenceManifestsPerRoute = new Map<
189185
string,
@@ -194,15 +190,11 @@ export function setManifestsSingleton({
194190
clientReferenceManifestsPerRoute
195191
)
196192

197-
const serverModuleMap = createServerModuleMap({
198-
serverActionsManifest,
199-
})
200-
201193
globalThisWithManifests[MANIFESTS_SINGLETON] = {
202194
clientReferenceManifestsPerRoute,
203195
proxiedClientReferenceManifest,
204196
serverActionsManifest,
205-
serverModuleMap,
197+
serverModuleMap: createServerModuleMap(),
206198
}
207199
}
208200
}

0 commit comments

Comments
 (0)