| name | publish-config |
| description | publishConfig rules for public npm packages in the Trezor Suite monorepo. Use when adding or editing publishConfig, exports, or preparing a package for npm publishing. |
Publish Config
Validated by requirePublishConfig in @trezor/requirements (packages/requirements/src/requirements/package-json/requirePublishConfig.ts).
Applies to any package with publishConfig.
Rules
- Top-level
main — required (e.g. "./src/index.ts").
files — must include "lib/".
publishConfig.main and publishConfig.types — both required.
publishConfig.exports["."].default and publishConfig.exports["."].types — must export the same files as in Rule 3.
- Wildcard exports — (
./lib/*) must be a passthrough string ("./lib/*") — an object would double the .mjs extension.
- Explicit (non-wildcard) exports — not shape-checked (intentional overrides). Typically used to route a directory import to its
index.mjs, e.g. "./lib/protocol-thp": { "types": "./lib/protocol-thp/index.d.mts", "default": "./lib/protocol-thp/index.mjs" } — without this, the wildcard would resolve to protocol-thp.mjs instead of protocol-thp/index.mjs.
- Key order —
"types" must come before "default" in every condition object (recursive). TypeScript evaluates conditions in declaration order.
type — must declare top-level "type": "module". Do not duplicate it under publishConfig.type — publishConfig would only shadow the top level with the same value at publish time, so we keep a single source of truth.
Example
{
"name": "@trezor/example",
"main": "./src/index.ts",
"type": "module",
"files": ["lib/", "CHANGELOG.md"],
"publishConfig": {
"main": "./lib/index.mjs",
"types": "./lib/index.d.mts",
"exports": {
".": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs",
},
"./lib/*": "./lib/*",
},
},
}