diff --git a/CHANGELOG.md b/CHANGELOG.md index e9da316768..87b77d5236 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,27 @@ and this project adheres to ## [Unreleased] +### Changed + +- all: The `package.json`s now all use the modern `exports` field instead of the + classic `main`/`types` to define the entry points. This ensures only symbols + from the top level module can be imported (like + `import { toBech32 } from "@cosmjs/encoding"`). Other import paths like + `import { toBech32 } from "@cosmjs/encoding/src/bech32"` are not allowed + anymore. As all public interfaces used to be exported from the top level for a + long time, this should not affect most users. However, if you accidentally + imported a subpath before you will get an error now. This can typically be + resolved like this: + + ```diff + -import { toBech32 } from "@cosmjs/encoding/src/bech32" + +import { toBech32 } from "@cosmjs/encoding" + ``` + + ([#1819]) + +[#1819]: https://github.com/cosmos/cosmjs/pull/1819 + ## [0.36.1] - 2025-10-02 ### Fixed diff --git a/packages/amino/package.json b/packages/amino/package.json index b0feeafef2..32165c56b5 100644 --- a/packages/amino/package.json +++ b/packages/amino/package.json @@ -6,8 +6,10 @@ "Simon Warta " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/cosmwasm-stargate/package.json b/packages/cosmwasm-stargate/package.json index bad652eab4..caf5403b88 100644 --- a/packages/cosmwasm-stargate/package.json +++ b/packages/cosmwasm-stargate/package.json @@ -6,8 +6,10 @@ "Will Clark " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 646e10718a..cfb1c286c1 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -7,8 +7,10 @@ "Simon Warta" ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/encoding/package.json b/packages/encoding/package.json index 302a2858c6..3a778ad7f8 100644 --- a/packages/encoding/package.json +++ b/packages/encoding/package.json @@ -6,8 +6,10 @@ "IOV SAS " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/faucet-client/package.json b/packages/faucet-client/package.json index 9994cc2d34..4aaf8d1b93 100644 --- a/packages/faucet-client/package.json +++ b/packages/faucet-client/package.json @@ -6,8 +6,10 @@ "Will Clark " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/json-rpc/package.json b/packages/json-rpc/package.json index 60d00bc82c..d7c33760f0 100644 --- a/packages/json-rpc/package.json +++ b/packages/json-rpc/package.json @@ -8,8 +8,10 @@ "Will Clark " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/ledger-amino/package.json b/packages/ledger-amino/package.json index 0df59a8925..4cde4c31f0 100644 --- a/packages/ledger-amino/package.json +++ b/packages/ledger-amino/package.json @@ -6,8 +6,10 @@ "Will Clark " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/math/package.json b/packages/math/package.json index 1f5dc8d996..9126f690e8 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -6,8 +6,10 @@ "IOV SAS " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/proto-signing/package.json b/packages/proto-signing/package.json index 2efcdbff01..ab1445244d 100644 --- a/packages/proto-signing/package.json +++ b/packages/proto-signing/package.json @@ -7,8 +7,10 @@ "Simon Warta " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/socket/package.json b/packages/socket/package.json index 804ae7ed60..76a76828df 100644 --- a/packages/socket/package.json +++ b/packages/socket/package.json @@ -8,8 +8,10 @@ "Will Clark " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/stargate/package.json b/packages/stargate/package.json index f0c9509a46..59c4452770 100644 --- a/packages/stargate/package.json +++ b/packages/stargate/package.json @@ -6,8 +6,10 @@ "Simon Warta " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/stream/package.json b/packages/stream/package.json index 634bc51e37..0723c6f50c 100644 --- a/packages/stream/package.json +++ b/packages/stream/package.json @@ -8,8 +8,10 @@ "Will Clark " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/tendermint-rpc/package.json b/packages/tendermint-rpc/package.json index 2b6517ad59..afbe35046c 100644 --- a/packages/tendermint-rpc/package.json +++ b/packages/tendermint-rpc/package.json @@ -8,8 +8,10 @@ "Will Clark " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md", diff --git a/packages/utils/package.json b/packages/utils/package.json index e959a00119..1bbb0a0a0a 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -6,8 +6,10 @@ "IOV SAS " ], "license": "Apache-2.0", - "main": "build/index.js", - "types": "build/index.d.ts", + "exports": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, "files": [ "build/", "*.md",