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

adapter-auto #2805

Closed
Rich-Harris opened this issue Nov 15, 2021 · 18 comments
Closed

adapter-auto #2805

Rich-Harris opened this issue Nov 15, 2021 · 18 comments
Labels
adapters - general Support for functionality general to all adapters

Comments

@Rich-Harris
Copy link
Member

Describe the problem

I've seen feedback from Vercel customers that SvelteKit 'doesn't work', because it wasn't clear to them that they needed to add an adapter. Even though it's documented reasonably well, it's definitely a source of friction. It would shock me if people using Kit with other platforms weren't experiencing the same thing.

Describe the proposed solution

There's probably a lot of value in having Kit auto-detect common platforms and build itself accordingly. (Nuxt does this, for example.) To that end I propose something like this in the default template:

import adapter from '@sveltejs/adapter-auto';

export default {
  kit: {
    adapter: adapter()
  }
};

TBD which platforms would be supported here, but the adapters tend to be fairly small and have overlapping dependencies, so we can probably be generous.

Alternatives considered

Builds could fail noisily if an adapter isn't configured. This would help with diagnosis, but it's still friction.

Importance

would make my life easier

Additional Information

No response

@bluwy
Copy link
Member

bluwy commented Nov 15, 2021

Would #2479 help with this? I think it's a good start before we go with something automatic.

@antony
Copy link
Member

antony commented Nov 15, 2021

does it actually require an adapter module at all? couldn't the default behaviour just be to find and install the relevant adapter (and print a warning that you should probably configure your project correctly?)

@TheOnlyTails
Copy link

I imagine this being integrated into the SvelteKit package itself, so users won't have to wonder what a seemingly unimportant package is doing in their project.

However, I do think it should still be required for the adapter field, so it won't be completely magical, and could even lead to discovery by users wondering "what's this doing here? better look it up!"

@Conduitry
Copy link
Member

@antony Going out and downloading an adapter on the fly was the behavior Rich originally suggested in the most recent Svelte maintainers call, which seemed to me to be a slightly gross mixing of concerns. I had then suggested making this be its own adapter instead, so the logic for picking an adapter can live solely in an adapter, rather than in SvelteKit core.

@Rich-Harris
Copy link
Member Author

#2479 probably would help, but it has downsides of its own — for people who just want to try Kit out (and have no intention of deploying their experiment, or don't yet know what it should be) it's a premature decision. It also adds complexity to the project scaffolding itself (overwriting a magic placeholder, etc(.

I had then suggested making this be its own adapter instead, so the logic for picking an adapter can live solely in an adapter, rather than in SvelteKit core.

exactly this — good to keep it separate, I think. And having it be 'just another adapter' makes it easier for people to figure out where and how to change it, if they have more niche requirements

@benmccann
Copy link
Member

Would adapter-auto be the default? Would it have an explicit dependency on the other adapters? Would it support only official adapters or also community adapters?

I think the thing that makes me most hesitant is that it seems like it could make community adapters slightly more like second-class citizens. It will give people more reason to campaign to make their adapters official adapters, but it's not scalable for us to be responsible for all these adapters on different platforms that we can't easily test and don't necessarily even have accounts on. There are some major platforms primarily supported by community adapters today, and I'm glad the community is handling them

@antony
Copy link
Member

antony commented Nov 15, 2021

slightly gross mixing of concerns

yep - I was thinking of what parcel does and I agree it makes me somewhat uneasy, though it is convenient.

good to keep it separate, I think

agreed, and I can see the reason now. I'm probably slightly concerned that the default behaviour of SvelteKit would now be "install all adapters" though, but I suppose an experienced user would then just uninstall the auto adapter and that would be fairly clean.

it could make community adapters slightly more like second-class citizens

For me the reasoning here is twofold:

  • We can't possibly know about every single community adapter
  • We can't install every single community adapter as a dependency of adapter-auto

Therefore what I might suggest is some sort of way of defining a heuristic such that community adapters can open a PR to allow auto-detection of their destination platform, which could then print a hint about where to get hold of such an adapter, but going slightly short of actually having it preinstalled (which of course also poses a security risk)

@antony antony added the adapters - general Support for functionality general to all adapters label Nov 15, 2021
@sphinxc0re
Copy link
Contributor

What about prompting the developer with a choice of adapters along the lines of what create-svelte does?

@TheOnlyTails
Copy link

@sphinxc0re as Rich has already said:

#2479 probably would help, but it has downsides of its own — for people who just want to try Kit out (and have no intention of deploying their experiment, or don't yet know what it should be) it's a premature decision. It also adds complexity to the project scaffolding itself (overwriting a magic placeholder, etc).

@sphinxc0re
Copy link
Contributor

Oops, sorry didn't see that 😓

@Tropix126
Copy link

My main concern is that a package like this will work as a one-size-fits-all for many deployment targets, but be slightly worse than the more "specialized" adapters alone. It would also discourage people from properly configuring their projects to work with a specific deployment type if included by default, because I imagine many would gloss over a config option they don't understand but also doesn't seem to affect anything.

@benmccann
Copy link
Member

A Svelte Adder that could add any adapter could be another solution for this. That would mean you don't have to decide at project creation time what adapter you want to add and allow us to support community adapters and avoid issues around adding dependencies on every single adapter

@gterras
Copy link

gterras commented Nov 18, 2021

The problem seems to be you can't hide and teach adapters at the same time and some people need one or the other. I think an elegant way would be npm run configure (ran on initial build) that would display a choice between auto/specific/community.

It would be at the right time of development, wouldn't mix concerns and could teach or promote as much as needed.

@Tropix126
Copy link

Tropix126 commented Nov 18, 2021

The problem seems to be you can't hide and teach adapters at the same time and some people need one or the other. I think an elegant way would be npm run configure (ran on initial build) that would display a choice between auto/specific/community.

It would be at the right time of development, wouldn't mix concerns and could teach or promote as much as needed.

The problem is that the configuration step usually happens during the creation wizard; adding an additional script here seems rather redundant.

My personal thoughts are that it's safe to say that most people wanting to create a SvelteKit project plan to deploy it. If they are just "trying it out", then knowledge of adapters is useful information to have in the event they do try to deploy a project later on.

@jthegedus
Copy link
Contributor

Is there a way for me to test out my adapter installs properly if it were to be added to the adapter-auto?

@bluwy
Copy link
Member

bluwy commented Dec 4, 2021

Is there a way for me to test out my adapter installs properly if it were to be added to the adapter-auto?

If you add your adapter as a dependency of adapter-auto and add it to adapters.js, it should then work. I'd recommend reading the adapter code too.


This issue seems to already be resolved by #2867. Closing this.

@bluwy bluwy closed this as completed Dec 4, 2021
@benmccann
Copy link
Member

I think Rich didn't want all community adapters as dependencies, but instead just detect the platform and spit out a message telling the user they can install it?

@bluwy
Copy link
Member

bluwy commented Dec 4, 2021

Yeah that's true. We probably don't want anymore community adapters as dependencies for adapter-auto. (I thought my comment had mentioned that but I must've accidentally deleted it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adapters - general Support for functionality general to all adapters
Projects
None yet
Development

No branches or pull requests

10 participants