Skip to content

photon-js/universal-deploy

Repository files navigation

universal-deploy

Deploying Vite apps anywhere.

Goal

POC that solves the issue point 1 and 3 of Netlify's RFC, i.e. "Server entry point location" and "Routing metadata". Mostly, how can a deployment target (Netlify, Cloudflare, Node, etc.) find and use the different server entries defined by a framework (or user)?

This POC demonstrates that we can solve this issue with a minimal API.

Features

Core Concepts

Store

@universal-deploy/store provides a global registry for server entries with routing:

import { store } from "@universal-deploy/store";

store.entries.push({
  id: "./src/server/api.ts",
  pattern: "/api/*",
  method: "GET",
});

See the store documentation for full API details.

Vite Plugins

The following Vite plugins help frameworks and deployment providers work with the global entries store.

  • compat: Auto-registers SSR rollup entries in the store (for Vite-based frameworks that didn't adopt universal-deploy yet).
  • catchAll: Utility plugin that aggregates and routes all global store entries behind a unique entry. Used by devServer, compat and node target.
  • devServer: Can be used by a framework during development to route requests to the entries defined in the global store.

Adapters

Temporary packages that demonstrate how deployment plugins can integrate @universal-deploy/store. Packages like @universal-deploy/netlify will no longer be required once directly supported by Vite deployment plugins (e.g. @netlify/vite-plugin).

Already compatible:

Usage

Framework authors

Call store.entries.push at any point, preferably before configResolved hooks.

Deployment plugin authors

For deployment providers requiring a unique server entry, the easiest way is to set rollupOptions.input to catchAllEntry. This virtual entry will be resolved by the catchAll plugin.

For deployment providers with support for multiple server entries, read store.entries in a post configEnvironment hook and set rollupOptions.input.

Note

this.emitFile can also be used at later stages to achieve the same result.

Examples

License

MIT

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •