Vite plugin for more convenient Relay experience.

Overview

vite-plugin-relay

Vite plugin for more convenient Relay experience.

What this plugin does for you:

  • Generates artifacts on code changes
  • Transform codes without Babel plugin
  • Respects project's Relay config file

With only minimum configuration!

Installation

yarn add -D vite graphql vite-plugin-relay-lite

# Assumes the project already have relay-compiler and configuration
// vite.config.ts

import { type UserConfig } from 'vite';
import relay from 'vite-plugin-relay-lite';

const config: UserConfig = {
  plugins: [
    relay(),
  ],
};

export default config;

Customize Options

Customize Relay Config

Plugin will automatically load the Relay config file.

You can use custom config file path.

{
  plugins: [
    relay({
      relayConfig: 'path/to/relay.js'
    })
  ]
}

Or pass config object.

{
  plugins: [
    relay({
      relayConfig: {
        // ...relay config
      }
    })
  ]
}

ES Module Output

Plugin respects the eagerEsModules option in the Relay config, so the default output format is commonjs.

However, using CommonJS in Vite projects may require additional config to transpile, and it's not recommended to use. Consider to set eagerEsModules to true in your Relay config, or set module: 'esmodule' in plugin options as you require.

Relay Compiler Integration

Plugin automatically runs relay-compiler before transform, so it should be installed in the project.

Or you can set the codegen option to false to disable it.

{
  plugins: [
    relay({
      codegen: false
    })
  ]
}

Plugin respects the codegenCommand option in the Relay config, it uses relay-compiler if not set.

Acknowledgements

The compilation has ported from esbuild-plugin-relay, which was originally introduced from a gist by Samuel Cormier-Iijima

LICENSE

MIT

You might also like...

Lingui loader for Vite, Rollup, Webpack, and more

unplugin-lingui-loader It’s a good practice to use compiled message catalogs during development. However, running compile everytime messages are chang

Nov 3, 2022

a Logseq plugin to float items (e.g. videos) for an improved note-taking experience

a Logseq plugin to float items (e.g. videos) for an improved note-taking experience

logseq-helium-plugin Features Float videos for better note-taking in 3 ways: Block context menu (right-click on bullet) → 🎈 Start float Slash (/) com

Jan 2, 2023

Enhanced Sanity.io plugin development experience.

@sanity/plugin-kit NOTE This is a developer preview package meant for Sanity Studio v3 plugin development. For a v2 alternative, consider using Sanipa

Dec 27, 2022

pjax is a jQuery plugin that uses ajax and pushState to deliver a fast browsing experience with real permalinks, page titles, and a working back button.

pjax = pushState + ajax pjax is a jQuery plugin that uses ajax and pushState to deliver a fast browsing experience with real permalinks, page titles,

Jan 5, 2023

A magical vite plugin that helps you to generate and manage documentation website.

vite-plugin-book A magical vite plugin that helps you to generate and manage documentation website. ⚠️ This project is still WIP. It's a MVP now. A bu

Dec 20, 2022

Out-of-the-box MPA plugin for Vite, with html template engine and virtual files support.

vite-plugin-virtual-mpa Out-of-the-box MPA plugin for Vite, with html template engine and virtual files support, generate multiple files using only on

Dec 16, 2022

⚡️📦 A Vite plugin to build Userscript for Tampermonkey, Greasemonkey and Violentmonkey.

vite-userscript-plugin ⚡️ Tampermonkey userscript developing and build plugin based on Vite. Features 🔥 Hot reloading after changing any files. 🔧 Co

Dec 18, 2022

Vite plugin to client bundle i18next locales composited from one to many json/yaml files from one to many libraries. Zero config HMR support included.

vite-plugin-i18next-loader yarn add -D vite-plugin-i18next-loader Vite plugin to client bundle i18next locales composited from one to many json/yaml f

Nov 30, 2022

The world of cryptocurrencies is diverse and becoming more and more popular

The world of cryptocurrencies is diverse and becoming more and more popular

