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

Importing from generate and tscodegen no longer possible #577

Closed
SimonEggert opened this issue Feb 13, 2024 · 4 comments
Closed

Importing from generate and tscodegen no longer possible #577

SimonEggert opened this issue Feb 13, 2024 · 4 comments

Comments

@SimonEggert
Copy link
Contributor

SimonEggert commented Feb 13, 2024

The package @rtk-query/codegen-openapi uses an older version of this library (4.8.0) and relies on some direct function and class imports:

https://github.com/reduxjs/redux-toolkit/blob/34c3b5f207e385c46441058e23d266202dec6283/packages/rtk-query-codegen-openapi/src/generate.ts#L3C1-L14C41

After #550 this is no longer possible due to the exports field that now makes exports of oazapfts explicit.

Error: Missing "./lib/codegen/generate" specifier in "oazapfts" package

In addition there are some rewrites happening right now in beta to split up runtime and codegen into separate packages.

My question is if you could guide the way in updating to a more current version of oazapfts in RTK (very selfishly including my bugfix from 5.1.7 😉). The main problem I see is with ApiGenerator that is no longer exported in versions after the above PR was merged. Is there a way to bring it back in or were these changes done on purpose and RTK should make changes to adapt to the newer interface this package provides?

Any help would be appreciated. Thanks in advance!

@Xiphe
Copy link
Collaborator

Xiphe commented Feb 13, 2024

I have added the file to exports. You should be able to import from oazapfts/generate now.

That said, I would consider this semi-official API. There might be breaking changes in that file that we don't communicate via semver.

I haven't really checked what RTK is doing but @fimion has started to work on a [plugin system]#562) you might want to chime in that discussion. Maybe that will be the cleaner way for the future.

@SimonEggert
Copy link
Contributor Author

@Xiphe Thanks for taking the time to add the exports! I just tried a local RTK repo and realized that v6 exports less than v5. Sorry for the confusion, but I wasn't aware of the fact that beta was so close to being released.

In this case the exports from tscodegen.ts would also need to be exposed in order to update the package on RTK's side (s. above code snippet what uses both generate and tscodegen). I also didn't check exactly what happens within RTK, so again: If this is an anti-pattern or the package is meant to be used in a different way, please let me know and I will see what I can do to help.

@Xiphe
Copy link
Collaborator

Xiphe commented Feb 14, 2024

No worries, added a change that re-exports all of tscodegen.ts as well as generateServers.ts on oazapfts/generate.

Hope this unblocks the RTK updates.

@SimonEggert
Copy link
Contributor Author

Thank you so much! It seems to work. RTK PR incoming.

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