A Vite plugin that integrates Relay (GraphQL) into Vite projects. Current stable version is 2.1.0, with periodic maintenance updates. It internally invokes babel-plugin-relay to transform GraphQL artifacts, ensuring compatibility with Relay's official toolchain. Key differentiators: zero-config setup (relay config auto-detected from package.json or relay.config.*), supports Vite 2+ and 3, pnpm-friendly, and ESM-first. The plugin handles babel-plugin-relay invocation, so developers skip its direct configuration. Maintenance is periodic as the author is not actively using the project.
npm install vite-plugin-relayVerified import paths — ran on the pinned version, not inferred.
Minimal Vite config to add Relay support. Must also have relay.config.json or similar.
Add snippet: if (typeof (window as any).global === 'undefined') {(window as any).global = globalThis;}Update to >=1.0.7 or add window polyfill manually.
Add <script>let global = globalThis;</script> in index.html before your JS.
Install babel-plugin-relay (>=13.0.1) as devDependency. Skip babel config in vite/relay plugin.
Set eagerEsModules: true in relay.config.json or package.json relay field.
Add to index.html: <script>let global = globalThis;</script> before importing your application JS.
Use: import relay from 'vite-plugin-relay'
Install babel-plugin-relay: npm install --save-dev babel-plugin-relay
Set eagerEsModules: true in relay config file (relay.config.json or package.json relay field).