-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
'use cache'
in route handlers using the Edge runtime (
#71258) Same as #70897, but for the Edge runtime. The changes are based on what we're already doing for app pages that are using the Edge runtime.
- Loading branch information
1 parent
e68ce6e
commit 2f16722
Showing
13 changed files
with
101 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,31 @@ | ||
import { createServerModuleMap } from '../../server/app-render/action-utils' | ||
import { setReferenceManifestsSingleton } from '../../server/app-render/encryption-utils' | ||
import type { NextConfigComplete } from '../../server/config-shared' | ||
import { EdgeRouteModuleWrapper } from '../../server/web/edge-route-module-wrapper' | ||
|
||
// Import the userland code. | ||
import * as module from 'VAR_USERLAND' | ||
|
||
// injected by the loader afterwards. | ||
declare const nextConfig: NextConfigComplete | ||
// INJECT:nextConfig | ||
|
||
const maybeJSONParse = (str?: string) => (str ? JSON.parse(str) : undefined) | ||
|
||
const rscManifest = self.__RSC_MANIFEST?.['VAR_PAGE'] | ||
const rscServerManifest = maybeJSONParse(self.__RSC_SERVER_MANIFEST) | ||
|
||
if (rscManifest && rscServerManifest) { | ||
setReferenceManifestsSingleton({ | ||
clientReferenceManifest: rscManifest, | ||
serverActionsManifest: rscServerManifest, | ||
serverModuleMap: createServerModuleMap({ | ||
serverActionsManifest: rscServerManifest, | ||
pageName: 'VAR_PAGE', | ||
}), | ||
}) | ||
} | ||
|
||
export const ComponentMod = module | ||
|
||
export default EdgeRouteModuleWrapper.wrap(module.routeModule) | ||
export default EdgeRouteModuleWrapper.wrap(module.routeModule, { nextConfig }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/use-cache-route-handler-only/app/edge/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const runtime = 'edge' | ||
|
||
export { GET } from '../node/route' |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters