Skip to content

Unified SSR checking way #2468

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

Closed
lukeromanowicz opened this issue Feb 20, 2019 · 2 comments
Closed

Unified SSR checking way #2468

lukeromanowicz opened this issue Feb 20, 2019 · 2 comments
Labels
refactor Code refactoring
Milestone

Comments

@lukeromanowicz
Copy link
Contributor

lukeromanowicz commented Feb 20, 2019

What is the motivation for adding / enhancing this feature?

Currently, we are using multiple ways of checking if the code is running in SSR including:

  • isServer in @vue-storefront/core/helpers
  • typeof window === 'undefined'
  • Vue.prototype.$isServer
  • Passing though parameters i.e. in server registration
    and possibly others.

I suggest to use isServer from @vue-storefront/core/helpers as the only way to check the environment type as it is the easiest way to mock in tests and allows us to add some enhancements in the future if needed.

What are the acceptance criteria

  • everywhere in the code we are using isServer in @vue-storefront/core/helpers as the way to check if the runtime environment is server or not
  • isServer in module registration hooks is deprecated and shall throw logger.warn when reading its value. Should be removed in a couple of versions as redundant.

Can you complete this feature request by yourself?

Yes

@vue-kacper
Copy link
Contributor

I agree

@pkarw
Copy link
Collaborator

pkarw commented Feb 20, 2019

Fixed in my PR: #2446

I need to change some other minor things and it will be ready the next week

@lukeromanowicz lukeromanowicz added feature request Requests for new features. Please be as specific as possible and provide proposal API if it you can refactor Code refactoring and removed feature request Requests for new features. Please be as specific as possible and provide proposal API if it you can labels Feb 21, 2019
@pkarw pkarw added this to the 1.9 milestone Feb 25, 2019
@pkarw pkarw closed this as completed Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code refactoring
Projects
None yet
Development

No branches or pull requests

3 participants