Remove the stellar-sdk npm aliases and deduplicate stellar-sdk copies
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript, webpack
- Ambito
- build-system, tooling
Direzione di ricerca
Inizia confrontando le voci delle dipendenze in extension/package.json, @shared/constants/package.json, @shared/api/package.json e @shared/helpers/package.json, quindi esamina getSdk() in @shared/helpers/stellar.ts e il percorso lavamoat in extension/package.json:125-126. Usa webpack-bundle-analyzer per misurare il bundle ed esegui yarn install, yarn tsc, yarn lint, yarn test, yarn build e la suite e2e. Il lavoro è completato quando ci sono meno copie dell’SDK e i workflow di key-manager, swap, signing e account continuano a superare i test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
The dependency tree contains four copies of @stellar/stellar-sdk. Two of them exist
because we install the same package twice under npm aliases. The other two come from
third-party packages that pin old SDK versions. All four are reachable from the built
extension.
This costs bundle size, install size, and supply-chain surface. This issue proposes
removing the aliases and reducing the number of copies.
Current state
Package name in node_modules |
Version | Comes from | Size on disk |
|---|---|---|---|
stellar-sdk (alias) |
16.0.0-rc.1 | our code, ~100 files | 33M |
stellar-sdk-next (alias) |
16.0.0-rc.1 | our code, 5 files | 33M |
@stellar/stellar-sdk |
15.0.1 | @stellar/[email protected] (background / key manager) |
17M |
@stellar/stellar-sdk (nested) |
11.3.0 | [email protected] (popup swap) |
3.8M |
The aliases are declared in four workspaces:
extension/package.json:87, @shared/constants/package.json:6,
@shared/api/package.json:12, @shared/helpers/package.json:7.
Note that Yarn already treats the two aliases as one package at resolution time:
yarn.lock:22301
"stellar-sdk-next@npm:@stellar/[email protected], stellar-sdk@npm:@stellar/[email protected]":
One locator, two descriptors. The duplication happens only at link time, because the
two package names are different, so they are installed into two directories. Webpack
then builds two separate module graphs from them. Yarn cannot merge this; only removing
the alias can.
Why the alias exists today
stellar-sdk-next was added to stage a protocol upgrade. The idea was to point -next
at a release candidate while stellar-sdk stayed on the stable release, then select one
per network at runtime with getSdk(networkPassphrase) (@shared/helpers/stellar.ts:22).
That is not what happens now:
- Both aliases are pinned to the same version. We always bump them together.
isNextSdkis[""].includes(networkPassphrase), which is always false. The-next
branch is dead code.
So the second copy currently gives us nothing.
Proposed change
- Replace
"stellar-sdk": "npm:@stellar/stellar-sdk@<version>"with
"@stellar/stellar-sdk": "<version>"in the four workspacepackage.jsonfiles. - Update the imports. About 100 files import
stellar-sdk. This is a mechanical
find-and-replace. - Remove
stellar-sdk-nextand the 5 imports that use it. KeepgetSdk()as a
one-line function that always returns the single SDK, so the call sites do not
change in this PR. - Reduce the third-party copies:
@stellar/[email protected]pins SDK15.0.1. Check for a newer
release built against SDK 16. If there is none, open an upstream request to make
@stellar/stellar-sdka peer dependency with a range, not an exact pin.[email protected]pins^11.3.0. Check whether a newer release exists.- A Yarn
resolutionsentry can force a single version, but this touches the key
manager, which is on the signing path. Do not do this without testing account
import, account recovery, and hardware wallet signing.
- Measure the bundle before and after with
webpack-bundle-analyzer, and record the
numbers in the PR.
Trade-off to decide
Removing stellar-sdk-next also removes the mechanism we would use for the next
protocol upgrade. Two options:
- (a) Remove it now, add it back only during a transition. Add the alias when we
need to run an RC beside the stable SDK, then delete it after activation. - (b) Keep it. Accept a permanent duplicate copy for a mechanism that is used for a
few weeks per protocol release.
Recommendation: (a). The current setup pays the cost all the time.
Verification
yarn installand confirmnode_moduleshas fewer@stellar/stellar-sdkcopies.yarn tsc,yarn lint,yarn testall pass.yarn build(webpack) succeeds, and lavamoat /allowScriptsstill resolves the
stellar-sdk>stellar-base>sodium-nativepath, which is keyed by package name
(extension/package.json:125-126). This path changes when the alias is removed.- Manual check of the key manager: create account, import account, recover account.
- Manual check of a swap, which uses
soroswap-router-sdk. - e2e suite passes.
Out of scope
Runtime behaviour changes. This is a packaging change only.
- Lingua principale
- TypeScript
- Stelle
- 122
- Fork
- 62
- Merge medio
- 4g 19h
- PR unite (30g)
- 41
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di stellar/freighter
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
Write the banner publishing guideForse già presa @aristidesstaffieri l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
stellar/freighter#3152 · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
Dont call blockaid on empty token listForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 2 giorni
-
follow-up
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di stellar/freighter
Issue simili
-
agent/guide documentation help wanted stage/010-actionable
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
kubestellar/console-marketplace#1101 ·
I maintainer di solito rispondono entro 1 giorno
-
Java Edition Tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
JSPrismarine/JSPrismarine#4178 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
totec448-spec/chat-on-steroids#2394 ·
I maintainer di solito rispondono entro 1 giorno
-
github_actions
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
StellarHyperion/stellarhyperion-backend#499 ·
I maintainer di solito rispondono entro 1 giorno