File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
packages/runtime/src/templates/edge Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 2
2
// deno-lint-ignore-file no-var prefer-const no-unused-vars no-explicit-any
3
3
import { decode as _base64Decode } from 'https://deno.land/std@0.175.0/encoding/base64.ts'
4
4
import { AsyncLocalStorage as ALSCompat } from 'https://deno.land/std@0.175.0/node/async_hooks.ts'
5
+ import { Buffer as BufferCompat } from 'https://deno.land/std@0.175.0/io/buffer.ts'
5
6
6
7
/**
7
8
* These are the shims, polyfills and other kludges to make Next.js work in standards-compliant runtime.
@@ -48,6 +49,15 @@ const fetch /* type {typeof globalThis.fetch} */ = async (url, init) => {
48
49
}
49
50
}
50
51
52
+ if ( typeof require === 'undefined' ) {
53
+ globalThis . require = ( name ) => {
54
+ if ( name === 'buffer' || name === 'node:buffer' ) {
55
+ return { Buffer : BufferCompat }
56
+ }
57
+ throw new ReferenceError ( 'require is not defined' )
58
+ }
59
+ }
60
+
51
61
// Next edge runtime uses "self" as a function-scoped global-like object, but some of the older polyfills expect it to equal globalThis
52
62
// See https://nextjs.org/docs/basic-features/supported-browsers-features#polyfills
53
63
const self = { ...globalThis , fetch }
You can’t perform that action at this time.
0 commit comments