oscartbeaumont / vite-plugin-relay

A vite plugin for Relay
MIT License
81 stars 14 forks source link

Support monorepo setups #509

Open ivosabev opened 2 weeks ago

ivosabev commented 2 weeks ago

The following setup needed for VSCode Relay extension to work with monorepos, doesn't work with vite-plugin-relay and throws ReferenceError: require is not defined where graphql template literal imported from react-relay is present.

If you put apps/app/relay.config.json file with eagerEsModules: true it will work. This hints me that the root relay.config.json is not read and respected, but I may be wrong.

apps/
  app/
  server/
  web/
relay.config.js

relay.config.js

{
  "root": ".",
  "sources": {
    "apps/app": "app"
    "apps/web": "web"
  },
  "excludes": ["**/node_modules/**", "**/__mocks__/**", "**/__generated__/**"],
  "projects": {
    "app": {
      "eagerEsModules": true,
      "language": "typescript",
      "output": "apps/app/src/__generated__",
      "schema": "apps/server/src/schema/schema.graphql"
    },
    "web": {
      "eagerEsModules": true,
      "language": "typescript",
      "output": "apps/web/src/__generated__",
      "schema": "apps/server/src/schema/schema.graphql"
    }
  }
}
ivosabev commented 2 weeks ago

Might be relevant: https://github.com/facebook/relay/issues/4407