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

Fix codegen-openapi build output #4509

Merged
merged 81 commits into from
Aug 30, 2024
Merged

Conversation

aryaemami59
Copy link
Contributor

@aryaemami59 aryaemami59 commented Jul 12, 2024

#4307 Will need to be merged first.

This PR:

  • Fixes codegen-openapi build output by adding tsup.
  • Fixes the CI tests for codegen-openapi.
  • Modernizes build output by adding the exports field to provide ESM/CJS dual compatibility.
  • Uses the compact lodash.camelcase package instead of the entire lodash library in order to minimize package bundle size.
  • Updates TypeScript and Vitest to make sure the library is compatible with the latest versions of those libraries.
  • Fixes the unit tests by copying over the changes made in Fix codegen-openapi tests #4307.
  • Adds vite-tsconfig-paths to get a similar setup for unit tests as @reduxjs/toolkit.

- This was done mostly to prevent TypeScript from using the hoisted version of `esbuild` which caused a type error since the types in version 0.21.5 (the hoisted version) don't match the types in version 0.18.20 (the version `tsup` uses as a direct dependency).
@aryaemami59 aryaemami59 mentioned this pull request Aug 27, 2024
4 tasks
aryaemami59 and others added 4 commits August 29, 2024 16:30
# Conflicts:
#	.github/workflows/test-codegen.yml
#	packages/rtk-query-codegen-openapi/package.json
#	yarn.lock
@markerikson
Copy link
Collaborator

Okay, merged the test changes over and this is clean.

@aryaemami59 just to check: could you remind me why we need any of the build setup changes in the first place?

@aryaemami59
Copy link
Contributor Author

Because the current build output is broken. The reason why it's broken is because we build with moduleResolution set to Bundler but we don't use one. So our build output is ESM but the library is CJS. Hence why we get the "cannot use import statement outside of a module" error.

@markerikson
Copy link
Collaborator

Okay. Can we do this PR without the package.exports change at all? That will require a major version bump. We can do that if necessary, I just don't want to do it casually.

@aryaemami59
Copy link
Contributor Author

1 - I don't think it can be done without.
2 - Since we're changing the entire build step, I think this could be considered a breaking change even without the exports field added.

@markerikson
Copy link
Collaborator

Okay. Any idea what other codegen-related changes (PRs, issues, etc) ought to go in as well?

@aryaemami59
Copy link
Contributor Author

I'm not sure tbh. #4568 looks good.

# Conflicts:
#	packages/rtk-query-codegen-openapi/package.json
#	yarn.lock
@markerikson markerikson merged commit a985f93 into reduxjs:master Aug 30, 2024
43 checks passed
@markerikson markerikson deleted the tsup-codegen branch August 30, 2024 22:31
@aryaemami59 aryaemami59 linked an issue Jan 3, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RTKQuery Codegen execution error
2 participants