-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
rtk-query-codegen-openapi has outdated prettier 2.x peer dependency #4038
Comments
Are there thoughts about removing the prettier dependency and support altogether and having people reformat the code after code gen? A dependency on specific prettier versions seems pretty rough as projects I assume are usually on their own prettier update schedule especially when it comes to major versions and 2.x to 3.x is a major breaking change for loading prettier plugins (prettier is now ESM). |
This honestly sounds like primarily a problem with your package manager - it should be standard procedure for your package manager to install prettier 2 in Did you enable some form of module hoisting? But generally, this is an Open Source project maintained by volunteers in our spare time and we are open for Pull Requests. |
I did suspect and investigate the package manager (npm in my case) angle at first as well, but it appears to me that npm behaves correctly and instead we are ending up with an incompatible combination of prettier and prettier plugins. I am using npm with default settings and from what I can observe it is working as intended, i.e. the
In addition there are also prettier plugins
I appreciate that and do like to contribute when possible. The reason I started this convo first is that I don't see a clear/obvious path forward between the following options:
I personally prefer option 1 as it keeps |
I'd like to keep prettier in there as we have no way of reliably keeping the diff small if an upstream dependency changes, and the generated code might generally not be readable without that. One thought - I believe this might be only problematic because we use the same prettier config as your main project:
Could you try running this in a subfolder with an empty If that's all that is causing inconsistencies with parallel prettier 2&3 installations, we could allow to specify an additional prettier config in the codegen configfile. (Also, I believe the api didn't really change between prettier 2 and 3, so maybe we could also allow prettier |
That makes sense, good point. 👍
Yes, that's definitely it. Running from a different folder with a
That should unblock projects that have a prettier config that is incompatible with the prettier that ships with @rtk-query/codegen-openapi because they can point at a minimal/empty/default prettierrc and reformat after using "their" prettier version and config if needed. It also wouldn't be a breaking change. I like that option.
You are right, allowing prettier 3.x would not solve the issue because @rtk-query/codegen-openapi is still CJS-only and thus can't load the ESM module plugins and we'd have to support running @rtk-query/codegen-openapi as ESM before you could fully share prettier config and plugins again. |
Would you consider trying a PR with that optional higher-priority prettier configuration? That should unblock users like you, and then we can independently decide if we want to stay at prettier v2 for now or switch that to v3 at some point. |
Allow users to optionally provide the explicit location of the prettier config to use. For example unblocks users that are using an incompatible/different major version of prettier as part of their project that breaks the prettier version rtk query code gen depends on. see reduxjs#4038
Allow users to optionally provide the explicit location of the prettier config to use. For example unblocks users that are using an incompatible/different major version of prettier as part of their project that breaks the prettier version rtk query code gen depends on. see reduxjs#4038
Should be live in /~https://github.com/reduxjs/redux-toolkit/releases/tag/%40rtk-query%2Fcodegen-openapi%402.0.0-alpha.0 ! Please try it out and let us know if it works. |
Prettier 3 has been out for half a year, it is probably time to update, see https://prettier.io/blog/2023/07/05/3.0.0.html.
See also #3604
The text was updated successfully, but these errors were encountered: