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: .d.ts is in ./dist folder #3018

Merged
merged 1 commit into from
Mar 3, 2025

Conversation

sfroment
Copy link
Contributor

Title

fix: .d.ts is in ./dist folder

Description

Since the export is badly done when you try to resolve with esplugin import it will lead to
1:27 error Unable to resolve path to module '@libp2p/bootstrap' import/no-unresolved

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

Signed-off-by: Sacha Froment <[email protected]>
@@ -48,7 +48,7 @@
],
"exports": {
".": {
"types": "./src/index.d.ts",
"types": "./dist/src/index.d.ts",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks correct, but the last time this was changed was 3 years ago..

https://github.com/libp2p/js-libp2p/blame/3d9b07c34857376adc6942aaba19bc8a208f58df/packages/crypto/package.json

I have a hard time believing that this issue would have gone noticed in all this time. Do you have a small reproduction repo?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether this field is used or not depends on the version of TypeScript you have and your tsconfig.json settings. The fields were added as a hedge against when they became more widespread but they weren't at the time so it's completely possible there was a mistake in it 😩

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(aegir's config still leans on the typesVersions hack instead - this will fix that but it needs module deps to have the "types" field in the exports map entries - need to check if everything is updated now before we can merge it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SgtPooki the problem went unnoticed for so long cause there is not many people activating estlint-plugin-import with typescript. For reproduction https://github.com/sfroment/eslint-libp2p-reproduction.

@achingbrain achingbrain merged commit 52a46ec into libp2p:main Mar 3, 2025
34 checks passed
@achingbrain achingbrain mentioned this pull request Mar 3, 2025
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.

3 participants