Skip to content

Conversation

dynst
Copy link
Contributor

@dynst dynst commented Aug 7, 2025

sed -i -E 's/(from "cosmjs-types.+)";$/\1.js";/' `grep cosmjs-types/ -rlI packages/`

Omitting a file extension only works when transpiled to CJS.

Prerequisite for #1004

can't omit a file extension if cosmjs becomes ESM. that only works
if transpiled to CJS.
@dynst
Copy link
Contributor Author

dynst commented Aug 17, 2025

Was there something blocking this?

@webmaster128
Copy link
Member

I did not look into / think about this topic yet. I think this answer is helpful to understand why this change is needed: https://stackoverflow.com/questions/63459159/omit-the-file-extension-es6-module-nodejs

To me it feels ugly to have to use cosmjs-types like this, especially as we are not only importing pure-JS code but also its types. Maybe we should auto-generate the paths for exports there and then map the path to the .js file.

@webmaster128
Copy link
Member

How do you feel about this solution instead of changing the imports here?
cosmos/cosmjs-types#105

@dynst
Copy link
Contributor Author

dynst commented Oct 8, 2025

it feels ugly

I know what you mean; that's just the convention the ecosystem has evolved towards, apparently. The TypeScript definition files are automatically found by looking for the matching .d.ts file regardless.

The noble cryptography packages explicitly removed extension-less import support in 2.0 releases, so it's just the new convention/best practice I guess. It also avoids ambiguity between directory imports (an invisible /index.js is added) and file imports (an invisible .js is added).

https://github.com/paulmillr/noble-ciphers/releases/tag/2.0.0
https://github.com/paulmillr/noble-hashes/releases/tag/2.0.0
https://github.com/paulmillr/noble-curves/releases/tag/2.0.0

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