{"id":25442,"library":"esbuild-relay-plugin","title":"esbuild-relay-plugin","description":"An esbuild plugin that transforms tagged GraphQL template literals for Relay by replacing `graphql` tagged templates with imports to the artifacts generated by `relay-compiler`. Version 1.0.0 is stable but uses naive string replacement rather than AST parsing, so it will attempt to compile even commented-out GraphQL literals. It supports both CommonJS and ESM module formats and is inspired by babel-plugin-relay, but with a simpler, faster approach for esbuild users. Release cadence is low; not actively maintained.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/mathiashsteffensen/esbuild-relay-plugin","tags":["javascript","esbuild","relay","graphql"],"install":[{"cmd":"npm install esbuild-relay-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-relay-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-relay-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; named export, not default.","wrong":"const EsbuildRelayPlugin = require('esbuild-relay-plugin')","symbol":"EsbuildRelayPlugin","correct":"import { EsbuildRelayPlugin } from 'esbuild-relay-plugin'"},{"note":"esbuild itself is also ESM-only. Use dynamic import or ESM context.","wrong":"const esbuild = require('esbuild')","symbol":"esbuild","correct":"import esbuild from 'esbuild'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport { EsbuildRelayPlugin } from 'esbuild-relay-plugin';\n\nawait esbuild.build({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  outfile: 'dist/index.js',\n  plugins: [\n    new EsbuildRelayPlugin({\n      artifactDirectory: '__generated__',\n      language: 'typescript'\n    })\n  ]\n});","lang":"typescript","description":"Shows basic usage of esbuild-relay-plugin with esbuild, specifying artifact directory and TypeScript language."},"warnings":[{"fix":"Ensure no commented-out graphql literals exist, or switch to babel-plugin-relay with esbuild-babel.","message":"Plugin uses string replacement and does not parse source code; it will replace `graphql` tagged templates even inside comments, potentially causing errors.","severity":"gotcha","affected_versions":"<=1.0.0"},{"fix":"Add relay-compiler to your build pipeline.","message":"Requires relay-compiler to be run separately; no automatic artifact generation.","severity":"deprecated","affected_versions":"<=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run relay-compiler first, then ensure artifactDirectory options matches output location.","cause":"relay-compiler artifacts not generated or wrong artifactDirectory path.","error":"Error: Could not resolve './__generated__/MyQuery.graphql'"},{"fix":"Check esbuild config has plugins array correctly and language option set (e.g., 'tsx' if using React).","cause":"Plugin didn't transform graphql tagged template because language option mismatched (e.g., TSX not set) or plugin not applied correctly.","error":"TypeError: graphql is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}