Dynamic `import()` of a Node-API addon doesn't work on Android
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- android, babel, react-native, typescript
- Domain
- build-system, mobile
Research direction
Start with the TODO in apps/test-app/App.tsx and reproduce the Android dynamic import failure, recording whether it rejects or throws and its message. Then inspect packages/host/src/node/babel-plugin/plugin.ts to compare handling of require() and import(). Done means either dynamic import works on Android or the limitation and its cause are documented, including a meaningful explanation for the eslint-disable.
Written by the indexing model from the issue text.
Description
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:
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.tsrewritesrequire("./addon.node")but leavesimport("./addon.node")untransformed — the plugin matchesrequirecall expressions, so a dynamic import may simply never be turned into arequireNodeAddon()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.
- Dominant language
- TypeScript
- Stars
- 206
- Forks
- 12
- Avg merge
- 4h 8m
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from callstackincubator/react-native-node-api
-
Android 🤖
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Sanity check of Hermes source directory via environment variable, when building Android projectsOpenAndroid 🤖 good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
callstackincubator/react-native-node-api#163 · 1 comment ·
-
enhancement good first issue gyp-to-cmake
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
callstackincubator/react-native-node-api#161 · 3 comments · 1 reaction ·
-
enhancement Linking 🔗
Difficulty 5/5 Over a week Newbie friendliness 8/100
-
enhancement Linking 🔗
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in callstackincubator/react-native-node-api
Similar issues
-
prio:low scope:hud
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OliverRomhagen/vrigstad-joyride#953 ·
Maintainers usually reply within 1 day
-
review-followup
Difficulty 1/5 Under an hour Newbie friendliness 92/100
griffinwork40/agent-afk#5446 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
kacper-szewczyk/Ticknest#346 ·
Maintainers usually reply within 1 day
-
echarts geo: a GeoJSON URL that returns 200 with a body that is not JSON is fetched on each refreshOpenbug plugin/echarts/geo
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Yeachan-Heo/gajae-code#8230 ·
Maintainers usually reply within 1 day