build: consume the forked @polkadot packages from the registry, drop the scaffolding

Removes every workaround the symlink approach needed, and reverts tsconfig to
upstream's exactly.

The three forked packages — @polkadot/{networks,util-crypto,keyring} — are now
pinned to Gitea tarball URLs in resolutions. @polkadot/util is not, because this
fork does not modify it; it comes from npm like the rest of the scope.

Tarball URLs rather than routing the @polkadot scope to Gitea, because the scope
is mostly *not* forked: routing it would send yarn looking for dozens of packages
that are not there. @quantus is routed as a whole scope in .yarnrc.yml, which is
safe because we own every name in it.

Four things go away, all of which existed for one reason — node resolves a portal
or link symlink to its realpath, after which @polkadot/util-crypto resolved inside
*common's* tree, where it is a workspace source directory with no exports map:

  - resolutions pointing four packages at ../common/packages/*/build
  - tsconfig.base.json `*.d.ts` path mappings, needed because NodeNext will not
    infer an extension for a bare path and looked for a `types` directory
  - tsconfig.json overriding those with a runtime `.js` view, because
    @polkadot/dev-ts reads that file and tried to import a declaration file as a
    module
  - --preserve-symlinks in the test scripts

Also drops fflate and @quantus/crypto from ui-keyring's devDependencies; they were
there only because `link:` does not install its target's dependencies.

`yarn lint` now reports 0 errors, down from 25 on pristine upstream. Those were
no-unsafe-assignment and no-unsafe-argument on values that were `any` purely
because the types did not resolve.

Refs quantus/extension#2, quantus/ui#1

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012uDUodEcRbBwNRi3UCmw8f
This commit is contained in:
rob thijssen
2026-09-15 11:08:43 +03:00
parent ec1399f3f3
commit f2a1ab3a72
6 changed files with 43 additions and 67 deletions

View File

@@ -13,3 +13,11 @@ logFilters:
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-4.5.1.cjs
# @quantus packages come from the Gitea registry — safe as a whole-scope route
# because we own every name in it. The forked @polkadot packages cannot be routed
# the same way (most of that scope is unforked and lives on npm), so they are
# pinned to tarball URLs in package.json resolutions instead.
npmScopes:
quantus:
npmRegistryServer: "https://git.lair.cafe/api/packages/quantus/npm/"

View File

@@ -29,8 +29,8 @@
"clean": "polkadot-dev-clean-build",
"lint": "polkadot-dev-run-lint",
"postinstall": "polkadot-dev-yarn-only",
"test": "NODE_OPTIONS='--preserve-symlinks --preserve-symlinks-main' polkadot-dev-run-test --env browser",
"test:one": "NODE_OPTIONS='--preserve-symlinks --preserve-symlinks-main' polkadot-dev-run-test --env browser"
"test": "polkadot-dev-run-test --env browser",
"test:one": "polkadot-dev-run-test --env browser"
},
"devDependencies": {
"@polkadot/dev": "^0.83.3",
@@ -42,11 +42,9 @@
"react-native": "^0.73.1"
},
"resolutions": {
"@polkadot/keyring": "portal:../common/packages/keyring/build",
"@polkadot/networks": "portal:../common/packages/networks/build",
"@polkadot/util": "portal:../common/packages/util/build",
"@polkadot/util-crypto": "portal:../common/packages/util-crypto/build",
"@quantus/crypto": "link:../wasm/packages/quantus-crypto/build",
"@polkadot/keyring": "https://git.lair.cafe/api/packages/quantus/npm/%40polkadot%2Fkeyring/-/14.0.3/keyring-14.0.3.tgz",
"@polkadot/networks": "https://git.lair.cafe/api/packages/quantus/npm/%40polkadot%2Fnetworks/-/14.0.3/networks-14.0.3.tgz",
"@polkadot/util-crypto": "https://git.lair.cafe/api/packages/quantus/npm/%40polkadot%2Futil-crypto/-/14.0.3/util-crypto-14.0.3.tgz",
"typescript": "5.5.4"
}
}

View File

@@ -30,10 +30,8 @@
"tslib": "^2.8.1"
},
"devDependencies": {
"@quantus/crypto": "^0.1.0",
"@types/mkdirp": "^2.0.0",
"@types/store": "^2.0.5",
"fflate": "^0.8.2"
"@types/store": "^2.0.5"
},
"peerDependencies": {
"@polkadot/keyring": "*",

View File

@@ -2,25 +2,7 @@
"extends": "@polkadot/dev/config/tsconfig.json",
"compilerOptions": {
"composite": true,
// Dev-time only: point at the forked @polkadot packages in the sibling
// `common` checkout. Needed because node resolves a portal/link symlink to
// its realpath, after which `@polkadot/util-crypto` resolves inside
// *common's* tree — where it is the workspace source directory, with no
// exports map — and `EncryptedJson` silently becomes unresolvable, so
// `KeyringPair$Json` loses `encoded` and `encoding`.
//
// The `*.d.ts` substitution comes first on purpose: NodeNext will not infer
// an extension for a bare path, so `.../build/types` is looked up as a
// directory and `types.d.ts` is never tried.
//
// Replace all of these with a registry dependency; see quantus/extension#2.
"paths": {
"@polkadot/keyring": ["../../common/packages/keyring/build/index.d.ts"],
"@polkadot/keyring/*": ["../../common/packages/keyring/build/*.d.ts", "../../common/packages/keyring/build/*"],
"@polkadot/networks": ["../../common/packages/networks/build/index.d.ts"],
"@polkadot/networks/*": ["../../common/packages/networks/build/*.d.ts", "../../common/packages/networks/build/*"],
"@polkadot/util-crypto": ["../../common/packages/util-crypto/build/index.d.ts"],
"@polkadot/util-crypto/*": ["../../common/packages/util-crypto/build/*.d.ts", "../../common/packages/util-crypto/build/*"],
"@polkadot/react-identicon": ["react-identicon/src/index.ts"],
"@polkadot/react-qr": ["react-qr/src/index.ts"],
"@polkadot/reactnative-identicon": ["reactnative-identicon/src/index.ts"],

View File

@@ -2,23 +2,7 @@
"extends": "./tsconfig.base.json",
"compilerOptions": {
"baseUrl": "./packages",
"composite": false,
// Overrides the `*.d.ts` mappings in tsconfig.base.json for the *runtime*
// loader. `@polkadot/dev-ts` reads this file (following `extends`, with the
// child winning) and would otherwise try to import a declaration file as a
// module — "Debug Failure. Output generation failed".
//
// tsc reads tsconfig.build.json, which extends the base directly and so
// keeps the declaration mappings it needs. Both views disappear once these
// packages come from a registry; see quantus/extension#2.
"paths": {
"@polkadot/keyring": ["../../common/packages/keyring/build/index.js"],
"@polkadot/keyring/*": ["../../common/packages/keyring/build/*"],
"@polkadot/networks": ["../../common/packages/networks/build/index.js"],
"@polkadot/networks/*": ["../../common/packages/networks/build/*"],
"@polkadot/util-crypto": ["../../common/packages/util-crypto/build/index.js"],
"@polkadot/util-crypto/*": ["../../common/packages/util-crypto/build/*"]
}
"composite": false
},
"include": [
"packages/**/src/**/*"

