{"id":13725648,"url":"https://github.com/relay-tools/relay-compiler-webpack-plugin","last_synced_at":"2025-10-07T13:59:27.169Z","repository":{"id":23242982,"uuid":"95397663","full_name":"relay-tools/relay-compiler-webpack-plugin","owner":"relay-tools","description":"Automatically run the Relay Compiler from Webpack","archived":false,"fork":false,"pushed_at":"2023-01-06T01:43:01.000Z","size":2261,"stargazers_count":65,"open_issues_count":17,"forks_count":31,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-05T11:52:18.526Z","etag":null,"topics":["graphql","javascript","react","reactjs","relay","relay-compiler","relayjs","webpack","webpack3","webpack4"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/relay-tools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-26T01:46:04.000Z","updated_at":"2024-08-25T01:54:05.000Z","dependencies_parsed_at":"2023-01-13T22:59:47.847Z","dependency_job_id":null,"html_url":"https://github.com/relay-tools/relay-compiler-webpack-plugin","commit_stats":null,"previous_names":["danielholmes/relay-compiler-webpack-plugin"],"tags_count":56,"template":false,"template_full_name":null,"purl":"pkg:github/relay-tools/relay-compiler-webpack-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relay-tools%2Frelay-compiler-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relay-tools%2Frelay-compiler-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relay-tools%2Frelay-compiler-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relay-tools%2Frelay-compiler-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/relay-tools","download_url":"https://codeload.github.com/relay-tools/relay-compiler-webpack-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relay-tools%2Frelay-compiler-webpack-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278786671,"owners_count":26045588,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","javascript","react","reactjs","relay","relay-compiler","relayjs","webpack","webpack3","webpack4"],"created_at":"2024-08-03T01:02:30.163Z","updated_at":"2025-10-07T13:59:27.130Z","avatar_url":"https://github.com/relay-tools.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Relay Compiler Webpack Plugin\n\n[![npm version](https://badge.fury.io/js/relay-compiler-webpack-plugin.svg)](https://badge.fury.io/js/relay-compiler-webpack-plugin)\n[![Travis Build Status](https://travis-ci.org/relay-tools/relay-compiler-webpack-plugin.svg?branch=master)](https://travis-ci.org/relay-tools/relay-compiler-webpack-plugin)\n![Github Actions Build Status](https://github.com/relay-tools/relay-compiler-webpack-plugin/workflows/Build/badge.svg)\n\nAre you running Relay Modern? Are you annoyed with constantly running the `relay-compiler` to generate code, especially\nif you're already running Webpack?\n\nWell be annoyed no more! Simply install this plugin to automatically hook into Webpack's build process to generate these\nfiles for you.\n\n\n## Installation\n\n  1. Add this to your project:\n\n```sh\n  yarn add --dev relay-compiler-webpack-plugin graphql\n  # Or if you're using npm\n  npm install --save-dev relay-compiler-webpack-plugin graphql\n```\n\n  2. Add the plugin to your Webpack configuration:\n\n```javascript\n// const RelayCompilerLanguageTypescript = require('relay-compiler-language-typescript').default\nconst RelayCompilerWebpackPlugin = require('relay-compiler-webpack-plugin')\nconst path = require('path')\n\nmodule.exports = {\n  // ... Your existing Webpack configuration\n  plugins: [\n    // ...\n    new RelayCompilerWebpackPlugin({\n      // languagePlugin: RelayCompilerLanguageTypescript,\n      schema: path.resolve(__dirname, './relative/path/to/schema.graphql'), // or schema.json\n      src: path.resolve(__dirname, './relative/path/to/source/files'),\n    })\n  ]\n  // ...\n}\n```\nNote: TypeScript projects also needs to add the TypeScript language plugin as shown in the commented out lines in the above snippet.\n\n  3. :tada:\n\n\n### Gotchas\n\nIf there are multiple versions of GraphQL in your dependency tree it will cause schema validation errors. To get around\nthis, ensure you have the same graphql version as your relay-compiler version depends on. To assist this you can\n[install dependencies as flat](https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-flat) which ensures only\none version of each dependency.\n\n\n### Plugin hooks\n\n`relay-compiler-webpack-plugin` exposes a few [tapable](https://github.com/webpack/tapable/tree/master) hooks, for plugins or tooling to use.\n\n- `beforeWrite` called before the plugin starts to compile queries\n- `afterWrite(compileResult)`: called after writing is complete\n\n```js\nclass MyPlugin {\n  apply (compiler) {\n    compiler.hooks.compilation.tap('MyPlugin', async (compilation) =\u003e {\n      RelayCompilerWebpackPlugin.getHooks(compilation).afterWrite.tapPromise(\n        'MyPlugin', // \u003c-- Set a meaningful name for stacktraces\n        async (compileResult) =\u003e {\n          if (compileResult === 'HAS_CHANGES') {\n            await doSomething()\n          }\n        }\n      )\n    })\n  }\n}\n```\n\n## Example Project\n\nTo see an example of its usage within a project, see\n[relay-compiler-webpack-plugin-example](https://github.com/danielholmes/relay-compiler-webpack-plugin-example).\n\n\n## Development\n\nRunning tests:\n\n```bash\nyarn test\n```\n\nRunning tests with coverage:\n\n```bash\nyarn test:coverage\n```\n\n\n## License\n\nRelay Compiler Webpack Plugin may be redistributed according to the [BSD 3-Clause License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelay-tools%2Frelay-compiler-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frelay-tools%2Frelay-compiler-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelay-tools%2Frelay-compiler-webpack-plugin/lists"}