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

Better detection of node/browser #15

Merged
merged 1 commit into from
Aug 13, 2020
Merged

Conversation

evertonfraga
Copy link
Contributor

At ethereumjs/ethereumjs-monorepo#785 (comment), we found that exports shouldn't guide the browser/node detection. It is usually present in browser builds made with Browserify, invalidating that clause.

While as ridiculous as it sounds, there isn't a certain way to know the platform for sure, but I propose at least this better heuristic, using window instead. The likelihood of a Node project to have a window global variable seems to be super low.

Additional ways to detect platforms involve: self and global.

More on this: https://v8.dev/features/globalthis.

@herumi herumi merged commit ddeb8df into herumi:master Aug 13, 2020
@herumi
Copy link
Owner

herumi commented Aug 13, 2020

Thanks for the useful patch.

@jochem-brouwer
Copy link

Thanks for merging this @herumi. Could you also bump the package version? 😄

@herumi
Copy link
Owner

herumi commented Aug 13, 2020

I've updated it.

@evertonfraga
Copy link
Contributor Author

Thanks!

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.

3 participants