egoist / vue-client-only

Vue component to wrap non SSR friendly components (428 bytes)
MIT License
474 stars 37 forks source link

add alternate detection methods #84

Open redxtech opened 4 years ago

redxtech commented 4 years ago

I have created this PR to allow this component to function with multiple prerendering libraries. The ones I have tested so far are below:

Library Working Notes
react-snap ✔️ details
prerender-spa-plugin not tested yet details
presite not implemented yet awaiting response from library author
snapshotify not implemented yet awaiting response from library author
prerenderer not implemented yet awaiting response from library author
prep not implemented yet awaiting response from library author

I will update this PR as I hear back from the library authors. I will also happily add detection methods for other libraries as requested if I can find out how to detect that the app is being prerendered.

egoist commented 4 years ago

I prefer exposing a prop like shouldRender over directly support every possible use case in this library.

redxtech commented 4 years ago

Ah ok. By this do you mean a shouldRender prop that you pass whatever expression that your prerendering library uses to signify that it is being used? If so, I can definitely see why, as I am also usually a fan of a general solution instead of numerous hard-coded solutions.

This being said, I still have a few concerns with just using a shouldRender prop:

  1. Wouldn't this result in a bunch of boilerplate code? Having to add the exact same prop to each instance of the component throughout a project seems rather repetitive. A single prop may not be much on its own, but it's still something extra that you have to remember and add each time you use it.
  2. Since this currently adds very little complexity, wouldn't it make sense to choose the "zero config" option? If it was more complex to hard-code a few libraries by default I would definitely agree, but at the moment it is not.

Perhaps including a few hard-coded options for some of the more popular libraries while also including a shouldRender prop would be a solution that combines the best of both worlds?