Skip to content

Choongkyu/vite-plugin-relay-lite-clojurescript

 
 

Repository files navigation

vite-plugin-relay-lite-clojurescript

Vite plugin for using Relay with ClojureScript.

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-clojurescript

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

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

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

This repo is a fork of vite-plugin-relay-lite. The compilation has ported from esbuild-plugin-relay, which was originally introduced from a gist by Samuel Cormier-Iijima

LICENSE

MIT

About

Vite plugin for use with ClojureScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%