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

App setup RFC #326

Closed
wants to merge 2 commits into from
Closed

App setup RFC #326

wants to merge 2 commits into from

Conversation

natemoo-re
Copy link
Member

@natemoo-re natemoo-re commented Oct 3, 2022

  • Start Date: 2022-10-03
  • Status: Draft

Summary

This RFC proposes a unified interface that provides a hook into island setup. User-provided hooks will run for both server rendering and client-side hydration.

The primary motivation is unblocking vue.use, but there are other use cases as well.

Links


- This proposal exposes lower-level control to users. Fine for advanced use cases, but makes it easier to introduce performance footguns if not used carefully.
- This proposal introduces a new pattern that, while modelled after similar patterns in other frameworks, has a unique design due to Astro's constraints
- This proposal **DOES NOT** solve a common problem for sharing state via `Provider`s. It's extremely likely that people will expect this feature to do that because you can setup a Provider. However, Providers in this proposal **ARE NOT** stateful between islands—updates to one Provider instance will not automatically propogate to other Provider instances unless specifically architected to do so by the user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the desire to avoid feature-bloat, but presumably you are thinking about this. Shared context in React is one very desirable feature. We can skip that for now, but it would be good if you have an idea of what that might look like so that this feature can be a stepping stone and that is not a completely different feature, if that makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that totally makes sense. This proposal is certainly not blocking an implementation of shared context in the future, since a prototype of that is what I extracted this proposal from. I was hoping to avoid this conversation being focused on shared state because there's still a lot to figure out there, but users asking to hook into vue.use comes up almost every day.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would even be open to not implementing this appEntrypoint proposal for React/Preact until shared state lands. It's possible this might just be a footgun until Providers can be singletons that only run once.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think holding off on React makes sense. I haven't seen as much of a demand for the "pyramid of providers" pattern as there has been for Vue .use() so far.

@L1lith
Copy link

L1lith commented Oct 5, 2022

It would be quite neat if there was a way to specify setup code that only gets loaded on server side or client side (like with the game engine melonJS, it would be cool to render the game to a static image on the server side, render that on the initial page load, then on the client side replace it with the actual game after the page has mounted)

See Also: melonjs/melonJS#1134 (to me this issue appears quite difficult to implement atm)

@natemoo-re
Copy link
Member Author

Update: After discussing this during [Community Call] October 4, 2022, we decided that it was too early to abstract this concept into a core Astro feature. As such, I have chosen to withdraw this RFC.

Thankfully, this can all be accomplished through our integration API (aka "in userland")! The plan is to implement this proposed behavior in the @astrojs/vue integration. In the future, if we find ourselves repeating this pattern, we can revisit the idea of an abstraction built-in to astro core.

@natemoo-re natemoo-re closed this Oct 6, 2022
@natemoo-re
Copy link
Member Author

It would be quite neat if there was a way to specify setup code that only gets loaded on server side or client side (like with the game engine melonJS, it would be cool to render the game to a static image on the server side, render that on the initial page load, then on the client side replace it with the actual game after the page has mounted)

See Also: melonjs/melonJS#1134 (to me this issue appears quite difficult to implement atm)

This should be possible now, even without a feature like this! Feel free to ping me on Discord and I can walk you through it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants