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

Update module build output to improve compatibility for ESM modules #454

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

DJDANNY123
Copy link

@DJDANNY123 DJDANNY123 commented Aug 19, 2024

Updates the tsup build configuration to package ESM module code with the .mjs file format, which ensures that CommonJs index.js is packaged into the same directory as index.mjs, and the types can be resolved from both.

@vscheuber
Copy link
Contributor

@DJDANNY123 thank you for your PR! Can you tell me a bit more about the issues you are encountering without the change?

@DJDANNY123
Copy link
Author

DJDANNY123 commented Aug 19, 2024

Due to the nature of legacy modules being enabled in tsup, the types are not specified correctly for consumers using ESM modules. When we attempt to consume frodo with the tsconfig of NodeNext for module and moduleResolution, or ESNext for module and Bundler for moduleResolution, it is unable to determine types.

`
Could not find a declaration file for module '@rockcarver/frodo-lib'. '.../node_modules/.pnpm/@rockcarver+frodo-lib@2.0.3/node_modules/@rockcarver/frodo-lib/dist/esm/index.js' implicitly has an 'any' type.

There are types at '.../node_modules/@rockcarver/frodo-lib/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@rockcarver/frodo-lib' library may need to update its package.json or typings.ts(7016)
`

@vscheuber
Copy link
Contributor

Fantastic, thanks @DJDANNY123 . Let me run the tests and make sure frodo-cli digests the change well and I'll merge the PR. I do have a crammed week ahead so it might take me a few days to get through everything.

@DJDANNY123
Copy link
Author

Hi @vscheuber do you think you'll be able to have a look at this one today or is it looking like next week?

@vscheuber vscheuber merged commit b80a68c into rockcarver:main Aug 23, 2024
7 checks passed
@vscheuber
Copy link
Contributor

@DJDANNY123 I did merge your PR a few mins ago. I will probably trigger a patch release now as well, so you can pull it from an official version vs a pre-release but your PR is in 2.1.1-0 for now.

@vscheuber
Copy link
Contributor

vscheuber commented Aug 23, 2024

@DJDANNY123 alright, it's in 2.1.1 now. Thank you for the contribution!

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