View File

@@ -1596,9 +1596,9 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/keyring@portal:../common/packages/keyring/build::locator=root-workspace-0b6124%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@polkadot/keyring@portal:../common/packages/keyring/build::locator=root-workspace-0b6124%40workspace%3A."
"@polkadot/keyring@https://git.lair.cafe/api/packages/quantus/npm/%40polkadot%2Fkeyring/-/14.0.3/keyring-14.0.3.tgz":
version: 14.0.3
resolution: "@polkadot/keyring@https://git.lair.cafe/api/packages/quantus/npm/%40polkadot%2Fkeyring/-/14.0.3/keyring-14.0.3.tgz"
dependencies:
"@polkadot/util": "npm:14.0.3"
"@polkadot/util-crypto": "npm:14.0.3"
@@ -1607,18 +1607,20 @@ __metadata:
peerDependencies:
"@polkadot/util": 14.0.3
"@polkadot/util-crypto": 14.0.3
checksum: 10/c6c571b8fd4669731563d03f80b261ba0b2c8ceab151f2d0b2f0506a1160461895c30da6eb0ab79046ac03ce548f6b66258aa381fc530d9659134afd3b0df21d
languageName: node
linkType: soft
linkType: hard
"@polkadot/networks@portal:../common/packages/networks/build::locator=root-workspace-0b6124%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@polkadot/networks@portal:../common/packages/networks/build::locator=root-workspace-0b6124%40workspace%3A."
"@polkadot/networks@https://git.lair.cafe/api/packages/quantus/npm/%40polkadot%2Fnetworks/-/14.0.3/networks-14.0.3.tgz":
version: 14.0.3
resolution: "@polkadot/networks@https://git.lair.cafe/api/packages/quantus/npm/%40polkadot%2Fnetworks/-/14.0.3/networks-14.0.3.tgz"
dependencies:
"@polkadot/util": "npm:14.0.3"
"@substrate/ss58-registry": "npm:^1.51.0"
tslib: "npm:^2.8.0"
checksum: 10/17f06f998af6f0ab894ec580246e6be20111bf6a180cd4da35027d0b9b1e1e3f553ad41c9000b07036188ee2a8eb6e70e2c3a6df3192cc8a73ef35a970fe1019
languageName: node
linkType: soft
linkType: hard
"@polkadot/react-identicon@workspace:packages/react-identicon":
version: 0.0.0-use.local
@@ -1694,10 +1696,8 @@ __metadata:
"@polkadot/ui-settings": "npm:3.16.7"
"@polkadot/util": "npm:^14.0.3"
"@polkadot/util-crypto": "npm:^14.0.3"
"@quantus/crypto": "npm:^0.1.0"
"@types/mkdirp": "npm:^2.0.0"
"@types/store": "npm:^2.0.5"
fflate: "npm:^0.8.2"
mkdirp: "npm:^3.0.1"
rxjs: "npm:^7.8.1"
store: "npm:^2.0.12"
@@ -1741,9 +1741,9 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/util-crypto@portal:../common/packages/util-crypto/build::locator=root-workspace-0b6124%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@polkadot/util-crypto@portal:../common/packages/util-crypto/build::locator=root-workspace-0b6124%40workspace%3A."
"@polkadot/util-crypto@https://git.lair.cafe/api/packages/quantus/npm/%40polkadot%2Futil-crypto/-/14.0.3/util-crypto-14.0.3.tgz":
version: 14.0.3
resolution: "@polkadot/util-crypto@https://git.lair.cafe/api/packages/quantus/npm/%40polkadot%2Futil-crypto/-/14.0.3/util-crypto-14.0.3.tgz"
dependencies:
"@noble/curves": "npm:^1.3.0"
"@noble/hashes": "npm:^1.3.3"
@@ -1759,12 +1759,13 @@ __metadata:
tslib: "npm:^2.8.0"
peerDependencies:
"@polkadot/util": 14.0.3
checksum: 10/97045c2dc5c98c2c663d5575ffffa10ae98904757f04846ca39f8d994af478ecefe90fce4a703b95295d335538a2e11fff7a152739950243bbeed04ff8f83036
languageName: node
linkType: soft
linkType: hard
"@polkadot/util@portal:../common/packages/util/build::locator=root-workspace-0b6124%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@polkadot/util@portal:../common/packages/util/build::locator=root-workspace-0b6124%40workspace%3A."
"@polkadot/util@npm:14.0.3, @polkadot/util@npm:^14.0.3":
version: 14.0.3
resolution: "@polkadot/util@npm:14.0.3"
dependencies:
"@polkadot/x-bigint": "npm:14.0.3"
"@polkadot/x-global": "npm:14.0.3"
@@ -1773,8 +1774,9 @@ __metadata:
"@types/bn.js": "npm:^5.1.6"
bn.js: "npm:^5.2.1"
tslib: "npm:^2.8.0"
checksum: 10/7731f26f363696a2e313fdd44d870d711924e8d24200e1c5e88769e02c220af99382460372caa1715511548753e1e3d5c1466a02308b0d4dec0700ec0ab4e88b
languageName: node
linkType: soft
linkType: hard
"@polkadot/vue-identicon@workspace:packages/vue-identicon":
version: 0.0.0-use.local
@@ -1936,11 +1938,15 @@ __metadata:
languageName: node
linkType: hard
"@quantus/crypto@link:../wasm/packages/quantus-crypto/build::locator=root-workspace-0b6124%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@quantus/crypto@link:../wasm/packages/quantus-crypto/build::locator=root-workspace-0b6124%40workspace%3A."
"@quantus/crypto@npm:^0.1.0":
version: 0.1.0
resolution: "@quantus/crypto@npm:0.1.0::__archiveUrl=https%3A%2F%2Fgit.lair.cafe%2Fapi%2Fpackages%2Fquantus%2Fnpm%2F%2540quantus%252Fcrypto%2F-%2F0.1.0%2Fcrypto-0.1.0.tgz"
dependencies:
fflate: "npm:^0.8.2"
tslib: "npm:^2.7.0"
checksum: 10/c6e531e0350d74d863cfa8acfbed0eeacaa2814c2f2628976b73b59a2ff4b6a382dd0d734e34c1c2442ba7e575f0ae12dd153b44fdbfec51b61f212c1ef41fbd
languageName: node
linkType: soft
linkType: hard
"@react-native-community/cli-clean@npm:12.3.0":
version: 12.3.0