{"id":26188,"library":"relay-compiler-webpack-plugin","title":"relay-compiler-webpack-plugin","description":"Automatically run the Relay Compiler from within the Webpack build process, eliminating manual compilation steps. Version 9.1.0 supports relay-compiler >=8.0.0, webpack >=3.0.0, and graphql >=14.0.0. Regularly updated with each Relay major release. Key differentiators: hooks (beforeWrite, afterWrite) for custom tooling, TypeScript plugin support via relay-compiler-language-typescript, and webpack 5 compatibility. Lighter-weight alternative to Babel macro-based solutions.","status":"active","version":"9.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/danielholmes/relay-compiler-webpack-plugin","tags":["javascript","relay","webpack","webpack3","webpack4","webpack5","react","reactjs","relay-compiler"],"install":[{"cmd":"npm install relay-compiler-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add relay-compiler-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add relay-compiler-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency — required to actually compile GraphQL fragments/queries","package":"relay-compiler","optional":false},{"reason":"peer dependency — plugin runs inside webpack build lifecycle","package":"webpack","optional":false},{"reason":"peer dependency — relay-compiler depends on graphql for schema/type handling","package":"graphql","optional":false}],"imports":[{"note":"CommonJS default; no named ESM export — do not use destructuring.","wrong":"import RelayCompilerWebpackPlugin from 'relay-compiler-webpack-plugin';","symbol":"default export","correct":"const RelayCompilerWebpackPlugin = require('relay-compiler-webpack-plugin');"},{"note":"CommonJS named export, but default is the constructor. Not available as ESM named export.","wrong":"import { getHooks } from 'relay-compiler-webpack-plugin';","symbol":"getHooks","correct":"const { getHooks } = require('relay-compiler-webpack-plugin');"},{"note":"Direct require yields the constructor, not an object with a property.","wrong":"require('relay-compiler-webpack-plugin').RelayCompilerWebpackPlugin","symbol":"Plugin constructor","correct":"new (require('relay-compiler-webpack-plugin'))({ schema: './schema.graphql', src: './src' })"}],"quickstart":{"code":"const RelayCompilerWebpackPlugin = require('relay-compiler-webpack-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  // ... webpack config\n  plugins: [\n    new RelayCompilerWebpackPlugin({\n      schema: path.resolve(__dirname, './schema.graphql'),\n      src: path.resolve(__dirname, './src'),\n      customScalars: {\n        DateTime: 'string'\n      }\n    })\n  ]\n};","lang":"javascript","description":"Shows minimal webpack config to auto-run relay-compiler with custom scalar support."},"warnings":[{"fix":"Use yarn —flat or npm dedupe to enforce a single graphql version matching relay-compiler's peer dep.","message":"Multiple versions of GraphQL in dependency tree cause schema validation errors.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade relay-compiler to >=6.0.0. See upgrade guide for breaking changes.","message":"v6.0.0 requires relay-compiler 6.0.0, not backward compatible with v5.x.","severity":"breaking","affected_versions":">=6.0.0 <7.0.0"},{"fix":"Update relay-compiler to >=7.0.0 and upgrade your GraphQL queries/fragments if needed.","message":"v7.0.0 requires relay-compiler 7.0.0, drops support for 6.x.","severity":"breaking","affected_versions":">=7.0.0 <8.0.0"},{"fix":"Upgrade to >=8.0.2. In v8.0.0/v8.0.1, set customScalars via relay-compiler's own config if possible.","message":"customScalars option broken in v8.0.0/v8.0.1 — overrides ignored.","severity":"broken","affected_versions":">=8.0.0 <8.0.3"},{"fix":"Add graphql (>=14.0.0) to your project's dependencies.","message":"v9.0.0 added graphql as peer dependency; builds may break if graphql not explicitly installed.","severity":"broken","affected_versions":">=9.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install a single version of graphql that satisfies both relay-compiler and this plugin's peer dep (>=14).","cause":"Incompatible graphql versions between compiler and runtime.","error":"ValidationError: GraphQL schema validation failed."},{"fix":"Ensure the plugin is added to the plugins array, not called inside a function.","cause":"Plugin instantiated before webpack compiler is available.","error":"TypeError: Cannot read property 'compiler' of undefined"},{"fix":"Install relay-compiler matching plugin's peer dependency range (>=8.0.0 for v9.x).","cause":"relay-compiler not installed or incorrect version.","error":"Module not found: Error: Can't resolve 'relay-compiler'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}