-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Same as #70897, but for the Edge runtime. The changes are based on what we're already doing for app pages using the Edge runtime.
- Loading branch information
1 parent
9b9dbe4
commit 59f329f
Showing
9 changed files
with
45 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
import { createServerModuleMap } from '../../server/app-render/action-utils' | ||
import { setReferenceManifestsSingleton } from '../../server/app-render/encryption-utils' | ||
import { EdgeRouteModuleWrapper } from '../../server/web/edge-route-module-wrapper' | ||
|
||
// Import the userland code. | ||
import * as module from 'VAR_USERLAND' | ||
|
||
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) |
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' |
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