Skip to content
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

Detect globalThis to support edge runtime #24

Merged
merged 1 commit into from
Jun 5, 2023

Conversation

andyjy
Copy link
Contributor

@andyjy andyjy commented Jun 5, 2023

We need to use globalThis rather than global (or window/self) to access the global scope under the Vercel Edge runtime.

Existing detection of global is specific to Node; globalThis is a newer standard to provide cross-platform support - and the required method under the Edge runtime:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#description

Fixes #20 (original issue is support for Edge runtime)

We need to use `globalThis` to access the global scope under the Vercel Edge runtime.

Existing detection of `global` is specific to Node; `globalThis` is a newer standard to provide cross-platform support - and the required method under the Edge runtime:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#description
@perry-mitchell
Copy link
Owner

Awesome, this looks great! Thanks @andyjy

@perry-mitchell perry-mitchell merged commit a189634 into perry-mitchell:main Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing node:crypto breaks compat with edge runtimes (Vercel etc)
2 participants