Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 1.22 KB

README.md

File metadata and controls

31 lines (23 loc) · 1.22 KB

vite-envs

PoC for running Vite's SSR support on emulated environments (e.g. Edge Runtime).

Powered by Vite Runtime API.

Features

  • Throwing errors when accessing global variables that exist in Node but don't in workers (e.g. process, global)
  • Ability to use worker-only features that are not supported in Node (e.g. Cloudflare KV, URLPattern)
  • Performant HMR

How to try this?

$ pnpm i
$ pnpm -r build
$ cd examples/cloudflare-pages # or other directories in example
$ pnpm dev

Description for each directory

  • packages
    • types: contains types for the common interface (ViteRuntimeEnv)
    • cloudflare-pages: a Vite plugin that exposes ViteRuntimeEnv for cloudflare workerd using the actual workerd
    • vercel-edge: a Vite plugin that exposes ViteRuntimeEnv for edge-runtime using @edge-runtime/vm
    • example-framework: an example framework that uses ViteRuntimeEnv
  • examples
    • cloudflare-pages: an example using example-framework + cloudflare pages ViteRuntimeEnv plugin
    • vercel-edge: an example using example-framework + vercel edge ViteRuntimeEnv plugin