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

Added check for window #1446

Merged
merged 2 commits into from
May 25, 2018

Conversation

mimse
Copy link
Contributor

@mimse mimse commented May 24, 2018

To support require in nodejs of shaka-player to fix this issue

#1445

I have added a check for window

@theodab
Copy link
Collaborator

theodab commented May 24, 2018

I've double-checked this. It seems to work as expected; i.e. it does the same thing as the change the plyr team made.

@joeyparrish
Copy link
Member

It seems that with this change, nothing would be imported at all. Is that intended? Why?

@mimse
Copy link
Contributor Author

mimse commented May 24, 2018

We are using shaka-player in a react environment. And we are using the same code for server-side and client-side rendering.
So when shaka-player is imported server-side window does not exist and we get an error.
We do not need video server-side so by checking for window we insure shaka-player is not imported.
Hope this make sense 😊

@joeyparrish
Copy link
Member

I see. I think, though, that it might be a little misleading if the import fails silently. What if we import to global instead of window?

@joeyparrish
Copy link
Member

For example, instead of checking typeof window === "object" at the top to decide to call the wrapper function, what if you changed call(window) at the bottom to call(typeof window === "object" ? window : global)? Would that work for you?

@mimse
Copy link
Contributor Author

mimse commented May 24, 2018

I will test this solution tomorrow. And get back to you. But I think it could work.

@joeyparrish
Copy link
Member

Great, thanks!

@mimse mimse force-pushed the bug/fix_issue_with_imports branch from e633e37 to 7302cd9 Compare May 25, 2018 06:24
@mimse
Copy link
Contributor Author

mimse commented May 25, 2018

@joeyparrish it worked and I have updated the PR with your feedback.

@mimse
Copy link
Contributor Author

mimse commented May 25, 2018

@joeyparrish also if the PR is accepted would it be possible for it to be cherry-picked to 2.4?

@joeyparrish joeyparrish added this to the v2.5 milestone May 25, 2018
@joeyparrish
Copy link
Member

The build bot is testing the change now. If all the tests pass, I would be happy to merge this and cherry-pick it for v2.4.1. Thank you for contributing!

@joeyparrish
Copy link
Member

Actually, it's trivial enough that I could also cherry-pick to v2.3.x in case we do another release from that branch.

@shaka-bot
Copy link
Collaborator

All tests passed!

@joeyparrish joeyparrish merged commit 68f9c76 into shaka-project:master May 25, 2018
@mimse mimse deleted the bug/fix_issue_with_imports branch May 28, 2018 12:07
joeyparrish pushed a commit that referenced this pull request Jun 1, 2018
If nodejs, use global as scope, else use window.

Closes #1445
joeyparrish pushed a commit that referenced this pull request Jun 1, 2018
If nodejs, use global as scope, else use window.

Closes #1445
@joeyparrish
Copy link
Member

Cherry-picked for v2.3.9 and v2.4.1.

@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants