Harden the host's resolution heuristics: addon detection and Xcode workspace lookup

Aperta
#421 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
typescript
Ambito
cli

Direzione di ricerca

Inizia da packages/host/src/node/path-utils.ts, esaminando isNodeApiModule, PLATFORM_EXTENSIONS e il TODO obsoleto, quindi esamina findXcodeWorkspace in packages/host/src/node/cli/xcode-helpers.ts. Verifica come funzionano il fast path e la ricerca discendente attuale. Il lavoro è completato quando il rilevamento degli addon richiede un’estensione specifica della piattaforma, il TODO obsoleto è rimosso e la ricerca del workspace risale dalle directory annidate prima di fallire.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Host 🏡 Linking 🔗

Two places in the host CLI where a shortcut stands in for a proper check. Both fail quietly or unhelpfully rather than loudly.

isNodeApiModule treats any .node file as an addon

https://github.com/callstackincubator/react-native-node-api/blob/29a527d87fa8cb965b0048b1b4c1cff2b0eab281/packages/host/src/node/path-utils.ts#L64-L78

The HACK short-circuits: if <path>.node exists, it returns true without ever checking that it is one of ours. But PLATFORM_EXTENSIONS is specific — .android.node and .apple.node — and a plain .node file is exactly what a Node.js-targeted addon (or a leftover node-gyp build output in build/Release/) looks like. Accepting it means auto-linking picks up something it cannot load, and the failure surfaces later and further away, at runtime on device.

The accompanying TODO on the doc comment asks for the same thing: check for a specific platform extension. Worth doing together, since the fast path exists to avoid the batch directory scan and any fix needs to preserve that.

While in this file: the TODO: Change to .apple.node above PLATFORMS (line 11) is stale — PLATFORM_EXTENSIONS.apple is already ".apple.node" two lines below. It can just be deleted.

findXcodeWorkspace gives up instead of walking upwards

https://github.com/callstackincubator/react-native-node-api/blob/29a527d87fa8cb965b0048b1b4c1cff2b0eab281/packages/host/src/node/cli/xcode-helpers.ts#L56-L69

The search descends into ios/macos from the starting directory and otherwise throws. Running the command from anywhere below the app root — src/, or a package directory in a monorepo, which is the normal place to be standing — fails with No Xcode workspace found in '<cwd>' even though the workspace is one level up. Walking up to the repository/package root before giving up (bounded, e.g. stopping at a .git or the filesystem root) would match what every other RN tool does.

Lingua principale
TypeScript
Stelle
188
Fork
10
Merge medio
2g 17h
PR unite (30g)
3

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di callstackincubator/react-native-node-api

Tutte le issue di callstackincubator/react-native-node-api

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.