Registry / devops / relay-compiler-webpack-plugin

relay-compiler-webpack-plugin

JSON →
library9.1.0jsnpmunverified

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.

npm install relay-compiler-webpack-plugin
INSTALL
IMPORT
SIG · RELAY-COMPILER-WEB
R
relay-compiler-webpack-plugin
devopsjavascriptv9.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export
const RelayCompilerWebpackPlugin = require('relay-compiler-webpack-plugin');
import RelayCompilerWebpackPlugin from 'relay-compiler-webpack-plugin';
CommonJS default; no named ESM export — do not use destructuring.
getHooks
const { getHooks } = require('relay-compiler-webpack-plugin');
import { getHooks } from 'relay-compiler-webpack-plugin';
CommonJS named export, but default is the constructor. Not available as ESM named export.
Plugin constructor
new (require('relay-compiler-webpack-plugin'))({ schema: './schema.graphql', src: './src' })
require('relay-compiler-webpack-plugin').RelayCompilerWebpackPlugin
Direct require yields the constructor, not an object with a property.

Shows minimal webpack config to auto-run relay-compiler with custom scalar support.

const RelayCompilerWebpackPlugin = require('relay-compiler-webpack-plugin'); const path = require('path'); module.exports = { // ... webpack config plugins: [ new RelayCompilerWebpackPlugin({ schema: path.resolve(__dirname, './schema.graphql'), src: path.resolve(__dirname, './src'), customScalars: { DateTime: 'string' } }) ] };
Debug
Known issues
gotchaMultiple versions of GraphQL in dependency tree cause schema validation errors.
fix
Use yarn —flat or npm dedupe to enforce a single graphql version matching relay-compiler's peer dep.
affects: *
breakingv6.0.0 requires relay-compiler 6.0.0, not backward compatible with v5.x.
fix
Upgrade relay-compiler to >=6.0.0. See upgrade guide for breaking changes.
affects: >=6.0.0 <7.0.0
breakingv7.0.0 requires relay-compiler 7.0.0, drops support for 6.x.
fix
Update relay-compiler to >=7.0.0 and upgrade your GraphQL queries/fragments if needed.
affects: >=7.0.0 <8.0.0
brokencustomScalars option broken in v8.0.0/v8.0.1 — overrides ignored.
fix
Upgrade to >=8.0.2. In v8.0.0/v8.0.1, set customScalars via relay-compiler's own config if possible.
affects: >=8.0.0 <8.0.3
brokenv9.0.0 added graphql as peer dependency; builds may break if graphql not explicitly installed.
fix
Add graphql (>=14.0.0) to your project's dependencies.
affects: >=9.0.0
Errors
Common errors & fixes
ValidationError: GraphQL schema validation failed.
Incompatible graphql versions between compiler and runtime.
fix
Install a single version of graphql that satisfies both relay-compiler and this plugin's peer dep (>=14).
TypeError: Cannot read property 'compiler' of undefined
Plugin instantiated before webpack compiler is available.
fix
Ensure the plugin is added to the plugins array, not called inside a function.
Module not found: Error: Can't resolve 'relay-compiler'
relay-compiler not installed or incorrect version.
fix
Install relay-compiler matching plugin's peer dependency range (>=8.0.0 for v9.x).
Upgrade
Version history
9.1.0latest on npm
Audit
Dependencies
relay-compilerrequiredpeer dependency — required to actually compile GraphQL fragments/queries
webpackrequiredpeer dependency — plugin runs inside webpack build lifecycle
graphqlrequiredpeer dependency — relay-compiler depends on graphql for schema/type handling
Agent activity
4 hits · last 30 days
node
4
Resources
relay-compiler-webpack-plugin — npm install relay-compiler-webpack-plugin · libregistry