-
Notifications
You must be signed in to change notification settings - Fork 92
fix: add Buffer shim if is not globally available, adjust process and AsyncLocalStorage shims to only be applied when not available #3222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,21 @@ | ||
| // NOTE: This is a fragment of a JavaScript program that will be inlined with | ||
| // a Webpack bundle. You should not import this file from anywhere in the | ||
| // application. | ||
| import { AsyncLocalStorage } from 'node:async_hooks' | ||
|
|
||
| import { createRequire } from 'node:module' // used in dynamically generated part | ||
| import process from 'node:process' | ||
|
|
||
| import { registerCJSModules } from '../edge-runtime/lib/cjs.ts' // used in dynamically generated part | ||
|
|
||
| globalThis.process = process | ||
| if (typeof process === 'undefined') { | ||
| globalThis.process = (await import('node:process')).default | ||
| } | ||
|
|
||
| if (typeof AsyncLocalStorage === 'undefined') { | ||
| globalThis.AsyncLocalStorage = (await import('node:async_hooks')).AsyncLocalStorage | ||
| } | ||
|
Comment on lines
+12
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is overall not globally available - it seems like Next.js quirk to expect it to be globally defined, checked if it is available just to be in line with other shims here |
||
|
|
||
| globalThis.AsyncLocalStorage = AsyncLocalStorage | ||
| if (typeof Buffer === 'undefined') { | ||
| globalThis.Buffer = (await import('node:buffer')).Buffer | ||
| } | ||
|
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is fun one - Buffer is not globally defined in deno 1.39.0, 1.46.3 or 2.2.4 (from tested versions), but is available in 2.4.2 |
||
|
|
||
| // needed for path.relative and path.resolve to work | ||
| Deno.cwd = () => '' | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
processis available in deno 2, not in deno 1