We are providing an user with a simple learning resource for an intro into the CryptoCurrency World. Along with a community grown message board to assist with further learning.

Jun 20, 2022
Comments
  • Update Vite peer dependency to including ^3.0.0

    Update Vite peer dependency to including ^3.0.0

    Current package indicates "vite": "^2.0.0" as its peer dependency, but since it is working well and comprehensively tested in Vite 3.x as well, I suggest modifying it to "vite": "^2.0.0 || ^3.0.0".

    As of now this package constantly showing unmet peer dependency warnings with Vite 3.x.

    opened by devunt 3
  • fix plugin not running on Windows

    fix plugin not running on Windows

    Currently, the plugin is not applied to any files because of the wrong path handling. On Windows. Vite passes strings that look like C:/Users/foo/index.js as id parameters of the transform hook. However, the platform path implementation of NodeJS returns something like C:\Users\foo\index.js, which has different path separators. This difference leads to the plugin never getting executed on Windows, since no module ID will start with sourceDirectory. This PR fixes the issue by replacing the separators with the UNIX ones. I didn't use path.posix.resolve because that doesn't put drive letters (C:\) at the front of the string.

    opened by XiNiHa 0
  • Support sourcemap

    Support sourcemap

    The plugin invalidate sourcemaps due to do not parse entire syntax. But it would be nice if you could find a way to get a valid sourcemap with minimal parsing.

    enhancement help wanted 
    opened by cometkim 0
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • package.json (npm)

    Configuration

    🔡 Renovate has detected a custom config for this PR. Feel free to ask for help if you have any doubts and would like it reviewed.

    Important: Now that this branch is edited, Renovate can't rebase it from the base branch any more. If you make changes to the base branch that could impact this onboarding PR, please merge them manually.

    What to Expect

    With your current configuration, Renovate will create 1 Pull Request:

    chore(deps): update yarn to v3.3.0
    • Schedule: ["at any time"]
    • Branch name: renovate/yarn-monorepo
    • Merge into: main
    • Upgrade yarn to 3.3.0

    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
Releases(v0.3.0)
Owner
Hyeseong Kim
Building developer platform @daangn | Integration engineer | Open source hitchhiker | DX enthusiast | KST, GMT+9
Hyeseong Kim
Webpack dev tools to make performance analysis, error investigation and loader development more convenient

build-tool-inspector Introduction Webpack dev tools to make performance analysis, error investigation and loader development more convenient. Provide

Modern JS 25 Nov 17, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A convenient tool to view the youtube superchat messages in the streaming.

Youtube 超級留言訊息實況小工具 一個可以用於實況中顯示Youtube 超級留言訊息的小工具。 下載頁面 可至Release頁面根據自身的作業系統下載最新版本。 檔名 作業系統 youtube-superchat-message-tool-win32-x64-{version}.zip Win

悠太翼 2 Apr 14, 2022
Convenient wrapper for launching CLI applications for Deno.

deno_cliwrap Convenient wrapper for launching CLI applications in Deno. Module link: https://deno.land/x/cliwrap Usage In the following examples, we'l

null 2 Jul 2, 2022
✏️ A new tab extension for convenient note-taking

MDTab Write quick notes in Markdown on any new tabs! Installation Right now MDTab has only been tested on Chrome (brave browser). You can install it f

Ian Huang (Shaoru) 8 Nov 11, 2022
📟🤖 PagerDuty Discord Webhook Relay

PagerDuty Webhook Relay PagerDuty doesn't natively have Discord webhooks, so we made this CloudFlare worker to relay them to Discord. We use Uptime Ku

Hop 10 Aug 2, 2022
Fullstack twitter clone developed with GraphQL and Relay

Fullstack twitter clone developed with GraphQL and Relay

null 31 Dec 1, 2022
A devtool improve your pakage manager use experience no more care about what package manager is this repo use; one line, try all.

pi A devtool improve your pakage manager use experience no more care about what package manager is this repo use; one line, try all. Stargazers over t

tick 11 Nov 1, 2022