Skip to content

Align on Vite's intended scope to allow for framework-agnostic provider plugins #3

Closed

Description

@serhalp

Deep in the bowels of this long and broad RFC I proposed these statements:

  1. Given a framework that follows the (Vite-endorsed AFAICT) "framework-as-Vite-plugin" approach, it should be tractable for a provider’s framework-agnostic Vite plugin to build apps for deployment—without requiring end users to write additional code or configuration.
  2. Given a framework that follows the classic approach (providing its own CLI and/or config and/or adapter mechanism; I refer to this as the "framework-as-toolchain" approach), it should be tractable for a provider’s framework adapter to delegate the app’s preparation for deployment to its framework-agnostic Vite plugin.
  3. In scope for Vite: Features and functionality involved in the framework fulfilling requests; for example, SSR pages, middleware, RSC, framework-defined API endpoints, Server Functions.
  4. Out of scope for Vite: Everything else; for example, static redirects, static response headers, image optimization, version skew protection, etc. These belong in some combination of framework configuration, provider configuration, and provider plugin/adapter configuration.

Before proceeding, it would be great to align on these statements.

Supporting material

"Framework-as-Vite-plugin" diagram Image
"Framework-as-toolchain" diagram Image

Activity

  1. sapphi-red commented on Apr 3, 2026

    @sapphi-red
    Member

    3. In scope for Vite: Features and functionality involved in the framework fulfilling requests; for example, SSR pages, middleware, RSC, framework-defined API endpoints, Server Functions.

    I guess we can focus only on the SSR pages and have a custom field in the first iteration. That should make it possible for us to start with a simple API and validate the idea with that. We'll need to have a custom field anyways and I think keeping it simple would also help us ensure that the custom field is flexible.

  2. magne4000 commented on Apr 3, 2026

    @magne4000

    For reference, this POC based on the RFC might be useful in shaping the API: https://github.com/universal-deploy/universal-deploy?tab=readme-ov-file#universal-deploy

  3. jamesopstad commented on Apr 7, 2026

    @jamesopstad

    Can I suggest we focus in on the "server entry point location" and "server entry point signature" parts of the discussion today and try to reach alignment on those?

  4. magne4000 commented on Apr 7, 2026

    @magne4000

    To help our discussion, here are links with excerpts to specifics discussions we had on those subjects.

    Server entry point location

    Previous discussions

    Summary

    Several options have been discussed across the RFC:

    Server entry point signature

    Summary

    I think the only proposed solution is the following:

    export default {
      fetch(request: Request): Response | Promise<Response>
    }

    Since so many actors have already chosen this signature, it feels like the natural choice.

  5. sapphi-red commented on Apr 20, 2026

    @sapphi-red
    Member

    We had two parts to figure out about this:

    1. Where should the metadata be stored?
    2. What information should the metadata have?

    I thought about the former a bit. I think there're roughly two places:

    • part of the config
      • easier composition
      • it feels strange to me to put it in the config as it isn't something we expect the end user to directly configure
    • part of the Plugin API
      • probably it shouldn't be tied to builder because the information is useful for dev as well
        • for example, if we want to make RunnableDevEnvironment fetchable, we need to configure the way to convert the interface
      • some candidate places:
        • ResolvedConfig.meta
        • builder.meta
        • this.meta.deployments
  6. matthewp commented on Apr 29, 2026

    @matthewp

    Is this thread about more than one subject? "metadata" is not part of what @serhalp is talking about here.

  7. florian-lefebvre commented on May 1, 2026

    @florian-lefebvre

    I've been experimenting with Vite adapters lately (https://vite-deploy.web-runes.dev/) and I have another opinion on this now.

    I'm not convinced allowing a given framework and a host plugin together through Vite brings much to the user. The big risk IMO is introducing some unecessary abstractions and hiding some useful logic from them.

    Instead what I'd like to suggest is a community convention, based around Fetchables. For example, Tanstack Start and Vite Deploy work very well together out of the box. It gives a lot of power to the user if they need custom things because they have full control over the actual request handler and platform specific APIs.

  8. serhalp commented on May 6, 2026

    @serhalp
    Author

    I put up a little mini spec page for Fetchable: https://fetchable.org/

  9. matthewp commented on May 9, 2026

    @matthewp

    Is it interoperable if ...extra: unknown[] is not?

  10. serhalp commented on May 11, 2026

    @serhalp
    Author

    Is it interoperable if ...extra: unknown[] is not?

    It's a good question. I think yes, because a Fetchable can always be safely called with a Request, and if a module extends the Fetchable interface by supporting additional arguments, this would be done in a way that is specific to that module (plugin/platform/whatever) and would only be read by code that is explicitly aware that it's using that plugin/platform/whatever.

    I could just omit ...extra: unknown[] from the documented type to avoid encouraging it? The language will allow it either way 😄.

    For the record (we discussed this on the call), it seems all platforms have alternative mechanisms for accessing "platform context" and things like waitUntil without going through entry point args:

    Personally, I find the whole pattern quite awkward, both for end users and for us all as maintainers. Requiring TypeScript module augmentation is not ideal DX, IMO.

    I also sense that there's a move away from it in frameworks:

  11. serhalp commented on May 11, 2026

    @serhalp
    Author

    Decisions

    On the Wed May 6 2026 Vite Ecosystem call, we decided that the statements in the body of this issue do reflect the vision of the Vite team and the Vite ecosystem. As such, this issue will be closed.

    Further discussion on solution specifics will proceed in #4 and I will open further issues for the (hopefully not very contentious) subtopics of "how do I find the path to a server entry point" and "how do I know it's a Fetchable?".

  12. moved this from Backlog to Done in ecosystemon May 11, 2026
  13. matthewp commented on May 13, 2026

    @matthewp

    I can't get logging into Tangled to work, so while I would have created an issue to discuss, I'll just do it here. What does it mean to say something is interoperable? Like you said, even without ...extra: unknown[] there are various other ways this information is read like with cloudflare:workers. I that's the case, you can't just run any Fetchable in any environment; they are dependent on a specific runtime.

    If that's the case, it's not really interoperable. The shape is the close to the same, and this benefits learning and understandability, but beyond that, is there any advantage?

  14. serhalp commented on May 16, 2026

    @serhalp
    Author

    Hmm, I don't see how the optional, untyped, additional arguments affect interoperability.

    A framework plugin generates:

    export default {
      async fetch(req: Request): Promise<Response> {
        return new Response(`Hello, ${req.headers.get("User-Agent")}!`)
      }
      // ... maybe even other properties here, doesn't matter
    }

    ^ This conforms to the Fetchable interface.

    A platform plugin doesn't need to know which framework it came from, if any, yet it can import and invoke it:

    /* ... */
    const req = new Request(/* ... get request from somewhere ... */)
    const entrypointPath = '...'
    const entrypoint = await import(entrypointPath)
    const res = await entrypoint.fetch(req, {/* ... maybe platform context ... */})
    /* ... do something with the response ... */

    ^ This imports and invokes a module conforming to the Fetchable interface.

    Making the call signature open to extension just affords flexibility to callers to pass additional arguments without type errors. It means that many existing signatures (like Cloudflare Workers) are conformant already today. It means that a (say) manually written entry point file for a specific platform can accept additional arguments specific to that platform.


    All this said, we could just omit this from the spec and not much would change in practice 🤷🏼‍♂️.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions