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

feat: esm + tsup #734

Closed
wants to merge 25 commits into from
Closed

feat: esm + tsup #734

wants to merge 25 commits into from

Conversation

kanadgupta
Copy link
Member

@kanadgupta kanadgupta commented Sep 20, 2023

🚥 Resolves ISSUE_ID

🧰 Changes

TODO

  • Look into using ESNext / bundler in tsconfig for core subpackage (based on my reading, I think the moduleResolution is the one that needs extra revisiting)

Current blockers:

🧬 QA & Testing

Provide as much information as you can on how to test what you've done.

this is specific to tsup but ideally any build tool we use will yield a result that looks like this
hopefully we don't need this, but tsup needed something like this in my testing (but maybe not?)
@kanadgupta kanadgupta mentioned this pull request Sep 20, 2023
3 tasks
@kanadgupta
Copy link
Member Author

Quick summary of the progress made in this PR thus far! I've gotten the functionality up and running where the api CLI will now do the following when you generate a TS SDK:

  • ts-morph builds the TS files (same as before), and tsup is subsequently run on the index.ts entrypoint and it builds a dist/ directory with SDKs in CJS and ESM, along with their respective declaration files 🎉 in order to do this, the SDK's directory now includes:
    1. A tsup config within the package.json
    2. An exports object within the package.json that maps to the generated CJS/ESM dist files
    3. A tsconfig.json file
    4. typescript and tsup as dev-deps (this may or may not be necessary)

The SDK works and is fully typed for usage in TS and CJS, but needs #733 to be merged and published to the alpha channel in order to get it working properly in ESM.

You can head over to this repo to see the sandbox environment I was testing this in.

Next steps (non-exhaustive list, just rattling off stuff off the top of my head, doesn't all have to happen for this PR):

  • Merge and publish feat: migrate api and core to ESM #733 to the alpha channel
  • Update any downstream deps (remove-undefined-objects, oas, etc.) to the latest so they're properly loaded into the tsup-generated SDKs
  • Add a README.md file and something to scripts (e.g., a prepare or prepack script) in the package.json so the user can regenerate the SDK as they please
  • Make sure the package.json and the tsconfig in the codegen'd SDK directory are configured properly and are in a good enough spot so the user doesn't need additional config in order to successfully publish a usable SDK

Base automatically changed from esm to main October 11, 2023 16:14
@erunion
Copy link
Member

erunion commented Oct 11, 2023

the merge conflicts with this on main are a mess so i'm going to redo this in a new branch.

@erunion erunion closed this Oct 11, 2023
@erunion erunion deleted the esm-tsup branch October 11, 2023 16:46
@kanadgupta
Copy link
Member Author

for posterity, this work has been continued in #754

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

Successfully merging this pull request may close these issues.

2 participants