Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RelayCompilerWebpackPluginOptions and relay.config.js overlap and mismatch #68

Open
sorenhoyer opened this issue Jul 15, 2021 · 1 comment

Comments

@sorenhoyer
Copy link
Contributor

sorenhoyer commented Jul 15, 2021

Currently the relay.config.js and the configuration object that is passed to RelayCompilerWebpackPlugin has some overlap, but is also inconsistent.

For example you'll find both schema, src, exclude, include, extensions and artifactDirectory at the top level of the configuration object, so it would only be natural to assume that you could pass the whole configuration object from relay.config.js into RelayCompilerWebpackPlugin.

However if you want to eg. turn on noFutureProofEnums, you have to pass it into the nested "config" object.

{
  // schema: ...
  // exclude: ...
  // include: ...
  // src: ...
  // artifactDirectory: ...
  // extensions: ...
  config: {
    noFutureProofEnums: true
    // etc...
  }
}

When adopting this plugin in our code, suddenly we had "%future value added" all over the place, and at first we assumed it was because of some updated dependency and undocumented change, so we first adjusted our code.

I think this can cause others some headaches as well, until they find out about this. So I think either this should be changed (would be best as we can just import relay.config.js and have it in 1 place) or a note about this should be added to the docs, or at least the config object should be partially typed and not as any as it is now.

What do you think?

@danielholmes
Copy link
Collaborator

@sorenhoyer that all makes sense. I think all values should probably be moved to the config sub object (leaving room for other plugin specific, non-relay.config.js related settings). This will break a bunch of things for people so we'd need a major version bump.

I haven't been working on relay projects recently so don't have the inclination to do this myself. Happy to accept PRs for it from anyone interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants