-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
RFC: renderer plugins #74
Comments
ShamelessnessI’m also currently unspoken for in an employment sense—exploring some prospects but no one has yet made an honest man/person of me—and while frontend problems isn’t especially one of my passions, boldly working on problems that could impact millions of people in countless thankless ways is definitely one of them. If I can pay my bills, keep my pup healthy and fed, and work on stuff like this, I’d be pleased as pie to devote more than weekend hours to it. Wow that was the weirdest, most unexpected cover letter I’ve ever written and published semi-publicly. |
Thanks for filing the issue. Our thoughts so far on how to allow other frameworks have fallen into 2 places:
I'm going to propose something like: export default {
experimentalFrameworkPlugins: [ { type: 'solid', Renderer } ],
extensions: {
'.solid': 'solid'
}
} The Also note that for something like Solid the plugin would need to provide a Snowpack plugin to compile the files to JS. |
That's pretty much the interface I had in mind, give or take some naming. I'm gonna poke around and see if I can get something like this working. |
@eyelidlessness I'm going to confirm with the rest of the core team that this API is fine with them. One thing to note with your experimentation is that you need a Solid snowpack plugin as well. You can bring your own snowpack config file in Astro and we'll load it. Something like this might work: https://github.com/ravupad/solid-snowpack-starter/blob/master/snowpack.config.json However this probably means you can't use other jsx frameworks side-by-side. It would be nice if we could get something figured out in the future so that you can. You currently can't use a React and Preact component in the same app for the same reason. |
@matthewp I should push up the stuff I have so far when I get to my desk. Even if it’s all throwaway prototyping it’s mostly types, but I had expanded the current interface to include a That said I’d also recommend bringing up previous discussions with @natemoo-re about making Microsite itself a Snowpack plugin, and whether Astro could be implemented that way too. There’s a certain amount of build tool config sprawl fatigue, and consolidating on one tool could be a big DX improvement. That might also be a better model for BYOF.
I haven’t tried but couldn’t you just choose custom extensions for each? This is something I saw in one of the screenshots. I’m not sure how much of a use case there is for mixing React/Preact, they’re so nearly compatible, but I could definitely see one for mixing Solid with one of the others for compatibility reasons. |
Regarding Snowpack integration, we're using Astro as a chance to dogfood Snowpack's JS API. Astro also does significantly more internal work than Microsite. We're keeping tool fatigue in mind but Astro is shaping up to be it's own thing at the moment for many reasons. Regarding React/Preact can we currently set I built the current renderer interface as a first pass but I haven't gotten the time to dig into this proposal just yet! I'll add more thoughts when I do. This is tangential, but part of the issue with the current approach is requiring every framework to be a direct dependency of Astro. I wonder if we completely sidestep that with |
I hesitate to recommend |
@eyelidlessness That's a good idea! Using |
I don’t want to overly push back on a project that’s new to me but you’ve lived and breathed for much longer, but if I may push back a bit... this may be a good way to dogfood and identify where the Snowpack config the rest of us use doesn’t serve use cases like this. One of my biggest frustrations with all of the current popular build tools is that configuring them for anything moderately complex can require jamming together a lot of tools with opaque or sprawling APIs spread out over many files. This is not only mentally taxing, it also makes it hard to understand what’s happening, and when. On the bright side this is what led me to get neck deep in Microsite and start contributing, but a lot of people understandably won’t want to do that. If there were one place to configure the whole build, including explicitly specifying which steps the user expects to perform before and after Astro does its thing, this would go a long way toward making all of that much easier to understand and maintain. And that kind of flexibility would also probably improve both Astro and Snowpack.
I had actually been thinking more along the lines of
This sort of suggests to me that it might be better to make all of the renderers use whatever the ultimate plugin interface turns out to be, installed separately from the Astro core. Then each such plugin could specify its |
We definitely don't want to force the first step of installing Astro to be installing some other framework plugins. React, Vue, Svelte, and Preact being builtin is pretty crucial. I'd rather add more frameworks to core rather than remove any we currently have. |
Happy to see that there are already some Astro X Solid talk going. The two sound definitely like they could be a nice match together. As per the Snowpack plugin requirement, I can probably work that out, based on the work we've done for @eyelidlessness If you have any question regarding the Solid part of the integration, feel free to poke us around on our Discord, you can find the link in our Github repo. Would a snowpack plugin that wraps Babel help you out? As per the general consensus of that discussion, it seems pretty alright so far with the little I know about Astro so far. Having a That's my two cents at the moment. /cc @davedbase |
Fair enough. For what it’s worth, this doesn’t have to be an additional step. Many projects providing optional functionality include single-step instructions for installing the core and whichever optional things in one command, or a If that’s still not the desired DX, I think there’s still benefits to implementing the built in frameworks against the same plugin interface that third party plugins would use, particularly in terms of decoupling and maintaining a clear interface between Astro and the frameworks. |
Thanks! I joined the other day and was happy to see some discussion of Astro there too! It really does feel like a good fit.
Possibly! I think it depends on the interface design here. In the proposed design above I think it will need to call Babel programmatically. I have some prototype code (which I really should push up) that may be most of the way there. It’s pretty straightforward, the only complexity really is a second step where I use the Babel AST to get the compiled imports, which Astro needs to know about (presumably to prevent compiling them out). |
@amoutonbrady For clarity, the discussion here is scoped towards unblocking people who want to use a non-builtin framework. In no way do I think that this proposal is the ideal API. It's being proposed because it's close to how Astro internally handles frameworks. The Otherwise it would probably be something like this: import SolidRenderer from 'astro-solid';
export default {
experimentalFrameworkPlugins: [
{
type: 'solid',
Renderer: SolidRenderer
}
],
extensions: {
'.jsx': 'solid'
}
} Then a snowpack.config.js that handles running Solid's babel plugin. That's all we need here. For now the user would bring their own snowpack.config.js, so using your starter app is perfect. In the future we'll figure out how to have the plugin provide that. |
Yeah ok that's what I understood as well, thanks for clarifying. That config sounds really solid and easy to process from a user perspective actually. I totally dig it! |
Oh. In my prototype WIP I’ve defined a plugin interface extending the renderer interface to add a |
Just catching up on this one! @eyelidlessness Leveraging Snowpack plugins to handle compilation is what we'd prefer! The "Astro renderer plugin" interface could possibly define which Snowpack plugin(s) the renderer relies on and Astro could automatically inject those plugins. Not a final decision, but we've been leaning towards Snowpack being an invisible implementation detail. So the "configuration" DX would be to configure Astro if necessary.
This is a good idea. I think at this point we're more comfortable building renderers into core because we want to make it really easy for everyone to try everything out. When we launch publicly, I imagine our implementation will look much more like what you're suggesting—a nice "start project" CLI and less built-in to core with a formal Renderer plugin interface. If you're just hoping to kick the tires on Solid support, does the current (not ideal) interface work? If it's missing something, I'm very open to suggestions. Hopefully building this out can inform what the official renderers should look like. |
This makes sense. One nit (and it’s one that already applies to Snowpack), I’d greatly prefer to be able to provide a plugin instance rather than
This is definitely good to hear. I’ll reiterate that I think it would be good if the interface for this is an extension of the Snowpack config. A lot of newer tooling is converging on similar config semantics, a very welcome development. It would be great to be able to transfer my familiarity with snowpack.config to this project from the same team built with the same tooling.
For what it’s worth, I’m less invested in the idea of the built in renderers being extracted into separate dependencies, and more invested in first party and third party renderers having the same interfaces. The former would benefit anyone sensitive to dependency bloat by alleviating the The latter would benefit everyone involved:
No, it’s actually quite good! And this is coming from someone who’s obviously a stickler on the topic and spends more time than I’d like quietly or privately complaining about interfaces I have to deal with. My goal starting to kick the tires was “can I bring Solid?” My goal now is “can I help shape a solution where the next weirdo after me wants to bring something else, and it’s good for everyone involved?” I think it’s clear there’s buy in for BYOF with a plugin system. That’s awesome. Mostly I’m looking for some clarity on the interface out of the gate (which is pretty clear now, at least to start it can match the internal interface with compilation handled by a Snowpack plugin), and some understanding of interest in the core/contrib renderers using the same mechanisms as third party ones will. |
Thank you all for the thoughts and feedback! We are launching this soon, with documentation being written now. Would love to continue getting feedback on this API as we move forward. |
This may be premature, but Astro offers almost everything I’ve wanted in a web [meta-]framework:
I also think it’s well positioned to check the one large-ish remaining checkbox on my list:
I already mentioned this to Nate: I want to try this with Solid (I’d love to @ Ryan here but I’m not sure how that would work in a private repo, but this project should definitely be on his radar), another performance-obsessed library supporting JSX, but currently lacking support for partial hydration.
I thought I was going to spend most of my initial early access time tinkering with using this clever bit of machinery. But I did what I always do and read through most of the source. (It’s some of the best I’ve seen in a web context by the way!)
As I would’ve hoped, the current BYOF offering works by abstracting each respective library’s interfaces behind a common one. This is an excellent design for the current set of supported component libraries.
My naïve thought seeing that was “oh, adding support for Solid would likely be trivial-ish and a great first contribution!” Taking a little hammock time led to: this design also provides a good foundation for a plugin architecture.
Proposal
Risks
This is a big ask for a young project and a small team with a lot going on. It feels like a good fit for the project, but I’d be remiss if I didn’t recognize the risks I see upfront:
?
types or those libraries get disappointing second-class treatment.That said:
✋ I wanna help
This project is something I want to use, support and promote. I’m big on contributing to open source. I’d be happy to participate in this effort (and others as they come to my attention) from a personal investment perspective alone.
The text was updated successfully, but these errors were encountered: