File tree Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -53,13 +53,21 @@ export const config = {
5353 } ,
5454} ;
5555
56- const isEdgeRuntime = origConfig . runtime === 'experimental-edge' ;
56+ // This is a variable that Next.js will string replace during build with a string if run in an edge runtime from Next.js
57+ // v12.2.1-canary.3 onwards:
58+ // https://github.com/vercel/next.js/blob/166e5fb9b92f64c4b5d1f6560a05e2b9778c16fb/packages/next/build/webpack-config.ts#L206
59+ // https://edge-runtime.vercel.sh/features/available-apis#addressing-the-runtime
60+ declare const EdgeRuntime : string | undefined ;
5761
58- export default userProvidedHandler
59- ? isEdgeRuntime
60- ? userProvidedHandler
61- : Sentry . withSentryAPI ( userProvidedHandler , '__ROUTE__' )
62- : undefined ;
62+ let exportedHandler ;
63+
64+ if ( typeof EdgeRuntime === 'string' ) {
65+ exportedHandler = userProvidedHandler ;
66+ } else {
67+ exportedHandler = userProvidedHandler ? Sentry . withSentryAPI ( userProvidedHandler , '__ROUTE__' ) : undefined ;
68+ }
69+
70+ export default exportedHandler ;
6371
6472// Re-export anything exported by the page module we're wrapping. When processing this code, Rollup is smart enough to
6573// not include anything whose name matchs something we've explicitly exported above.
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ declare const __SENTRY_TRACING__: boolean;
3434// This is a variable that Next.js will string replace during build with a string if run in an edge runtime from Next.js
3535// v12.2.1-canary.3 onwards:
3636// https://github.com/vercel/next.js/blob/166e5fb9b92f64c4b5d1f6560a05e2b9778c16fb/packages/next/build/webpack-config.ts#L206
37+ // https://edge-runtime.vercel.sh/features/available-apis#addressing-the-runtime
3738declare const EdgeRuntime : string | undefined ;
3839
3940const globalWithInjectedValues = global as typeof global & {
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ const domain = domainModule as typeof domainModule & { active: (domainModule.Dom
3333// This is a variable that Next.js will string replace during build with a string if run in an edge runtime from Next.js
3434// v12.2.1-canary.3 onwards:
3535// https://github.com/vercel/next.js/blob/166e5fb9b92f64c4b5d1f6560a05e2b9778c16fb/packages/next/build/webpack-config.ts#L206
36+ // https://edge-runtime.vercel.sh/features/available-apis#addressing-the-runtime
3637declare const EdgeRuntime : string | undefined ;
3738
3839// Exporting this constant means we can compute it without the linter complaining, even if we stop directly using it in
You can’t perform that action at this time.
0 commit comments