Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e536181

Browse files
authored
fix: add Buffer shim if is not globally available, adjust process and AsyncLocalStorage shims to only be applied when not available (#3222)
1 parent e0f489b commit e536181

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

‎edge-runtime/shim/node.js‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
// NOTE: This is a fragment of a JavaScript program that will be inlined with
22
// a Webpack bundle. You should not import this file from anywhere in the
33
// application.
4-
import { AsyncLocalStorage } from 'node:async_hooks'
5-
64
import { createRequire } from 'node:module' // used in dynamically generated part
7-
import process from 'node:process'
85

96
import { registerCJSModules } from '../edge-runtime/lib/cjs.ts' // used in dynamically generated part
107

11-
globalThis.process = process
8+
if (typeof process === 'undefined') {
9+
globalThis.process = (await import('node:process')).default
10+
}
11+
12+
if (typeof AsyncLocalStorage === 'undefined') {
13+
globalThis.AsyncLocalStorage = (await import('node:async_hooks')).AsyncLocalStorage
14+
}
1215

13-
globalThis.AsyncLocalStorage = AsyncLocalStorage
16+
if (typeof Buffer === 'undefined') {
17+
globalThis.Buffer = (await import('node:buffer')).Buffer
18+
}
1419

1520
// needed for path.relative and path.resolve to work
1621
Deno.cwd = () => ''

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /