-
Notifications
You must be signed in to change notification settings - Fork 3
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
refactor: replace try-import with globalThis.process #18
Conversation
Isn't checking after |
Because the |
Precisely, ins't checking after |
You can simply check if you are in the Node.js environment. Some points to prefer the
Absurdly, the user can install a library called |
The issue with |
As alternative you can enforce with: export function isNodeLike() {
return globalThis.process !== undefined && globalThis.process.versions?.node !== undefined
} Some source: https://www.30secondsofcode.org/js/s/is-node-or-browser |
I ain't sure it catches Bun or Deno then. |
We can use instead: export function isNodeLike() {
return (
globalThis.window === undefined &&
globalThis.document === undefined &&
globalThis.navigator === undefined
)
} |
I think it's better we check for capability instead. |
No description provided.