-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix: updated isNode check (#1221) #1363
Conversation
* Fixes #1221 when used within SSR. `process` is a global variable since node [0.1.7](https://nodejs.org/api/globals.html#globals_process) and versions since [0.2.0](https://nodejs.org/api/process.html#process_process_versions).
Haven't checked and might be a false alarm, but referencing |
Thanks @dcodeIO, let me check this. This is basically why we decided to merge stuff on Fridays and let it bake for a while before we make an actual release next week :) I'll update the issue and/or send a fix if needed. |
So, several things here:
My personal opinion here is that it's better to fix the code for users who actually reported they have problems (in #1221), and then fix it once more if the fix actually breaks someone else's code (it definitely will, obligatory xkcd). Folks who really care about the extra 1.6K of minimized code will be able to configure their bundler to remove this shim. |
...but the bad thing is that it actually breaks |
The |
Perhaps with an additional safeguard there: function checkNodeGlobal(global) {
if (global && global.process) return global; // or whatever reasonably identifies node
return null;
}
// global object reference
util.global = typeof global !== "undefined" && checkNodeGlobal(global)
|| typeof window !== "undefined" && window
|| typeof self !== "undefined" && self
|| this; // eslint-disable-line no-invalid-this |
* Fixes protobufjs#1221 when used within SSR. `process` is a global variable since node [0.1.7](https://nodejs.org/api/globals.html#globals_process) and versions since [0.2.0](https://nodejs.org/api/process.html#process_process_versions). Co-authored-by: Alexander Fenster <[email protected]>
process
is a global variable since node 0.1.7 and versions since 0.2.0.