1.0.0 • Published 2 years ago

esbuild-relay-plugin v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

esbuild-relay-plugin

An esbuild plugin to transform tagged GraphQL template literals for Relay. Heavily inspired by babel-plugin-relay.

Features

  • Replaces graphql tagged template literals with imports to the artifacts generated by relay-compiler
  • Supports CommonJS and ESM module formats

Caveat

  • This plugin uses string replacements and does not parse the source code. This means it will try to compile GraphQL literals even if they are commented out. If that does not fit your workflow, you'll need to use ESBuild + babel + babel-plugin-relay.

Installation

Using NPM

npm install -D esbuild-relay-plugin

Using yarn

yarn add -D esbuild-relay-plugin

Usage

import esbuild from "esbuild"
import { EsbuildRelayPlugin } from "esbuild-relay-plugin"

esbuild.build({
    // ...other options,
    plugins: [
      new EsbuildRelayPlugin(),
    ]
})

Acknowledgements

This plugin is based on the official babel-plugin-relay.