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

feat: allow ssrRef to work outside of setup #46

Merged
merged 8 commits into from
May 10, 2020
Merged

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented May 9, 2020

This PR removes the custom prefetching we were doing (via redefinition of onServerPrefetch, and instead uses a transparent proxy for the ssrRef on server-side to update the state every time it is changed.

see #40

@danielroe danielroe added the enhancement New feature or request label May 9, 2020
@danielroe danielroe self-assigned this May 9, 2020
@vercel
Copy link

vercel bot commented May 9, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nuxt-community/composition-api/c9na82xy3
✅ Preview: https://composition-api-git-no-setup-ssrrefs.nuxt-community.now.sh

@danielroe
Copy link
Member Author

Would value your thoughts @mathe42. Do we lose anything by doing it this way?

@mathe42
Copy link
Collaborator

mathe42 commented May 9, 2020

Yes we can not track deep changes.

@danielroe
Copy link
Member Author

@mathe42 Yes, of course. Good catch. Thoughts on amended proxy approach?

@danielroe danielroe marked this pull request as ready for review May 10, 2020 12:16
@mathe42
Copy link
Collaborator

mathe42 commented May 10, 2020

This will break IE11

@mathe42
Copy link
Collaborator

mathe42 commented May 10, 2020

I think we can add a option to use Proxies and fallback to the onServerPrefetch stuff.

Outside Setup when Proxies allowed use it else always send state to client...

@danielroe
Copy link
Member Author

danielroe commented May 10, 2020

@mathe42

This will break IE11

The proxy code won't be in the client bundle; it's just server-side.

Outside Setup when Proxies allowed use it else always send state to client...

It should only send state after something is assigned to the proxy. So

// This shouldn't be sent
const a = ssrRef('init')
// But this now will be
a.value = 'init'

@mathe42
Copy link
Collaborator

mathe42 commented May 10, 2020

Nice 👍

Does this mean we need Node Version >= x? => change package.json

@mathe42
Copy link
Collaborator

mathe42 commented May 10, 2020

@mathe42
Copy link
Collaborator

mathe42 commented May 10, 2020

Node >= 6.0

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy

But nuxt needs later versions:

https://github.com/nuxt/nuxt.js/blob/dev/distributions/nuxt/package.json

@danielroe danielroe merged commit 6a67c05 into master May 10, 2020
@danielroe danielroe deleted the no-setup-ssrrefs branch May 10, 2020 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants