Skip to content

Commit bcb90bf

Browse files
committed
fix: assign globals to self
1 parent 6a0b040 commit bcb90bf

File tree

1 file changed

+3
-2
lines changed
  • packages/runtime/src/helpers

1 file changed

+3
-2
lines changed

packages/runtime/src/helpers/edge.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ import {
8585
// Deno defines "window", but naughty libraries think this means it's a browser
8686
delete globalThis.window
8787
globalThis.process = { env: {...Deno.env.toObject(), NEXT_RUNTIME: 'edge', 'NEXT_PRIVATE_MINIMAL_MODE': '1' } }
88-
// Next uses "self" as a function-scoped global-like object
89-
const self = {}
9088
let _ENTRIES = {}
9189
9290
// Next.js uses this extension to the Headers API implemented by Cloudflare workerd
@@ -118,6 +116,9 @@ const fetch = async (url, init) => {
118116
}
119117
}
120118
119+
// Latest Next uses "self" as a function-scoped global-like object, but older versions expect it to equal "globalThis"
120+
const self = { ...globalThis, fetch }
121+
121122
`
122123

123124
// Slightly different spacing in different versions!

0 commit comments

Comments
 (0)