Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Dynamic `import()` of a Node-API addon doesn't work on Android

Aperta
#416 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
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
android, babel, react-native, typescript

Direzione di ricerca

Inizia con il TODO in apps/test-app/App.tsx e riproduci il fallimento dell’importazione dinamica su Android, registrando se viene rifiutata o genera un’eccezione e qual è il relativo messaggio. Poi esamina packages/host/src/node/babel-plugin/plugin.ts per confrontare la gestione di require() e import(). Il lavoro è completato quando l’importazione dinamica funziona su Android oppure quando sono documentati il limite e la sua causa, inclusa una spiegazione significativa di eslint-disable.

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

Descrizione

Android 🤖 Host 🏡

Tracking the TODO in apps/test-app/App.tsx.

The ferric-example test has to use require() — with an ESLint disable for @typescript-eslint/no-require-imports — because a dynamic import() of the same addon does not work on Android:

https://github.com/callstackincubator/react-native-node-api/blob/29a527d87fa8cb965b0048b1b4c1cff2b0eab281/apps/test-app/App.tsx#L78-L83

Nobody has established why. It matters beyond the test app: consumers writing modern ESM will reach for await import("some-addon") first, and if that silently fails on Android while working on iOS, it is a confusing first-run experience for exactly the audience this project targets.

Worth checking, roughly in order of likelihood:

  • Whether the Babel plugin in packages/host/src/node/babel-plugin/plugin.ts rewrites require("./addon.node") but leaves import("./addon.node") untransformed — the plugin matches require call expressions, so a dynamic import may simply never be turned into a requireNodeAddon() call.
  • Whether Metro's async-import handling on Android (inline requires / RAM bundles) defers the module in a way that breaks the TurboModule lookup.
  • Whether the failure is a rejected promise or a hard error, and what it actually says — the current comment records the symptom without the message.

Outcome should be either a fix (most likely: handle import() in the Babel plugin alongside require()) or a documented limitation, so the eslint-disable can carry a real explanation instead of an open question.

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.