https://github.com/sapphi-red/vite-envs
https://github.com/sapphi-red/vite-envs
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sapphi-red/vite-envs
- Owner: sapphi-red
- Created: 2023-09-03T16:19:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-16T04:59:56.000Z (over 1 year ago)
- Last Synced: 2024-05-01T14:19:44.768Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 53.9 MB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vite-envs
PoC for running Vite's SSR support on emulated environments (e.g. [Edge Runtime](https://edge-runtime.vercel.app/)).
Powered by [Vite Runtime API](https://vitejs.dev/guide/api-vite-runtime.html).
## 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?
```sh
$ 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`](https://www.npmjs.com/package/@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