esbuild-relay-plugin
v1.0.0
Published
Relay plugin for esbuild based on https://www.npmjs.com/package/babel-plugin-relay
Downloads
786
Readme
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 byrelay-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.