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(animations): false positive when detecting Node in Webpack builds #35134
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 |
---|---|---|
|
@@ -15,12 +15,17 @@ import {AnimationDriver} from '../../src/render/animation_driver'; | |
// types. `process` is just declared locally here as a result. | ||
declare const process: any; | ||
|
||
export function isBrowser() { | ||
export function isBrowser(): boolean { | ||
return (typeof window !== 'undefined' && typeof window.document !== 'undefined'); | ||
} | ||
|
||
export function isNode() { | ||
return (typeof process !== 'undefined'); | ||
export function isNode(): boolean { | ||
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. Thinking out loud: shouldn't somehow 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. Looking at the only place |
||
// Checking only for `process` isn't enough to identify whether or not we're in a Node | ||
// environment, because Webpack by default will polyfill the `process`. While we can discern | ||
// that Webpack polyfilled it by looking at `process.browser`, it's very Webpack-specific and | ||
// might not be future-proof. Instead we look at the stringified version of `process` which | ||
// is `[object process]` in Node and `[object Object]` when polyfilled. | ||
return typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; | ||
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. 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. 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. The REPL parses the |
||
} | ||
|
||
export function optimizeGroupPlayer(players: AnimationPlayer[]): AnimationPlayer { | ||
|
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.
Why are the
(
and)
parenthesis needed?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.
I don't think they are. I didn't put it in, I just added a return type to the function.
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.
return (typeof ... )
are optional and are somewhat useful in increasing the readability of the code because they mean, what follows is a bit complex so we put it into()
to warn you.